/* ============================================
   Global Styles
   ============================================ */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --bg-primary: #080d14;
    --bg-secondary: #0e1624;
    --bg-card: #131d2c;
    --bg-card-hover: #182537;
    --bg-input: #0b1320;
    --bg-sidebar: #070b12;
    --bg-elevated: #101928;
    --body-glow: rgba(74, 158, 255, 0.08);
    --sidebar-bg: linear-gradient(180deg, #070b12 0%, #0c1220 100%);
    --text-primary: #edf3fb;
    --text-secondary: #98a8bd;
    --text-muted: #64748b;
    --border-color: #223047;
    --border-light: #33435d;
    
    --accent-primary: #00d4aa;
    --accent-secondary: #00b894;
    --accent-blue: #4a9eff;
    --accent-purple: #7c5cfc;
    --accent-pink: #ff6b9d;
    --accent-orange: #ff9f43;
    --accent-red: #ff4757;
    
    --success: #00d4aa;
    --warning: #ff9f43;
    --danger: #ff4757;
    --info: #4a9eff;
    --chart-grid-color: rgba(152, 168, 189, 0.13);
    
    --shadow: 0 18px 48px rgba(0, 0, 0, 0.32);
    --shadow-hover: 0 22px 60px rgba(0, 0, 0, 0.44);
    --radius: 8px;
    --radius-sm: 6px;
    --transition: all 0.2s ease;
    
    --sidebar-width: 260px;
    --header-height: 70px;
}

:root[data-theme="light"] {
    --bg-primary: #f5f7fb;
    --bg-secondary: #eef3f8;
    --bg-card: #ffffff;
    --bg-card-hover: #f2f6fb;
    --bg-input: #ffffff;
    --bg-sidebar: #ffffff;
    --bg-elevated: #ffffff;
    --body-glow: rgba(0, 184, 148, 0.12);
    --sidebar-bg: linear-gradient(180deg, #ffffff 0%, #f8fbfd 100%);
    --text-primary: #162033;
    --text-secondary: #516071;
    --text-muted: #7b8795;
    --border-color: #dbe3ed;
    --border-light: #c6d2df;
    --shadow: 0 18px 42px rgba(20, 32, 48, 0.11);
    --shadow-hover: 0 22px 56px rgba(20, 32, 48, 0.16);
    --chart-grid-color: rgba(81, 96, 113, 0.18);
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: radial-gradient(circle at top left, var(--body-glow), transparent 32rem), var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    overflow-x: hidden;
    min-height: 100vh;
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: var(--bg-secondary);
}

::-webkit-scrollbar-thumb {
    background: var(--border-light);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--accent-primary);
}

/* ============================================
   Layout
   ============================================ */
#app {
    display: flex;
    min-height: 100vh;
}

/* ============================================
   Sidebar
   ============================================ */
#sidebar {
    width: var(--sidebar-width);
    background: var(--sidebar-bg);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    z-index: 1000;
    transition: transform 0.3s ease;
}

.sidebar-header {
    padding: 18px 20px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.logo {
    display: flex;
    align-items: center;
    gap: 10px;
}

.logo-icon {
    font-size: 28px;
}

.logo-text {
    font-size: 22px;
    font-weight: 800;
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.logo-badge {
    font-size: 10px;
    font-weight: 600;
    background: var(--accent-primary);
    color: var(--bg-primary);
    padding: 2px 8px;
    border-radius: 4px;
    -webkit-text-fill-color: var(--bg-primary);
}

.sidebar-toggle {
    display: none;
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 20px;
    cursor: pointer;
}

.sidebar-nav {
    flex: 1;
    padding: 16px 12px;
    overflow-y: auto;
}

.sidebar-nav ul {
    list-style: none;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 11px 14px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: var(--transition);
    color: var(--text-secondary);
    position: relative;
    margin-bottom: 2px;
}

.nav-item:hover {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-primary);
}

.nav-item.active {
    background: rgba(0, 212, 170, 0.12);
    color: var(--accent-primary);
    box-shadow: inset 3px 0 0 var(--accent-primary);
}

.nav-item .nav-icon {
    font-size: 20px;
    width: 28px;
    text-align: center;
}

.nav-item .nav-text {
    font-size: 14px;
    font-weight: 500;
}

.nav-item .nav-badge {
    margin-left: auto;
    background: var(--danger);
    color: white;
    font-size: 11px;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 10px;
}

.sidebar-footer {
    padding: 16px 20px;
    border-top: 1px solid var(--border-color);
}

.admin-info {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 0;
}

.admin-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--accent-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 16px;
    color: var(--bg-primary);
    flex-shrink: 0;
}

.admin-details {
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.admin-name {
    font-weight: 600;
    font-size: 14px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

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

.logout-btn {
    width: 100%;
    padding: 10px;
    margin-top: 8px;
    background: rgba(255, 71, 87, 0.1);
    border: 1px solid rgba(255, 71, 87, 0.2);
    border-radius: var(--radius-sm);
    color: var(--danger);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.logout-btn:hover {
    background: rgba(255, 71, 87, 0.2);
    border-color: var(--danger);
}

/* ============================================
   Main Content
   ============================================ */
#main-content {
    margin-left: var(--sidebar-width);
    flex: 1;
    min-width: 0;
    width: calc(100% - var(--sidebar-width));
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.main-header {
    min-height: var(--header-height);
    height: auto;
    padding: 14px 32px;
    background: rgba(14, 22, 36, 0.94);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 100;
    backdrop-filter: blur(16px);
    gap: 18px;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 16px;
}

.header-left h1 {
    font-size: 22px;
    font-weight: 700;
}

.header-left .subtitle {
    font-size: 14px;
    color: var(--text-secondary);
}

.header-right {
    display: flex;
    align-items: center;
    gap: 16px;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.mobile-menu-btn {
    display: none;
    width: 38px;
    height: 38px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    background: var(--bg-card);
    color: var(--text-primary);
    font-size: 18px;
    cursor: pointer;
}

.date-range-selector {
    position: relative;
    display: flex;
    align-items: center;
    gap: 10px;
}

.date-range-selector select,
.custom-date-controls input {
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 8px 14px;
    color: var(--text-primary);
    font-size: 13px;
    cursor: pointer;
    outline: none;
}

.date-range-selector select:focus,
.custom-date-controls input:focus {
    border-color: var(--accent-primary);
}

.custom-date-controls {
    position: absolute;
    top: calc(100% + 10px);
    right: 0;
    width: min(520px, calc(100vw - 32px));
    display: grid;
    grid-template-columns: 1fr 1fr auto auto;
    gap: 10px;
    align-items: end;
    padding: 14px;
    background: var(--bg-elevated);
    border: 1px solid var(--border-light);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.custom-date-controls.hidden {
    display: none;
}

.custom-date-controls label {
    display: flex;
    flex-direction: column;
    gap: 5px;
    min-width: 0;
}

.custom-date-controls label span {
    font-size: 11px;
    font-weight: 700;
    color: var(--text-secondary);
    text-transform: uppercase;
}

.btn-apply-filter,
.btn-reset-filter {
    height: 36px;
    border: 0;
    border-radius: var(--radius-sm);
    padding: 0 14px;
    font-weight: 700;
    cursor: pointer;
}

.btn-apply-filter {
    background: var(--accent-primary);
    color: #04100d;
}

.btn-reset-filter {
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.btn-apply-filter:disabled,
.btn-reset-filter:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

.date-filter-error {
    grid-column: 1 / -1;
    min-height: 16px;
    color: var(--danger);
    font-size: 12px;
}

.notif-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 20px;
    cursor: pointer;
    padding: 6px;
    border-radius: 50%;
    transition: var(--transition);
    position: relative;
}

.notif-btn:hover {
    background: var(--bg-card);
}

.theme-toggle {
    width: 70px;
    height: 38px;
    display: inline-flex;
    align-items: center;
    justify-content: space-between;
    gap: 4px;
    position: relative;
    flex: 0 0 auto;
    padding: 4px 7px;
    border: 1px solid var(--border-color);
    border-radius: 999px;
    background: var(--bg-card);
    color: var(--text-secondary);
    cursor: pointer;
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.02);
    transition: var(--transition);
}

.theme-toggle:hover,
.theme-toggle:focus-visible {
    border-color: var(--border-light);
    color: var(--text-primary);
    outline: none;
}

.theme-toggle__icon {
    width: 22px;
    height: 22px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    position: relative;
    z-index: 1;
    font-size: 13px;
    line-height: 1;
}

.theme-toggle__thumb {
    width: 28px;
    height: 28px;
    position: absolute;
    top: 4px;
    left: 4px;
    border-radius: 50%;
    background: var(--accent-primary);
    box-shadow: 0 8px 18px rgba(0, 212, 170, 0.22);
    transition: transform 0.2s ease;
}

:root[data-theme="dark"] .theme-toggle__thumb {
    transform: translateX(32px);
}

:root[data-theme="light"] .theme-toggle__thumb {
    transform: translateX(0);
}

.notif-badge {
    position: absolute;
    top: 0;
    right: 0;
    background: var(--danger);
    color: white;
    font-size: 10px;
    font-weight: 700;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.refresh-btn {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    width: 38px;
    height: 38px;
    padding: 0;
    color: var(--text-secondary);
    font-size: 16px;
    cursor: pointer;
    transition: var(--transition);
}

.refresh-btn:hover {
    border-color: var(--accent-primary);
    color: var(--text-primary);
}

#page-content {
    padding: 24px 32px 36px;
    flex: 1;
}

/* ============================================
   Notification Dropdown
   ============================================ */
.dropdown {
    position: fixed;
    top: 80px;
    right: 20px;
    width: 380px;
    max-height: 500px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    z-index: 1001;
    overflow: hidden;
}

.dropdown.hidden {
    display: none;
}

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

.dropdown-header h3 {
    font-size: 16px;
}

.dropdown-header button {
    background: none;
    border: none;
    color: var(--accent-blue);
    font-size: 12px;
    cursor: pointer;
}

.dropdown-list {
    max-height: 400px;
    overflow-y: auto;
    padding: 8px 0;
}

.notification-item {
    padding: 12px 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    cursor: pointer;
    transition: var(--transition);
}

.notification-item:hover {
    background: rgba(255, 255, 255, 0.05);
}

.notification-item.unread {
    border-left: 3px solid var(--accent-blue);
}

.notification-item .notif-title {
    font-weight: 600;
    font-size: 14px;
    margin-bottom: 4px;
}

.notification-item .notif-message {
    font-size: 13px;
    color: var(--text-secondary);
}

.notification-item .notif-time {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 4px;
}

/* ============================================
   Toast Notifications
   ============================================ */
.toast-container {
    position: fixed;
    top: 80px;
    right: 20px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-width: 380px;
}

.toast {
    padding: 14px 20px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow);
    animation: slideInRight 0.3s ease;
    display: flex;
    align-items: center;
    gap: 12px;
}

.toast-success {
    border-left: 4px solid var(--success);
}

.toast-error {
    border-left: 4px solid var(--danger);
}

.toast-warning {
    border-left: 4px solid var(--warning);
}

.toast-info {
    border-left: 4px solid var(--info);
}

.toast-icon {
    font-size: 20px;
}

.toast-content {
    flex: 1;
}

.toast-title {
    font-weight: 600;
    font-size: 14px;
}

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

.toast-close {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 18px;
    padding: 0 4px;
}

@keyframes slideInRight {
    from {
        opacity: 0;
        transform: translateX(20px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* ============================================
   Loading Overlay
   ============================================ */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    z-index: 9998;
    display: flex;
    align-items: center;
    justify-content: center;
}

.loading-overlay.hidden {
    display: none;
}

.loader {
    width: 50px;
    height: 50px;
    border: 3px solid var(--border-color);
    border-top: 3px solid var(--accent-primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

/* ============================================
   Responsive
   ============================================ */
@media (max-width: 1024px) {
    .main-header {
        padding: 0 20px;
    }
    #page-content {
        padding: 16px 20px;
    }

    .custom-date-controls {
        position: fixed;
        top: 76px;
        right: 20px;
    }
}

@media (max-width: 768px) {
    #sidebar {
        transform: translateX(-100%);
    }
    
    #sidebar.open {
        transform: translateX(0);
    }
    
    .sidebar-toggle {
        display: block;
    }

    .mobile-menu-btn {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        flex-shrink: 0;
    }
    
    #main-content {
        margin-left: 0;
        width: 100%;
    }
    
    .main-header {
        padding: 0 16px;
        min-height: 64px;
        align-items: flex-start;
        flex-direction: column;
        padding-top: 12px;
        padding-bottom: 12px;
    }
    
    .header-left h1 {
        font-size: 18px;
    }
    
    .header-left .subtitle {
        display: none;
    }

    .header-right,
    .header-actions,
    .date-range-selector {
        width: 100%;
    }

    .header-actions {
        justify-content: space-between;
    }

    .theme-toggle {
        margin-left: auto;
    }

    .notif-btn,
    #notificationDropdown {
        display: none !important;
    }

    .date-range-selector select {
        width: 100%;
    }

    .custom-date-controls {
        position: static;
        width: 100%;
        grid-template-columns: 1fr;
        margin-top: 10px;
    }
    
    #page-content {
        padding: 12px 16px;
    }
    
    .dropdown {
        width: 320px;
        right: 10px;
        top: 70px;
    }
}

@media (max-width: 480px) {
    .dropdown {
        width: 290px;
        right: 5px;
    }
    
    .date-range-selector select {
        max-width: none;
        font-size: 12px;
        padding: 6px 10px;
    }
}

/* ============================================
   Animations
   ============================================ */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.fade-in {
    animation: fadeIn 0.3s ease;
}

@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
}

.loading-skeleton {
    animation: pulse 1.5s ease-in-out infinite;
    background: var(--bg-card);
    border-radius: var(--radius-sm);
}
.auth-pending body {
    visibility: hidden;
}
