/* ============================================
   WriteXO Editor
   ============================================ */

/* Prevent transitions on page load */
.preload * {
    transition: none !important;
}

/* Font Awesome icon sizing */
i.fa-solid,
i.fa-regular {
    font-size: 16px;
    width: 16px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

:root {
    --sidebar-width: 300px;
    --sidebar-min-width: 200px;
    --sidebar-max-width: 500px;
    --topbar-height: 50px;
    /* WriteXO color scheme - matches global.css */
    --sidebar-bg: #f5f5f5;
    --sidebar-hover: #eeeeee;
    --sidebar-active: #e0e0e0;
    --text-primary: #333333;
    --text-secondary: #696969;
    --border-color: #dddddd;
    --content-bg: #ffffff;
    --accent-color: #50ca59;
    --accent-hover: #3da449;
    --resize-handle-color: #dddddd;
    --resize-handle-hover: #cccccc;
    --topbar-actions-width: 240px;
    --status-info: var(--accent-color);
    --status-info-hover: var(--accent-hover);
    --status-success: #50ca59;
    --status-success-hover: #3da449;
    --status-warning: #f59e0b;
    --status-warning-hover: #d97706;
    --status-danger: #ff3b30;
    --status-danger-hover: #e12c23;
}

/* Dark mode variables - ONLY for main editor (scoped to .editor-container) */
body.dark .editor-container {
    --sidebar-bg: #1d1d1d;
    --sidebar-hover: #252525;
    --sidebar-active: #2d2d2d;
    --text-primary: #d4d4d4;
    --text-secondary: #b0b0b0;
    --border-color: #353535;
    --content-bg: #171717;
    --accent-color: #50ca59;
    --accent-hover: #3da449;
    --resize-handle-color: #353535;
    --resize-handle-hover: #404040;
}

/* Dark mode editor title - ensure it matches content area (scoped to editor only) */
body.dark .editor-container .editor-title {
    background: var(--content-bg) !important;
}

/* Dark mode for feature modals (modals are siblings to editor-container, not children) */
body.dark .feature-modal .modal-content {
    background: #1d1d1d;
}

body.dark .feature-modal .modal-header {
    background: #252525;
    color: #d4d4d4;
    border-bottom-color: #353535;
}

body.dark .feature-modal .modal-header h3 {
    color: #d4d4d4;
}

body.dark .feature-modal .modal-body {
    background: #1d1d1d;
    color: #d4d4d4;
}

body.dark .feature-modal .modal-body::-webkit-scrollbar-thumb {
    background: #404040;
}

body.dark .feature-modal .modal-body::-webkit-scrollbar-track {
    background: #252525;
}

body.dark .feature-modal .modal-body p {
    color: #b0b0b0;
}

body.dark .feature-modal .modal-section h4 {
    color: #d4d4d4;
}

body.dark .feature-modal .help-text {
    color: #b0b0b0;
}

body.dark .feature-modal .link-item input,
body.dark .feature-modal .form-input {
    background: #252525;
    border-color: #404040 !important;
    color: #d4d4d4;
}

body.dark .feature-modal .link-item input:focus,
body.dark .feature-modal .form-input:focus {
    border-color: #50ca59 !important;
    outline: none;
}

body.dark .feature-modal .toggle-label span:not(.toggle-slider) {
    color: #d4d4d4;
}

body.dark .feature-modal .modal-close {
    background: #353535;
    color: #b0b0b0;
}

body.dark .feature-modal .modal-close:hover {
    background: #404040;
    color: #d4d4d4;
}

/* Dark mode for export modal options */
body.dark .feature-modal .export-option-btn {
    background: #252525;
    border-color: #404040;
}

body.dark .feature-modal .export-option-btn:hover {
    background: #2d2d2d;
    border-color: #50ca59;
}

body.dark .feature-modal .export-name {
    color: #e0e0e0;
}

body.dark .feature-modal .export-desc {
    color: #b0b0b0;
}

body.dark .feature-modal .export-option-btn > i:last-child {
    color: #696969;
}

/* Dark mode for attachments modal */
body.dark .feature-modal .upload-section {
    border-color: #404040;
}

body.dark .feature-modal .attachments-empty,
body.dark .feature-modal .attachments-loading {
    color: #b0b0b0;
}

body.dark .feature-modal .attachments-empty i,
body.dark .feature-modal .attachments-loading i {
    color: #696969;
}

body.dark .feature-modal .attachment-item {
    background: #252525 !important;
    border-color: #404040;
}

body.dark .feature-modal .attachment-item:hover {
    background: #2d2d2d !important;
}

body.dark .feature-modal .attachment-name {
    color: #e0e0e0;
}

body.dark .feature-modal .attachment-meta {
    color: #b0b0b0;
}

body.dark .feature-modal .attachment-action-btn {
    background: transparent;
    border-color: #404040;
    color: #d4d4d4 !important;
}

body.dark .feature-modal .attachment-action-btn:hover {
    background: #2d2d2d;
    border-color: #50ca59;
    color: #d4d4d4 !important;
}

body.dark .feature-modal .attachment-action-btn.delete-btn {
    border-color: rgba(231, 76, 60, 0.5);
    color: #e74c3c !important;
}

body.dark .feature-modal .attachment-action-btn.delete-btn:hover {
    background: rgba(231, 76, 60, 0.1);
    border-color: #e74c3c;
    color: #e74c3c !important;
}

/* ============================================
   Main Container Layout
   ============================================ */

.editor-container {
    display: flex;
    height: 100vh;
    width: 100vw;
    overflow: hidden;
    background: var(--content-bg);
    position: fixed;
    top: 0;
    left: 0;
}

/* ============================================
   Sidebar
   ============================================ */

.editor-sidebar {
    width: var(--sidebar-width);
    min-width: var(--sidebar-min-width);
    max-width: var(--sidebar-max-width);
    background: var(--sidebar-bg);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    position: relative;
    z-index: 600;
    flex-shrink: 0;
    transform: translateX(0);
    will-change: width;
}

.editor-sidebar.transitions-enabled {
    transition: width 0.3s ease 0.15s, min-width 0.3s ease 0.15s, transform 0.3s ease 0.15s;
}

.editor-sidebar.collapsed {
    width: 0;
    min-width: 0;
    max-width: 0;
    pointer-events: none;
    overflow: hidden;
    border-right: none;
    transform: translateX(-100%);
    transition: width 0.3s ease, min-width 0.3s ease, transform 0.3s ease;
}

/* Sidebar Header */
.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-color);
    height: var(--topbar-height);
    min-height: var(--topbar-height);
    box-sizing: border-box;
    opacity: 1;
}

.editor-sidebar.transitions-enabled .sidebar-header {
    transition: opacity 0.15s ease;
}

.editor-sidebar.collapsed .sidebar-header {
    opacity: 0;
}

.editor-sidebar.transitions-enabled.collapsed .sidebar-header {
    transition: opacity 0.1s ease;
}

.sidebar-logo {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 17px;
    color: var(--text-primary);
    letter-spacing: 0.5px;
}

.sidebar-logo i {
    color: var(--text-secondary);
}

.sidebar-collapse-btn {
    background: transparent;
    border: none;
    padding: 4px;
    cursor: pointer;
    border-radius: 4px;
    color: var(--text-secondary);
    transition: background 0.15s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.sidebar-collapse-btn:hover {
    background: var(--sidebar-hover);
}

/* Sidebar Content */
.sidebar-content {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 16px 8px;
    padding-bottom: 100px; /* Add space for fixed bottom section */
    opacity: 1;
    scrollbar-gutter: stable;
}

.editor-sidebar.transitions-enabled .sidebar-content {
    transition: opacity 0.15s ease;
}

.editor-sidebar.collapsed .sidebar-content {
    opacity: 0;
}

.editor-sidebar.transitions-enabled.collapsed .sidebar-content {
    transition: opacity 0.1s ease;
}

.sidebar-content::-webkit-scrollbar {
    width: 9px;
}

.sidebar-content::-webkit-scrollbar-track {
    background: transparent;
    margin: 8px 0;
}

.sidebar-content::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 4px;
}

/* Sections */
.workspace-section,
.nav-section {
    margin-bottom: 24px;
}

.section-label {
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    color: var(--text-secondary);
    padding: 0 8px;
    margin-bottom: 6px;
    letter-spacing: 0.5px;
}

/* Workspace Item */
.workspace-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 8px;
    border-radius: 4px;
    cursor: pointer;
    transition: background 0.15s ease;
    color: var(--text-primary);
    font-size: 15px;
    min-height: 34px;
}

.workspace-item:hover {
    background: var(--sidebar-hover);
}

.workspace-item.active {
    background: var(--sidebar-active);
    font-weight: 500;
}

.workspace-item i {
    color: var(--text-primary);
    flex-shrink: 0;
    width: 18px;
    font-size: 18px;
}

/* Parent note icon - always visible */
.parent-note-icon {
    opacity: 1;
}

/* Chevron toggle for parent notes with sub-notes */
.parent-note-chevron {
    cursor: pointer;
    transition: transform 0.2s ease, opacity 0.15s ease;
    font-size: 12px !important;
    opacity: 0;
}

/* Show chevron on workspace-item hover or when expanded */
.workspace-item:hover .parent-note-chevron,
.parent-note-chevron.expanded {
    opacity: 1;
}

.parent-note-chevron.expanded {
    transform: rotate(90deg);
}

.parent-note-chevron:hover {
    color: var(--text-primary);
}

.workspace-item #sidebar-note-title {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    text-align: left;
}

.workspace-item.has-parent {
    cursor: pointer;
}

.workspace-item.has-parent:hover {
    background: var(--sidebar-hover);
}

.sub-notes-container {
    margin: 6px 0 0 30px;
    padding: 0;
}

.sub-notes-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 4px;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
}

.sub-notes-actions {
    display: flex;
    gap: 6px;
}

.sub-note-add-btn {
    width: 24px;
    height: 24px;
    border-radius: 4px;
    border: none;
    background: var(--sidebar-hover);
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease;
}

.sub-note-add-btn:hover:not(:disabled) {
    background: var(--sidebar-active);
    color: var(--text-primary);
}

.sub-note-add-btn:disabled {
    cursor: not-allowed;
    opacity: 0.5;
}

.sub-notes-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
    max-height: 220px;
    overflow-y: auto;
}

.sub-note-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 8px;
    border-radius: 4px;
    background: transparent;
    transition: background 0.15s ease;
    color: var(--text-primary);
    font-size: 14px;
    position: relative;
    cursor: pointer;
}

.sub-note-item:hover {
    background: var(--sidebar-hover);
}

.sub-note-item > i {
    flex-shrink: 0;
    color: var(--text-secondary);
    font-size: 14px;
}

.sub-note-item .note-icon {
    flex-shrink: 0;
    font-size: 14px;
    width: 16px;
    height: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

.sub-note-title {
    flex: 1;
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sub-note-delete-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    background: rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 4px;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.sub-note-item:hover .sub-note-delete-btn {
    opacity: 1;
}

.sub-note-delete-btn:hover {
    background: rgba(255, 255, 255, 0.95);
}

.sub-note-delete-btn i {
    font-size: 14px;
}

/* Dark mode adjustments for sub-note delete button */
body.dark .sub-note-delete-btn {
    background: rgba(29, 29, 29, 0.8);
    border-color: var(--border-color);
}

body.dark .sub-note-delete-btn:hover {
    background: rgba(29, 29, 29, 0.95);
}

.sub-note-badge {
    font-size: 11px;
    color: var(--text-secondary);
}

.sub-notes-placeholder {
    font-size: 14px;
    color: var(--text-secondary);
    padding: 6px 0;
    font-style: italic;
}

.sub-notes-placeholder.sub-notes-disabled {
    opacity: 0.6;
}

.sub-note-item.active {
    background: var(--sidebar-active);
}

.sub-note-item.active i {
    color: var(--text-primary);
}

/* Nav Items */
.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 8px;
    border-radius: 4px;
    cursor: pointer;
    transition: background 0.15s ease;
    color: var(--text-primary);
    font-size: 15px;
    text-decoration: none;
    margin-bottom: 2px;
}

.nav-item:hover {
    background: var(--sidebar-hover);
    color: var(--text-primary);
    text-decoration: none;
}

.nav-item i {
    color: var(--text-primary);
    flex-shrink: 0;
    width: 18px;
    font-size: 18px;
}

.nav-item > span:not(.note-icon) {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    text-align: left;
}

/* Sidebar Bottom - Fixed position for note limit */
.sidebar-bottom {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--sidebar-bg);
    border-top: 1px solid var(--border-color);
    z-index: 10;
}

/* Note Limit Progress Display */
.note-limit-display {
    padding: 12px;
    font-size: 14px;
}

.note-limit-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
    color: var(--text-secondary);
}

.note-limit-label {
    font-weight: 500;
}

.note-count {
    font-weight: 600;
    color: var(--text-primary);
}

.note-progress-bar {
    width: 100%;
    height: 6px;
    background: #e5e5e5;
    border-radius: 3px;
    overflow: hidden;
}

.note-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #50ca59 0%, #3ba644 100%);
    border-radius: 3px;
    transition: width 0.3s ease, background 0.3s ease;
}

/* Warning colors when approaching limit */
.note-limit-display.near-limit .note-progress-fill {
    background: linear-gradient(90deg, #f39c12 0%, #e67e22 100%);
}

.note-limit-display.near-limit .note-count {
    color: #f39c12;
}

.note-limit-display.at-limit .note-progress-fill {
    background: linear-gradient(90deg, #e74c3c 0%, #c0392b 100%);
}

.note-limit-display.at-limit .note-count {
    color: #e74c3c;
}

/* Note Limit Upgrade Link */
.note-limit-upgrade-link {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    margin-top: 10px;
    padding: 6px 0;
    font-size: 13px;
    color: var(--text-secondary);
    text-decoration: none;
    cursor: pointer;
    transition: all 0.2s ease;
}

.note-limit-upgrade-link:hover {
    color: var(--text-primary);
    text-decoration: none;
}

.note-limit-upgrade-link i {
    font-size: 11px;
}

/* New Note Button */
.new-note-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 8px 12px;
    border-radius: 4px;
    cursor: pointer;
    background: transparent;
    color: var(--text-primary);
    font-size: 15px;
    font-weight: 500;
    border: 1px solid var(--border-color);
    width: 100%;
    transition: all 0.15s ease;
}

.new-note-btn:hover {
    background: var(--hover-bg);
    border-color: var(--text-secondary);
}

.new-note-btn i {
    flex-shrink: 0;
    width: 18px;
    font-size: 18px;
}

/* Loading/Empty/Error States */
.sidebar-loading,
.sidebar-empty,
.sidebar-error {
    padding: 20px 10px;
    text-align: center;
    color: var(--text-secondary);
    font-size: 14px;
}

.sidebar-loading i,
.sidebar-empty i,
.sidebar-error i {
    font-size: 24px;
    display: block;
    margin-bottom: 8px;
    color: var(--text-secondary);
}

.sidebar-loading i {
    animation: spin 1s linear infinite;
}

@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

.sidebar-empty p,
.sidebar-error p {
    margin: 4px 0;
    font-size: 14px;
}

.sidebar-empty a {
    color: var(--accent-color);
    text-decoration: none;
    font-size: 12px;
}

.sidebar-empty a:hover {
    text-decoration: underline;
}

/* Sidebar Footer */
.sidebar-footer {
    padding: 12px 8px;
    border-top: 1px solid var(--border-color);
    opacity: 1;
}

.editor-sidebar.transitions-enabled .sidebar-footer {
    transition: opacity 0.15s ease;
}

.editor-sidebar.collapsed .sidebar-footer {
    opacity: 0;
}

.editor-sidebar.transitions-enabled.collapsed .sidebar-footer {
    transition: opacity 0.1s ease;
}

.testing-badge {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    color: var(--text-secondary);
    padding: 6px 8px;
    background: rgba(255, 200, 0, 0.1);
    border-radius: 4px;
    border: 1px solid rgba(255, 200, 0, 0.3);
}

.testing-badge i {
    color: #ffc800;
    width: 14px;
    font-size: 14px;
}

/* Resize Handle */
.sidebar-resize-handle {
    position: absolute;
    top: 0;
    right: 0;
    width: 4px;
    height: 100%;
    cursor: col-resize;
    background: transparent;
    transition: background 0.15s ease;
    z-index: 10;
}

.sidebar-resize-handle:hover,
.sidebar-resize-handle.resizing {
    background: var(--resize-handle-hover);
}

/* Expand Button in Toolbar (when sidebar is collapsed) */
.sidebar-expand-btn-toolbar {
    background: transparent;
    border: none;
    border-radius: 4px;
    padding: 6px;
    cursor: pointer;
    color: var(--text-secondary);
    transition: all 0.15s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-right: 8px;
}

.sidebar-expand-btn-toolbar:hover {
    background: var(--sidebar-hover);
    color: var(--text-primary);
}

/* ============================================
   Main Content Area
   ============================================ */

.editor-main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: var(--content-bg);
}

/* Top Toolbar Wrapper */
.editor-topbar-wrapper {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 6px 16px;
    height: var(--topbar-height);
    min-height: var(--topbar-height);
    max-height: var(--topbar-height);
    border-bottom: 1px solid var(--border-color);
    background: var(--content-bg);
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    width: 100%;
    z-index: 500;
    box-sizing: border-box;
    padding-left: calc(var(--sidebar-width) + 16px);
    overflow-y: visible; /* still allow dropdowns to extend below the bar */
}

.editor-topbar-wrapper::after {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    width: calc(var(--topbar-actions-width) + 16px);
    height: 100%;
    background: transparent;
    pointer-events: none;
    z-index: 1200;
}

.editor-topbar-wrapper.transitions-enabled {
    transition: padding-left 0.2s ease;
}

body.sidebar-collapsed .editor-topbar-wrapper {
    padding-left: 16px;
}

.quill-topbar-toolbar {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 2px;
    position: relative;
    min-width: 0;
}

/* Wrapper for toolbar to apply fade effect without clipping dropdowns */
.quill-topbar-toolbar::before {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    width: 80px;
    bottom: 0;
    background: linear-gradient(to right, rgba(255, 255, 255, 0), var(--content-bg) 60%, var(--content-bg));
    pointer-events: none;
    z-index: 1500;
}

/* Dark mode gradient */
body.dark .quill-topbar-toolbar::before {
    background: linear-gradient(to right, rgba(23, 23, 23, 0), var(--content-bg) 60%, var(--content-bg));
}

/* Ensure toolbar buttons are below the fade overlay but dropdowns are above */
.quill-topbar-toolbar button,
.quill-topbar-toolbar .ql-picker-label {
    position: relative;
    z-index: 0;
}

/* Allow Quill dropdowns to escape and appear above everything */
.quill-topbar-toolbar .ql-picker-options {
    position: absolute !important;
    z-index: 10000 !important;
}

.editor-topbar-actions {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-left: 16px;
    padding-left: 12px;
    position: relative; /* For absolute positioning of more menu */
    flex-shrink: 0;
    width: var(--topbar-actions-width);
    justify-content: flex-end;
    z-index: 2000;
    background: var(--content-bg);
}

/* Breadcrumb */
.breadcrumb {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    color: var(--text-secondary);
}

.breadcrumb-item {
    color: var(--text-secondary);
}

.breadcrumb-item.active {
    color: var(--text-primary);
    font-weight: 500;
}

.breadcrumb-separator {
    color: var(--text-secondary);
    opacity: 0.5;
}

/* Topbar Buttons */
.topbar-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    background: transparent;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    cursor: pointer;
    color: var(--text-primary);
    font-size: 13px;
    transition: background 0.15s ease;
}

.topbar-btn:hover {
    background: var(--sidebar-hover);
}

.topbar-btn.disabled,
.topbar-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    pointer-events: none;
}

.topbar-btn i {
    color: var(--text-primary);
    font-size: 14px;
}

/* Editor Content Wrapper */
.editor-content-wrapper {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    background: var(--content-bg);
    height: calc(100vh - var(--topbar-height));
    box-sizing: border-box;
    margin-top: var(--topbar-height);
}

.editor-content-wrapper::-webkit-scrollbar {
    width: 9px;
}

.editor-content-wrapper::-webkit-scrollbar-track {
    background: transparent;
    margin: 8px 0;
}

.editor-content-wrapper::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 4px;
}

/* Editor Page */
.editor-page {
    max-width: 900px;
    margin: 0 auto;
    padding: 60px 96px;
    min-height: calc(100vh - var(--topbar-height));
    background: var(--content-bg);
}

/* Title Input */
.editor-title {
    width: 100%;
    border: none;
    outline: none;
    background: transparent;
    font-size: 40px;
    font-weight: 700;
    color: var(--text-primary);
    padding: 0;
    margin-bottom: 16px;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
    line-height: 1.2;
    resize: none;
    overflow: hidden;
    min-height: 48px;
    white-space: pre-wrap;
    word-break: break-word;
    overflow-wrap: anywhere;
}

.editor-title::placeholder {
    color: var(--text-secondary);
    opacity: 0.4;
}

/* Quill Editor Customization */
.editable {
    border: none !important;
    padding: 0 !important;
    font-size: 16px;
    line-height: 1.6;
    color: var(--text-primary);
    background: transparent !important;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
    min-height: 400px;
}

.editable.ql-container {
    border: none !important;
}

.editable .ql-editor {
    padding: 24px 0 !important;
    color: var(--text-primary);
}

.editable .ql-editor.ql-blank::before {
    color: var(--text-secondary);
    opacity: 0.6;
    font-style: normal;
    left: 0;
}

.editable p {
    margin-bottom: 8px;
}

.editable h1 {
    font-size: 32px;
    font-weight: 700;
    margin: 24px 0 8px;
}

.editable h2 {
    font-size: 24px;
    font-weight: 600;
    margin: 20px 0 8px;
}

.editable h3 {
    font-size: 20px;
    font-weight: 600;
    margin: 16px 0 8px;
}

.editable blockquote {
    border-left: 3px solid var(--border-color);
    padding-left: 16px;
    margin: 12px 0;
    color: var(--text-secondary);
}

.editable pre {
    background: var(--sidebar-bg);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    padding: 12px;
    margin: 12px 0;
}

.editable code {
    background: var(--sidebar-bg);
    padding: 2px 6px;
    border-radius: 3px;
    font-size: 14px;
    font-family: "SF Mono", Monaco, Consolas, monospace;
}

/* Quill Toolbar - in topbar, clean modern styling */
#quill-toolbar {
    background: transparent;
    border: none;
    padding: 0 !important;
    padding-top: 0 !important;
    padding-bottom: 0 !important;
    display: flex;
    flex-wrap: nowrap;
    align-items: center;
    gap: 4px;
    flex: 1 1 calc(100% - var(--topbar-actions-width));
    max-width: calc(100% - var(--topbar-actions-width));
    min-width: 0;
    overflow-x: auto;
    overflow-y: visible; /* allow Quill dropdowns to extend outside toolbar */
    scrollbar-width: thin;
    position: relative;
    z-index: 1000;
}

/* When Quill adds ql-toolbar class */
#quill-toolbar.ql-toolbar {
    background: transparent;
    border: none;
    padding: 0 !important;
    padding-top: 0 !important;
    padding-bottom: 0 !important;
}

#quill-toolbar.ql-toolbar.ql-snow {
    background: transparent;
    border: none;
    padding: 0 !important;
    padding-top: 0 !important;
    padding-bottom: 0 !important;
}

body.dark #quill-toolbar.ql-toolbar.ql-snow {
    background: transparent;
    border: none;
    padding: 0 !important;
    padding-top: 0 !important;
    padding-bottom: 0 !important;
}

#quill-toolbar .ql-formats {
    margin-right: 4px;
    display: flex;
    align-items: center;
    gap: 1px;
}

#quill-toolbar .ql-formats button {
    outline: none;
    color: var(--text-primary);
    width: 28px !important;
    height: 28px !important;
    border-radius: 3px;
    transition: all 0.15s ease;
    border: none;
    background: transparent;
    padding: 4px !important;
}

#quill-toolbar .ql-formats button:hover {
    background: var(--sidebar-hover) !important;
    color: var(--text-primary) !important;
}

#quill-toolbar .ql-formats button.ql-active {
    background: var(--sidebar-active) !important;
    color: var(--accent-color) !important;
}

body.dark #quill-toolbar .ql-formats button:hover {
    background: var(--sidebar-hover) !important;
    color: #fff !important;
}

body.dark #quill-toolbar .ql-formats button.ql-active {
    background: rgba(80, 202, 89, 0.15) !important;
    color: var(--accent-color) !important;
}

/* Quill picker styling */
#quill-toolbar .ql-formats .ql-picker {
    color: var(--text-secondary);
}

#quill-toolbar .ql-formats .ql-picker-label {
    border: none;
    padding: 6px 8px;
    border-radius: 4px;
    transition: background 0.15s ease;
}

#quill-toolbar .ql-formats .ql-picker-label:hover {
    background: var(--sidebar-hover);
}

#quill-toolbar .ql-formats .ql-picker.ql-expanded .ql-picker-label {
    background: var(--sidebar-active);
}

/* Ensure Quill picker dropdowns appear above everything */
.ql-picker-options {
    z-index: 10000 !important;
}

.ql-picker.ql-expanded .ql-picker-options {
    z-index: 10000 !important;
}

/* Add header button icons using text and hide original SVG */
button.ql-header[value="1"] svg,
button.ql-header[value="2"] svg,
button.ql-header[value="3"] svg {
    display: none;
}

button.ql-header[value="1"]::after {
    content: 'H1';
    font-size: 11px;
    font-weight: 600;
    color: var(--text-secondary);
}

button.ql-header[value="1"]:hover::after {
    color: var(--text-primary);
}

button.ql-header[value="1"].ql-active::after {
    color: var(--accent-color);
}

button.ql-header[value="2"]::after {
    content: 'H2';
    font-size: 11px;
    font-weight: 600;
    color: var(--text-secondary);
}

button.ql-header[value="2"]:hover::after {
    color: var(--text-primary);
}

button.ql-header[value="2"].ql-active::after {
    color: var(--accent-color);
}

button.ql-header[value="3"]::after {
    content: 'H3';
    font-size: 11px;
    font-weight: 600;
    color: var(--text-secondary);
}

button.ql-header[value="3"]:hover::after {
    color: var(--text-primary);
}

button.ql-header[value="3"].ql-active::after {
    color: var(--accent-color);
}

/* Quill stroke colors for icons */
#quill-toolbar button:hover .ql-stroke {
    stroke: var(--text-primary) !important;
}

#quill-toolbar button.ql-active .ql-stroke {
    stroke: var(--accent-color) !important;
}

#quill-toolbar button:hover .ql-fill {
    fill: var(--text-primary) !important;
}

#quill-toolbar button.ql-active .ql-fill {
    fill: var(--accent-color) !important;
}

body.dark #quill-toolbar button:hover .ql-stroke {
    stroke: #fff !important;
}

body.dark #quill-toolbar button.ql-active .ql-stroke {
    stroke: var(--accent-color) !important;
}

body.dark #quill-toolbar button:hover .ql-fill {
    fill: #fff !important;
}

body.dark #quill-toolbar button.ql-active .ql-fill {
    fill: var(--accent-color) !important;
}

#quill-toolbar::-webkit-scrollbar {
    height: 6px;
}

#quill-toolbar::-webkit-scrollbar-track {
    background: transparent;
}

#quill-toolbar::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 999px;
}

#quill-toolbar::-webkit-scrollbar-thumb:hover {
    background: var(--text-secondary);
}

/* Replace Quill's default link icon with Font Awesome */
#quill-toolbar .ql-link svg {
    display: none !important;
}

#quill-toolbar .ql-link::before {
    font-family: "Font Awesome 6 Free";
    font-weight: 900;
    content: "\f0c1";
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
}

/* ============================================
   Responsive Design
   ============================================ */

@media (max-width: 768px) {
    /* Prevent any horizontal scrolling or shifting */
    body {
        overflow-x: hidden;
        position: relative;
        width: 100%;
    }

    .editor-container {
        overflow-x: hidden;
    }

    .editor-topbar-wrapper {
        padding-left: 16px;
    }

    .editor-sidebar {
        position: fixed;
        top: 0;
        left: 0;
        height: 100%;
        z-index: 700;
        box-shadow: 2px 0 8px rgba(0, 0, 0, 0.1);
        transform: translateX(-100%);
    }

    /* When NOT collapsed on mobile, show the sidebar */
    .editor-sidebar:not(.collapsed) {
        transform: translateX(0);
    }

    /* Ensure main content stays full width */
    .editor-main-content {
        width: 100%;
    }

    /* Lock topbar width */
    .editor-topbar-wrapper {
        width: 100%;
    }

    #quill-toolbar {
        visibility: hidden !important;
        pointer-events: none;
    }

    .editor-page {
        padding: 40px 24px;
    }

    .editor-title {
        font-size: 32px;
    }

    .sidebar-resize-handle {
        display: none;
    }

    /* Icon picker modal adjustments */
    .modal-content {
        max-width: 95% !important;
        width: 95%;
    }

    .emoji-grid {
        grid-template-columns: repeat(5, 1fr);
    }

    .emoji-item {
        font-size: 28px;
        padding: 6px;
    }

    .icon-picker-tabs {
        gap: 6px;
    }

    .icon-tab {
        padding: 5px 10px;
        font-size: 13px;
    }
}

/* ============================================
   Feature Modals & Dropdowns
   ============================================ */

/* Modal Base */
.feature-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
}

.modal-content {
    position: relative;
    background: var(--content-bg);
    border-radius: 8px;
    max-width: 500px;
    width: 90%;
    max-height: 80vh;
    overflow: hidden;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
    z-index: 1;
    display: flex;
    flex-direction: column;
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    border-bottom: 1px solid var(--border-color);
    flex-shrink: 0;
}

.modal-header h3 {
    margin: 0;
    font-size: 16px;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 8px;
}

.feature-modal .modal-header .modal-icon {
    font-size: 20px;
    width: 20px;
}

.modal-close {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: var(--text-secondary);
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: all 0.15s;
}

.modal-close:hover {
    background: var(--sidebar-hover);
    color: var(--text-primary);
}

.modal-body {
    padding: 16px;
    overflow-y: auto;
    flex: 1;
    min-height: 0;
}

.modal-body::-webkit-scrollbar {
    width: 9px;
}

.modal-body::-webkit-scrollbar-track {
    background: transparent;
}

.modal-body::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 4px;
}

.editor-alert-modal .modal-body {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.editor-alert-modal .modal-message {
    margin: 0;
    font-size: 15px;
    line-height: 1.6;
    color: var(--text-primary);
    white-space: pre-line;
}

.modal-alert-actions {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
}

.modal-alert-btn {
    border: none;
    border-radius: 4px;
    padding: 10px 20px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease;
}

.modal-alert-btn:focus-visible {
    outline: 2px solid var(--accent-color);
    outline-offset: 2px;
}

.modal-alert-btn.modal-cancel-btn {
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
}

.modal-alert-btn.modal-cancel-btn:hover {
    background: var(--sidebar-hover);
    color: var(--text-primary);
}

.modal-alert-btn.confirm-info,
.modal-alert-btn.confirm-success {
    background: var(--status-info);
    color: #ffffff;
}

.modal-alert-btn.confirm-info:hover,
.modal-alert-btn.confirm-success:hover {
    background: var(--status-info-hover);
}

.modal-alert-btn.confirm-warning {
    background: var(--status-warning);
    color: #ffffff;
}

.modal-alert-btn.confirm-warning:hover {
    background: var(--status-warning-hover);
}

.modal-alert-btn.confirm-error {
    background: var(--status-danger);
    color: #ffffff;
}

.modal-alert-btn.confirm-error:hover {
    background: var(--status-danger-hover);
}

.modal-content.alert-info .modal-icon {
    color: var(--status-info);
}

.modal-content.alert-success .modal-icon {
    color: var(--status-success);
}

.modal-content.alert-warning .modal-icon {
    color: var(--status-warning);
}

.modal-content.alert-error .modal-icon {
    color: var(--status-danger);
}

.modal-section {
    margin-bottom: 24px;
}

.modal-section:last-child {
    margin-bottom: 0;
}

.modal-section h4 {
    margin: 0 0 12px 0;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
}

.help-text {
    margin: 8px 0 0 0;
    font-size: 12px;
    color: var(--text-secondary);
}

/* Toggle Label */
.toggle-label {
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
}

.toggle-label input[type="checkbox"] {
    position: relative;
    appearance: none;
    width: 44px;
    height: 24px;
    background: #ddd;
    border-radius: 12px;
    transition: background 0.2s;
    cursor: pointer;
}

.toggle-label input[type="checkbox"]:checked {
    background: var(--accent-color);
}

.toggle-label input[type="checkbox"]::before {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: 20px;
    height: 20px;
    background: white;
    border-radius: 50%;
    transition: transform 0.2s;
}

.toggle-label input[type="checkbox"]:checked::before {
    transform: translateX(20px);
}

/* Dark mode toggle styles */
body.dark .toggle-label input[type="checkbox"] {
    background: #404040;
}

body.dark .toggle-label input[type="checkbox"]:checked {
    background: var(--accent-color);
}

body.dark .toggle-label input[type="checkbox"]::before {
    background: #e0e0e0;
}

/* Link Items */
.link-item {
    display: flex;
    gap: 8px;
    margin-bottom: 4px;
}

.link-item input {
    flex: 1;
    padding: 8px 12px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    background: var(--sidebar-bg);
    color: var(--text-primary);
    font-size: 13px;
}

.copy-btn {
    padding: 8px 16px;
    background: var(--accent-color);
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    transition: background 0.15s;
    white-space: nowrap;
}

.copy-btn:hover {
    background: var(--accent-hover);
}

/* Social Buttons */
.social-buttons {
    display: flex;
    gap: 8px;
}

.social-btn {
    flex: 1;
    padding: 10px 16px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    transition: all 0.15s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.social-btn.facebook {
    background: #1877f2;
    color: white;
    border-color: #1877f2;
}

.social-btn.facebook:hover {
    background: #166fe5;
}

.social-btn.twitter {
    background: #1da1f2;
    color: white;
    border-color: #1da1f2;
}

.social-btn.twitter:hover {
    background: #1a94da;
}

/* More Menu Dropdown */
.more-menu-dropdown {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    background: var(--content-bg);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    min-width: 200px;
    z-index: 1000;
}

.more-menu-section {
    padding: 8px 0;
    border-bottom: 1px solid var(--border-color);
}

.more-menu-section:last-child {
    border-bottom: none;
}

.menu-section-title {
    padding: 8px 16px 4px;
    font-size: 11px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.menu-item {
    width: 100%;
    padding: 10px 16px;
    background: none;
    border: none;
    text-align: left;
    cursor: pointer;
    font-size: 14px;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 12px;
    transition: background 0.15s;
}

.menu-item:hover {
    background: var(--sidebar-hover);
}

.menu-item i {
    width: 18px;
    color: var(--text-primary);
    font-size: 16px;
}

.menu-item.premium-locked {
    color: var(--text-primary);
    cursor: not-allowed;
    opacity: 0.5;
}

.premium-badge {
    margin-left: auto;
    font-size: 12px;
    color: #ff9500;
}

/* Form Inputs */
.form-input {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    background: var(--sidebar-bg);
    color: var(--text-primary);
    font-size: 14px;
    margin-bottom: 12px;
    font-family: inherit;
}

.form-input:focus {
    outline: none;
    border-color: var(--accent-color);
}

/* Action Buttons */
.action-btn {
    width: 100%;
    padding: 12px 16px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all 0.15s;
}

.primary-btn {
    background: var(--accent-color);
    color: white;
}

.primary-btn:hover {
    background: var(--accent-hover);
}

.danger-btn {
    background: #ff3b30;
    color: white;
    margin-bottom: 12px;
}

.danger-btn:hover {
    background: #e63027;
}

/* Export Options */
.export-options {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.export-option-btn {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    background: var(--sidebar-bg);
    cursor: pointer;
    transition: all 0.15s;
}

.export-option-btn:hover {
    background: var(--sidebar-hover);
    border-color: var(--accent-color);
}

.export-icon {
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    font-size: 24px;
}

.export-icon.pdf {
    background: #ff3b30;
    color: white;
}

.export-icon.word {
    background: #2b579a;
    color: white;
}

.export-icon.markdown {
    background: #0366d6;
    color: white;
}

.export-icon.html {
    background: #e34c26;
    color: white;
}

.export-details {
    flex: 1;
    text-align: left;
}

.export-name {
    font-size: 15px;
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.export-desc {
    font-size: 13px;
    color: var(--text-secondary);
}

.export-option-btn > i:last-child {
    color: var(--text-secondary);
    font-size: 18px;
}

.attachments-modal-content {
    max-width: 640px;
}

.upload-section {
    text-align: center;
    padding: 24px;
    border: 2px dashed var(--border-color);
    border-radius: 8px;
    margin-bottom: 24px;
}

.upload-btn {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 12px 24px;
    background: var(--accent-color);
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: background 0.15s;
}

.upload-btn:hover {
    background: var(--accent-hover);
}

.attachments-list {
    min-height: 100px;
}

.attachments-loading,
.attachments-empty {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-secondary);
    font-size: 14px;
}

.attachments-loading i {
    font-size: 24px;
    display: block;
    margin-bottom: 12px;
}

.attachment-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    margin-bottom: 8px;
    transition: all 0.15s;
}

.attachment-item:hover {
    background: var(--sidebar-hover);
}

.attachment-icon {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--sidebar-bg);
    border-radius: 6px;
    font-size: 18px;
    color: var(--text-secondary);
}

.attachment-info {
    flex: 1;
}

.attachment-name {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 4px;
    word-break: break-word;
}

.attachment-meta {
    font-size: 12px;
    color: var(--text-secondary);
}

.attachment-actions {
    display: flex;
    gap: 8px;
}

.attachment-action-btn {
    padding: 6px 12px;
    border: 1px solid var(--border-color);
    background: transparent;
    border-radius: 4px;
    cursor: pointer;
    font-size: 13px;
    color: var(--text-primary);
    transition: all 0.15s;
}

.attachment-action-btn:hover {
    background: var(--sidebar-hover);
}

.attachment-action-btn.delete {
    color: #ff3b30;
    border-color: #ff3b30;
}

.attachment-action-btn.delete:hover {
    background: #ff3b30;
    color: white;
}

@media (max-width: 480px) {
    .editor-page {
        padding: 32px 16px;
    }

    .editor-topbar {
        padding: 0 12px;
    }

    .breadcrumb {
        font-size: 12px;
    }

    /* Smaller emoji grid for small mobile devices */
    .emoji-grid {
        grid-template-columns: repeat(4, 1fr);
        gap: 6px;
        padding: 8px;
    }

    .emoji-item {
        font-size: 24px;
        padding: 4px;
    }

    .modal-body {
        padding: 16px;
    }

    .modal-header {
        padding: 16px;
    }

    .icon-picker-tabs {
        gap: 4px;
    }

    .icon-tab {
        padding: 4px 8px;
        font-size: 12px;
    }
}

/* ============================================
   Animations & Transitions
   ============================================ */

@keyframes slideIn {
    from {
        margin-left: calc(-1 * var(--sidebar-width));
        opacity: 0;
    }
    to {
        margin-left: 0;
        opacity: 1;
    }
}

@keyframes slideOut {
    from {
        margin-left: 0;
        opacity: 1;
    }
    to {
        margin-left: calc(-1 * var(--sidebar-width));
        opacity: 0;
    }
}

/* ============================================
   Version History Styles
   ============================================ */

/* Version history modal needs special structure */
#version-history-modal .modal-content {
    display: flex;
    flex-direction: column;
    max-height: 80vh;
    overflow: hidden; /* Remove scrollbar from outer container */
}

#version-history-modal .modal-header {
    flex-shrink: 0; /* Header stays fixed */
}

#version-history-modal .modal-body {
    flex: 1;
    overflow-y: auto; /* Only body scrolls */
    padding: 24px;
}

/* Scrollbar styling for version history modal */
#version-history-modal .modal-body::-webkit-scrollbar {
    width: 9px;
}

#version-history-modal .modal-body::-webkit-scrollbar-track {
    background: transparent;
}

#version-history-modal .modal-body::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 4px;
}

/* Scrollbar styling for upgrade modal */
.upgrade-modal-scrollable::-webkit-scrollbar {
    width: 9px;
}

.upgrade-modal-scrollable::-webkit-scrollbar-track {
    background: transparent;
}

.upgrade-modal-scrollable::-webkit-scrollbar-thumb {
    background: #dddddd;
    border-radius: 4px;
}

/* Dark mode scrollbar for upgrade modal */
body.dark .upgrade-modal-scrollable::-webkit-scrollbar-thumb {
    background: #404040;
    border-radius: 4px;
}

/* Horizontal Upgrade Modal Layout */
.upgrade-modal-content-horizontal {
    display: flex;
    gap: 40px;
    padding: 30px;
    max-width: 900px;
    margin: 0 auto;
}

.upgrade-header-section {
    flex: 0 0 280px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    text-align: center;
    padding: 20px;
    background: linear-gradient(135deg, #50ca59 0%, #3ba644 100%);
    border-radius: 12px;
    color: white;
}

.upgrade-plan-badge-horizontal {
    display: inline-block;
    background: rgba(255, 255, 255, 0.25);
    padding: 6px 16px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin: 0 auto;
}

.upgrade-header-section h2 {
    margin: 0;
    font-size: 24px;
    font-weight: 700;
    line-height: 1.3;
}

.upgrade-plan-price-horizontal {
    display: flex;
    align-items: baseline;
    justify-content: center;
    gap: 2px;
    margin: 8px 0;
}

.upgrade-plan-price-horizontal .currency {
    font-size: 24px;
    font-weight: 600;
}

.upgrade-plan-price-horizontal .amount {
    font-size: 48px;
    font-weight: 700;
    line-height: 1;
}

.upgrade-plan-price-horizontal .period {
    font-size: 16px;
    opacity: 0.9;
}

.upgrade-subscribe-btn-horizontal {
    background: white;
    color: #50ca59;
    border: none;
    padding: 14px 28px;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    margin-top: auto;
}

.upgrade-subscribe-btn-horizontal:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.15);
}

.upgrade-subscribe-btn-horizontal i {
    margin-right: 8px;
}

.upgrade-features-section {
    flex: 1;
    display: flex;
    align-items: center;
}

.upgrade-features-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 20px;
    width: 100%;
}

.feature-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    background: var(--bg-secondary);
    border-radius: 8px;
    transition: all 0.2s ease;
}

.feature-item:hover {
    transform: translateX(4px);
    background: var(--bg-tertiary);
}

.feature-item i {
    font-size: 20px;
    color: #50ca59;
    flex-shrink: 0;
}

.feature-item span {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-primary);
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .upgrade-modal-content-horizontal {
        flex-direction: column;
        gap: 30px;
        padding: 20px;
    }

    .upgrade-header-section {
        flex: 1;
    }

    .upgrade-features-grid {
        grid-template-columns: 1fr;
    }
}

/* Scrollbar styling for payment modal */
.payment-modal-body::-webkit-scrollbar {
    width: 9px;
}

.payment-modal-body::-webkit-scrollbar-track {
    background: transparent;
}

.payment-modal-body::-webkit-scrollbar-thumb {
    background: #dddddd;
    border-radius: 4px;
}

/* Dark mode scrollbar for payment modal */
body.dark .payment-modal-body::-webkit-scrollbar-thumb {
    background: #404040;
    border-radius: 4px;
}

.version-history-list {
    margin-top: 15px;
}

.version-loading,
.version-empty {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-secondary);
}

.version-loading i,
.version-empty i {
    font-size: 32px;
    margin-bottom: 10px;
    display: block;
}

.version-item {
    background: var(--sidebar-bg);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 15px;
    margin-bottom: 12px;
    transition: all 0.2s ease;
}

.version-item:hover {
    border-color: var(--accent-color);
    box-shadow: 0 2px 8px rgba(80, 202, 89, 0.1);
}

.version-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.version-number {
    font-weight: 600;
    color: var(--text-primary);
    font-size: 15px;
}

.version-date {
    color: var(--text-secondary);
    font-size: 13px;
}

.version-preview {
    color: var(--text-secondary);
    font-size: 13px;
    margin-bottom: 12px;
    max-height: 60px;
    overflow: hidden;
    line-height: 1.5;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
}

.version-actions {
    display: flex;
    gap: 8px;
}

.version-btn {
    padding: 6px 14px;
    border: 1px solid var(--border-color);
    background: var(--content-bg);
    color: var(--text-primary);
    border-radius: 6px;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 6px;
}

.version-btn:hover {
    border-color: var(--accent-color);
    background: var(--accent-color);
    color: white;
}

.version-btn.view-btn:hover {
    border-color: #2196F3;
    background: #2196F3;
}

.version-btn i {
    font-size: 12px;
}

.version-current-badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    background: var(--accent-color);
    color: white;
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
}

/* Dark mode adjustments */
body.dark .version-item {
    background: #252525;
    border-color: #404040;
}

body.dark .version-item:hover {
    border-color: #50ca59;
}

body.dark .version-number {
    color: #e0e0e0;
}

body.dark .version-date {
    color: #b0b0b0;
}

body.dark .version-preview {
    color: #b0b0b0;
}

body.dark .version-btn {
    background: #1d1d1d;
    border-color: #404040;
    color: #d4d4d4;
}

body.dark .version-btn:hover {
    border-color: #50ca59;
    background: #50ca59;
    color: white;
}

body.dark .version-loading p {
    color: #b0b0b0;
}

body.dark #version-history-modal .modal-body::-webkit-scrollbar-thumb {
    background: #404040;
}

body.dark #version-history-modal .modal-body::-webkit-scrollbar-track {
    background: #252525;
}

/* ============================================
   Notes Pagination Chevrons
   ============================================ */

.pagination-chevron {
    width: 20px;
    height: 20px;
    border: none;
    border-radius: 3px;
    background: transparent;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.15s ease;
    padding: 0;
}

.pagination-chevron:hover:not(:disabled) {
    background: var(--sidebar-hover);
    color: var(--text-primary);
}

.pagination-chevron:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.pagination-chevron i {
    font-size: 10px;
}

#notes-pagination {
    display: flex;
    align-items: center;
    gap: 4px;
}

/* ============================================
   Sidebar Notes Search
   ============================================ */

.sidebar-icon-btn {
    transition: all 0.2s ease;
}

.sidebar-icon-btn:hover {
    background: var(--sidebar-hover) !important;
    color: var(--text-primary) !important;
}

.sidebar-icon-btn:active {
    background: var(--sidebar-active) !important;
}

#sidebar-notes-search-input:focus {
    outline: none;
    border-color: var(--accent-color);
}

#sidebar-search-info {
    display: flex;
    align-items: center;
    gap: 6px;
}

#sidebar-search-info i {
    font-size: 11px;
}

.sidebar-empty {
    text-align: center;
    padding: 30px 20px;
    color: var(--text-secondary);
}

.sidebar-empty i {
    font-size: 32px;
    margin-bottom: 10px;
    opacity: 0.5;
}

.sidebar-empty p {
    margin: 0;
    font-size: 13px;
}

/* ============================================
   Recent Notes More Menu
   ============================================ */

.nav-item {
    position: relative;
}

.recent-note-more-btn {
    width: 22px;
    height: 22px;
    border: none;
    border-radius: 4px;
    background: var(--sidebar-hover);
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.15s ease;
    opacity: 0;
    margin-left: auto;
}

.nav-item:hover .recent-note-more-btn {
    opacity: 1;
}

.recent-note-more-btn:hover {
    background: var(--sidebar-active);
    color: var(--text-primary);
}

.recent-note-more-menu {
    position: absolute;
    top: calc(100% + 4px);
    right: 0;
    background: var(--content-bg);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    min-width: 140px;
    z-index: 1000;
    padding: 4px 0;
}

.recent-note-more-menu .menu-item {
    width: 100%;
    padding: 8px 12px;
    background: none;
    border: none;
    text-align: left;
    cursor: pointer;
    font-size: 14px;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 10px;
    transition: background 0.15s;
}

.recent-note-more-menu .menu-item:hover {
    background: var(--sidebar-hover);
}

.recent-note-more-menu .menu-item i {
    width: 14px;
    color: var(--text-primary);
    font-size: 14px;
}

/* Current note delete button */
.workspace-item {
    position: relative;
}

.workspace-item .delete-note-btn {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    opacity: 0;
    background: rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 4px;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.workspace-item:hover .delete-note-btn {
    opacity: 1;
}

.workspace-item .delete-note-btn:hover {
    color: #ff4444;
    background: rgba(255, 255, 255, 0.95);
}

.workspace-item .delete-note-btn i {
    font-size: 14px;
}

/* Dark mode delete button adjustments */
body.dark .nav-item .delete-note-btn,
body.dark .workspace-item .delete-note-btn {
    background: rgba(29, 29, 29, 0.8);
    border-color: var(--border-color);
}

body.dark .nav-item .delete-note-btn:hover,
body.dark .workspace-item .delete-note-btn:hover {
    background: rgba(29, 29, 29, 0.95);
}
.workspace-note-actions {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 6px;
}

.workspace-note-actions .shared-badge {
    margin-left: 0;
}

.sub-note-inline-btn {
    width: 22px;
    height: 22px;
    border: none;
    border-radius: 4px;
    background: var(--sidebar-hover);
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease;
}

.sub-note-inline-btn:hover:not(:disabled) {
    background: var(--sidebar-active);
    color: var(--text-primary);
}

.sub-note-inline-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Parent Note More Button and Menu */
.parent-note-more-btn {
    width: 22px;
    height: 22px;
    border: none;
    border-radius: 4px;
    background: var(--sidebar-hover);
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.15s ease;
    opacity: 0;
}

.workspace-item:hover .parent-note-more-btn {
    opacity: 1;
}

.parent-note-more-btn:hover {
    background: var(--sidebar-active);
    color: var(--text-primary);
}

.parent-note-more-menu {
    position: absolute;
    top: calc(100% + 4px);
    right: 0;
    background: var(--content-bg);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    min-width: 160px;
    z-index: 1000;
    padding: 4px 0;
}

.parent-note-more-menu .menu-item {
    width: 100%;
    padding: 8px 12px;
    background: none;
    border: none;
    text-align: left;
    cursor: pointer;
    font-size: 14px;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 10px;
    transition: background 0.15s;
}

.parent-note-more-menu .menu-item:hover {
    background: var(--sidebar-hover);
}

.parent-note-more-menu .menu-item i {
    width: 14px;
    color: var(--text-primary);
    font-size: 14px;
}

/* Disabled menu item */
.parent-note-more-menu .menu-item.menu-item-disabled {
    opacity: 0.5;
    cursor: not-allowed;
    color: var(--text-secondary);
}

.parent-note-more-menu .menu-item.menu-item-disabled:hover {
    background: transparent;
}

/* Dark mode adjustments */
body.dark .parent-note-more-menu {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

body.dark .note-limit-display {
    border-top-color: var(--border-color);
}

body.dark .note-progress-bar {
    background: rgba(255, 255, 255, 0.1);
}

body.dark .note-limit-display.near-limit .note-count {
    color: #f39c12;
}

body.dark .note-limit-display.at-limit .note-count {
    color: #e74c3c;
}

body.dark .note-limit-upgrade-link {
    color: var(--text-secondary);
}

body.dark .note-limit-upgrade-link:hover {
    color: var(--text-primary);
}

/* ============================================
   Note Icon Picker
   ============================================ */

/* Icon container in editor */
.note-icon-container {
    margin-bottom: 8px;
}

.note-icon-button {
    background: transparent;
    border: 2px dashed transparent;
    border-radius: 6px;
    padding: 4px 8px;
    cursor: pointer;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 48px;
    line-height: 1;
    width: 64px;
    height: 64px;
}

.note-icon-button:hover {
    background: var(--sidebar-hover);
    border-color: var(--border-color);
}

/* Text link style for "Add icon" */
.note-icon-link {
    background: transparent;
    border: none;
    padding: 6px 0;
    cursor: pointer;
    color: var(--text-secondary);
    font-size: 14px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: all 0.2s;
    font-weight: 400;
    opacity: 0.6;
}

.note-icon-link:hover {
    color: var(--text-primary);
    opacity: 0.9;
}

.note-icon-link i {
    font-size: 16px;
}

.note-icon-display {
    display: flex;
    align-items: center;
    justify-content: center;
}

.note-icon-empty {
    opacity: 0.3;
    font-size: 32px;
}

.note-icon-button:hover .note-icon-empty {
    opacity: 0.6;
}

/* Icon Picker Modal */
.icon-picker-tabs {
    display: flex;
    gap: 6px;
    margin-bottom: 12px;
    flex-wrap: wrap;
}

.icon-tab {
    background: transparent;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    padding: 4px 10px;
    cursor: pointer;
    font-size: 13px;
    color: var(--text-secondary);
    transition: all 0.2s;
}

.icon-tab:hover {
    background: var(--sidebar-hover);
    color: var(--text-primary);
}

.icon-tab.active {
    background: var(--accent-color);
    color: white;
    border-color: var(--accent-color);
}

.emoji-grid {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 4px;
    padding: 8px;
    margin-bottom: 12px;
}

.emoji-item {
    font-size: 28px;
    padding: 6px;
    cursor: pointer;
    border-radius: 4px;
    transition: all 0.2s;
    text-align: center;
    background: var(--content-bg);
}

.emoji-item:hover {
    background: var(--sidebar-hover);
    transform: scale(1.1);
}

.icon-picker-actions {
    display: flex;
    justify-content: center;
    gap: 8px;
}

.btn-secondary {
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 8px 16px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.btn-secondary:hover {
    background: var(--sidebar-hover);
}

/* Sidebar icon display */
#sidebar-note-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    width: 18px;
    height: 18px;
}

.nav-item .note-icon,
.workspace-item .note-icon {
    font-size: 16px;
    width: 18px;
    height: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    line-height: 1;
    text-align: center;
}

/* Dark mode styles */
body.dark .note-icon-link {
    color: var(--text-secondary);
}

body.dark .note-icon-link:hover {
    color: var(--text-primary);
}

body.dark .note-icon-button:hover {
    background: rgba(255, 255, 255, 0.05);
}

body.dark .icon-tab {
    border-color: rgba(255, 255, 255, 0.1);
    color: var(--text-secondary);
}

body.dark .icon-tab:hover {
    background: rgba(255, 255, 255, 0.05);
}

body.dark .icon-tab.active {
    background: var(--accent-color);
    color: white;
}


body.dark .emoji-item {
    background: rgba(255, 255, 255, 0.05);
}

body.dark .emoji-item:hover {
    background: rgba(255, 255, 255, 0.1);
}

body.dark .btn-secondary {
    border-color: rgba(255, 255, 255, 0.5);
    color: rgba(255, 255, 255, 0.9);
}

body.dark .btn-secondary:hover {
    background: rgba(255, 255, 255, 0.15);
    border-color: rgba(255, 255, 255, 0.7);
    color: rgba(255, 255, 255, 1);
}

/* ============================================
   Todo List Editor Styles
   ============================================ */

/* New Todo List Button - Matches New Note Button Style */
.new-todo-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 8px 12px;
    background: transparent;
    color: var(--text-primary);
    font-size: 15px;
    font-weight: 500;
    cursor: pointer;
    border-radius: 4px;
    border: 1px solid var(--border-color);
    width: 100%;
    transition: all 0.15s ease;
    margin-top: 8px;
}

.new-todo-btn:hover {
    background: var(--hover-bg);
    border-color: var(--text-secondary);
}

.new-todo-btn i {
    flex-shrink: 0;
    width: 18px;
    font-size: 18px;
}

/* New Board Button - Matches New Note and Todo Button Style */
.new-board-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 8px 12px;
    background: transparent;
    color: var(--text-primary);
    font-size: 15px;
    font-weight: 500;
    cursor: pointer;
    border-radius: 4px;
    border: 1px solid var(--border-color);
    width: 100%;
    transition: all 0.15s ease;
    margin-top: 8px;
}

.new-board-btn:hover {
    background: var(--hover-bg);
    border-color: var(--text-secondary);
}

.new-board-btn i {
    flex-shrink: 0;
    width: 18px;
    font-size: 18px;
}

/* New Habit Tracker Button - Matches New Note, Todo, and Board Button Style */
.new-habit-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 8px 12px;
    background: transparent;
    color: var(--text-primary);
    font-size: 15px;
    font-weight: 500;
    cursor: pointer;
    border-radius: 4px;
    border: 1px solid var(--border-color);
    width: 100%;
    transition: all 0.15s ease;
    margin-top: 8px;
}

.new-habit-btn:hover {
    background: var(--hover-bg);
    border-color: var(--text-secondary);
}

.new-habit-btn i {
    flex-shrink: 0;
    width: 18px;
    font-size: 18px;
}

/* ============================================
   Browse Tools Button - Matches New Note, Todo, and Board Button Style
   ============================================ */

.browse-tools-link {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 8px 12px;
    background: transparent;
    color: var(--text-primary);
    font-size: 15px;
    font-weight: 500;
    cursor: pointer;
    border-radius: 4px;
    border: 1px solid var(--border-color);
    width: 100%;
    transition: all 0.15s ease;
    margin-top: 8px;
    text-decoration: none;
}

.browse-tools-link:hover {
    background: var(--hover-bg);
    border-color: var(--text-secondary);
}

.browse-tools-link i {
    flex-shrink: 0;
    width: 18px;
    font-size: 18px;
}

/* ============================================
   Tools Modal
   ============================================ */

.tools-modal-content {
    max-width: 600px;
    width: 90%;
}

.tools-category {
    margin-bottom: 32px;
}

.tools-category:last-child {
    margin-bottom: 0;
}

.category-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 16px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border-color);
}

.tools-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
}

@media (max-width: 768px) {
    .tools-grid {
        grid-template-columns: 1fr;
    }
}

.tool-card {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px;
    background: var(--content-bg);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.tool-card:hover {
    background: var(--sidebar-hover);
    border-color: var(--accent-color);
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

.tool-icon {
    flex-shrink: 0;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--accent-color);
    color: white;
    border-radius: 8px;
}

.tool-icon i {
    font-size: 20px;
}

.tool-info {
    flex: 1;
}

.tool-info h5 {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0 0 4px 0;
}

.tool-info p {
    font-size: 12px;
    color: var(--text-secondary);
    margin: 0;
    line-height: 1.4;
}

.no-tools-message {
    text-align: center;
    color: var(--text-secondary);
    font-size: 13px;
    padding: 24px;
    font-style: italic;
}

/* ============================================
   Dark Mode - Tools Modal
   ============================================ */

body.dark .category-title {
    color: #d4d4d4;
    border-bottom-color: #353535;
}

body.dark .tool-card {
    background: #252525;
    border-color: #353535;
}

body.dark .tool-card:hover {
    background: #2d2d2d;
    border-color: var(--accent-color);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
}

body.dark .tool-info h5 {
    color: #d4d4d4;
}

body.dark .tool-info p {
    color: #b0b0b0;
}

body.dark .no-tools-message {
    color: #b0b0b0;
}
