/* NoteVault — Styles */
:root {
    --primary: #534AB7;
    --primary-light: #7B6FD6;
    --primary-dark: #3D3590;
    --bg: #f5f6fa;
    --bg-white: #ffffff;
    --text: #1a1a2e;
    --text-light: #6c6c80;
    --border: #e0e0e8;
    --shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    --radius: 8px;
    --sidebar-width: 240px;
    --snippet-bg: #f8f9fa;
    --search-mark-bg: #fef08a;
}

/* Dark mode */
[data-theme="dark"] {
    --bg: #1a1a2e;
    --bg-white: #16213e;
    --text: #e0e0e8;
    --text-light: #8888a0;
    --border: #2a2a4a;
    --shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    --snippet-bg: #1e1e3a;
    --search-mark-bg: #854d0e;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
    background: var(--bg);
    color: var(--text);
    height: 100vh;
    overflow: hidden;
}

/* Header */
header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    height: 56px;
    background: var(--bg-white);
    border-bottom: 1px solid var(--border);
    z-index: 10;
}
.logo {
    font-size: 20px;
    font-weight: 700;
    color: var(--primary);
    white-space: nowrap;
}
.header-center {
    flex: 1;
    max-width: 500px;
    margin: 0 20px;
}
.header-center input {
    width: 100%;
    padding: 8px 16px;
    border: 1px solid var(--border);
    border-radius: 20px;
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s;
}
.header-center input:focus {
    border-color: var(--primary);
}
.header-right button {
    background: none;
    border: none;
    font-size: 20px;
    cursor: pointer;
    color: var(--text-light);
    padding: 4px 8px;
    border-radius: 4px;
}
.header-right button:hover {
    background: var(--bg);
}

/* Main layout */
.main-layout {
    display: flex;
    height: calc(100vh - 56px);
    overflow: hidden;
}

/* Sidebars */
.sidebar {
    width: var(--sidebar-width);
    min-width: var(--sidebar-width);
    background: var(--bg-white);
    border-right: 1px solid var(--border);
    overflow-y: auto;
    padding: 12px;
}
#sidebar-right {
    border-right: none;
    border-left: 1px solid var(--border);
}
.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
}
.sidebar-header h3 {
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-light);
}
.sidebar-header button {
    background: none;
    border: 1px solid var(--border);
    border-radius: 4px;
    width: 24px;
    height: 24px;
    cursor: pointer;
    font-size: 16px;
    color: var(--text-light);
    display: flex;
    align-items: center;
    justify-content: center;
}
.sidebar-header button:hover {
    background: var(--bg);
    color: var(--primary);
}

/* Folder tree */
.folder-item {
    padding: 6px 8px;
    cursor: pointer;
    border-radius: var(--radius);
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: background 0.15s;
}
.folder-item:hover {
    background: var(--bg);
}
.folder-item.active {
    background: var(--primary);
    color: white;
}
.folder-item .arrow {
    font-size: 10px;
    width: 14px;
    text-align: center;
    flex-shrink: 0;
}
.folder-item .arrow.collapsed {
    transform: rotate(-90deg);
}
.folder-item .name {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.folder-item .count {
    font-size: 12px;
    color: var(--text-light);
    flex-shrink: 0;
}
.folder-item.active .count {
    color: rgba(255, 255, 255, 0.7);
}
.folder-children {
    padding-left: 16px;
}
.folder-children.collapsed {
    display: none;
}

/* Content area */
#content-area {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    min-width: 0;
}

/* Breadcrumb */
#breadcrumb {
    margin-bottom: 16px;
    font-size: 14px;
    color: var(--text-light);
}
#breadcrumb a {
    color: var(--primary);
    text-decoration: none;
    cursor: pointer;
}
#breadcrumb a:hover {
    text-decoration: underline;
}
#breadcrumb span {
    margin: 0 4px;
}

/* File list */
.file-card {
    background: var(--bg-white);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
    margin-bottom: 12px;
    cursor: pointer;
    transition: box-shadow 0.2s, border-color 0.2s;
}
.file-card:hover {
    box-shadow: var(--shadow);
    border-color: var(--primary-light);
}
.file-card .file-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--primary-dark);
    margin-bottom: 4px;
}
.file-card .file-desc {
    font-size: 13px;
    color: var(--text-light);
    margin-bottom: 8px;
    line-height: 1.4;
}
.file-card .file-meta {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 12px;
    color: var(--text-light);
}
.file-card .file-tags {
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
}
.tag-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 12px;
    background: var(--primary);
    color: white;
    cursor: pointer;
    transition: opacity 0.15s;
}
.tag-badge:hover {
    opacity: 0.8;
}

/* Pagination */
#pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-top: 20px;
    padding: 12px;
}
#pagination button {
    padding: 6px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg-white);
    cursor: pointer;
    font-size: 13px;
}
#pagination button:hover {
    border-color: var(--primary);
    color: var(--primary);
}
#pagination button:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}
#pagination .page-info {
    font-size: 13px;
    color: var(--text-light);
}

/* Tag cloud */
.tag-cloud-item {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    margin: 3px;
    border-radius: 14px;
    font-size: 13px;
    background: var(--bg);
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}
.tag-cloud-item:hover {
    background: var(--primary);
    color: white;
}
.tag-cloud-item.active {
    background: var(--primary);
    color: white;
}
.tag-cloud-item .tag-count {
    font-size: 11px;
    opacity: 0.7;
}

/* Modals */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
}
.modal {
    background: var(--bg-white);
    border-radius: 12px;
    padding: 32px;
    width: 90%;
    max-width: 400px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
}
.modal h2 {
    margin-bottom: 12px;
    color: var(--primary);
}
.modal p {
    margin-bottom: 16px;
    font-size: 14px;
    color: var(--text-light);
}
.modal input[type="password"],
.modal input[type="text"] {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 14px;
    margin-bottom: 16px;
    outline: none;
}
.modal input:focus {
    border-color: var(--primary);
}
.modal button {
    width: 100%;
    padding: 10px;
    border: none;
    border-radius: var(--radius);
    background: var(--primary);
    color: white;
    font-size: 14px;
    cursor: pointer;
    transition: background 0.2s;
}
.modal button:hover {
    background: var(--primary-dark);
}
.modal-full {
    background: var(--bg-white);
    width: 95vw;
    height: 90vh;
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
}
.modal-header h2 {
    font-size: 18px;
    color: var(--text);
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.modal-header button {
    background: none;
    border: none;
    font-size: 28px;
    cursor: pointer;
    color: var(--text-light);
    padding: 0 4px;
}
.modal-header button:hover {
    color: var(--text);
}
.modal-body {
    flex: 1;
    overflow: hidden;
}
.modal-body iframe {
    width: 100%;
    height: 100%;
    border: none;
}

/* Search results overlay */
#search-results {
    position: fixed;
    inset: 56px 0 0 0;
    background: var(--bg);
    z-index: 50;
    overflow-y: auto;
    padding: 20px;
}
.search-results-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}
.search-results-header h2 {
    font-size: 18px;
}
.search-results-header h2 span {
    color: var(--primary);
}
.search-results-header button {
    background: none;
    border: none;
    font-size: 28px;
    cursor: pointer;
    color: var(--text-light);
}
#search-list .search-item {
    background: var(--bg-white);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
    margin-bottom: 12px;
    cursor: pointer;
    transition: box-shadow 0.2s;
}
#search-list .search-item:hover {
    box-shadow: var(--shadow);
}
#search-list .search-item .file-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--primary-dark);
    margin-bottom: 4px;
}
#search-list .search-item .file-desc {
    font-size: 13px;
    color: var(--text-light);
    margin-bottom: 8px;
}
#search-list .search-item .snippet {
    font-size: 13px;
    line-height: 1.5;
    color: var(--text);
    background: var(--snippet-bg);
    padding: 8px 12px;
    border-radius: 4px;
    margin-bottom: 8px;
}
#search-list .search-item .snippet mark {
    background: var(--search-mark-bg);
    color: var(--text);
    border-radius: 2px;
    padding: 0 2px;
}

/* Dark mode toggle */
.theme-toggle {
    background: none;
    border: 1px solid var(--border);
    border-radius: 4px;
    font-size: 18px;
    cursor: pointer;
    color: var(--text-light);
    padding: 4px 8px;
    margin-right: 4px;
}
.theme-toggle:hover {
    background: var(--bg);
    color: var(--primary);
}

/* Batch import */
.import-area {
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    padding: 24px;
    text-align: center;
    cursor: pointer;
    transition: border-color 0.2s, background 0.2s;
    margin-bottom: 16px;
}
.import-area:hover,
.import-area.dragover {
    border-color: var(--primary);
    background: rgba(83, 74, 183, 0.05);
}
.import-area .icon {
    font-size: 32px;
    margin-bottom: 8px;
}
.import-area p {
    font-size: 14px;
    color: var(--text-light);
}
.import-progress {
    margin-top: 12px;
}
.import-progress .bar {
    height: 4px;
    background: var(--border);
    border-radius: 2px;
    overflow: hidden;
}
.import-progress .bar .fill {
    height: 100%;
    background: var(--primary);
    transition: width 0.3s;
}
.import-progress .status {
    font-size: 13px;
    color: var(--text-light);
    margin-top: 4px;
}

/* Empty state */
.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-light);
}
.empty-state .icon {
    font-size: 48px;
    margin-bottom: 12px;
}

/* Loading */
.loading {
    text-align: center;
    padding: 20px;
    color: var(--text-light);
}

/* Responsive */
@media (max-width: 768px) {
    :root {
        --sidebar-width: 200px;
    }
    #sidebar-right {
        display: none;
    }
    .header-center {
        max-width: 300px;
    }
}

@media (max-width: 600px) {
    #sidebar-left {
        display: none;
    }
    .header-center {
        max-width: none;
        margin: 0 12px;
    }
}
