/* ══════════════════════════════════════════
   CSS Variables — Light / Dark
══════════════════════════════════════════ */
:root {
  --bg: #f4f5f7;
  --card-bg: #ffffff;
  --text: #1a1a2e;
  --text-muted: #6c757d;
  --border: #e0e3e8;
  --input-bg: #ffffff;
  --table-stripe: #f8f9fa;
  --nav-bg: #0a0a14;
  --shadow: 0 4px 20px rgba(0,0,0,0.07);
}
[data-theme="dark"] {
  --bg: #0a0a14;
  --card-bg: #13131f;
  --text: #e2e2e8;
  --text-muted: #888899;
  --border: #1e1e30;
  --input-bg: #1a1a2e;
  --table-stripe: #161626;
  --nav-bg: #050508;
  --shadow: 0 4px 20px rgba(0,0,0,0.4);
}

/* ══════════════════════════════════════════
   Base
══════════════════════════════════════════ */
*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  background-color: var(--bg);
  color: var(--text);
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  transition: background 0.3s, color 0.3s;
  -webkit-font-smoothing: antialiased;
}

/* ══════════════════════════════════════════
   Cards
══════════════════════════════════════════ */
.card {
  background-color: var(--card-bg) !important;
  border-color: var(--border) !important;
  border-radius: 16px !important;
  box-shadow: var(--shadow);
  transition: background 0.3s;
}
.card-header { border-color: var(--border) !important; }
.section-header {
  background: linear-gradient(90deg, #1a1a2e, #0f3460) !important;
  color: white !important;
  padding: 14px 20px;
  font-weight: 700;
  font-size: 0.9rem;
}
.section-header i { color: #ffc107; }

/* ══════════════════════════════════════════
   Lists / Tables
══════════════════════════════════════════ */
.list-group-item { background-color: var(--card-bg); color: var(--text); border-color: var(--border); }
.table { color: var(--text); }
.table-striped > tbody > tr:nth-of-type(odd) > * { background-color: var(--table-stripe); }
.table-dark { background: #1a1a2e !important; }
.table th { font-weight: 700; font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.4px; }
.table td, .table th { vertical-align: middle; }

/* ══════════════════════════════════════════
   Dropdowns / Alerts / Misc
══════════════════════════════════════════ */
.dropdown-menu { background-color: var(--card-bg); border-color: var(--border); border-radius: 12px; box-shadow: var(--shadow); }
.dropdown-item { color: var(--text); border-radius: 8px; }
.dropdown-item:hover { background-color: var(--border); }
.alert { border-radius: 12px; }
hr { border-color: var(--border); opacity: 1; }
.text-muted { color: var(--text-muted) !important; }

/* ══════════════════════════════════════════
   Inputs
══════════════════════════════════════════ */
.form-control, .form-select {
  background-color: var(--input-bg) !important;
  color: var(--text) !important;
  border: 1.5px solid var(--border) !important;
  border-radius: 10px !important;
  padding: 0.55rem 0.9rem;
  font-size: 0.95rem;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.form-control:focus, .form-select:focus {
  border-color: #ffc107 !important;
  box-shadow: 0 0 0 3px rgba(255,193,7,0.18) !important;
  outline: none;
}
.form-label { font-weight: 600; font-size: 0.875rem; color: var(--text-muted); margin-bottom: 5px; }

/* ══════════════════════════════════════════
   Buttons
══════════════════════════════════════════ */
.btn-warning { color: #000 !important; font-weight: 700; }
.btn { border-radius: 10px; font-weight: 600; }
.btn-sm { border-radius: 8px; }

/* ══════════════════════════════════════════
   Navbar
══════════════════════════════════════════ */
.navbar {
  background-color: var(--nav-bg) !important;
  padding: 10px 0;
  border-bottom: 1px solid rgba(255,255,255,0.05);
}
.navbar-brand { font-size: 1.25rem; font-weight: 800; letter-spacing: 0.3px; }
.nav-link { font-weight: 500; font-size: 0.9rem; }

/* ══════════════════════════════════════════
   Mobile Bottom Navigation
══════════════════════════════════════════ */
.mobile-bottom-nav {
  position: fixed; bottom: 0; left: 0; right: 0;
  background: var(--card-bg);
  border-top: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-around;
  padding: 6px 0 max(10px, env(safe-area-inset-bottom));
  z-index: 1000;
  box-shadow: 0 -4px 24px rgba(0,0,0,0.12);
}
.mobile-nav-item {
  display: flex; flex-direction: column; align-items: center;
  color: var(--text-muted); text-decoration: none;
  font-size: 0.6rem; font-weight: 700;
  gap: 2px; flex: 1; padding: 4px 0;
  transition: color 0.2s;
}
.mobile-nav-item i { font-size: 1.35rem; }
.mobile-nav-item:hover,
.mobile-nav-item.active { color: #ffc107; }
.mobile-nav-center {
  background: linear-gradient(135deg, #ffc107, #ff9800);
  color: #000 !important; border-radius: 50%;
  width: 54px; height: 54px; margin-top: -22px;
  box-shadow: 0 4px 20px rgba(255,193,7,0.55);
  justify-content: center; flex: none;
}
.mobile-nav-center i { font-size: 1.5rem; margin: 0; }

/* ══════════════════════════════════════════
   Streak / Achievement Badges
══════════════════════════════════════════ */
.badge-bronze  { background: linear-gradient(135deg,#cd7f32,#a05a2c); color:white; }
.badge-silver  { background: linear-gradient(135deg,#c0c0c0,#909090); color:white; }
.badge-gold    { background: linear-gradient(135deg,#ffd700,#ffa500); color:#000; }
.badge-diamond { background: linear-gradient(135deg,#00d2ff,#3a7bd5); color:white; }
.streak-badge  { border-radius: 12px; padding: 10px 14px; text-align: center; min-width: 85px; }
.streak-badge .badge-icon  { font-size: 1.5rem; display: block; }
.streak-badge .badge-label { font-size: 0.68rem; font-weight: 700; display: block; margin-top: 3px; }

/* ══════════════════════════════════════════
   Chat
══════════════════════════════════════════ */
#chat-box { overscroll-behavior: contain; }
#chat-box::-webkit-scrollbar { width: 4px; }
#chat-box::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

/* ══════════════════════════════════════════
   Scrollbar
══════════════════════════════════════════ */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

/* ══════════════════════════════════════════
   Mobile spacing — reserve room for bottom nav
══════════════════════════════════════════ */
.container { padding-bottom: 90px; }
@media (min-width: 992px) {
  .container { padding-bottom: 24px; }
  .mobile-bottom-nav { display: none !important; }
}

/* ══════════════════════════════════════════
   Mobile — general touch-friendly fixes
══════════════════════════════════════════ */
@media (max-width: 768px) {
  .card { border-radius: 14px !important; }
  .table-responsive { font-size: 0.78rem; }
  .btn { min-height: 42px; }
  .form-control, .form-select { font-size: 16px !important; } /* prevent iOS zoom */
  h2 { font-size: 1.5rem; }
  h3 { font-size: 1.3rem; }
  .section-header { font-size: 0.85rem; padding: 12px 16px; }

  /* Stat pills stack nicely */
  .stat-pill h2 { font-size: 1.6rem; }

  /* Charts don't overflow */
  canvas { max-width: 100% !important; }

  /* Radar chart height on mobile */
  #radarChart { height: 260px !important; }
}

@media (max-width: 480px) {
  .container { padding-left: 14px; padding-right: 14px; }
  .hero-btns { flex-direction: column; align-items: stretch; }
  .btn-hero-primary, .btn-hero-secondary { text-align: center; }
}
