/* ==========================================================================
   Mercury Hub — thème dark / violet / gold, style tech moderne
   ========================================================================== */

:root {
  --bg: #07050c;
  --bg-elevated: #0f0b1a;
  --bg-card: #130f21;
  --border: #241c38;

  --violet: #8b5cf6;
  --violet-soft: #6d28d9;
  --violet-glow: rgba(139, 92, 246, 0.35);

  --gold: #d4af37;
  --gold-soft: #f1e0a1;

  --text: #ece9f5;
  --text-muted: #9a92b3;

  --danger: #ef4444;
  --success: #34d399;

  --radius: 14px;
  --transition: 180ms ease;
}

:root[data-theme="light"] {
  --bg: #f6f4fb;
  --bg-elevated: #ffffff;
  --bg-card: #ffffff;
  --border: #e3ddf2;

  --violet: #7c3aed;
  --violet-soft: #6d28d9;
  --violet-glow: rgba(124, 58, 237, 0.14);

  --gold: #b8860b;
  --gold-soft: #92660b;

  --text: #1c1730;
  --text-muted: #6b6480;

  --danger: #dc2626;
  --success: #16a34a;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Inter", "Segoe UI", system-ui, sans-serif;
  min-height: 100vh;
}

body {
  background-image:
    radial-gradient(ellipse 60% 40% at 20% 0%, var(--violet-glow), transparent 60%),
    radial-gradient(ellipse 50% 30% at 100% 100%, rgba(212, 175, 55, 0.10), transparent 60%);
  background-attachment: fixed;
}

a { color: var(--gold-soft); text-decoration: none; transition: color var(--transition); }
a:hover { color: var(--gold); }

/* ---------- Layout ---------- */

.page {
  max-width: 1100px;
  margin: 0 auto;
  padding: 32px 24px 80px;
}

.navbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 24px;
  border-bottom: 1px solid var(--border);
  background: rgba(15, 11, 26, 0.7);
  backdrop-filter: blur(10px);
  position: sticky;
  top: 0;
  z-index: 20;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 1.15rem;
  letter-spacing: 0.02em;
  color: var(--text);
}

.brand-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--violet), var(--gold));
  box-shadow: 0 0 12px var(--violet-glow);
  animation: pulse 2.4s ease-in-out infinite;
}

.preview-banner {
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--gold);
  color: var(--gold-soft);
  font-size: 0.82rem;
  text-align: center;
  padding: 8px 16px;
}
.preview-banner a {
  margin-left: 10px;
  font-weight: 600;
  text-decoration: underline;
}

.theme-toggle {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text);
  transition: border-color var(--transition), transform var(--transition);
}
.theme-toggle:hover {
  border-color: var(--violet-soft);
  color: var(--gold-soft);
}
.theme-toggle svg {
  width: 18px;
  height: 18px;
}

.icon-btn {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  color: var(--text);
  transition: border-color var(--transition), color var(--transition);
  flex-shrink: 0;
}
.icon-btn:hover {
  border-color: var(--violet-soft);
  color: var(--gold-soft);
}

.theme-toggle-fixed {
  position: static;
}

.floating-controls {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 50;
  display: flex;
  gap: 8px;
}

/* ---------- Menu latéral (sidebar) ---------- */

.menu-toggle-checkbox {
  display: none;
}

.sidebar-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  opacity: 0;
  pointer-events: none;
  transition: opacity 220ms ease;
  z-index: 90;
  display: block;
}

.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  height: 100%;
  width: 270px;
  max-width: 82vw;
  background: var(--bg-card);
  border-right: 1px solid var(--border);
  transform: translateX(-100%);
  transition: transform 220ms ease;
  z-index: 100;
  display: flex;
  flex-direction: column;
  padding: 20px;
}

.menu-toggle-checkbox:checked ~ .sidebar-backdrop {
  opacity: 1;
  pointer-events: auto;
}

.menu-toggle-checkbox:checked ~ .sidebar {
  transform: translateX(0);
}

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

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 10px;
  color: var(--text);
  font-size: 0.92rem;
  transition: background var(--transition), color var(--transition);
}

.sidebar-nav a:hover {
  background: var(--bg-elevated);
  color: var(--gold-soft);
}

@keyframes pulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.25); opacity: 0.7; }
}

.nav-user {
  display: flex;
  align-items: center;
  gap: 10px;
}

.nav-user img {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 1px solid var(--border);
}

.avatar-initial {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  color: var(--gold-soft);
  font-size: 0.8rem;
  font-weight: 700;
}

.avatar-initial-sm {
  width: 24px;
  height: 24px;
  font-size: 0.68rem;
}

/* ---------- Cards ---------- */

.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  transition: border-color var(--transition), transform var(--transition), box-shadow var(--transition);
}

.card:hover {
  border-color: var(--violet-soft);
  box-shadow: 0 8px 30px -12px var(--violet-glow);
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 18px;
  margin-top: 24px;
}

.module-card {
  display: flex;
  flex-direction: column;
  gap: 10px;
  cursor: pointer;
  animation: fade-up 420ms ease backwards;
}

.module-card:nth-child(1) { animation-delay: 40ms; }
.module-card:nth-child(2) { animation-delay: 100ms; }
.module-card:nth-child(3) { animation-delay: 160ms; }
.module-card:nth-child(4) { animation-delay: 220ms; }

@keyframes fade-up {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

.module-icon {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--violet-soft), var(--violet));
  color: white;
}

.module-icon svg {
  width: 20px;
  height: 20px;
}

.module-card h3 { margin: 0; font-size: 1.05rem; }
.module-card p { margin: 0; color: var(--text-muted); font-size: 0.9rem; }
.module-card { color: var(--text); }

/* ---------- Login page ---------- */

.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.login-card {
  width: 100%;
  max-width: 380px;
  text-align: center;
  padding: 40px 32px;
  animation: fade-up 500ms ease;
}

.login-logo {
  width: 56px;
  height: 56px;
  margin: 0 auto 18px;
  border-radius: 16px;
  background: linear-gradient(135deg, var(--violet), var(--gold));
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  color: #0a0714;
  font-size: 1.4rem;
  box-shadow: 0 0 30px var(--violet-glow);
}

.login-card h1 { font-size: 1.3rem; margin: 0 0 6px; }
.login-card p { color: var(--text-muted); font-size: 0.9rem; margin: 0 0 26px; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 20px;
  border-radius: 10px;
  border: 1px solid transparent;
  font-weight: 600;
  font-size: 0.92rem;
  cursor: pointer;
  transition: transform var(--transition), box-shadow var(--transition), background var(--transition);
}

.btn:active { transform: scale(0.97); }

.btn-discord {
  width: 100%;
  background: #5865f2;
  color: white;
}
.btn-discord:hover { box-shadow: 0 0 22px rgba(88, 101, 242, 0.45); }

/* ---------- Divider + formulaire de connexion locale ---------- */

.divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 20px 0;
  color: var(--text-muted);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.divider::before, .divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--border);
}

.local-form {
  display: flex;
  flex-direction: column;
  gap: 6px;
  text-align: left;
}

.local-form label {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 8px;
}

.local-form input {
  width: 100%;
}

.local-form button {
  margin-top: 16px;
}

.btn-gold {
  background: rgba(139, 92, 246, 0.12);
  border: 1px solid var(--gold);
  color: var(--text);
}
.btn-gold:hover {
  background: rgba(139, 92, 246, 0.2);
  border-color: var(--gold-soft);
}

.btn-outline {
  background: transparent;
  border-color: var(--border);
  color: var(--text);
}
.btn-outline:hover { border-color: var(--violet-soft); }

.btn-danger {
  background: transparent;
  border-color: var(--danger);
  color: var(--danger);
}

/* ---------- Badges / roles ---------- */

.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  border: 1px solid var(--border);
}

/* ---------- Tables ---------- */

table { width: 100%; border-collapse: collapse; margin-top: 16px; }
th, td { text-align: left; padding: 12px 10px; border-bottom: 1px solid var(--border); font-size: 0.9rem; }
th { color: var(--text-muted); font-weight: 600; font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.04em; }

select, input[type="text"] {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 0.88rem;
}
select:focus, input[type="text"]:focus { outline: none; border-color: var(--violet-soft); }

/* ---------- Curseurs (range) ---------- */

input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 6px;
  border-radius: 999px;
  cursor: pointer;
  background: linear-gradient(
    to right,
    var(--gold-soft) 0%,
    var(--violet) var(--range-pct, 50%),
    var(--border) var(--range-pct, 50%),
    var(--border) 100%
  );
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #ffffff;
  border: 3px solid var(--violet);
  box-shadow: 0 0 10px var(--violet-glow);
  cursor: pointer;
}
input[type="range"]::-moz-range-thumb {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #ffffff;
  border: 3px solid var(--violet);
  box-shadow: 0 0 10px var(--violet-glow);
  cursor: pointer;
}
input[type="range"]::-moz-range-track {
  height: 6px;
  border-radius: 999px;
  background: transparent;
}
input[type="range"]:focus {
  outline: none;
}

/* ---------- Flash messages ---------- */

.flash {
  padding: 12px 16px;
  border-radius: 10px;
  margin-bottom: 16px;
  font-size: 0.9rem;
  border: 1px solid var(--border);
  animation: fade-up 300ms ease;
}
.flash-success { border-color: var(--success); color: var(--success); }
.flash-error { border-color: var(--danger); color: var(--danger); }

.text-muted { color: var(--text-muted); }
.section-title { margin: 30px 0 4px; font-size: 1.2rem; }

/* ---------- Team of the Fallen (stats Roblox) ---------- */

/* Couleurs des courbes : une couleur fixe par jeu (ordre d'ajout), jamais
   réattribuée quand on filtre. Palette testée daltonisme, clair ET sombre. */
:root {
  --series-1: #3987e5;
  --series-2: #d95926;
  --series-3: #199e70;
  --series-4: #c98500;
  --series-5: #d55181;
  --series-6: #008300;
  --series-7: #9085e9;
  --series-8: #e66767;
  --series-other: #6b6480;
}
:root[data-theme="light"] {
  --series-1: #2a78d6;
  --series-2: #eb6834;
  --series-3: #1baf7a;
  --series-4: #eda100;
  --series-5: #e87ba4;
  --series-6: #008300;
  --series-7: #4a3aa7;
  --series-8: #e34948;
  --series-other: #9a92b3;
}

.rbx-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  justify-content: space-between;
  margin-top: 16px;
}

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text);
  font-size: 0.84rem;
  font-weight: 600;
}
.chip:hover { border-color: var(--violet-soft); color: var(--text); }
.chip.active { border-color: var(--violet); background: var(--violet-glow); }
.chip img { width: 20px; height: 20px; border-radius: 5px; }
.chip .swatch { width: 10px; height: 10px; border-radius: 3px; flex-shrink: 0; }

.segmented {
  display: inline-flex;
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  background: var(--bg-card);
}
.segmented a {
  padding: 7px 12px;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-muted);
  border-right: 1px solid var(--border);
}
.segmented a:last-child { border-right: none; }
.segmented a.active { background: var(--violet-glow); color: var(--text); }

.rbx-section-title {
  margin: 34px 0 12px;
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 10px;
}
.rbx-section-title::after { content: ""; flex: 1; height: 1px; background: var(--border); }

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(165px, 1fr));
  gap: 12px;
}
.stat {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px 16px;
  min-width: 0;
}
.stat .label { font-size: 0.75rem; color: var(--text-muted); }
.stat .value {
  font-size: 1.45rem;
  font-weight: 700;
  margin-top: 4px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.stat .sub { font-size: 0.72rem; color: var(--text-muted); margin-top: 2px; }
.stat.hero { border-color: var(--gold); }
.stat.hero .value { color: var(--gold-soft); }
.live-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--success);
  margin-right: 6px;
  animation: pulse 2s ease-in-out infinite;
}

.chart-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 440px), 1fr));
  gap: 14px;
  margin-top: 14px;
}
.chart-card { padding: 18px; min-width: 0; }
.chart-card.wide { grid-column: 1 / -1; }
.chart-card h3 { margin: 0; font-size: 0.95rem; }
.chart-card .hint { margin: 2px 0 10px; font-size: 0.75rem; color: var(--text-muted); }
.chart-box { position: relative; height: 240px; }
.chart-card.wide .chart-box { height: 280px; }
.chart-empty {
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.85rem;
  border: 1px dashed var(--border);
  border-radius: 10px;
  padding: 16px;
}

.legend { display: flex; flex-wrap: wrap; gap: 12px; margin-bottom: 8px; font-size: 0.78rem; color: var(--text-muted); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }

.heatmap { display: grid; grid-template-columns: 30px repeat(24, minmax(0, 1fr)); gap: 2px; font-size: 0.66rem; color: var(--text-muted); }
.heatmap .cell { aspect-ratio: 1; border-radius: 3px; min-height: 8px; }
.heatmap .rowlabel { display: flex; align-items: center; }
.heatmap .collabel { white-space: nowrap; overflow: visible; }

.table-scroll { overflow-x: auto; }
.table-scroll table { margin-top: 6px; min-width: 360px; }
table.wide-table { min-width: 640px; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.game-cell { display: flex; align-items: center; gap: 10px; }
.game-cell img { width: 32px; height: 32px; border-radius: 8px; }

.callout {
  border: 1px solid var(--gold);
  border-radius: 12px;
  padding: 14px 16px;
  margin-top: 16px;
  font-size: 0.88rem;
  background: var(--bg-card);
}

.code-block {
  position: relative;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px;
  max-height: 260px;
  overflow: auto;
  font-family: "Cascadia Code", Consolas, monospace;
  font-size: 0.76rem;
  white-space: pre;
  color: var(--text);
}

@media (max-width: 600px) {
  .page { padding: 20px 16px 60px; }
  .stat .value { font-size: 1.2rem; }
  .nav-user span { display: none; }
}
