/* ============================================================
   sidebar.css — Shared across Articles / Research / Docs
   ============================================================ */

/* ── Theme definitions ─────────────────────────────────────── */
:root,
[data-theme="light"] {
    --app-bg:            #F5F5F7;
    --surface-primary:   #FFFFFF;
    --surface-secondary: #F5F5F7;
    --surface-tertiary:  #E8E8ED;
    --text-primary:      #1D1D1F;
    --text-secondary:    #6E6E73;
    --text-tertiary:     #AEAEB2;
    --accent-color:      #111111;
    --accent-secondary:  #3A3A3C;
    --border-color:      #D2D2D7;
    --hover-bg:          #EBEBF0;
    --card-bg:           #FFFFFF;
    --card-image-bg:     #F5F5F7;
    --nav-bg:            rgba(255,255,255,0.88);
    --shadow-color:      rgba(0,0,0,0.08);
    --sidebar-bg:        #FFFFFF;
    --sidebar-border:    #E5E5EA;
    --sidebar-active-bg: #F0F0F5;
}

[data-theme="rose"] {
    --app-bg:            #FFF5F5;
    --surface-primary:   #FFFFFF;
    --surface-secondary: #FFF0F0;
    --surface-tertiary:  #FFE4E4;
    --text-primary:      #2D1515;
    --text-secondary:    #8B5E5E;
    --text-tertiary:     #C4A0A0;
    --accent-color:      #E84393;
    --accent-secondary:  #FF8FAB;
    --border-color:      #FACCCC;
    --hover-bg:          #FDEAEA;
    --card-bg:           #FFFFFF;
    --card-image-bg:     #FFF0F0;
    --nav-bg:            rgba(255,255,255,0.88);
    --shadow-color:      rgba(232,67,147,0.12);
    --sidebar-bg:        #FFFFFF;
    --sidebar-border:    #FACCCC;
    --sidebar-active-bg: #FFF0F0;
}

[data-theme="dracula"] {
    --app-bg:            #282a36;
    --surface-primary:   #21222c;
    --surface-secondary: #343746;
    --surface-tertiary:  #44475a;
    --text-primary:      #f8f8f2;
    --text-secondary:    #8b8fa8;
    --text-tertiary:     #6272a4;
    --accent-color:      #bd93f9;
    --accent-secondary:  #50fa7b;
    --border-color:      #44475a;
    --hover-bg:          #343746;
    --card-bg:           rgba(33,34,44,0.9);
    --card-image-bg:     #343746;
    --nav-bg:            rgba(40,42,54,0.88);
    --shadow-color:      rgba(0,0,0,0.5);
    --sidebar-bg:        #21222c;
    --sidebar-border:    #44475a;
    --sidebar-active-bg: #343746;
}

[data-theme="dark"] {
    --app-bg:            #000000;
    --surface-primary:   #1C1C1E;
    --surface-secondary: #2C2C2E;
    --surface-tertiary:  #3A3A3C;
    --text-primary:      #FFFFFF;
    --text-secondary:    rgba(235,235,245,0.6);
    --text-tertiary:     rgba(235,235,245,0.3);
    --accent-color:      #0A84FF;
    --accent-secondary:  #30D158;
    --border-color:      #38383A;
    --hover-bg:          #2C2C2E;
    --card-bg:           rgba(28,28,30,0.8);
    --card-image-bg:     #2C2C2E;
    --nav-bg:            rgba(0,0,0,0.7);
    --shadow-color:      rgba(0,0,0,0.6);
    --sidebar-bg:        #1C1C1E;
    --sidebar-border:    #38383A;
    --sidebar-active-bg: #2C2C2E;
}

[data-theme="midnight"] {
    --app-bg:            #0D1117;
    --surface-primary:   #161B22;
    --surface-secondary: #21262D;
    --surface-tertiary:  #30363D;
    --text-primary:      #E6EDF3;
    --text-secondary:    #7D8590;
    --text-tertiary:     #484F58;
    --accent-color:      #58A6FF;
    --accent-secondary:  #3FB950;
    --border-color:      #30363D;
    --hover-bg:          #21262D;
    --card-bg:           rgba(22,27,34,0.85);
    --card-image-bg:     #21262D;
    --nav-bg:            rgba(13,17,23,0.88);
    --shadow-color:      rgba(0,0,0,0.6);
    --sidebar-bg:        #161B22;
    --sidebar-border:    #30363D;
    --sidebar-active-bg: #21262D;
}

/* ── Reset & base ──────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--app-bg);
    color: var(--text-primary);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}
a   { text-decoration: none; color: inherit; }
ul  { list-style: none; }
button { cursor: pointer; border: none; background: none; font-family: inherit; }

/* ── App Shell Layout ──────────────────────────────────────── */
.app-shell {
    display: flex;
    min-height: 100vh;
}

/* ── Sidebar ───────────────────────────────────────────────── */
.sidebar {
    width: 200px;
    min-width: 200px;
    background: var(--sidebar-bg);
    border-right: 1px solid var(--sidebar-border);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0; left: 0;
    height: 100vh;
    z-index: 50;
    padding: 20px 12px;
    overflow-y: auto;
    overflow-x: hidden;
}

.sidebar-logo {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px 20px;
    cursor: pointer;
    user-select: none;
    text-decoration: none;
    color: inherit;
}
.sidebar-logo-text {
    font-size: 15px;
    font-weight: 700;
    letter-spacing: -0.02em;
    color: var(--text-primary);
}

.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 2px;
    flex: 1;
}

.sidebar-section-label {
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    color: var(--text-tertiary);
    padding: 12px 12px 4px;
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 12px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    background: none;
    border: none;
    cursor: pointer;
    text-align: left;
    width: 100%;
    text-decoration: none;
    transition: color 0.15s, background 0.15s;
    font-family: inherit;
    letter-spacing: -0.01em;
    min-height: 36px;
}
.sidebar-link:hover {
    color: var(--text-primary);
    background: var(--sidebar-active-bg);
}
.sidebar-link.active {
    color: var(--accent-color);
    background: var(--sidebar-active-bg);
    font-weight: 600;
}

.sidebar-icon {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
    opacity: 0.7;
}
.sidebar-link.active .sidebar-icon,
.sidebar-link:hover .sidebar-icon { opacity: 1; }

.sidebar-link--muted {
    font-size: 12px;
    color: var(--text-tertiary);
}
.sidebar-link--muted:hover { color: var(--text-secondary); }

.sidebar-bottom {
    display: flex;
    flex-direction: column;
    gap: 2px;
    margin-top: auto;
    padding-top: 12px;
}
.sidebar-divider {
    height: 1px;
    background: var(--sidebar-border);
    margin: 8px 0;
}

/* ── Customize popup ───────────────────────────────────────── */
.custom-popup {
    position: fixed;
    z-index: 500;
    background: var(--surface-primary);
    border: 1px solid var(--border-color);
    border-radius: 14px;
    padding: 16px;
    min-width: 240px;
    box-shadow: 0 16px 40px rgba(0,0,0,0.2);
    animation: popIn 0.18s cubic-bezier(0.34,1.56,0.64,1);
}
@keyframes popIn {
    from { opacity: 0; transform: scale(0.93) translateY(-6px); }
    to   { opacity: 1; transform: scale(1) translateY(0); }
}
.cp-customize-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
}
.cp-customize-title { font-size: 13px; font-weight: 700; color: var(--text-primary); letter-spacing: -0.01em; }
.cp-close-btn {
    background: none; border: none;
    color: var(--text-tertiary); cursor: pointer;
    font-size: 13px; padding: 2px 6px; border-radius: 4px;
    font-family: inherit; transition: color 0.15s, background 0.15s;
}
.cp-close-btn:hover { color: var(--text-primary); background: var(--surface-tertiary); }
.cp-section {
    display: flex; flex-direction: column; gap: 8px;
    padding: 12px 0 0; border-top: 1px solid var(--border-color);
}
.cp-section-label {
    font-size: 10px; font-weight: 600; text-transform: uppercase;
    letter-spacing: 0.08em; color: var(--text-tertiary);
}
.cp-theme-row { display: flex; gap: 6px; flex-wrap: wrap; }
.cp-theme-btn {
    padding: 6px 10px; border-radius: 8px;
    background: var(--surface-tertiary);
    border: 1.5px solid transparent;
    font-size: 16px; cursor: pointer;
    transition: border-color 0.15s, transform 0.12s;
    min-width: 36px; min-height: 36px;
    display: flex; align-items: center; justify-content: center;
}
.cp-theme-btn:hover { transform: scale(1.1); }
.cp-theme-btn.active { border-color: var(--accent-color); }
.cp-accent-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.cp-accent-dot {
    width: 26px; height: 26px; border-radius: 50%;
    border: 2.5px solid transparent; cursor: pointer;
    transition: transform 0.15s, border-color 0.15s; padding: 0;
}
.cp-accent-dot:hover { transform: scale(1.15); }
.cp-accent-dot.active { border-color: var(--text-primary); transform: scale(1.1); }

/* ── Main Content ──────────────────────────────────────────── */
.main-content {
    margin-left: 200px;
    flex: 1;
    min-width: 0;
}

/* ── Focus / Selection ─────────────────────────────────────── */
::selection {
    background: color-mix(in srgb, var(--accent-color) 25%, transparent);
    color: var(--text-primary);
}
:focus-visible { outline: 2px solid var(--accent-color); outline-offset: 3px; border-radius: 6px; }
::-webkit-scrollbar       { width: 8px; }
::-webkit-scrollbar-track { background: var(--app-bg); }
::-webkit-scrollbar-thumb { background: var(--surface-tertiary); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-tertiary); }

/* ── Responsive ─────────────────────────────────────────────── */
@media (max-width: 768px) {
    .sidebar {
        width: 56px; min-width: 56px; padding: 16px 8px;
    }
    .sidebar-logo-text,
    .sidebar-link span,
    .sidebar-link--muted span,
    .sidebar-section-label { display: none; }
    .sidebar-logo { justify-content: center; padding: 8px 0 20px; }
    .sidebar-link { justify-content: center; padding: 10px; }
    .main-content { margin-left: 56px; }
}
