/* ========================================
   ROOT VARIABLES - LIGHT THEME (DEFAULT)
   ======================================== */

:root {
    /* ===== PRIMARY COLORS ===== */
    --color-primary: #000000;
    --color-primary-hover: #1a1a1a;
    --color-accent: #667eea;
    --color-accent-hover: #5568d3;
    
    /* ===== BACKGROUND COLORS ===== */
    --bg-primary: #ffffff;
    --bg-secondary: #f8f8f7;
    --bg-tertiary: #f5f5f7;
    --bg-elevated: #ffffff;
    --bg-hover: #f0f0f0;
    --bg-active: #e0e0e0;
    
    /* ===== TEXT COLORS ===== */
    --text-primary: #1d1d1f;
    --text-secondary: #666666;
    --text-tertiary: #888888;
    --text-light: #999999;
    --text-disabled: #cccccc;
    --text-inverted: #ffffff;
    
    /* ===== BORDER COLORS ===== */
    --border-primary: #e5e5e5;
    --border-secondary: #f0f0f0;
    --border-focus: #2c2c2c;
    --border-subtle: rgba(0, 0, 0, 0.08);
    
    /* ===== CARD & SURFACE COLORS ===== */
    --card-bg: #ffffff;
    --card-border: #e5e5e5;
    --card-shadow: rgba(0, 0, 0, 0.06);
    --card-shadow-hover: rgba(0, 0, 0, 0.1);
    
    /* ===== SIDEBAR COLORS ===== */
    --sidebar-bg: #000000;
    --sidebar-text: #ffffff;
    --sidebar-text-secondary: #cfcfcf;
    --sidebar-hover: #ffffff;
    --sidebar-active-bg: #ffffff;
    --sidebar-active-text: #000000;
    --sidebar-button-bg: #111111;
    
    /* ===== BUTTON COLORS ===== */
    --btn-primary-bg: #2c2c2c;
    --btn-primary-hover: #1a1a1a;
    --btn-primary-text: #ffffff;
    --btn-secondary-bg: #f0f0f0;
    --btn-secondary-hover: #e0e0e0;
    --btn-secondary-text: #2c2c2c;
    
    /* ===== INPUT COLORS ===== */
    --input-bg: #fafafa;
    --input-border: #e0e0e0;
    --input-focus-bg: #ffffff;
    --input-focus-border: #2c2c2c;
    --input-placeholder: rgba(0, 0, 0, 0.3);
    
    /* ===== SEARCH COLORS ===== */
    --search-bg: #ffffff;
    --search-border: #0000000a;
    --search-highlight: #fff3cd;
    --search-result-hover: #f5f5f5;
    
    /* ===== NOTIFICATION COLORS ===== */
    --notification-badge: #ff3b30;
    --notification-bg: #ffffff;
    --notification-unread-bg: #f0f7ff;
    
    /* ===== SHADOWS ===== */
    --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.04);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.08);
    --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.12);
    --shadow-xl: 0 12px 48px rgba(0, 0, 0, 0.15);
    
    /* ===== TRANSITIONS ===== */
    --transition-fast: 0.2s;
    --transition-normal: 0.3s;
    --transition-slow: 0.4s;
    
    /* ===== BORDER RADIUS ===== */
    --radius-sm: 6px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --radius-xl: 16px;
    --radius-2xl: 20px;
    --radius-full: 50%;
}

/* ========================================
   DARK THEME
   ======================================== */

body.dark-theme {
    /* ===== PRIMARY COLORS ===== */
    --color-primary: #ffffff;
    --color-primary-hover: #e0e0e0;
    --color-accent: #8b9dff;
    --color-accent-hover: #a5b4ff;
    
    /* ===== BACKGROUND COLORS ===== */
    --bg-primary: #1a1a1a;
    --bg-secondary: #0f0f0f;
    --bg-tertiary: #2c2c2c;
    --bg-elevated: #2c2c2c;
    --bg-hover: #3a3a3a;
    --bg-active: #4a4a4a;
    
    /* ===== TEXT COLORS ===== */
    --text-primary: #e0e0e0;
    --text-secondary: #b0b0b0;
    --text-tertiary: #888888;
    --text-light: #666666;
    --text-disabled: #4a4a4a;
    --text-inverted: #1a1a1a;
    
    /* ===== BORDER COLORS ===== */
    --border-primary: #3a3a3a;
    --border-secondary: #2c2c2c;
    --border-focus: #8b9dff;
    --border-subtle: rgba(255, 255, 255, 0.08);
    
    /* ===== CARD & SURFACE COLORS ===== */
    --card-bg: #2c2c2c;
    --card-border: #3a3a3a;
    --card-shadow: rgba(0, 0, 0, 0.3);
    --card-shadow-hover: rgba(0, 0, 0, 0.4);
    
    /* ===== SIDEBAR COLORS ===== */
    --sidebar-bg: #1a1a1a;
    --sidebar-text: #e0e0e0;
    --sidebar-text-secondary: #b0b0b0;
    --sidebar-hover: #e0e0e0;
    --sidebar-active-bg: #3a3a3a;
    --sidebar-active-text: #ffffff;
    --sidebar-button-bg: #2c2c2c;
    
    /* ===== BUTTON COLORS ===== */
    --btn-primary-bg: #8b9dff;
    --btn-primary-hover: #a5b4ff;
    --btn-primary-text: #1a1a1a;
    --btn-secondary-bg: #3a3a3a;
    --btn-secondary-hover: #4a4a4a;
    --btn-secondary-text: #e0e0e0;
    
    /* ===== INPUT COLORS ===== */
    --input-bg: #2c2c2c;
    --input-border: #3a3a3a;
    --input-focus-bg: #3a3a3a;
    --input-focus-border: #8b9dff;
    --input-placeholder: rgba(255, 255, 255, 0.3);
    
    /* ===== SEARCH COLORS ===== */
    --search-bg: #2c2c2c;
    --search-border: #ffffff39;
    --search-highlight: #4a3d1a;
    --search-result-hover: #3a3a3a;
    
    /* ===== NOTIFICATION COLORS ===== */
    --notification-badge: #ef4444;
    --notification-bg: #2c2c2c;
    --notification-unread-bg: #1e3a5f;
    
    /* ===== SHADOWS ===== */
    --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.5);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.6);
    --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.7);
    --shadow-xl: 0 12px 48px rgba(0, 0, 0, 0.8);
}

/* ========================================
   BASE STYLES
   ======================================== */

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
}

body {
    display: flex;
    height: 100vh;
    background: var(--bg-secondary);
    padding: 16px;
    color: var(--text-primary);
    transition: background-color var(--transition-normal), color var(--transition-normal);
}

/* ========================================
   SIDEBAR
   ======================================== */

.sidebar {
    width: 260px;
    background: var(--sidebar-bg);
    color: var(--sidebar-text);
    padding: 20px 14px;
    display: flex;
    flex-direction: column;
    transition: width .4s ease;
    border-radius: var(--radius-2xl);
}

.sidebar.collapsed {
    width: 90px;
}

.logo {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 28px;
    padding: 10px 12px;
    border-radius: var(--radius-lg);
}

.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 20px;
    font-weight: 600;
    cursor: pointer;
    color: var(--sidebar-text);
}

.brand i {
    font-size: 22px;
}

.collapse-btn {
    background: var(--sidebar-button-bg);
    border: none;
    color: var(--sidebar-text);
    border-radius: var(--radius-lg);
    padding: 6px 8px;
    cursor: pointer;
    font-size: 18px;
    transition: background var(--transition-fast);
}

.collapse-btn:hover {
    background: var(--bg-hover);
}

.nav {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.nav button,
.logout button {
    width: 100%;
    background: transparent;
    border: none;
    color: var(--sidebar-text-secondary);
    padding: 14px 14px 14px 20px;
    border-radius: var(--radius-lg);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 12px;
    transition: background var(--transition-normal), color var(--transition-normal);
}

.nav button i,
.logout button i {
    font-size: 18px;
    min-width: 20px;
}

.nav button:hover,
.nav button.active {
    background: var(--sidebar-active-bg);
    color: var(--sidebar-active-text);
}

.logout {
    margin-top: auto;
}

.logout button:hover {
    background: var(--sidebar-active-bg);
    color: var(--sidebar-active-text);
    border-radius: var(--radius-lg);
}

/* ========================================
   MAIN CONTENT
   ======================================== */

.main {
    flex: 1;
    padding: 26px 32px;
    overflow-y: scroll;
    overflow-x: hidden;
}

.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 28px;
}

.top-left {
    font-size: 22px;
    font-weight: 600;
    color: var(--text-primary);
}

.top-right {
    display: flex;
    align-items: center;
    gap: 14px;
}

.search {
    background: var(--search-bg);
    border-radius: var(--radius-2xl);
    padding: 10px 14px;
    display: flex;
    align-items: center;
    gap: 8px;
    border: 2px solid var(--search-border);
    width: 600px;
    transition: border-color var(--transition-fast), background var(--transition-normal);
}

.search input {
    border: none;
    outline: none;
    font-size: 14px;
    width: 100%;
    background: transparent;
    color: var(--text-primary);
}

.search input::placeholder {
    color: var(--input-placeholder);
}

.search i {
    color: var(--text-secondary);
}

.icon-btn {
    background: transparent;
    border: none;
    border-radius: var(--radius-lg);
    padding: 10px 12px;
    cursor: pointer;
    font-size: 18px;
    color: var(--text-primary);
    transition: background var(--transition-fast);
    position: relative;
}

.icon-btn:hover {
    background: var(--bg-hover);
}

/* ========================================
   CONTENT SECTIONS
   ======================================== */

.content-wrapper {
    position: relative;
    height: auto;
}

.section {
    position: absolute;
    inset: 0;
    opacity: 0;
    pointer-events: none;
    transform: translateY(20px);
    transition: opacity var(--transition-slow), transform var(--transition-slow);
    height: auto;
}

.section.active {
    opacity: 1;
    pointer-events: auto;
    transform: translateY(0);
}

.section-box {
    height: auto;
    background: transparent;
    border-radius: var(--radius-2xl);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 64px;
    font-weight: 600;
    color: var(--text-primary);
}

/* ========================================
   COLLAPSED SIDEBAR
   ======================================== */

.sidebar.collapsed span {
    display: none;
}

.sidebar.collapsed .logo {
    justify-content: center;
}

.sidebar.collapsed .collapse-btn {
    display: none;
}

/* ========================================
   GLOBAL SEARCH RESULTS
   ======================================== */

.global-search-results {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    margin-top: 8px;
    background: var(--card-bg);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    max-height: 500px;
    overflow-y: auto;
    z-index: 1000;
    display: none;
    transition: background var(--transition-normal);
}

.global-search-results.show {
    display: block;
    animation: slideDown 0.2s ease;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.search-results-content {
    padding: 8px;
}

.search-loading {
    padding: 20px;
    text-align: center;
    color: var(--text-secondary);
}

.search-category {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    color: var(--text-light);
    padding: 12px 12px 8px;
    letter-spacing: 0.5px;
}

.search-result-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: background var(--transition-fast);
}

.search-result-item:hover {
    background: var(--search-result-hover);
}

.search-result-icon {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-md);
    background: var(--bg-hover);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    flex-shrink: 0;
}

.search-result-info {
    flex: 1;
    min-width: 0;
}

.search-result-title {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.search-result-title mark {
    background: var(--search-highlight);
    padding: 2px 4px;
    border-radius: 3px;
}

.search-result-meta {
    font-size: 12px;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.search-badge {
    background: var(--bg-active);
    color: var(--text-primary);
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 500;
}

.search-date {
    color: var(--text-tertiary);
}

.search-no-results,
.search-error {
    padding: 40px 20px;
    text-align: center;
    color: var(--text-light);
}

/* ========================================
   SCROLLBAR STYLING
   ======================================== */

.global-search-results::-webkit-scrollbar,
.main::-webkit-scrollbar {
    width: 6px;
}

.global-search-results::-webkit-scrollbar-track,
.main::-webkit-scrollbar-track {
    background: transparent;
}

.global-search-results::-webkit-scrollbar-thumb,
.main::-webkit-scrollbar-thumb {
    background: var(--border-primary);
    border-radius: 3px;
}

.global-search-results::-webkit-scrollbar-thumb:hover,
.main::-webkit-scrollbar-thumb:hover {
    background: var(--border-focus);
}

/* ========================================
   LOADING SPINNER
   ======================================== */

@keyframes spin {
    from {
        transform: rotate(0deg);
    }
    to {
        transform: rotate(360deg);
    }
}

.bx-spin {
    animation: spin 1s linear infinite;
}

/* ========================================
   RESPONSIVE
   ======================================== */

@media (max-width: 768px) {
    body {
        padding: 8px;
    }

    .sidebar {
        width: 80px;
    }

    .sidebar span {
        display: none;
    }

    .sidebar .logo {
        justify-content: center;
    }

    .sidebar .collapse-btn {
        display: none;
    }

    .main {
        padding: 16px;
    }

    .search {
        width: 100%;
        max-width: 300px;
    }

    .topbar {
        flex-direction: column;
        align-items: flex-start;
        gap: 16px;
    }
}

/* ========================================
   SMOOTH TRANSITIONS FOR THEME CHANGE
   ======================================== */

body,

.card,
.search,
.icon-btn,
.logout button,
.global-search-results,
.search-result-item {
    transition: background-color var(--transition-normal),
                color var(--transition-normal),
                border-color var(--transition-normal);
}