/* ============================================================
   JETS NMS - Mobile-First Stylesheet
   ============================================================ */

:root {
  --primary:     #1a3a5c;
  --primary-dark:#0f2340;
  --secondary:   #e8a020;
  --accent:      #2ecc71;
  --danger:      #e74c3c;
  --warning:     #f39c12;
  --info:        #3498db;
  --light:       #f8f9fa;
  --dark:        #2c3e50;
  --muted:       #6c757d;
  --border:      #dee2e6;
  --sidebar-w:   260px;
  --topbar-h:    60px;
  --radius:      8px;
  --shadow:      0 2px 12px rgba(0,0,0,.10);
  --shadow-lg:   0 4px 24px rgba(0,0,0,.16);
  --transition:  .2s ease;
}

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

html { font-size: 15px; scroll-behavior: smooth; }

body {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: #eef2f7;
  color: var(--dark);
  min-height: 100vh;
  line-height: 1.6;
}

a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--secondary); }

/* ── SIDEBAR ────────────────────────────────────────── */
.sidebar {
  position: fixed;
  top: 0; left: 0;
  width: var(--sidebar-w);
  height: 100vh;
  background: var(--primary);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  z-index: 1000;
  transition: transform var(--transition);
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 20px 18px;
  border-bottom: 1px solid rgba(255,255,255,.12);
}

.sidebar-brand img { width: 38px; height: 38px; border-radius: 6px; }

.sidebar-brand-text { color: #fff; }
.sidebar-brand-text .brand-title { font-size: .95rem; font-weight: 700; line-height: 1.2; }
.sidebar-brand-text .brand-sub   { font-size: .72rem; opacity: .7; }

.sidebar-nav { flex: 1; padding: 12px 0; }

.nav-section { padding: 16px 18px 6px; font-size: .68rem; font-weight: 700;
               letter-spacing: .1em; color: rgba(255,255,255,.4); text-transform: uppercase; }

.nav-item { display: block; padding: 10px 18px; color: rgba(255,255,255,.82);
            font-size: .88rem; display: flex; align-items: center; gap: 10px;
            transition: background var(--transition), color var(--transition);
            border-left: 3px solid transparent; }
.nav-item:hover, .nav-item.active {
  background: rgba(255,255,255,.10);
  color: #fff;
  border-left-color: var(--secondary);
}
.nav-item i { width: 18px; text-align: center; font-size: .95rem; }

.sidebar-footer { padding: 16px 18px; border-top: 1px solid rgba(255,255,255,.12); }
.sidebar-user { display: flex; align-items: center; gap: 10px; }
.sidebar-avatar { width: 36px; height: 36px; border-radius: 50%; background: var(--secondary);
                  display: flex; align-items: center; justify-content: center;
                  font-weight: 700; font-size: .9rem; color: #fff; flex-shrink: 0; }
.sidebar-user-info .user-name  { font-size: .85rem; font-weight: 600; color: #fff; }
.sidebar-user-info .user-role  { font-size: .72rem; color: rgba(255,255,255,.55); }

/* ── TOPBAR ─────────────────────────────────────────── */
.topbar {
  position: fixed; top: 0; left: var(--sidebar-w); right: 0;
  height: var(--topbar-h);
  background: #fff;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 20px;
  z-index: 900;
  box-shadow: 0 1px 6px rgba(0,0,0,.07);
}

.topbar-left { display: flex; align-items: center; gap: 14px; }

.menu-toggle {
  display: none;
  background: none; border: none; cursor: pointer; padding: 6px;
  color: var(--primary); font-size: 1.2rem;
}

.topbar-title { font-size: 1rem; font-weight: 700; color: var(--primary); }

.topbar-right { display: flex; align-items: center; gap: 14px; }

.topbar-badge { position: relative; }
.topbar-badge .badge { position: absolute; top: -4px; right: -4px; background: var(--danger);
                        color: #fff; font-size: .6rem; padding: 2px 5px; border-radius: 20px; }

.topbar-user { display: flex; align-items: center; gap: 8px; font-size: .85rem; color: var(--dark); }

/* ── MAIN CONTENT ───────────────────────────────────── */
.main-content {
  margin-left: var(--sidebar-w);
  padding-top: var(--topbar-h);
  min-height: 100vh;
}

.content-area { padding: 24px; }

/* ── PAGE HEADER ────────────────────────────────────── */
.page-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 24px; flex-wrap: wrap; gap: 12px;
}
.page-header h1 { font-size: 1.35rem; font-weight: 700; color: var(--primary); }
.breadcrumb { font-size: .8rem; color: var(--muted); margin-top: 2px; }
.breadcrumb a { color: var(--muted); }
.breadcrumb span { color: var(--secondary); }

/* ── STAT CARDS ─────────────────────────────────────── */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 16px; margin-bottom: 24px; }

.stat-card {
  background: #fff; border-radius: var(--radius); padding: 20px;
  box-shadow: var(--shadow); display: flex; align-items: center; gap: 16px;
  border-left: 4px solid var(--primary); transition: transform var(--transition);
}
.stat-card:hover { transform: translateY(-2px); }
.stat-card.green  { border-left-color: var(--accent); }
.stat-card.orange { border-left-color: var(--secondary); }
.stat-card.red    { border-left-color: var(--danger); }
.stat-card.blue   { border-left-color: var(--info); }

.stat-icon { width: 48px; height: 48px; border-radius: var(--radius);
             display: flex; align-items: center; justify-content: center;
             font-size: 1.3rem; flex-shrink: 0; }
.stat-card .stat-icon { background: rgba(26,58,92,.1); color: var(--primary); }
.stat-card.green  .stat-icon { background: rgba(46,204,113,.1); color: var(--accent); }
.stat-card.orange .stat-icon { background: rgba(232,160,32,.1); color: var(--secondary); }
.stat-card.red    .stat-icon { background: rgba(231,76,60,.1);  color: var(--danger); }
.stat-card.blue   .stat-icon { background: rgba(52,152,219,.1); color: var(--info); }

.stat-value { font-size: 1.7rem; font-weight: 800; line-height: 1; color: var(--dark); }
.stat-label { font-size: .8rem; color: var(--muted); margin-top: 3px; }

/* ── CARD ───────────────────────────────────────────── */
.card {
  background: #fff; border-radius: var(--radius);
  box-shadow: var(--shadow); overflow: hidden;
}
.card-header {
  padding: 16px 20px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  background: #fff;
}
.card-header h2, .card-header h3 { font-size: 1rem; font-weight: 700; color: var(--primary); }
.card-body { padding: 20px; }
.card-footer { padding: 14px 20px; border-top: 1px solid var(--border); background: var(--light); }

/* ── TABLES ─────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }

.table { width: 100%; border-collapse: collapse; font-size: .875rem; }
.table th { background: var(--primary); color: #fff; padding: 11px 14px; text-align: left;
            font-weight: 600; font-size: .8rem; white-space: nowrap; }
.table td { padding: 10px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tr:last-child td { border-bottom: none; }
.table tbody tr:hover { background: #f0f4f8; }
.table .actions { display: flex; gap: 6px; }

/* ── BADGES ─────────────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center;
  padding: 3px 9px; border-radius: 20px;
  font-size: .72rem; font-weight: 700; line-height: 1.4;
}
.badge-success  { background: #d4edda; color: #155724; }
.badge-warning  { background: #fff3cd; color: #856404; }
.badge-danger   { background: #f8d7da; color: #721c24; }
.badge-info     { background: #d1ecf1; color: #0c5460; }
.badge-primary  { background: rgba(26,58,92,.12); color: var(--primary); }
.badge-secondary{ background: #e2e3e5; color: #383d41; }
.badge-gold     { background: #fef3cd; color: #7d5a00; }

/* ── BUTTONS ─────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 16px; border-radius: var(--radius);
  font-size: .875rem; font-weight: 600; cursor: pointer;
  border: none; transition: all var(--transition); white-space: nowrap;
  text-decoration: none;
}
.btn:focus { outline: 2px solid var(--secondary); outline-offset: 2px; }
.btn-sm { padding: 5px 11px; font-size: .78rem; }
.btn-lg { padding: 12px 24px; font-size: 1rem; }
.btn-block { width: 100%; justify-content: center; }

.btn-primary  { background: var(--primary);   color: #fff; }
.btn-primary:hover  { background: var(--primary-dark); color: #fff; }
.btn-secondary{ background: var(--muted);     color: #fff; }
.btn-secondary:hover{ background: #5a6268;    color: #fff; }
.btn-success  { background: var(--accent);    color: #fff; }
.btn-success:hover  { background: #27ae60;    color: #fff; }
.btn-danger   { background: var(--danger);    color: #fff; }
.btn-danger:hover   { background: #c0392b;    color: #fff; }
.btn-warning  { background: var(--warning);   color: #fff; }
.btn-warning:hover  { background: #d68910;    color: #fff; }
.btn-info     { background: var(--info);      color: #fff; }
.btn-info:hover     { background: #2980b9;    color: #fff; }
.btn-outline-primary{ background: transparent; border: 2px solid var(--primary); color: var(--primary); }
.btn-outline-primary:hover { background: var(--primary); color: #fff; }
.btn-outline-danger { background: transparent; border: 2px solid var(--danger); color: var(--danger); }
.btn-outline-danger:hover { background: var(--danger); color: #fff; }
.btn-gold     { background: var(--secondary); color: #fff; }
.btn-gold:hover { background: #c88a18; color: #fff; }

/* ── FORMS ──────────────────────────────────────────── */
.form-group { margin-bottom: 18px; }
.form-label { display: block; font-size: .85rem; font-weight: 600; color: var(--dark); margin-bottom: 5px; }
.form-label .req { color: var(--danger); }

.form-control {
  width: 100%; padding: 9px 13px; border: 1.5px solid var(--border);
  border-radius: var(--radius); font-size: .875rem; color: var(--dark);
  transition: border-color var(--transition), box-shadow var(--transition);
  background: #fff;
}
.form-control:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(26,58,92,.12); }
.form-control.is-invalid { border-color: var(--danger); }

select.form-control { cursor: pointer; }
textarea.form-control { resize: vertical; min-height: 90px; }

.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-row.three { grid-template-columns: 1fr 1fr 1fr; }

.form-text { font-size: .78rem; color: var(--muted); margin-top: 3px; }
.invalid-feedback { font-size: .78rem; color: var(--danger); margin-top: 3px; }

.form-check { display: flex; align-items: center; gap: 8px; }
.form-check input { width: 16px; height: 16px; cursor: pointer; }

/* ── ALERTS ─────────────────────────────────────────── */
.alert {
  padding: 12px 16px; border-radius: var(--radius); margin-bottom: 18px;
  display: flex; align-items: flex-start; gap: 10px; font-size: .875rem;
}
.alert i { margin-top: 2px; }
.alert-success { background: #d4edda; color: #155724; border-left: 4px solid var(--accent); }
.alert-danger   { background: #f8d7da; color: #721c24; border-left: 4px solid var(--danger); }
.alert-warning  { background: #fff3cd; color: #856404; border-left: 4px solid var(--warning); }
.alert-info     { background: #d1ecf1; color: #0c5460; border-left: 4px solid var(--info); }

/* ── MODALS ─────────────────────────────────────────── */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 2000;
  display: flex; align-items: center; justify-content: center; padding: 16px;
  opacity: 0; pointer-events: none; transition: opacity var(--transition);
}
.modal-backdrop.show { opacity: 1; pointer-events: all; }
.modal { background: #fff; border-radius: 12px; width: 100%; max-width: 540px;
         box-shadow: var(--shadow-lg); max-height: 90vh; overflow-y: auto; }
.modal-header { padding: 18px 22px; border-bottom: 1px solid var(--border);
                display: flex; align-items: center; justify-content: space-between; }
.modal-header h3 { font-size: 1.05rem; font-weight: 700; color: var(--primary); }
.modal-close { background: none; border: none; cursor: pointer; font-size: 1.2rem; color: var(--muted); }
.modal-close:hover { color: var(--danger); }
.modal-body { padding: 22px; }
.modal-footer { padding: 14px 22px; border-top: 1px solid var(--border); display: flex; gap: 10px; justify-content: flex-end; }

/* ── PAGINATION ─────────────────────────────────────── */
.pagination { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.page-link {
  padding: 6px 12px; border: 1.5px solid var(--border); border-radius: 6px;
  font-size: .82rem; color: var(--primary); cursor: pointer; transition: all var(--transition);
}
.page-link:hover { background: var(--primary); color: #fff; border-color: var(--primary); }
.page-link.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.page-link.disabled { color: var(--muted); pointer-events: none; }

/* ── POSITION MEDALS ────────────────────────────────── */
.pos-1 { background: #fef3cd; color: #7d5a00; font-weight: 800; border-radius: 50%; width: 28px; height: 28px; display: inline-flex; align-items: center; justify-content: center; }
.pos-2 { background: #e2e3e5; color: #383d41; font-weight: 800; border-radius: 50%; width: 28px; height: 28px; display: inline-flex; align-items: center; justify-content: center; }
.pos-3 { background: #fde5d3; color: #7d3a00; font-weight: 800; border-radius: 50%; width: 28px; height: 28px; display: inline-flex; align-items: center; justify-content: center; }

/* ── SCORE BAR ──────────────────────────────────────── */
.score-bar { background: var(--border); border-radius: 20px; height: 8px; overflow: hidden; }
.score-fill { height: 100%; background: linear-gradient(90deg, var(--primary), var(--secondary)); border-radius: 20px; transition: width .5s ease; }

/* ── QUIZ UI ────────────────────────────────────────── */
.quiz-timer { font-size: 2rem; font-weight: 800; color: var(--primary); text-align: center; }
.quiz-timer.warn { color: var(--warning); }
.quiz-timer.danger { color: var(--danger); animation: pulse .5s infinite; }
@keyframes pulse { 0%,100% { opacity:1; } 50% { opacity:.5; } }

.quiz-progress-bar { height: 6px; background: var(--border); border-radius: 6px; margin: 12px 0; }
.quiz-progress-fill { height: 100%; background: var(--accent); border-radius: 6px; transition: width .3s; }

.quiz-answer-input { font-size: 1.1rem; padding: 14px; text-align: center; }

/* ── LIVE INDICATOR ─────────────────────────────────── */
.live-dot { width: 10px; height: 10px; background: var(--accent); border-radius: 50%;
            display: inline-block; margin-right: 5px; animation: blink 1.2s infinite; }
@keyframes blink { 0%,100% { opacity:1; } 50% { opacity:.3; } }

/* ── LOGIN PAGE ─────────────────────────────────────── */
.login-bg {
  min-height: 100vh;
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 60%, #091622 100%);
  display: flex; align-items: center; justify-content: center; padding: 20px;
}
.login-card {
  background: #fff; border-radius: 16px; width: 100%; max-width: 440px;
  box-shadow: var(--shadow-lg); overflow: hidden;
}
.login-header {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  padding: 32px 28px; text-align: center;
}
.login-logo { width: 70px; height: 70px; background: var(--secondary);
              border-radius: 50%; display: flex; align-items: center; justify-content: center;
              font-size: 2rem; color: #fff; margin: 0 auto 14px; }
.login-title { color: #fff; font-size: 1.3rem; font-weight: 800; }
.login-sub   { color: rgba(255,255,255,.7); font-size: .82rem; margin-top: 4px; }
.login-body  { padding: 32px 28px; }

/* ── RESPONSIVE ─────────────────────────────────────── */
@media (max-width: 900px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .topbar, .main-content { left: 0 !important; margin-left: 0 !important; }
  .menu-toggle { display: flex; }
  .overlay { position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 999; display: none; }
  .overlay.show { display: block; }
  .form-row, .form-row.three { grid-template-columns: 1fr; }
}

@media (max-width: 600px) {
  .stat-grid { grid-template-columns: 1fr 1fr; }
  .content-area { padding: 14px; }
  .page-header { flex-direction: column; align-items: flex-start; }
  .topbar { padding: 0 12px; }
}

/* ── UTILITIES ──────────────────────────────────────── */
.text-center  { text-align: center; }
.text-right   { text-align: right; }
.text-muted   { color: var(--muted); }
.text-danger  { color: var(--danger); }
.text-success { color: var(--accent); }
.text-warning { color: var(--warning); }
.text-primary { color: var(--primary); }
.fw-bold  { font-weight: 700; }
.mt-0 { margin-top: 0; }
.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mt-3 { margin-top: 24px; }
.mb-0 { margin-bottom: 0; }
.mb-1 { margin-bottom: 8px; }
.mb-2 { margin-bottom: 16px; }
.mb-3 { margin-bottom: 24px; }
.d-flex { display: flex; }
.align-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-1 { gap: 8px; }
.gap-2 { gap: 16px; }
.w-100 { width: 100%; }
.hidden { display: none !important; }
.loading { opacity: .5; pointer-events: none; }
.no-data { text-align: center; padding: 40px; color: var(--muted); font-size: .9rem; }
.avatar { width: 36px; height: 36px; border-radius: 50%; object-fit: cover; }

/* ── SCORE CRITERIA ─────────────────────────────────── */
.criteria-row { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 12px; margin-bottom: 12px; }
.criteria-label { font-weight: 600; font-size: .85rem; }
.criteria-input { width: 90px; text-align: center; }

/* ── DASHBOARD WELCOME ──────────────────────────────── */
.welcome-banner {
  background: linear-gradient(135deg, var(--primary) 0%, #2457a0 100%);
  border-radius: var(--radius); padding: 22px 24px; margin-bottom: 24px;
  color: #fff; display: flex; justify-content: space-between; align-items: center;
}
.welcome-banner h2 { font-size: 1.25rem; font-weight: 800; }
.welcome-banner p  { font-size: .85rem; opacity: .85; margin-top: 4px; }
.welcome-icon { font-size: 3rem; opacity: .3; }

/* ── RANK TABLE HIGHLIGHTS ──────────────────────────── */
.rank-row-1 { background: #fffbea !important; }
.rank-row-2 { background: #f5f5f5 !important; }
.rank-row-3 { background: #fff5ef !important; }

/* ============================================================
   THEME: Charcoal & Red  (data-theme="charcoal")
   Primary: #2f3136 (charcoal)  Secondary: #e63946 (crimson)
   Complement: #5ba4f5 (sky blue)
   ============================================================ */
body[data-theme="charcoal"] {
  --primary:      #2f3136;
  --primary-dark: #1e2124;
  --secondary:    #e63946;
  --info:         #5ba4f5;
  --border:       #d1d3d6;
  --muted:        #8a8f98;
  background:     #e3e5e8;
}

/* Stat-card icon: default uses hard-coded primary-blue rgba */
body[data-theme="charcoal"] .stat-card .stat-icon {
  background: rgba(47,49,54,.12);
  color: var(--primary);
}

/* Welcome banner: has hard-coded #2457a0 in gradient */
body[data-theme="charcoal"] .welcome-banner {
  background: linear-gradient(135deg, #2f3136 0%, #484b52 100%);
}

/* Login page gradient */
body[data-theme="charcoal"] .login-bg {
  background: linear-gradient(135deg, #2f3136 0%, #1e2124 60%, #080808 100%);
}

/* Table row hover: hard-coded #f0f4f8 */
body[data-theme="charcoal"] .table tbody tr:hover { background: #dcdee0; }

/* Form focus ring: hard-coded primary rgba */
body[data-theme="charcoal"] .form-control:focus {
  border-color: var(--secondary);
  box-shadow: 0 0 0 3px rgba(230,57,70,.18);
}

/* Badge primary: hard-coded primary rgba fill */
body[data-theme="charcoal"] .badge-primary {
  background: rgba(47,49,54,.13);
  color: var(--primary);
}

/* Score fill: gradient uses hard-coded secondary color */
body[data-theme="charcoal"] .score-fill {
  background: linear-gradient(90deg, var(--primary), var(--secondary));
}

/* Rank highlights: cooler tones suit charcoal */
body[data-theme="charcoal"] .rank-row-1 { background: #fff0f1 !important; }
body[data-theme="charcoal"] .rank-row-2 { background: #ebebeb !important; }
body[data-theme="charcoal"] .rank-row-3 { background: #f5f0ee !important; }

/* ── THEME SWITCHER WIDGET ──────────────────────────── */
.theme-switcher { display: flex; gap: 10px; align-items: center; margin-bottom: 12px; }
.theme-swatch {
  width: 30px; height: 30px; border-radius: 50%; cursor: pointer;
  border: 2px solid transparent; transition: transform .15s, border-color .15s;
  display: flex; align-items: center; justify-content: center;
  font-size: .65rem; color: #fff; font-weight: 800; text-decoration: none;
}
.theme-swatch:hover { transform: scale(1.15); color: #fff; }
.theme-swatch.active { border-color: #fff; box-shadow: 0 0 0 2px rgba(255,255,255,.4); }
.theme-swatch-blue    { background: linear-gradient(135deg, #1a3a5c, #e8a020); }
.theme-swatch-charcoal{ background: linear-gradient(135deg, #2f3136, #e63946); }
