@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=Outfit:wght@400;500;600;700;800&display=swap');

:root {
    /* Dark Theme Variables (Default) */
    --bg-base: #0b0f19;
    --bg-surface: rgba(22, 28, 45, 0.65);
    --bg-surface-solid: #161c2d;
    --border-color: rgba(255, 255, 255, 0.08);
    --text-primary: #f3f4f6;
    --text-secondary: #9ca3af;
    --text-muted: #6b7280;
    
    --primary: #6366f1;
    --primary-glow: rgba(99, 102, 241, 0.15);
    --primary-gradient: linear-gradient(135deg, #6366f1, #a855f7);
    
    --success: #10b981;
    --success-glow: rgba(16, 185, 129, 0.15);
    --warning: #f59e0b;
    --warning-glow: rgba(245, 158, 11, 0.15);
    --danger: #ef4444;
    --danger-glow: rgba(239, 68, 68, 0.15);
    
    --sidebar-width: 260px;
    --sidebar-collapsed-width: 80px;
    --header-height: 70px;
    --glass-blur: blur(16px);
    --shadow-main: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
    --font-heading: 'Outfit', sans-serif;
    --font-body: 'Inter', sans-serif;
}

body.light-mode {
    /* Light Theme Variables */
    --bg-base: #f3f4f6;
    --bg-surface: rgba(255, 255, 255, 0.7);
    --bg-surface-solid: #ffffff;
    --border-color: rgba(0, 0, 0, 0.08);
    --text-primary: #111827;
    --text-secondary: #4b5563;
    --text-muted: #9ca3af;
    
    --primary-glow: rgba(99, 102, 241, 0.08);
    --shadow-main: 0 8px 32px 0 rgba(31, 38, 135, 0.08);
}

/* --- BASE STYLES --- */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    background-color: var(--bg-base);
    color: var(--text-primary);
    font-family: var(--font-body);
    min-height: 100vh;
    display: flex;
    overflow-x: hidden;
    transition: background-color 0.4s ease, color 0.4s ease;
}

h1, h2, h3, h4, h5, h6 {
    font-family: var(--font-heading);
    font-weight: 600;
    letter-spacing: -0.02em;
}

a {
    color: inherit;
    text-decoration: none;
}

/* --- GLASS CONTAINER UTILITY --- */
.glass-panel {
    background: var(--bg-surface);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    box-shadow: var(--shadow-main);
    transition: transform 0.3s ease, box-shadow 0.3s ease, border-color 0.3s ease;
}

.glass-panel:hover {
    border-color: rgba(255, 255, 255, 0.15);
}

/* --- MAIN LAYOUT --- */
.sidebar {
    width: var(--sidebar-width);
    height: 100vh;
    position: fixed;
    top: 0;
    left: 0;
    z-index: 100;
    background: var(--bg-surface-solid);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    transition: width 0.3s ease;
    overflow: hidden;
}

.sidebar.collapsed {
    width: var(--sidebar-collapsed-width);
}

.main-content {
    margin-left: var(--sidebar-width);
    flex: 1;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    transition: margin-left 0.3s ease;
    position: relative;
    padding: 30px;
    padding-top: calc(var(--header-height) + 30px);
}

.main-content.expanded {
    margin-left: var(--sidebar-collapsed-width);
}

/* --- SIDEBAR COMPONENTS --- */
.sidebar-logo {
    height: var(--header-height);
    display: flex;
    align-items: center;
    padding: 0 24px;
    border-bottom: 1px solid var(--border-color);
    font-family: var(--font-heading);
    font-size: 1.5rem;
    font-weight: 800;
    background: var(--primary-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    gap: 12px;
}

.sidebar-logo i {
    -webkit-text-fill-color: initial;
    color: var(--primary);
    font-size: 1.8rem;
}

.sidebar-menu {
    flex: 1;
    list-style: none;
    padding: 24px 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    overflow-y: auto;
}

.menu-section-title {
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    color: var(--text-muted);
    padding: 12px 12px 4px 12px;
    letter-spacing: 0.05em;
}

.sidebar.collapsed .menu-section-title {
    display: none;
}

.menu-item a {
    display: flex;
    align-items: center;
    padding: 12px;
    border-radius: 12px;
    color: var(--text-secondary);
    gap: 16px;
    font-weight: 500;
    transition: background 0.2s ease, color 0.2s ease;
}

.menu-item a:hover {
    background: var(--primary-glow);
    color: var(--primary);
}

.menu-item.active a {
    background: var(--primary-gradient);
    color: #ffffff;
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.35);
}

.menu-item i {
    font-size: 1.25rem;
    width: 24px;
    text-align: center;
}

.sidebar-footer {
    padding: 16px;
    border-top: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    gap: 12px;
}

.sidebar-footer .user-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--primary-gradient);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    color: #ffffff;
    font-size: 1.1rem;
}

.sidebar-footer .user-info {
    display: flex;
    flex-direction: column;
}

.sidebar-footer .user-name {
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--text-primary);
}

.sidebar-footer .user-role {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.sidebar.collapsed .sidebar-footer .user-info {
    display: none;
}

/* --- HEADER BAR --- */
.header-bar {
    height: var(--header-height);
    position: fixed;
    top: 0;
    right: 0;
    left: var(--sidebar-width);
    z-index: 99;
    background: rgba(22, 28, 45, 0.4);
    backdrop-filter: var(--glass-blur);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 30px;
    transition: left 0.3s ease;
}

.sidebar.collapsed ~ .header-bar {
    left: var(--sidebar-collapsed-width);
}

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

.toggle-sidebar-btn {
    background: none;
    border: none;
    color: var(--text-primary);
    font-size: 1.25rem;
    cursor: pointer;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s ease;
}

.toggle-sidebar-btn:hover {
    background: var(--border-color);
}

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

.theme-toggle-btn {
    background: none;
    border: none;
    color: var(--text-primary);
    font-size: 1.2rem;
    cursor: pointer;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s ease;
}

.theme-toggle-btn:hover {
    background: var(--border-color);
}

/* --- PAGES & DASHBOARD CONTENT --- */
.page-header {
    margin-bottom: 30px;
}

.page-title {
    font-size: 2.2rem;
    color: var(--text-primary);
    font-weight: 700;
}

.page-subtitle {
    color: var(--text-secondary);
    font-size: 0.95rem;
    margin-top: 4px;
}

/* --- STATS GRID --- */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 24px;
    margin-bottom: 30px;
}

.stat-card {
    padding: 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.stat-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 12px 40px rgba(0,0,0,0.4);
}

.stat-info {
    display: flex;
    flex-direction: column;
}

.stat-label {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.stat-value {
    font-size: 2.25rem;
    font-weight: 800;
    font-family: var(--font-heading);
    margin-top: 4px;
}

.stat-icon {
    width: 56px;
    height: 56px;
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
}

.stat-icon.primary { background: var(--primary-glow); color: var(--primary); }
.stat-icon.success { background: var(--success-glow); color: var(--success); }
.stat-icon.warning { background: var(--warning-glow); color: var(--warning); }
.stat-icon.danger { background: var(--danger-glow); color: var(--danger); }

/* --- CHARTS GRID --- */
.charts-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
    gap: 24px;
    margin-bottom: 30px;
}

.chart-card {
    padding: 24px;
    display: flex;
    flex-direction: column;
}

.chart-title {
    font-size: 1.15rem;
    color: var(--text-primary);
    margin-bottom: 20px;
    font-weight: 600;
}

.chart-container {
    position: relative;
    width: 100%;
    height: 280px;
}

/* --- BUTTONS --- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 20px;
    border-radius: 12px;
    font-weight: 600;
    font-size: 0.9rem;
    cursor: pointer;
    border: none;
    transition: all 0.2s ease;
}

.btn-primary {
    background: var(--primary-gradient);
    color: #ffffff;
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.2);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(99, 102, 241, 0.35);
}

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

.btn-secondary:hover {
    background: rgba(255,255,255,0.12);
}

.btn-success { background-color: var(--success); color: #ffffff; }
.btn-success:hover { background-color: #0d9668; }
.btn-danger { background-color: var(--danger); color: #ffffff; }
.btn-danger:hover { background-color: #dc2626; }

/* --- FORMS & INPUTS --- */
.form-group {
    margin-bottom: 20px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.form-label {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-secondary);
}

.form-control {
    background: rgba(0,0,0,0.2);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 12px;
    font-size: 0.95rem;
    color: var(--text-primary);
    font-family: var(--font-body);
    transition: border-color 0.2s ease;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary);
}

select.form-control {
    appearance: none;
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%239ca3af' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 16px;
    padding-right: 40px;
}

/* --- BADGES & LABELS --- */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.02em;
}

.badge-success { background: var(--success-glow); color: var(--success); }
.badge-warning { background: var(--warning-glow); color: var(--warning); }
.badge-danger { background: var(--danger-glow); color: var(--danger); }
.badge-info { background: var(--primary-glow); color: var(--primary); }

/* --- FLASH MESSAGES --- */
.flash-container {
    margin-bottom: 24px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.alert {
    padding: 16px 20px;
    border-radius: 12px;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 12px;
    animation: slideIn 0.3s ease forwards;
}

.alert-success { background: var(--success-glow); border-left: 4px solid var(--success); color: var(--success); }
.alert-danger { background: var(--danger-glow); border-left: 4px solid var(--danger); color: var(--danger); }
.alert-info { background: var(--primary-glow); border-left: 4px solid var(--primary); color: var(--primary); }

/* --- CARD LISTS & TABLES --- */
.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 24px;
    margin-bottom: 30px;
}

.data-card {
    padding: 24px;
    position: relative;
    overflow: hidden;
}

.data-card:hover {
    transform: translateY(-4px);
    border-color: var(--primary);
}

.data-card-title {
    font-size: 1.25rem;
    margin-bottom: 8px;
    font-weight: 700;
}

.data-card-subtitle {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 16px;
}

.data-card-body {
    display: flex;
    flex-direction: column;
    gap: 8px;
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.data-card-item {
    display: flex;
    align-items: center;
    gap: 10px;
}

.data-card-item i {
    width: 16px;
    color: var(--primary);
}

.data-table-container {
    overflow-x: auto;
    border-radius: 14px;
    border: 1px solid var(--border-color);
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
    font-size: 0.9rem;
}

.data-table th {
    background: rgba(22, 28, 45, 0.8);
    padding: 16px 20px;
    font-weight: 600;
    color: var(--text-secondary);
    border-bottom: 1px solid var(--border-color);
}

.data-table td {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-primary);
}

.data-table tr:last-child td {
    border-bottom: none;
}

.data-table tbody tr:hover {
    background: rgba(255,255,255,0.02);
}

/* --- TAB CONTAINER --- */
.tabs-header {
    display: flex;
    gap: 12px;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 30px;
    overflow-x: auto;
}

.tab-btn {
    padding: 14px 20px;
    font-weight: 600;
    font-size: 0.95rem;
    color: var(--text-secondary);
    background: none;
    border: none;
    cursor: pointer;
    border-bottom: 3px solid transparent;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.tab-btn:hover {
    color: var(--primary);
}

.tab-btn.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
}

.tab-pane {
    display: none;
    animation: fadeIn 0.4s ease forwards;
}

.tab-pane.active {
    display: block;
}

/* --- MODAL DIALOGS --- */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(8px);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.modal-overlay.open {
    opacity: 1;
    pointer-events: auto;
}

.modal-box {
    width: 100%;
    max-width: 600px;
    padding: 30px;
    transform: scale(0.9);
    transition: transform 0.3s ease;
}

.modal-overlay.open .modal-box {
    transform: scale(1);
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
}

.modal-close-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 1.25rem;
    cursor: pointer;
}

/* --- ANIMATIONS --- */
@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* --- RESPONSIVE ADJUSTMENTS --- */
@media (max-width: 992px) {
    .sidebar {
        width: var(--sidebar-collapsed-width);
    }
    .main-content {
        margin-left: var(--sidebar-collapsed-width);
    }
    .header-bar {
        left: var(--sidebar-collapsed-width);
    }
    .sidebar-footer .user-info {
        display: none;
    }
    .sidebar-logo span {
        display: none;
    }
}

@media (max-width: 576px) {
    .main-content {
        padding: 16px;
        padding-top: calc(var(--header-height) + 16px);
    }
    .stats-grid {
        grid-template-columns: 1fr;
    }
}
