/* Alliance Points — thème « precision dashboard ».
   Fond neutre proche du noir, accent doré (valeur/récompense — cohérent
   avec un outil qui sert à calculer des paiements), violet en accent
   secondaire pour la hiérarchie des rôles. UI/UX pro max. */

@import url('https://fonts.googleapis.com/css2?family=Manrope:wght@400;500;600;700;800&family=JetBrains+Mono:wght@400;500;600;700&display=swap');

:root {
  --bg:         #09090b;
  --panel:      #111113;
  --card:       #17171a;
  --card-2:     #1f1f23;
  --card-hover: #232327;
  --input:      #0c0c0e;
  --border:     #2a2a2f;
  --border-sub: #1c1c1f;
  --border-strong: #3a3a41;

  --text:       #f2f0ec;
  --muted:      #9c968b;
  --faint:      #6a655d;

  /* Accent principal : or (valeur, récompense, paiement) */
  --accent:      #e2ac47;
  --accent-h:    #c99327;
  --accent-ink:  #1c1404;
  --accent-soft: rgba(226,172,71,.14);
  --accent-bd:   rgba(226,172,71,.35);

  /* Accent secondaire : violet (statut technique, rôles) */
  --violet:      #a68cf7;
  --violet-soft: rgba(166,140,247,.14);
  --violet-bd:   rgba(166,140,247,.35);

  /* Sémantique */
  --success:    #46c469;
  --success-bg: rgba(70,196,105,.14);
  --danger:     #e5584f;
  --danger-h:   #c8443c;
  --danger-bg:  rgba(229,88,79,.14);
  --danger-bd:  rgba(229,88,79,.35);

  --def: #e57a52;
  --atk: #52a4f5;

  --r-sm: 8px; --r-md: 12px; --r-lg: 16px; --r-xl: 20px;
  --sp-1: 4px; --sp-2: 8px; --sp-3: 12px; --sp-4: 16px; --sp-5: 24px; --sp-6: 32px;
  --shadow-sm: 0 1px 2px rgba(0,0,0,.4);
  --shadow: 0 12px 32px -8px rgba(0,0,0,.55);
  --font: "Manrope", "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
  --mono: "JetBrains Mono", "Cascadia Mono", Consolas, ui-monospace, monospace;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background:
    radial-gradient(900px 480px at 85% -8%, rgba(226,172,71,.07), transparent 60%),
    radial-gradient(700px 420px at -5% 15%, rgba(166,140,247,.05), transparent 55%),
    var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
h1, h2, h3 { margin: 0; font-weight: 800; letter-spacing: -.02em; text-wrap: balance; }
p { margin: 0; }
button { font-family: inherit; }
[hidden] { display: none !important; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.tabnum { font-variant-numeric: tabular-nums; font-family: var(--mono); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
::selection { background: var(--accent-soft); color: var(--text); }

.skip-link { position: absolute; left: 8px; top: -48px; z-index: 100;
  background: var(--accent); color: var(--accent-ink); font-weight: 700;
  font-size: 13.5px; padding: 10px 16px; border-radius: var(--r-sm);
  transition: top .15s ease; }
.skip-link:focus { top: 8px; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important; animation-iteration-count: 1 !important;
    transition-duration: .001ms !important; scroll-behavior: auto !important;
  }
}

/* ---- Marque --------------------------------------------------------- */
.logo { width: 44px; height: 44px; flex: none; display: block; }
.topbar-brand .logo { width: 28px; height: 28px; }
.credit { font-size: 12px; color: var(--faint); margin-top: 2px; }
.tb-name { display: flex; flex-direction: column; line-height: 1.15; }
.tb-name strong { font-size: 14.5px; letter-spacing: -.01em; }
.tb-name .credit { margin-top: 0; font-size: 10.5px; }
.brand { display: flex; gap: var(--sp-3); align-items: center; margin-bottom: var(--sp-5); }
.brand h1 { font-size: 21px; }

/* ---- Boutons ---------------------------------------------------------- */
.btn {
  --b: var(--card); --bh: var(--card-hover); --ink: var(--text); --bd: var(--border);
  appearance: none; border: 1px solid var(--bd);
  background: var(--b); color: var(--ink);
  padding: 9px 16px; border-radius: var(--r-sm); min-height: 44px;
  font-weight: 700; font-size: 13.5px; letter-spacing: -.005em; cursor: pointer;
  transition: background .15s ease, border-color .15s ease, transform .05s ease, box-shadow .15s ease;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; white-space: nowrap;
  touch-action: manipulation;
}
.btn:hover { background: var(--bh); border-color: var(--border-strong); }
.btn:active { transform: translateY(1px); }
.btn-primary { --b: var(--accent); --bh: var(--accent-h); --ink: var(--accent-ink); --bd: transparent; }
.btn-primary:hover { box-shadow: 0 0 0 3px var(--accent-soft); }
.btn-danger  { --b: var(--danger); --bh: var(--danger-h); --ink: #fff; --bd: transparent; }
.btn-ghost   { background: transparent; --bd: transparent; color: var(--muted); }
.btn-ghost:hover { background: var(--card); color: var(--text); }
.btn-block { width: 100%; }
.btn-icon { padding: 8px 10px; line-height: 1; min-width: 44px; }
.btn-sm { padding: 6px 11px; font-size: 12.5px; min-height: 38px; }

/* ---- Champs ------------------------------------------------------- */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: var(--sp-4); }
.field > span { font-size: 12.5px; color: var(--muted); font-weight: 700; text-transform: uppercase; letter-spacing: .03em; }
input, select {
  appearance: none; background: var(--input); color: var(--text);
  border: 1px solid var(--border); border-radius: var(--r-sm);
  padding: 10px 12px; font-size: 14px; font-family: inherit; width: 100%;
  min-height: 44px; transition: border-color .15s ease, box-shadow .15s ease;
  touch-action: manipulation;
}
input[type="checkbox"] { min-height: 0; width: auto; }
input::placeholder { color: var(--faint); }
input:focus, select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
select { background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 18px) 50%, calc(100% - 13px) 50%; background-size: 5px 5px, 5px 5px; background-repeat: no-repeat; padding-right: 34px;
  cursor: pointer; }
.erreur { color: #ffb4ac; background: var(--danger-bg); border: 1px solid var(--danger-bd);
  border-radius: var(--r-sm); padding: 9px 12px; font-size: 13px; margin: 0 0 var(--sp-4); }

/* ---- Connexion ---------------------------------------------------- */
.login-wrap { min-height: 100dvh; display: grid; place-items: center; padding: var(--sp-4); }
.login-card { width: 100%; max-width: 386px; background: var(--panel);
  border: 1px solid var(--border-sub); border-radius: var(--r-xl); padding: var(--sp-6); box-shadow: var(--shadow); }

/* ---- Barre supérieure -------------------------------------------- */
.topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: var(--sp-4);
  padding: 11px 22px; background: rgba(17,17,19,.86); backdrop-filter: blur(10px) saturate(1.2);
  border-bottom: 1px solid var(--border-sub); }
.topbar-brand { display: flex; align-items: center; gap: 10px; }
.nav { display: flex; align-items: center; gap: 2px; flex: 1; overflow-x: auto; }
.nav button { border: 0; background: transparent; color: var(--muted); padding: 8px 14px;
  border-radius: var(--r-sm); font-weight: 700; font-size: 13.5px; cursor: pointer; white-space: nowrap;
  display: inline-flex; align-items: center; gap: 7px;
  transition: background .15s ease, color .15s ease; position: relative; }
.nav button:hover { color: var(--text); background: var(--card); }
.nav button.actif { color: var(--accent-ink); background: var(--accent); }
.nav-icone { display: inline-flex; flex: none; width: 15px; height: 15px; opacity: .85; }
.nav-icone svg { width: 100%; height: 100%; display: block; }
.nav button.actif .nav-icone { opacity: 1; }
/* Sépare visuellement les 3 familles d'onglets (consultation / configuration
   / administration) : plus facile à balayer du regard que 7 boutons identiques. */
.nav-separateur { width: 1px; align-self: stretch; margin: 7px 6px; background: var(--border-sub); flex: none; }
.topbar-user { display: flex; align-items: center; gap: 10px; }
.user-nom { font-weight: 700; font-size: 13.5px; }
.badge { font-size: 10.5px; font-weight: 800; text-transform: uppercase; letter-spacing: .05em;
  padding: 3px 9px; border-radius: 999px; background: var(--card-2); color: var(--muted); border: 1px solid var(--border); }
.badge.superadmin { background: var(--accent-soft); color: var(--accent); border-color: var(--accent-bd); }
.badge.admin { background: var(--violet-soft); color: var(--violet); border-color: var(--violet-bd); }

.menu { position: relative; }
.menu-pop { position: absolute; right: 0; top: calc(100% + 8px); background: var(--card);
  border: 1px solid var(--border); border-radius: var(--r-md); padding: 6px; min-width: 224px; box-shadow: var(--shadow); }
.menu-item { display: block; width: 100%; text-align: left; background: transparent; border: 0; color: var(--text);
  padding: 9px 10px; border-radius: var(--r-sm); font-size: 13.5px; font-weight: 600; cursor: pointer; }
.menu-item:hover { background: var(--card-2); }
.menu-item.danger { color: #ff9d94; }

/* ---- Vue / cartes ------------------------------------------------- */
.vue { max-width: 1160px; margin: 0 auto; padding: var(--sp-5) 22px var(--sp-6); }
.vue-tete { margin-bottom: var(--sp-5); }
.vue-tete h2 { font-size: 23px; }
.vue-tete p { color: var(--muted); font-size: 13.5px; margin-top: 5px; max-width: 62ch; }
.card { background: var(--card); border: 1px solid var(--border-sub); border-radius: var(--r-lg); }
.card-pad { padding: var(--sp-4); }
.card + .card { margin-top: var(--sp-4); }
.card-titre { font-size: 14.5px; font-weight: 800; padding: var(--sp-4) var(--sp-4) 0; letter-spacing: -.01em; }
.card-sous { font-size: 12.5px; color: var(--faint); padding: 3px var(--sp-4) 0; }

.grille { display: grid; gap: var(--sp-4); }
.filtres { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: var(--sp-3); align-items: end; }
.filtres .field { margin: 0; }

/* ---- Barre de filtres du classement (toolbar) ---------------------- */
.toolbar { background: var(--card); border: 1px solid var(--border-sub); border-radius: var(--r-lg);
  padding: var(--sp-4); margin-bottom: var(--sp-4); display: flex; flex-direction: column; gap: var(--sp-3); }
.toolbar-row { display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-3); }
.toolbar-row + .toolbar-row { padding-top: var(--sp-3); border-top: 1px solid var(--border-sub); }
.toolbar-label { font-size: 11px; font-weight: 800; text-transform: uppercase; letter-spacing: .06em;
  color: var(--faint); flex: none; }

.segment { display: inline-flex; background: var(--input); border: 1px solid var(--border);
  border-radius: var(--r-sm); padding: 3px; gap: 2px; }
.segment-btn { appearance: none; border: 0; background: transparent; color: var(--muted);
  font-family: inherit; font-weight: 700; font-size: 13px; padding: 7px 13px; border-radius: 6px;
  min-height: 38px; cursor: pointer; white-space: nowrap; touch-action: manipulation;
  transition: background .15s ease, color .15s ease; }
.segment-btn:hover { color: var(--text); }
.segment-btn.actif { background: var(--accent); color: var(--accent-ink); }
.segment-btn.actif.type-def { background: var(--def); color: #1a0a03; }
.segment-btn.actif.type-atk { background: var(--atk); color: #04101c; }

.daterange { display: inline-flex; align-items: center; gap: 8px; background: var(--input);
  border: 1px solid var(--border); border-radius: var(--r-sm); padding: 4px 8px; }
.daterange input[type="date"] { border: 0; background: transparent; width: 138px; padding: 5px 2px; }
.daterange input[type="date"]:focus { box-shadow: none; }
.daterange-sep { color: var(--faint); font-size: 13px; }

.select-inline { display: inline-flex; align-items: center; gap: 8px; }
.select-inline > span { font-size: 12.5px; font-weight: 700; color: var(--muted); white-space: nowrap; }
.select-inline select { width: auto; min-width: 168px; }

.search-box { position: relative; flex: 1 1 200px; min-width: 180px; }
.search-box svg { position: absolute; left: 11px; top: 50%; transform: translateY(-50%);
  width: 15px; height: 15px; color: var(--faint); pointer-events: none; }
.search-box input { padding-left: 34px; }

.input-compact { width: 108px; }

/* Résumé de la période sélectionnée (utile pour les paiements) */
.resume-periode { display: flex; flex-wrap: wrap; gap: var(--sp-5); align-items: baseline;
  background: var(--card); border: 1px solid var(--border-sub); border-radius: var(--r-lg);
  padding: var(--sp-4); margin-bottom: var(--sp-4); }
.resume-item .valeur { font-family: var(--mono); font-size: 22px; font-weight: 700; color: var(--text);
  font-variant-numeric: tabular-nums; }
.resume-item .libelle { font-size: 11.5px; color: var(--faint); text-transform: uppercase; letter-spacing: .05em; margin-top: 2px; }
.resume-item.accent .valeur { color: var(--accent); }

/* ---- Tableaux ----------------------------------------------------- */
.scroll-x { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
thead th { text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .05em;
  color: var(--faint); font-weight: 800; padding: 12px 14px; border-bottom: 1px solid var(--border-sub); white-space: nowrap; }
tbody td { padding: 12px 14px; border-bottom: 1px solid var(--border-sub); }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: rgba(255,255,255,.025); }
.col-num { text-align: center; font-variant-numeric: tabular-nums; font-family: var(--mono); }
.rang { width: 54px; text-align: center; color: var(--muted); font-weight: 700; font-family: var(--mono); }
.podium-1 .rang, .podium-2 .rang, .podium-3 .rang { color: var(--accent); font-size: 16px; }
.pts { font-weight: 700; font-variant-numeric: tabular-nums; font-family: var(--mono); }
.type-def { color: var(--def); } .type-atk { color: var(--atk); }
.type-tempo { color: var(--violet); }
.vide { padding: var(--sp-6); text-align: center; color: var(--muted); font-size: 13.5px; }

.tag { display: inline-block; font-size: 11.5px; font-weight: 700; padding: 2px 9px; border-radius: 999px;
  background: var(--card-2); color: var(--muted); border: 1px solid var(--border); }

/* Tableau combats : une colonne par type */
.combats-table thead th { text-align: center; }
.combats-table thead th:first-child, .combats-table tbody td:first-child { text-align: left; position: sticky; left: 0; background: var(--card); }
.combats-table .ligne-principale td { font-weight: 700; }

/* Barème matriciel (alliés × ennemis) */
.matrice { border-collapse: separate; border-spacing: 0; }
.matrice thead th { text-align: center; white-space: nowrap; color: var(--muted); font-size: 11px; padding: 8px 10px; }
.matrice thead th:first-child { text-align: left; font-size: 10.5px; }
.matrice tbody th { text-align: left; white-space: nowrap; color: var(--text); font-weight: 700; padding-right: 14px; font-size: 13px; }
.matrice td { padding: 4px; text-align: center; }
.matrice input.mx { width: 64px; text-align: center; padding: 7px 4px; font-variant-numeric: tabular-nums; font-family: var(--mono); }

/* Périodes de paie : cartes-liste */
.periode-carte { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3);
  background: var(--card-2); border: 1px solid var(--border); border-radius: var(--r-md);
  padding: 13px 16px; }
.periode-carte + .periode-carte { margin-top: 8px; }
.periode-carte .nom { font-weight: 700; font-size: 14px; }
.periode-carte .dates { font-size: 12.5px; color: var(--muted); font-family: var(--mono); margin-top: 2px; }

/* ---- Modale / toast ---------------------------------------------- */
.modale { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: var(--sp-4); }
.modale-fond { position: absolute; inset: 0; background: rgba(5,5,6,.65); backdrop-filter: blur(3px); }
.modale-boite { position: relative; width: 100%; max-width: 460px; background: var(--panel);
  border: 1px solid var(--border); border-radius: var(--r-lg); box-shadow: var(--shadow); }
.modale-tete { display: flex; align-items: center; justify-content: space-between; padding: var(--sp-4) var(--sp-4) 0; }
.modale-tete h2 { font-size: 16.5px; }
.modale-corps { padding: var(--sp-4); }
/* Reste dans le DOM en permanence (jamais [hidden]) : un aria-live doit déjà
   être présent dans l'arbre d'accessibilité pour que son contenu soit
   annoncé de façon fiable par un lecteur d'écran. */
.toast { position: fixed; left: 50%; bottom: 26px; transform: translateX(-50%) translateY(8px);
  z-index: 60; background: var(--card); border: 1px solid var(--border); color: var(--text);
  padding: 12px 18px; border-radius: var(--r-md); box-shadow: var(--shadow); font-size: 13.5px; font-weight: 600;
  opacity: 0; visibility: hidden; pointer-events: none; max-width: calc(100vw - 32px);
  transition: opacity .2s ease, transform .2s ease, visibility 0s linear .2s; }
.toast.visible { opacity: 1; visibility: visible; transform: translateX(-50%) translateY(0);
  transition: opacity .2s ease, transform .2s ease; }
.toast.ok { border-color: var(--accent-bd); }
.toast.ko { border-color: var(--danger-bd); }

.ligne-actions { display: flex; gap: var(--sp-2); flex-wrap: wrap; align-items: center; }
.entre { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3); flex-wrap: wrap; }

@media (max-width: 640px) {
  .vue { padding: var(--sp-4) 14px var(--sp-5); }
  .login-card { padding: var(--sp-5) var(--sp-4); }

  .topbar { flex-wrap: wrap; padding: 10px 14px; }
  .nav { order: 3; width: 100%; }
  .nav button { padding: 10px 14px; min-height: 44px; }
  .user-nom { display: none; }

  /* Empêche le zoom automatique iOS au focus d'un champ (nécessite >=16px). */
  input, select { font-size: 16px; }

  /* La barre de filtres du classement s'empile : chaque contrôle en pleine
     largeur plutôt que côte à côte, illisible sur un petit écran. */
  .toolbar-row { flex-direction: column; align-items: stretch; gap: var(--sp-2); }
  .segment { width: 100%; }
  .segment-btn { flex: 1; text-align: center; }
  .daterange { width: 100%; }
  .daterange input[type="date"] { width: auto; flex: 1; min-width: 0; }
  .select-inline { width: 100%; }
  .select-inline select { width: 100%; min-width: 0; }
  .search-box { width: 100%; min-width: 0; }
  .input-compact { width: 100%; }

  .filtres { grid-template-columns: 1fr; }

  .resume-periode { display: grid; grid-template-columns: 1fr 1fr; gap: var(--sp-4); }

  .periode-carte { flex-direction: column; align-items: stretch; gap: var(--sp-3); }
  .periode-carte .ligne-actions { justify-content: flex-end; }

  /* Les tableaux à colonnes fixes (matrice, combats) défilent horizontalement
     dans leur propre conteneur : on réduit juste le remplissage des cellules
     pour limiter le défilement nécessaire. */
  thead th, tbody td { padding: 10px 12px; }

  /* Le classement (le « ladder ») devient une pile de cartes plutôt qu'un
     tableau à faire défiler horizontalement : chaque joueur = une carte,
     avec le libellé de chaque valeur affiché devant elle. */
  .table-classement thead { position: absolute; width: 1px; height: 1px;
    overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; }
  .table-classement, .table-classement tbody { display: block; width: 100%; }
  .table-classement tr { display: flex; flex-wrap: wrap; align-items: center;
    gap: 3px 14px; padding: 13px 14px; border-bottom: 1px solid var(--border-sub); }
  .table-classement tr:last-child { border-bottom: 0; }
  .table-classement td { display: inline-flex; align-items: baseline; gap: 6px;
    padding: 0; border: 0; }
  .table-classement td::before { content: attr(data-label); font-size: 10.5px;
    font-weight: 800; text-transform: uppercase; letter-spacing: .04em; color: var(--faint); }
  /* Rang + Joueur forment l'en-tête de la carte, en pleine largeur. */
  .table-classement td.rang { order: 1; padding: 0; font-size: 16px; }
  .table-classement td.rang::before { content: ""; }
  .table-classement td[data-label="Joueur"] { order: 2; flex: 1 1 auto; min-width: 0;
    font-weight: 700; font-size: 15px; }
  .table-classement td[data-label="Joueur"]::before { content: ""; }
  .table-classement td.pts { order: 3; }
  .table-classement td[data-label="Combats"] { order: 4; }
  .table-classement td[data-label="Récoltes"] { order: 5; }
}

@media (max-width: 380px) {
  .resume-periode { grid-template-columns: 1fr; }
}
