/*
 * Feuille de style unique, ecrite a la main.
 * Aucune dependance Node : le portail doit pouvoir etre deploye sur un serveur
 * qui n'a que PHP, et la page publique doit rester legere sur un reseau lent.
 */

:root {
  --bg: #f4f6f9;
  --surface: #ffffff;
  --surface-alt: #f8fafc;
  --border: #e2e8f0;
  --text: #16202e;
  --muted: #64748b;
  --accent: #1d6fd6;
  --accent-ink: #ffffff;
  --accent-soft: #e8f1fd;
  --ok: #12855a;
  --ok-soft: #e3f6ee;
  --warn: #b06d05;
  --warn-soft: #fdf3e1;
  --danger: #c02c34;
  --danger-soft: #fdeaea;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(15, 30, 55, .06), 0 4px 14px rgba(15, 30, 55, .05);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e141d;
    --surface: #161f2b;
    --surface-alt: #1c2735;
    --border: #2a3849;
    --text: #e6edf6;
    --muted: #93a4ba;
    --accent: #5aa2f5;
    --accent-ink: #08111c;
    --accent-soft: #14283f;
    --ok: #46d19b;
    --ok-soft: #102c22;
    --warn: #e0a23c;
    --warn-soft: #2e2413;
    --danger: #f2777f;
    --danger-soft: #331a1c;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 4px 14px rgba(0, 0, 0, .25);
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.55 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-text-size-adjust: 100%;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3 { line-height: 1.25; margin: 0 0 .4em; font-weight: 650; }
h1 { font-size: 1.5rem; }
h2 { font-size: 1.15rem; }
h3 { font-size: 1rem; }
p { margin: 0 0 1em; }

/* ---------- Structure : barre laterale + contenu ---------- */

.shell { display: flex; min-height: 100vh; }

.sidebar {
  width: 232px;
  flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 1.1rem .8rem;
  display: flex;
  flex-direction: column;
  gap: 1.2rem;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.brand {
  font-weight: 700;
  letter-spacing: -.02em;
  color: var(--text);
  font-size: 1.05rem;
  padding: 0 .5rem;
}
.brand:hover { text-decoration: none; }

.sidebar nav { display: flex; flex-direction: column; gap: 1.1rem; flex: 1; }

.nav-group { display: flex; flex-direction: column; gap: .1rem; }

.nav-heading {
  font-size: .7rem;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--muted);
  font-weight: 700;
  padding: 0 .5rem .3rem;
}

.sidebar nav a {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .5rem;
  padding: .44rem .5rem;
  border-radius: 7px;
  color: var(--muted);
  font-weight: 550;
  font-size: .91rem;
}
.sidebar nav a:hover { background: var(--surface-alt); color: var(--text); text-decoration: none; }
.sidebar nav a[aria-current="page"] { background: var(--accent-soft); color: var(--accent); }

.sidebar-foot {
  border-top: 1px solid var(--border);
  padding-top: .8rem;
  display: flex;
  flex-direction: column;
  gap: .55rem;
}

.page { flex: 1; min-width: 0; padding: 1.6rem 1.6rem 4rem; max-width: 1100px; }

.page-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 1.3rem;
}
.page-head p { color: var(--muted); margin: .2rem 0 0; font-size: .93rem; }

.crumb { font-size: .88rem; color: var(--muted); margin-bottom: .35rem; }

/* Le menu ne se replie qu'en dessous de 860px ; au-dela il reste visible. */
.menu-toggle { display: none; }

@media (max-width: 860px) {
  .shell { flex-direction: column; }

  .menu-toggle {
    display: block;
    padding: .7rem 1.1rem;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    font-weight: 600;
    color: var(--text);
    position: sticky;
    top: 0;
    z-index: 30;
  }
  .menu-toggle:hover { text-decoration: none; }

  .sidebar {
    width: auto;
    height: auto;
    position: static;
    border-right: 0;
    border-bottom: 1px solid var(--border);
    display: none;
  }
  .sidebar:target { display: flex; }

  .page { padding: 1.2rem 1.1rem 3rem; }
}

/* ---------- Cartes ---------- */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.1rem 1.2rem;
  margin-bottom: 1.1rem;
}
.card > :last-child { margin-bottom: 0; }
.card-title { display: flex; justify-content: space-between; align-items: center; gap: 1rem; margin-bottom: .9rem; flex-wrap: wrap; }

.grid { display: grid; gap: 1rem; }
.grid-stats { grid-template-columns: repeat(auto-fit, minmax(165px, 1fr)); }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }

.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: .9rem 1rem; }
.stat-label { color: var(--muted); font-size: .82rem; text-transform: uppercase; letter-spacing: .04em; }
.stat-value { font-size: 1.55rem; font-weight: 680; margin-top: .15rem; letter-spacing: -.02em; }
.stat-value small { font-size: .8rem; font-weight: 500; color: var(--muted); }

/* ---------- Tableaux ---------- */

.table-wrap { overflow-x: auto; margin: 0 -1.2rem; padding: 0 1.2rem; }

table { width: 100%; border-collapse: collapse; font-size: .93rem; }
th, td { text-align: left; padding: .6rem .7rem; border-bottom: 1px solid var(--border); vertical-align: middle; }
th { color: var(--muted); font-weight: 600; font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; white-space: nowrap; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: var(--surface-alt); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.mono { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; }

/* ---------- Formulaires ---------- */

.field { margin-bottom: .9rem; }
.field label { display: block; font-weight: 570; font-size: .88rem; margin-bottom: .28rem; }
.field .hint { color: var(--muted); font-size: .82rem; margin-top: .25rem; }

input[type=text], input[type=email], input[type=password], input[type=number], input[type=tel], select, textarea {
  width: 100%;
  padding: .55rem .7rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
}
input:focus, select:focus, textarea:focus {
  outline: 2px solid var(--accent);
  outline-offset: -1px;
  border-color: var(--accent);
}
textarea { min-height: 150px; resize: vertical; font-family: ui-monospace, Consolas, monospace; font-size: .88rem; }

.check { display: flex; align-items: center; gap: .5rem; font-size: .92rem; }
.check input { width: auto; }

.form-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 0 1rem; }
.form-actions { display: flex; gap: .5rem; flex-wrap: wrap; margin-top: 1rem; }

.error { color: var(--danger); font-size: .85rem; margin-top: .25rem; }

/* ---------- Boutons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  padding: .5rem .95rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-weight: 570;
  cursor: pointer;
  white-space: nowrap;
}
.btn:hover { background: var(--surface-alt); text-decoration: none; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { filter: brightness(1.08); background: var(--accent); }
.btn-danger { color: var(--danger); border-color: transparent; background: transparent; }
.btn-danger:hover { background: var(--danger-soft); }
.btn-sm { padding: .3rem .6rem; font-size: .85rem; }
.btn-block { width: 100%; justify-content: center; }

/* ---------- Signaux ---------- */

.badge {
  display: inline-block;
  padding: .16rem .5rem;
  border-radius: 999px;
  font-size: .77rem;
  font-weight: 620;
  white-space: nowrap;
}
.badge-ok { background: var(--ok-soft); color: var(--ok); }
.badge-warn { background: var(--warn-soft); color: var(--warn); }
.badge-danger { background: var(--danger-soft); color: var(--danger); }
.badge-muted { background: var(--surface-alt); color: var(--muted); }
.badge-accent { background: var(--accent-soft); color: var(--accent); }

.alert { padding: .75rem 1rem; border-radius: 8px; margin-bottom: 1rem; font-size: .92rem; border: 1px solid transparent; }
.alert-ok { background: var(--ok-soft); color: var(--ok); border-color: color-mix(in srgb, var(--ok) 25%, transparent); }
.alert-warn { background: var(--warn-soft); color: var(--warn); border-color: color-mix(in srgb, var(--warn) 25%, transparent); }
.alert-danger { background: var(--danger-soft); color: var(--danger); border-color: color-mix(in srgb, var(--danger) 25%, transparent); }

.empty { text-align: center; padding: 2.2rem 1rem; color: var(--muted); }
.muted { color: var(--muted); }
.small { font-size: .87rem; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }

/* ---------- Vitrine publique ---------- */

.public-shell { max-width: 560px; margin: 0 auto; padding: 1.5rem 1.1rem 3rem; }

.public-head { text-align: center; margin-bottom: 1.4rem; }
.public-head h1 { margin-bottom: .15rem; }
.public-head .muted { font-size: .93rem; }

.forfait-list { display: grid; gap: .6rem; margin-bottom: 1.2rem; }

.forfait {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  width: 100%;
  text-align: left;
  padding: .85rem 1rem;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  cursor: pointer;
}
.forfait:hover:not(:disabled) { border-color: var(--accent); }
.forfait[aria-pressed="true"] { border-color: var(--accent); background: var(--accent-soft); }
.forfait:disabled { opacity: .5; cursor: not-allowed; }
.forfait-name { font-weight: 620; }
.forfait-price { font-size: 1.12rem; font-weight: 700; letter-spacing: -.02em; white-space: nowrap; }

/* Le code livre : c'est l'unique information que le client vient chercher. */
.code-box {
  text-align: center;
  padding: 1.4rem 1rem;
  border: 2px dashed var(--ok);
  border-radius: var(--radius);
  background: var(--ok-soft);
  margin: 1rem 0;
}
.code-value {
  font-family: ui-monospace, "Cascadia Mono", Consolas, monospace;
  font-size: 1.9rem;
  font-weight: 700;
  letter-spacing: .06em;
  color: var(--ok);
  word-break: break-all;
}

.spinner {
  width: 34px; height: 34px;
  margin: 0 auto 1rem;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 850ms linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

@media (prefers-reduced-motion: reduce) {
  .spinner { animation-duration: 3s; }
}

/* ---------- Authentification ---------- */

.auth-shell { max-width: 400px; margin: 0 auto; padding: 3rem 1.1rem; }
.auth-shell .brand { display: block; text-align: center; font-size: 1.3rem; margin-bottom: 1.3rem; }

/* ---------- Pagination Livewire ---------- */

.pagination { display: flex; gap: .3rem; flex-wrap: wrap; align-items: center; margin-top: 1rem; font-size: .9rem; }
.pagination a, .pagination span { padding: .35rem .6rem; border-radius: 6px; border: 1px solid var(--border); }
.pagination a:hover { background: var(--surface-alt); text-decoration: none; }

/* Libelle reserve aux lecteurs d'ecran */
.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ---------- Graphiques ----------
   Rampe bleue mono-teinte issue du systeme de reference, verifiee au contraste
   contre les surfaces reelles de l'application (2:1 min pour un aplat, 3:1 pour
   la courbe). Les barres encodent la magnitude : plus fonce = plus vendu, ce
   qui double la longueur sans depenser le canal de l'identite. */

:root {
  --chart-line: #2a78d6;
  --chart-area: rgba(42, 120, 214, .14);
  --chart-grid: rgba(22, 32, 46, .10);
  --chart-1: #256abf;
  --chart-2: #2a78d6;
  --chart-3: #3987e5;
  --chart-4: #5598e7;
  --chart-5: #6da7ec;
}

@media (prefers-color-scheme: dark) {
  :root {
    --chart-line: #86b6ef;
    --chart-area: rgba(134, 182, 239, .16);
    --chart-grid: rgba(230, 237, 246, .12);
    --chart-1: #9ec5f4;
    --chart-2: #86b6ef;
    --chart-3: #6da7ec;
    --chart-4: #5598e7;
    --chart-5: #3987e5;
  }
}

.chart { margin-bottom: .3rem; }

.chart-svg { width: 100%; display: block; }

/* La courbe occupe une hauteur fixe : preserveAspectRatio="none" l'etire en
   largeur, il faut donc contraindre la hauteur en CSS. */
.chart .chart-svg { height: 170px; }

.chart-grid { stroke: var(--chart-grid); stroke-width: 1; }
.chart-area { fill: var(--chart-area); stroke: none; }
.chart-line { stroke: var(--chart-line); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }

/* Anneau de la couleur de surface : le point se detache meme sur l'aplat. */
.chart-dot { fill: var(--chart-line); stroke: var(--surface); stroke-width: 2; }

.chart-hit { cursor: crosshair; }
.chart-hit:hover { fill: var(--accent-soft); opacity: .35; }

.chart-bar-1 { fill: var(--chart-1); }
.chart-bar-2 { fill: var(--chart-2); }
.chart-bar-3 { fill: var(--chart-3); }
.chart-bar-4 { fill: var(--chart-4); }
.chart-bar-5 { fill: var(--chart-5); }
.chart-bar { transition: opacity .12s; }
.chart-bar:hover { opacity: .78; }

/* Les valeurs portent l'encre du texte, jamais la couleur de la serie. */
.chart-value { fill: var(--muted); font-size: 11px; font-weight: 600; font-family: inherit; }

.chart-axis {
  display: flex;
  justify-content: space-between;
  gap: .6rem;
  font-size: .78rem;
  color: var(--muted);
  margin-top: .3rem;
}
.chart-peak { color: var(--chart-line); font-weight: 600; }

@media (prefers-reduced-motion: reduce) {
  .chart-bar { transition: none; }
}
