/* ============ THEME SYSTEM ============ */
:root {
    --bg-primary: #06060a;
    --bg-secondary: #0c0c12;
    --bg-tertiary: #121218;
    --bg-card: #0f0f16;
    --bg-elevated: #161620;
    --bg-sidebar: #0a0a0f;
    --accent: #6366f1;
    --accent-secondary: #8b5cf6;
    --accent-glow: rgba(99, 102, 241, 0.25);
    --success: #10b981;
    --warning: #f59e0b;
    --error: #ef4444;
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --border: #1e1e2e;
    --border-hover: #2d2d42;
    --sidebar-width: 260px;
    --shadow-sm: 0 2px 8px rgba(0,0,0,0.3);
    --shadow-md: 0 4px 16px rgba(0,0,0,0.4);
    --shadow-lg: 0 8px 32px rgba(0,0,0,0.5);
}

[data-theme="light"] {
    --bg-primary: #f8fafc;
    --bg-secondary: #f1f5f9;
    --bg-tertiary: #e2e8f0;
    --bg-card: #ffffff;
    --bg-elevated: #f1f5f9;
    --bg-sidebar: #ffffff;
    --text-primary: #0f172a;
    --text-secondary: #475569;
    --text-muted: #64748b;
    --border: #e2e8f0;
    --border-hover: #cbd5e1;
    --shadow-sm: 0 2px 8px rgba(0,0,0,0.06);
    --shadow-md: 0 4px 16px rgba(0,0,0,0.08);
    --shadow-lg: 0 8px 32px rgba(0,0,0,0.1);
}

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

body {
    font-family: 'Outfit', -apple-system, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    transition: background 0.3s, color 0.3s;
}

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

/* ============ THEME TOGGLE ============ */
.theme-toggle {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.4rem 0.6rem;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 1rem;
}
.theme-toggle:hover { border-color: var(--accent); }

/* ============ LOGIN ============ */
.login-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; position: relative; }
.login-bg { position: absolute; top: 0; left: 0; width: 100%; height: 100%; background: radial-gradient(ellipse 80% 50% at 50% -20%, rgba(99, 102, 241, 0.15), transparent); pointer-events: none; }
.login-card { background: var(--bg-card); border: 1px solid var(--border); border-radius: 24px; padding: 3rem; width: 100%; max-width: 420px; position: relative; z-index: 1; box-shadow: var(--shadow-lg); }
.login-logo { text-align: center; margin-bottom: 2rem; }
.login-logo-icon { width: 64px; height: 64px; background: linear-gradient(135deg, var(--accent), var(--accent-secondary)); border-radius: 16px; display: inline-flex; align-items: center; justify-content: center; font-size: 2rem; margin-bottom: 1rem; box-shadow: 0 8px 32px var(--accent-glow); }
.login-logo h1 { font-size: 1.75rem; font-weight: 700; }
.login-logo p { color: var(--text-muted); font-size: 0.9rem; margin-top: 0.5rem; }
.login-form .form-group { margin-bottom: 1.25rem; }
.login-form label { display: block; font-size: 0.8rem; font-weight: 600; color: var(--text-secondary); margin-bottom: 0.5rem; }
.login-form input { width: 100%; padding: 0.875rem 1rem; background: var(--bg-primary); border: 1px solid var(--border); border-radius: 12px; color: var(--text-primary); font-size: 1rem; transition: all 0.2s; }
.login-form input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-glow); }
.login-error { background: rgba(239, 68, 68, 0.1); border: 1px solid var(--error); color: var(--error); padding: 0.75rem 1rem; border-radius: 10px; font-size: 0.85rem; margin-bottom: 1rem; display: none; }
.login-error.show { display: block; }

/* ============ LAYOUT ============ */
.app-layout { display: flex; min-height: 100vh; }

/* ============ SIDEBAR ============ */
.sidebar { width: var(--sidebar-width); background: var(--bg-sidebar); border-right: 1px solid var(--border); display: flex; flex-direction: column; position: fixed; top: 0; left: 0; height: 100vh; z-index: 100; transition: all 0.3s; }
.sidebar-header { padding: 1.5rem; border-bottom: 1px solid var(--border); }
.sidebar-logo { display: flex; align-items: center; gap: 0.75rem; }
.sidebar-logo-icon { width: 40px; height: 40px; background: linear-gradient(135deg, var(--accent), var(--accent-secondary)); border-radius: 10px; display: flex; align-items: center; justify-content: center; font-size: 1.25rem; }
.sidebar-logo-text h2 { font-size: 1.1rem; font-weight: 700; }
.sidebar-logo-text span { font-size: 0.7rem; color: var(--text-muted); }
.sidebar-nav { flex: 1; padding: 1rem 0; overflow-y: auto; }
.nav-section { padding: 0 0.75rem; margin-bottom: 1.5rem; }
.nav-section-title { font-size: 0.7rem; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.08em; padding: 0 0.75rem; margin-bottom: 0.5rem; }
.nav-item { display: flex; align-items: center; gap: 0.75rem; padding: 0.75rem; border-radius: 10px; color: var(--text-secondary); transition: all 0.2s; margin-bottom: 0.25rem; }
.nav-item:hover { background: var(--bg-elevated); color: var(--text-primary); }
.nav-item.active { background: var(--accent); color: white; box-shadow: 0 4px 12px var(--accent-glow); }
.nav-item-icon { width: 20px; text-align: center; font-size: 1rem; }
.nav-item-text { font-size: 0.9rem; font-weight: 500; }
.nav-item-badge { margin-left: auto; padding: 0.15rem 0.5rem; background: var(--accent); color: white; font-size: 0.65rem; font-weight: 600; border-radius: 100px; text-transform: uppercase; }
.nav-item-badge.soon { background: var(--text-muted); }
.nav-item.active .nav-item-badge { background: rgba(255,255,255,0.2); }
.nav-item.disabled { opacity: 0.5; cursor: not-allowed; pointer-events: none; }
.sidebar-footer { padding: 1rem 1.5rem; border-top: 1px solid var(--border); }
.user-info { display: flex; align-items: center; gap: 0.75rem; }
.user-avatar { width: 36px; height: 36px; background: linear-gradient(135deg, var(--accent), var(--accent-secondary)); border-radius: 10px; display: flex; align-items: center; justify-content: center; font-weight: 600; color: white; font-size: 0.9rem; }
.user-details { flex: 1; }
.user-name { font-size: 0.85rem; font-weight: 600; }
.user-role { font-size: 0.7rem; color: var(--text-muted); }
.logout-btn { background: none; border: none; color: var(--text-muted); cursor: pointer; padding: 0.5rem; border-radius: 8px; transition: all 0.2s; font-size: 1rem; }
.logout-btn:hover { background: var(--error); color: white; }

/* ============ MAIN ============ */
.main-content { flex: 1; margin-left: var(--sidebar-width); min-height: 100vh; transition: all 0.3s; }
.page-header { padding: 1.25rem 2rem; border-bottom: 1px solid var(--border); background: var(--bg-secondary); display: flex; align-items: center; justify-content: space-between; position: sticky; top: 0; z-index: 50; backdrop-filter: blur(12px); }
.page-title h1 { font-size: 1.4rem; font-weight: 700; display: flex; align-items: center; gap: 0.5rem; }
.page-title p { color: var(--text-muted); font-size: 0.8rem; margin-top: 0.2rem; }
.page-header-actions { display: flex; align-items: center; gap: 0.75rem; }
.page-body { padding: 1.5rem 2rem; }

/* ============ CARDS ============ */
.card { background: var(--bg-card); border: 1px solid var(--border); border-radius: 16px; overflow: hidden; box-shadow: var(--shadow-sm); transition: all 0.2s; }
.card:hover { box-shadow: var(--shadow-md); }
.card-header { display: flex; align-items: center; justify-content: space-between; padding: 1rem 1.25rem; background: var(--bg-tertiary); border-bottom: 1px solid var(--border); }
.card-title { display: flex; align-items: center; gap: 0.6rem; font-size: 0.9rem; font-weight: 600; }
.card-title-icon { width: 32px; height: 32px; background: linear-gradient(135deg, var(--accent), var(--accent-secondary)); border-radius: 8px; display: flex; align-items: center; justify-content: center; font-size: 0.9rem; }
.card-body { padding: 1.25rem; }

/* ============ BUTTONS ============ */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 0.5rem; padding: 0.7rem 1.2rem; font-family: inherit; font-size: 0.85rem; font-weight: 600; border: none; border-radius: 10px; cursor: pointer; transition: all 0.2s; }
.btn-primary { background: linear-gradient(135deg, var(--accent), var(--accent-secondary)); color: white; box-shadow: 0 4px 16px var(--accent-glow); }
.btn-primary:hover:not(:disabled) { transform: translateY(-2px); box-shadow: 0 6px 20px var(--accent-glow); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-success { background: var(--success); color: white; }
.btn-danger { background: var(--error); color: white; }
.btn-ghost { background: transparent; color: var(--text-secondary); border: 1px solid var(--border); }
.btn-ghost:hover { background: var(--bg-elevated); color: var(--text-primary); border-color: var(--border-hover); }
.btn-sm { padding: 0.5rem 0.875rem; font-size: 0.8rem; }

/* ============ FORMS ============ */
.form-group { margin-bottom: 1rem; }
.form-group label { display: block; font-size: 0.75rem; font-weight: 600; color: var(--text-secondary); margin-bottom: 0.5rem; text-transform: uppercase; letter-spacing: 0.05em; }
input, textarea, select { width: 100%; padding: 0.7rem 1rem; background: var(--bg-primary); border: 1px solid var(--border); border-radius: 10px; color: var(--text-primary); font-family: 'JetBrains Mono', monospace; font-size: 0.85rem; transition: all 0.2s; }
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-glow); }
input::placeholder, textarea::placeholder { color: var(--text-muted); }
textarea { resize: vertical; min-height: 100px; line-height: 1.6; }
select { cursor: pointer; }

/* ============ DASHBOARD ============ */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 1.25rem; margin-bottom: 1.5rem; }
.stat-card { background: var(--bg-card); border: 1px solid var(--border); border-radius: 16px; padding: 1.25rem; display: flex; align-items: flex-start; gap: 1rem; box-shadow: var(--shadow-sm); transition: all 0.2s; }
.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.stat-icon { width: 48px; height: 48px; background: linear-gradient(135deg, var(--accent), var(--accent-secondary)); border-radius: 12px; display: flex; align-items: center; justify-content: center; font-size: 1.4rem; }
.stat-info { flex: 1; }
.stat-value { font-family: 'JetBrains Mono', monospace; font-size: 1.6rem; font-weight: 700; }
.stat-label { color: var(--text-muted); font-size: 0.8rem; margin-top: 0.2rem; }
.quick-actions { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 1rem; }
.quick-action { background: var(--bg-card); border: 1px solid var(--border); border-radius: 14px; padding: 1.25rem; display: flex; align-items: center; gap: 1rem; transition: all 0.2s; cursor: pointer; text-decoration: none; }
.quick-action:hover { border-color: var(--accent); transform: translateY(-3px); box-shadow: var(--shadow-md); }
.quick-action-icon { width: 44px; height: 44px; background: linear-gradient(135deg, var(--accent), var(--accent-secondary)); border-radius: 12px; display: flex; align-items: center; justify-content: center; font-size: 1.2rem; }
.quick-action-text h4 { font-size: 0.9rem; font-weight: 600; }
.quick-action-text p { font-size: 0.75rem; color: var(--text-muted); margin-top: 0.15rem; }

/* ============ MODAL ============ */
.modal-overlay { display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.6); backdrop-filter: blur(8px); z-index: 1000; justify-content: center; align-items: center; padding: 2rem; }
.modal-overlay.active { display: flex; }
.modal { background: var(--bg-card); border: 1px solid var(--border); border-radius: 20px; max-width: 500px; width: 100%; max-height: 85vh; overflow: hidden; animation: modalIn 0.3s ease; box-shadow: var(--shadow-lg); }
@keyframes modalIn { from { opacity: 0; transform: scale(0.95) translateY(20px); } }
.modal-header { display: flex; justify-content: space-between; align-items: center; padding: 1.25rem 1.5rem; background: var(--bg-tertiary); border-bottom: 1px solid var(--border); }
.modal-title { font-weight: 600; font-size: 1.1rem; }
.modal-close { background: none; border: none; color: var(--text-muted); font-size: 1.5rem; cursor: pointer; }
.modal-close:hover { color: var(--error); }
.modal-body { padding: 1.5rem; overflow-y: auto; max-height: calc(85vh - 140px); }
.modal-footer { padding: 1rem 1.5rem; background: var(--bg-tertiary); border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 0.75rem; }

/* ============ TABLES ============ */
.table-container { overflow-x: auto; border-radius: 12px; border: 1px solid var(--border); }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; padding: 0.75rem 1rem; background: var(--bg-tertiary); font-size: 0.7rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-muted); border-bottom: 1px solid var(--border); }
td { padding: 0.75rem 1rem; border-bottom: 1px solid var(--border); font-size: 0.85rem; }
tr:last-child td { border-bottom: none; }
tr:hover { background: var(--bg-tertiary); }

/* ============ BADGES ============ */
.badge { display: inline-flex; align-items: center; padding: 0.2rem 0.5rem; font-size: 0.65rem; font-weight: 600; border-radius: 100px; text-transform: uppercase; }
.badge-success { background: rgba(16, 185, 129, 0.15); color: var(--success); }
.badge-warning { background: rgba(245, 158, 11, 0.15); color: var(--warning); }
.badge-error { background: rgba(239, 68, 68, 0.15); color: var(--error); }
.badge-info { background: rgba(99, 102, 241, 0.15); color: var(--accent); }
.badge-muted { background: var(--bg-elevated); color: var(--text-muted); }

/* ============ EMPTY STATE ============ */
.empty-state { text-align: center; padding: 3rem 2rem; }
.empty-state-icon { font-size: 3.5rem; margin-bottom: 1rem; opacity: 0.5; }
.empty-state h3 { font-size: 1.2rem; margin-bottom: 0.5rem; }
.empty-state p { color: var(--text-muted); font-size: 0.9rem; }

/* ============ LOADING ============ */
.loading { display: flex; align-items: center; justify-content: center; padding: 3rem; color: var(--text-muted); }
.loading::before { content: ''; width: 24px; height: 24px; border: 3px solid var(--border); border-top-color: var(--accent); border-radius: 50%; animation: spin 0.8s linear infinite; margin-right: 0.75rem; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ============ SCROLLBAR ============ */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg-primary); }
::-webkit-scrollbar-thumb { background: var(--border-hover); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ============ UTILITIES ============ */
.text-muted { color: var(--text-muted); }
.text-success { color: var(--success); }
.text-error { color: var(--error); }
.text-warning { color: var(--warning); }
.text-accent { color: var(--accent); }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.flex { display: flex; }
.flex-1 { flex: 1; }
.gap-1 { gap: 0.5rem; }
.gap-2 { gap: 1rem; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.hidden { display: none !important; }
