/* ── NotepadAI — Lark-inspired design system ── */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600&display=swap');

:root {
    --lark-blue:      #3370FF;
    --lark-blue-bg:   #EEF3FF;
    --lark-blue-soft: #D4E1FF;
    --text-primary:   #1F2329;
    --text-secondary: #646A73;
    --text-muted:     #8F959E;
    --bg-page:        #F5F6F8;
    --bg-sidebar:     #F5F6F8;
    --bg-white:       #FFFFFF;
    --border:         #E4E7EC;
    --hover-bg:       #ECEDF0;
    --radius-sm:      6px;
    --radius-md:      8px;
    --header-h:       48px;
}

*, *::before, *::after { box-sizing: border-box; }

body, html {
    height: 100%;
    margin: 0; padding: 0;
    overflow: hidden;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--bg-page);
    color: var(--text-primary);
    font-size: 14px;
    -webkit-font-smoothing: antialiased;
}

/* ── Layout ── */
.notes-container {
    display: flex;
    height: calc(100vh - var(--header-h));
}

/* ── Header ── */
.app-header {
    height: var(--header-h);
    background: var(--bg-white);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    position: relative;
    z-index: 100;
}
.header-brand {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}
.header-brand i { color: var(--lark-blue); }

.header-tabs {
    display: flex;
    gap: 2px;
    margin-left: 24px;
    flex: 1;
}
.header-tab {
    padding: 6px 14px;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    cursor: pointer;
    border-radius: var(--radius-sm);
    border-bottom: 2px solid transparent;
    transition: background 0.15s, color 0.15s;
    display: flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
}
.header-tab:hover { background: var(--hover-bg); color: var(--text-primary); }
.header-tab.active {
    color: var(--lark-blue);
    border-bottom-color: var(--lark-blue);
    background: transparent;
}
.header-count-badge {
    background: var(--hover-bg);
    color: var(--text-secondary);
    font-size: 10px;
    padding: 1px 6px;
    border-radius: 10px;
    font-weight: 600;
}
.header-tab.active .header-count-badge {
    background: var(--lark-blue-bg);
    color: var(--lark-blue);
}

.header-actions { display: flex; align-items: center; gap: 8px; }
.user-dropdown-container { position: relative; }
.user-btn {
    display: flex; align-items: center; gap: 8px;
    background: transparent;
    border: none;
    padding: 4px 8px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: background 0.15s;
}
.user-btn:hover { background: var(--hover-bg); }
.user-avatar {
    width: 28px; height: 28px;
    background: var(--lark-blue);
    color: white;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: 12px; font-weight: 600;
}
.user-name { font-size: 13px; font-weight: 500; color: var(--text-primary); }
.dropdown-menu-custom {
    display: none;
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    background: var(--bg-white);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    box-shadow: 0 8px 24px rgba(0,0,0,0.10);
    width: 210px;
    z-index: 1004;
    padding: 6px 0;
}
.dropdown-menu-custom.show { display: block; }
.dropdown-item-custom {
    display: flex; align-items: center; gap: 10px;
    padding: 8px 14px;
    color: var(--text-primary);
    text-decoration: none;
    font-size: 13px;
    transition: background 0.12s;
}
.dropdown-item-custom:hover { background: var(--hover-bg); }
.dropdown-item-custom i { width: 16px; text-align: center; color: var(--text-secondary); }

/* ── Sidebar ── */
.notes-sidebar {
    width: 264px;
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
}
.sidebar-header {
    padding: 10px 10px 8px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.sidebar-search-input {
    width: 100%;
    padding: 7px 12px;
    background: var(--bg-white);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-family: inherit;
    color: var(--text-primary);
    outline: none;
    transition: border-color 0.15s, box-shadow 0.15s;
}
.sidebar-search-input::placeholder { color: var(--text-muted); }
.sidebar-search-input:focus {
    border-color: var(--lark-blue);
    box-shadow: 0 0 0 2px var(--lark-blue-bg);
}
#btnNewAtTop {
    background: var(--lark-blue);
    color: white;
    border: none;
    border-radius: var(--radius-sm);
    padding: 7px 0;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    width: 100%;
    display: flex; align-items: center; justify-content: center; gap: 6px;
    transition: background 0.15s;
}
#btnNewAtTop:hover { background: #2860e8; }
#btnNewAtTop:disabled { opacity: 0.5; cursor: not-allowed; }

/* Tags section */
.sidebar-tags-container {
    padding: 6px 10px 8px;
    border-bottom: 1px solid var(--border);
}
.tags-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 6px;
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    letter-spacing: 0.04em;
    text-transform: uppercase;
}
.tags-list { display: flex; flex-wrap: wrap; gap: 4px; }
.tag-chip {
    font-size: 11px;
    padding: 2px 9px;
    background: var(--bg-white);
    border: 1px solid var(--border);
    border-radius: 20px;
    cursor: pointer;
    color: var(--text-secondary);
    transition: all 0.15s;
    display: inline-flex; align-items: center; gap: 3px;
}
.tag-chip:hover { border-color: var(--lark-blue); color: var(--lark-blue); }
.tag-chip.active { background: var(--lark-blue-bg); border-color: var(--lark-blue-soft); color: var(--lark-blue); }
.btn-add-tag {
    background: none; border: none;
    color: var(--lark-blue);
    cursor: pointer; padding: 0;
    font-size: 11px; font-weight: 500;
}
.btn-add-tag:hover { opacity: 0.75; }

/* Note list */
.sidebar-list { flex: 1; overflow-y: auto; padding: 4px 6px; }
.sidebar-list::-webkit-scrollbar { width: 4px; }
.sidebar-list::-webkit-scrollbar-thumb { background: #D0D3D9; border-radius: 4px; }

.note-item {
    padding: 8px 10px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: background 0.12s;
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 2px;
    margin-bottom: 1px;
}
.note-item:hover { background: var(--hover-bg); }
.note-item.active { background: var(--lark-blue-bg); }
.note-item-title {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.note-item.active .note-item-title { color: var(--lark-blue); }
.note-index-badge {
    position: absolute; top: 4px; right: 6px;
    font-size: 9px; color: var(--text-muted);
}
.note-item-date { font-size: 11px; color: var(--text-muted); }

/* Sidebar footer */
.sidebar-footer {
    padding: 8px 6px;
    border-top: 1px solid var(--border);
}
.sidebar-footer .btn-group { gap: 4px; }
.sidebar-footer .btn-group .btn {
    border-radius: var(--radius-sm) !important;
    border: none !important;
    font-size: 12px;
    font-weight: 500;
    color: var(--text-secondary);
    background: transparent;
    padding: 5px 0;
    transition: background 0.12s, color 0.12s;
}
.sidebar-footer .btn-group .btn:hover { background: var(--hover-bg); color: var(--text-primary); }
.sidebar-footer .btn-group .btn.active {
    background: var(--lark-blue-bg) !important;
    color: var(--lark-blue) !important;
}
#trashFooter .btn {
    border-radius: var(--radius-sm) !important;
    border: 1px solid var(--border) !important;
    font-size: 12px; color: var(--text-secondary);
    background: transparent;
}
#trashFooter .btn:hover { background: var(--hover-bg); }

/* Sync status bar */
#sidebarSyncStatus {
    font-size: 10px; color: var(--text-muted);
    padding: 4px 10px;
    text-align: center;
    border-top: 1px solid var(--border);
    display: flex; align-items: center; justify-content: center; gap: 6px;
}
#sidebarSyncStatus .btn-link {
    font-size: 10px; color: var(--lark-blue);
    text-decoration: none; padding: 0;
    background: none; border: none; cursor: pointer;
}
#sidebarSyncStatus .btn-link:hover { text-decoration: underline; }

/* ── Content area ── */
.notes-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 20px 24px;
    background: var(--bg-white);
    overflow: hidden;
}
#noteTitle {
    width: 100%;
    padding: 8px 0;
    font-size: 22px;
    font-weight: 600;
    font-family: inherit;
    border: none;
    outline: none;
    color: var(--text-primary);
    background: transparent;
    line-height: 1.3;
}
#noteTitle::placeholder { color: var(--text-muted); font-weight: 400; }
#noteStatus { font-size: 11px; color: var(--text-muted); padding-top: 4px; text-align: right; }
.tox-tinymce { border: none !important; flex: 1; }

/* Star icon */
.star-icon { color: var(--border); cursor: pointer; transition: color 0.15s; font-size: 16px; }
.star-icon.starred { color: #F5A623; }
.star-icon:hover { color: #F5A623; }

/* Toolbar icon buttons */
.toolbar-icon-btn {
    width: 30px; height: 30px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    font-size: 13px;
    transition: background 0.12s, border-color 0.12s, color 0.12s;
    flex-shrink: 0;
    position: relative;
}
.toolbar-icon-btn:hover { background: var(--hover-bg); border-color: #C8CDD6; color: var(--text-primary); }

/* Save button */
#saveBtn {
    padding: 5px 16px;
    height: 30px;
    font-size: 13px;
    font-weight: 500;
    border-radius: var(--radius-sm);
    background: var(--lark-blue);
    color: white;
    border: none;
    cursor: pointer;
    display: flex; align-items: center; gap: 6px;
    white-space: nowrap;
    flex-shrink: 0;
    transition: background 0.15s;
}
#saveBtn:hover { background: #2860e8; }
#saveBtn:disabled { opacity: 0.6; cursor: not-allowed; }

/* Toolbar divider */
.toolbar-divider {
    width: 1px; height: 18px;
    background: var(--border);
    flex-shrink: 0;
}

/* Color picker */
.color-picker-dropdown {
    display: none;
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    background: var(--bg-white);
    border: 1px solid var(--border);
    padding: 10px;
    border-radius: var(--radius-md);
    box-shadow: 0 8px 24px rgba(0,0,0,0.10);
    z-index: 1005;
    flex-wrap: wrap;
    gap: 6px;
    width: 148px;
}
.color-picker-dropdown.show { display: flex; }
.color-dot {
    width: 20px; height: 20px;
    border-radius: 50%;
    cursor: pointer;
    border: 2px solid transparent;
    transition: transform 0.15s, box-shadow 0.15s;
}
.color-dot:hover { transform: scale(1.15); box-shadow: 0 0 0 2px var(--lark-blue); }
.color-dot.selected { box-shadow: 0 0 0 2px var(--lark-blue); }

/* Editor tags */
.editor-tags-area {
    display: flex; align-items: center; gap: 6px;
    flex-wrap: wrap; margin-bottom: 8px;
}
.editor-tag-chip {
    font-size: 11px; padding: 2px 8px;
    background: var(--lark-blue-bg);
    border-radius: 20px; color: var(--lark-blue);
    display: inline-flex; align-items: center; gap: 4px;
}
.editor-tag-remove { cursor: pointer; color: var(--lark-blue); opacity: 0.6; font-size: 10px; }
.editor-tag-remove:hover { opacity: 1; }

.editor-tag-dropdown {
    display: none;
    position: absolute; top: 100%; left: 0;
    background: var(--bg-white);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    box-shadow: 0 8px 24px rgba(0,0,0,0.10);
    z-index: 1006; min-width: 160px;
    max-height: 200px; overflow-y: auto; padding: 4px 0;
}
.editor-tag-dropdown.show { display: block; }
.editor-tag-item {
    padding: 7px 14px; font-size: 13px; cursor: pointer;
    display: flex; align-items: center; justify-content: space-between;
    color: var(--text-primary);
}
.editor-tag-item:hover { background: var(--hover-bg); }
.editor-tag-item.selected { color: var(--lark-blue); background: var(--lark-blue-bg); }
.editor-tag-item i { font-size: 10px; visibility: hidden; }
.editor-tag-item.selected i { visibility: visible; }

/* Bookmarks */
.bookmarks-container {
    flex: 1; padding: 48px;
    display: flex; flex-direction: column; align-items: center;
    background: var(--bg-page); overflow-y: auto;
}
.bookmarks-placeholder {
    text-align: center; max-width: 480px; padding: 48px;
    background: var(--bg-white);
    border-radius: 12px;
    box-shadow: 0 2px 12px rgba(0,0,0,0.06);
}
.bookmarks-icon { font-size: 48px; color: var(--lark-blue); margin-bottom: 20px; }

/* Mobile menu button */
.btn-menu-mobile {
    display: none;
    background: none; border: none;
    font-size: 18px; color: var(--text-primary);
    cursor: pointer; padding: 4px 6px;
    border-radius: var(--radius-sm);
    line-height: 1;
}
.btn-menu-mobile:active { background: var(--hover-bg); }

/* Sidebar overlay */
.sidebar-overlay {
    display: none; position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.35); z-index: 999;
}

/* Login overlay */
.login-overlay {
    position: fixed; top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(255,255,255,1);
    z-index: 10000; display: flex;
    align-items: center; justify-content: center; text-align: center;
}

/* Tags Modal */
.modal-overlay {
    display: none; position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.4);
    z-index: 2000; justify-content: center; align-items: center;
}
.modal-content {
    background: var(--bg-white);
    padding: 24px; border-radius: var(--radius-md);
    width: 90%; max-width: 400px;
    max-height: 80vh; overflow-y: auto; position: relative;
}
.modal-close {
    position: absolute; top: 14px; right: 16px;
    cursor: pointer; font-size: 18px; color: var(--text-muted);
}

/* Trash action buttons */
.note-trash-actions { display: flex; gap: 6px; margin-top: 4px; }
.note-trash-actions .btn {
    font-size: 11px; padding: 2px 10px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
}
.note-trash-actions .btn:hover { background: var(--hover-bg); }

/* ── Toast notification ── */
#appToast {
    position: fixed;
    bottom: 28px;
    left: 50%;
    transform: translateX(-50%) translateY(16px);
    background: var(--text-primary);
    color: white;
    padding: 9px 20px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 500;
    z-index: 9999;
    opacity: 0;
    transition: opacity 0.2s ease, transform 0.2s ease;
    pointer-events: none;
    white-space: nowrap;
    box-shadow: 0 4px 16px rgba(0,0,0,0.20);
}
#appToast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}
#appToast.toast-success { background: #12B76A; }
#appToast.toast-error   { background: #F04438; }
#appToast.toast-info    { background: var(--lark-blue); }

/* ── Mobile ── */
@media (max-width: 768px) {
    .app-header {
        height: 52px; padding: 0 12px;
        flex-wrap: nowrap; justify-content: space-between;
        position: fixed; top: 0; left: 0; right: 0; z-index: 1010;
    }
    .btn-menu-mobile { display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
    .header-brand {
        position: absolute; left: 50%; transform: translateX(-50%);
        font-size: 15px; white-space: nowrap;
    }
    .header-tabs { display: none; }
    .user-btn .user-name, .user-btn .fa-chevron-down { display: none; }
    .user-btn { padding: 4px; border-radius: 50%; }
    .notes-sidebar {
        position: fixed; left: -280px; top: 52px; bottom: 0;
        width: 280px; z-index: 1005; transition: left 0.26s ease; box-shadow: none;
    }
    .notes-sidebar.open { left: 0; box-shadow: 4px 0 20px rgba(0,0,0,0.15); }
    .sidebar-overlay.show { display: block; top: 52px; }
    .notes-container { height: calc(100vh - 52px); margin-top: 52px; }
    .notes-content { padding: 12px; }
    #btnInstall { display: none !important; }
    #noteTitle { font-size: 18px; }
    #appToast { bottom: 16px; font-size: 12px; }
}
