/* ── Variables ──────────────────────────────────────────────────────────────── */
:root {
    --primary: #1a3a5c;
    --primary-light: #2563a8;
    --accent: #f59e0b;
    --accent-dark: #d97706;
    --success: #10b981;
    --danger: #ef4444;
    --sidebar-width: 240px;
    --topbar-height: 56px;
    --bg: #f0f4f8;
    --card-bg: #ffffff;
    --text: #1e293b;
    --text-muted: #64748b;
    --border: #e2e8f0;
    --shadow: 0 1px 3px rgba(0,0,0,.12), 0 1px 2px rgba(0,0,0,.08);
    --shadow-lg: 0 4px 16px rgba(0,0,0,.12);
    --sidebar-bg: #0f2236;
    --sidebar-hover: #1a3a5c;
    --topbar-bg: #ffffff;
}

/* ── Reset / Base ────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; font-family: 'Segoe UI', system-ui, sans-serif; background: var(--bg); color: var(--text); }

/* ── Topbar ──────────────────────────────────────────────────────────────────── */
.topbar {
    position: fixed; top: 0; left: 0; right: 0; height: var(--topbar-height);
    background: var(--topbar-bg); border-bottom: 1px solid var(--border);
    display: flex; align-items: center; padding: 0 1rem; z-index: 1000;
    box-shadow: var(--shadow);
}
.topbar-brand {
    font-size: 1.2rem; font-weight: 700; color: var(--primary); text-decoration: none;
    display: flex; align-items: center; gap: .4rem; margin-left: .5rem;
}
.topbar-brand i { color: var(--accent); }
.topbar-right { margin-left: auto; display: flex; align-items: center; }
.topbar-user { font-size: .875rem; color: var(--text-muted); }
.sidebar-toggle {
    background: none; border: none; font-size: 1.4rem; color: var(--primary); cursor: pointer;
    display: flex; align-items: center; padding: .25rem .5rem; border-radius: .375rem;
}
.sidebar-toggle:hover { background: var(--bg); }
.btn-logout {
    background: transparent; border: 1px solid var(--border); color: var(--text-muted);
    border-radius: .375rem; padding: .25rem .75rem; font-size: .8rem;
}
.btn-logout:hover { background: var(--danger); color: white; border-color: var(--danger); }

/* ── Sidebar ─────────────────────────────────────────────────────────────────── */
.sidebar {
    position: fixed; top: var(--topbar-height); left: 0; bottom: 0;
    width: var(--sidebar-width); background: var(--sidebar-bg); overflow-y: auto;
    z-index: 900; transition: transform .3s ease; display: flex; flex-direction: column;
}
.sidebar-header {
    display: flex; align-items: center; gap: .75rem; padding: 1.25rem 1rem;
    border-bottom: 1px solid rgba(255,255,255,.08);
}
.sidebar-logo { font-size: 1.5rem; color: var(--accent); }
.sidebar-title { font-size: 1rem; font-weight: 700; color: white; }
.sidebar-nav { display: flex; flex-direction: column; padding: .5rem 0; flex: 1; }
.sidebar-section {
    font-size: .65rem; font-weight: 700; letter-spacing: .1em; text-transform: uppercase;
    color: rgba(255,255,255,.35); padding: 1rem 1rem .25rem;
}
.sidebar-link {
    display: flex; align-items: center; gap: .75rem; padding: .625rem 1rem;
    color: rgba(255,255,255,.7); text-decoration: none; font-size: .875rem;
    border-left: 3px solid transparent; transition: all .2s;
}
.sidebar-link:hover { background: var(--sidebar-hover); color: white; border-left-color: var(--accent); }
.sidebar-link.active { background: var(--primary); color: white; border-left-color: var(--accent); font-weight: 600; }
.sidebar-link i { font-size: 1rem; width: 1.25rem; text-align: center; }

/* ── Main Content ────────────────────────────────────────────────────────────── */
.app-body { overflow-x: hidden; }
.main-content {
    margin-left: var(--sidebar-width); margin-top: var(--topbar-height);
    min-height: calc(100vh - var(--topbar-height)); transition: margin-left .3s ease;
}
.content-wrapper { padding: 1.5rem; }

/* ── Cards ───────────────────────────────────────────────────────────────────── */
.card { background: var(--card-bg); border: 1px solid var(--border); border-radius: .75rem; box-shadow: var(--shadow); }
.card-header { background: var(--card-bg); border-bottom: 1px solid var(--border); padding: 1rem 1.25rem; border-radius: .75rem .75rem 0 0; }
.card-header h5 { margin: 0; font-weight: 600; color: var(--primary); }

/* ── Stat Cards (Dashboard) ──────────────────────────────────────────────────── */
.stat-card {
    background: var(--card-bg); border: 1px solid var(--border); border-radius: .75rem;
    padding: 1.25rem; display: flex; align-items: center; gap: 1rem; box-shadow: var(--shadow);
    transition: transform .2s, box-shadow .2s;
}
.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }
.stat-icon {
    width: 52px; height: 52px; border-radius: .75rem; display: flex;
    align-items: center; justify-content: center; font-size: 1.4rem; flex-shrink: 0;
}
.stat-icon.gold { background: #fef3c7; color: #d97706; }
.stat-icon.blue { background: #dbeafe; color: #2563eb; }
.stat-icon.green { background: #d1fae5; color: #059669; }
.stat-icon.red { background: #fee2e2; color: #dc2626; }
.stat-value { font-size: 1.75rem; font-weight: 700; color: var(--primary); line-height: 1; }
.stat-label { font-size: .8rem; color: var(--text-muted); margin-top: .2rem; }

/* ── Scoreboard ──────────────────────────────────────────────────────────────── */
.rank-badge {
    width: 36px; height: 36px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: .9rem; flex-shrink: 0;
}
.rank-badge.rank-1 { background: linear-gradient(135deg, #fbbf24, #f59e0b); color: white; }
.rank-badge.rank-2 { background: linear-gradient(135deg, #94a3b8, #64748b); color: white; }
.rank-badge.rank-3 { background: linear-gradient(135deg, #d97706, #b45309); color: white; }
.rank-badge.rank-other { background: var(--bg); color: var(--text-muted); }
.progress { height: 8px; border-radius: 4px; }
.progress-bar { background: linear-gradient(90deg, var(--primary-light), var(--accent)); border-radius: 4px; }

/* ── Tables ──────────────────────────────────────────────────────────────────── */
.table { font-size: .875rem; }
.table thead th { background: #f8fafc; color: var(--primary); font-weight: 600; font-size: .8rem; text-transform: uppercase; letter-spacing: .05em; border-bottom: 2px solid var(--border); }
.table tbody tr:hover { background: #f8fafc; }
.table td { vertical-align: middle; }

/* ── Badges ──────────────────────────────────────────────────────────────────── */
.badge-prize-1 { background: #fef3c7; color: #92400e; border: 1px solid #fde68a; }
.badge-prize-2 { background: #f1f5f9; color: #475569; border: 1px solid #cbd5e1; }
.badge-prize-3 { background: #fff7ed; color: #9a3412; border: 1px solid #fed7aa; }

/* ── Page Header ─────────────────────────────────────────────────────────────── */
.page-header { margin-bottom: 1.5rem; display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: .75rem; }
.page-title { font-size: 1.4rem; font-weight: 700; color: var(--primary); margin: 0; }
.page-subtitle { font-size: .875rem; color: var(--text-muted); margin: .1rem 0 0; }

/* ── Buttons ─────────────────────────────────────────────────────────────────── */
.btn-primary { background: var(--primary); border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-light); border-color: var(--primary-light); }
.btn-accent { background: var(--accent); border-color: var(--accent); color: white; }
.btn-accent:hover { background: var(--accent-dark); border-color: var(--accent-dark); color: white; }

/* ── Forms ───────────────────────────────────────────────────────────────────── */
.form-label { font-weight: 500; font-size: .875rem; color: var(--text); }
.form-control, .form-select { border-color: var(--border); font-size: .875rem; }
.form-control:focus, .form-select:focus { border-color: var(--primary-light); box-shadow: 0 0 0 3px rgba(37, 99, 168, .15); }

/* ── Auth Pages ──────────────────────────────────────────────────────────────── */
.auth-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%); }
.auth-card { background: white; border-radius: 1rem; padding: 2.5rem; width: 100%; max-width: 420px; box-shadow: 0 20px 60px rgba(0,0,0,.2); }
.auth-logo { text-align: center; margin-bottom: 1.5rem; }
.auth-logo i { font-size: 3rem; color: var(--accent); }
.auth-logo h1 { font-size: 1.5rem; font-weight: 700; color: var(--primary); margin: .5rem 0 0; }
.auth-logo p { color: var(--text-muted); font-size: .875rem; margin: .25rem 0 0; }

/* ── Status Badges ───────────────────────────────────────────────────────────── */
.status-pending { background: #fef9c3; color: #854d0e; padding: .25rem .6rem; border-radius: 999px; font-size: .75rem; font-weight: 600; }
.status-approved { background: #dcfce7; color: #166534; padding: .25rem .6rem; border-radius: 999px; font-size: .75rem; font-weight: 600; }
.status-rejected { background: #fee2e2; color: #991b1b; padding: .25rem .6rem; border-radius: 999px; font-size: .75rem; font-weight: 600; }

/* ── Responsive ──────────────────────────────────────────────────────────────── */
@media (max-width: 768px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.open { transform: translateX(0); }
    .main-content { margin-left: 0; }
    .sidebar-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 850; }
    .sidebar-overlay.show { display: block; }
    .topbar-user { display: none; }
}
@media (min-width: 769px) {
    .sidebar-toggle { display: none; }
}

/* ── Print ───────────────────────────────────────────────────────────────────── */
@media print {
    .topbar, .sidebar, .no-print { display: none !important; }
    .main-content { margin: 0; }
}
.print-header { text-align: center; margin-bottom: 1.5rem; border-bottom: 2px solid var(--primary); padding-bottom: 1rem; }
.print-header h2 { color: var(--primary); font-weight: 700; }
