/* ============================================================
   MAIN.CSS — Système de design global — Athleon
   ============================================================ */

/* ── Design tokens ────────────────────────────────────────── */
:root {
  /* Fonds */
  --bg:    #0b0d0f;
  --card:  #15181c;
  --card2: #1a1e24;

  /* Bordures */
  --line:          rgba(255,255,255,.07);
  --border:        rgba(255,255,255,.07);
  --border-strong: rgba(255,255,255,.15);

  /* Typographie */
  --text:  #f3f4f6;
  --muted: #9aa3af;

  /* Couleurs d'action */
  --accent:  #10b981;   /* vert — action principale */
  --accent2: #0ea5e9;   /* bleu — action secondaire */
  --danger:  #ef4444;   /* rouge */
  --amber:   #f59e0b;   /* orange */
  --purple:  #a78bfa;   /* violet */

  /* Ombres & effets */
  --shadow:    0 8px 28px rgba(0,0,0,.35);
  --shadow-sm: 0 2px 10px rgba(0,0,0,.25);
  --ring:      0 0 0 3px rgba(16,185,129,.3);

  /* Radius */
  --radius-sm: 8px;
  --radius:    12px;
  --radius-lg: 16px;
  --radius-xl: 20px;

  /* Espacements */
  --sp-1: .25rem; --sp-2: .5rem; --sp-3: .75rem;
  --sp-4: 1rem;   --sp-5: 1.25rem; --sp-6: 1.5rem;
}

/* ── Reset ────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
html { overflow-x: hidden; }

body {
  margin: 0;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  font-family: Inter, system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

img, svg, video, canvas, audio, iframe { display: block; max-width: 100%; }
* { word-break: break-word; overflow-wrap: break-word; }
input, select, textarea { min-width: 0; max-width: 100%; }
pre, code { overflow-x: auto; max-width: 100%; }

@media (max-width: 540px) {
  input[type="text"], input[type="search"], input[type="email"],
  input[type="number"], input[type="url"], select, textarea {
    min-width: 0 !important; width: 100%;
  }
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
:focus-visible { outline: none; box-shadow: var(--ring); border-radius: var(--radius-sm); }

/* ── Layout ───────────────────────────────────────────────── */
.container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 1rem;
}

main {
  flex: 1 0 auto;
  margin: 2rem auto;
  padding: 0 1rem;
  width: 100%;
  max-width: 1100px;
}
@media (max-width: 600px) { main { margin: 1rem auto; padding: 0 .75rem; } }

/* ── Typographie utilitaire ───────────────────────────────── */
.h1 { font-size: clamp(1.8rem,4vw,3rem); font-weight: 900; letter-spacing: -.02em; }
.h2 { font-size: clamp(1.4rem,3vw,2rem); font-weight: 800; }
.h3 { font-size: 1.25rem; font-weight: 700; }
.text-muted { color: var(--muted); }
.muted      { color: var(--muted); }

/* ── Cartes ───────────────────────────────────────────────── */
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 1rem;
  box-shadow: var(--shadow-sm);
}
.card--subtle { background: var(--card2); }
.card--title {
  position: relative; overflow: hidden;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
}
.card--title .card-title {
  background: linear-gradient(135deg, #0b1f17 0%, #0f1825 100%);
  padding: .9rem 1rem;
  font-weight: 800;
  border-bottom: 1px solid var(--line);
}
.card--title .card-body { padding: 1rem; }

/* ── Boutons ──────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: .5rem;
  padding: .6rem 1rem;
  border-radius: var(--radius);
  border: 1px solid transparent;
  font-size: .875rem;
  font-weight: 600;
  cursor: pointer;
  line-height: 1;
  text-decoration: none;
  transition: filter .15s, background .15s, transform .08s;
  white-space: nowrap;
}
.btn:hover { text-decoration: none; }
.btn:active { transform: translateY(1px); }

/* Primaire */
.btn,
.btn-primary {
  background: var(--accent);
  color: #052014;
  border-color: transparent;
}
.btn:hover,
.btn-primary:hover { filter: brightness(1.08); }

/* Ghost */
.btn-ghost,
.btn--ghost {
  background: rgba(255,255,255,.04);
  border: 1px solid var(--line);
  color: var(--text);
}
.btn-ghost:hover,
.btn--ghost:hover { background: rgba(255,255,255,.08); }

/* Danger */
.btn-danger {
  background: rgba(239,68,68,.12);
  border: 1px solid rgba(239,68,68,.25);
  color: #fca5a5;
}
.btn-danger:hover { background: rgba(239,68,68,.2); }

/* Success */
.btn--success {
  background: var(--accent);
  color: #052014;
}

/* Accent2 (bleu) */
.btn--accent2 {
  background: var(--accent2);
  color: #fff;
}
.btn--accent2:hover { filter: brightness(1.08); }

/* ── Formulaires ──────────────────────────────────────────── */
input[type="text"], input[type="email"], input[type="password"],
input[type="number"], input[type="url"], input[type="search"],
input[type="date"], textarea, select {
  width: 100%;
  padding: .6rem .75rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: rgba(255,255,255,.04);
  color: var(--text);
  font-family: inherit;
  font-size: .9rem;
  transition: border-color .15s;
}
input::placeholder, textarea::placeholder { color: var(--muted); opacity: .7; }
input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--accent);
  background: rgba(16,185,129,.04);
  box-shadow: var(--ring);
}
label {
  display: block;
  font-size: .82rem;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .04em;
  margin-bottom: .3rem;
}
select option { background: var(--card2); color: var(--text); }

/* ── Tables ───────────────────────────────────────────────── */
.table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border-radius: var(--radius-lg);
}
.table {
  width: 100%;
  border-collapse: collapse;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  overflow: hidden;
}
.table th, .table td { padding: .75rem 1rem; border-bottom: 1px solid var(--line); }
.table th {
  text-align: left;
  color: var(--muted);
  background: rgba(255,255,255,.025);
  font-size: .75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .05em;
}
.table tr:last-child td { border-bottom: none; }
.table tr:hover td { background: rgba(255,255,255,.025); }
@media (max-width: 600px) {
  .table th, .table td { padding: .55rem .65rem; font-size: .85rem; }
}

/* ── Chips / badges ───────────────────────────────────────── */
.chip, .badge {
  display: inline-flex;
  align-items: center;
  gap: .25rem;
  padding: .2em .65em;
  border-radius: 99px;
  font-size: .75rem;
  font-weight: 600;
  background: rgba(255,255,255,.07);
  color: var(--muted);
  white-space: nowrap;
}
.chip-green, .badge-green   { background: rgba(16,185,129,.15); color: #6ee7b7; }
.chip-blue,  .badge-blue    { background: rgba(14,165,233,.15);  color: #7dd3fc; }
.chip-amber, .badge-amber   { background: rgba(245,158,11,.15);  color: #fcd34d; }
.chip-red,   .badge-red     { background: rgba(239,68,68,.15);   color: #fca5a5; }
.chip-purple,.badge-purple  { background: rgba(167,139,250,.15); color: #c4b5fd; }

/* Status pills */
.status-pill { display: inline-flex; align-items: center; padding: .2em .65em; border-radius: 99px; font-size: .73rem; font-weight: 600; }
.status-published { background: rgba(16,185,129,.15); color: #34d399; }
.status-draft     { background: rgba(155,155,155,.1);  color: #9ca3af; }
.status-active    { background: rgba(14,165,233,.15);  color: #7dd3fc; }

/* ── Alertes ──────────────────────────────────────────────── */
.alert {
  padding: .75rem 1rem;
  border-radius: var(--radius);
  font-size: .88rem;
  margin-bottom: 1rem;
  border: 1px solid;
}
.alert-ok,
.alert-success { background: rgba(16,185,129,.08); border-color: rgba(16,185,129,.25); color: #6ee7b7; }
.alert-err,
.alert-error   { background: rgba(239,68,68,.08);  border-color: rgba(239,68,68,.2);   color: #fca5a5; }
.alert-warning { background: rgba(245,158,11,.08); border-color: rgba(245,158,11,.2);  color: #fcd34d; }
.alert-info    { background: rgba(14,165,233,.08); border-color: rgba(14,165,233,.2);  color: #7dd3fc; }

/* ── Hero ─────────────────────────────────────────────────── */
.hero {
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
  padding: clamp(1.5rem,4vw,2.5rem);
  background:
    radial-gradient(1100px 400px at 5% -10%, rgba(16,185,129,.15), transparent 60%),
    radial-gradient(900px 400px  at 95% 120%, rgba(14,165,233,.1), transparent 60%),
    linear-gradient(180deg, #0f1317 0%, var(--bg) 100%);
  box-shadow: var(--shadow-sm);
}
.hero .lead { color: var(--muted); }

/* ── Grilles ──────────────────────────────────────────────── */
.grid   { display: grid; gap: var(--sp-4); }
.grid-2 { grid-template-columns: repeat(2, minmax(0,1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0,1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0,1fr)); }
@media (max-width: 900px) {
  .grid-2 { grid-template-columns: 1fr; }
  .grid-3, .grid-4 { grid-template-columns: repeat(2, minmax(0,1fr)); }
}
@media (max-width: 540px) {
  .grid-3, .grid-4 { grid-template-columns: 1fr; }
}

/* Form grille (admin) */
.fg { display: flex; flex-direction: column; gap: .35rem; }

/* ── Stats ────────────────────────────────────────────────── */
.stat {
  display: flex;
  align-items: center;
  gap: .6rem;
  padding: .6rem .75rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255,255,255,.025);
}
.stat .n   { font-size: 1.35rem; font-weight: 900; }
.stat .lbl { color: var(--muted); font-size: .9rem; }

/* ── Accordion ────────────────────────────────────────────── */
.accordion {
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: var(--card);
}
.accordion__item + .accordion__item { border-top: 1px solid var(--line); }
.accordion__btn {
  width: 100%; text-align: left; padding: .9rem 1rem;
  background: transparent; color: var(--text);
  border: none; cursor: pointer; font-weight: 700; font-size: .95rem;
}
.accordion__btn:hover { background: rgba(255,255,255,.03); }
.accordion__panel {
  padding: .75rem 1rem 1rem;
  color: var(--muted);
  border-top: 1px solid var(--line);
  line-height: 1.65;
}

/* ── Card list (recettes, plans) ──────────────────────────── */
.card-list { display: grid; gap: var(--sp-3); }
.card-list .item {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  transition: border-color .15s, transform .15s;
}
.card-list .item:hover { border-color: rgba(16,185,129,.3); transform: translateY(-1px); }
.card-list .thumb { aspect-ratio: 16/9; background: #0d1017; }
.card-list .meta  { padding: .65rem .8rem; }
.card-list .title { font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card-list .sub   { color: var(--muted); font-size: .9rem; margin-top: .15rem; }

/* ── Utilitaires ──────────────────────────────────────────── */
.flex            { display: flex; }
.items-center    { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: var(--sp-2); }
.gap-3 { gap: var(--sp-3); }
.gap-4 { gap: var(--sp-4); }
.hide  { display: none !important; }
.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; }

/* ── Avatar ───────────────────────────────────────────────── */
.avatar-img {
  width: 28px; height: 28px;
  border-radius: 50%;
  object-fit: cover;
  display: inline-block;
}

/* ── Cookie banner ────────────────────────────────────────── */
@media (max-width: 960px) {
  #cookieBanner { bottom: calc(60px + env(safe-area-inset-bottom)) !important; }
}

/* ── Nav mobile (drawer backdrop) ────────────────────────── */
.nav-mobile, .nav-backdrop { display: none; }
@media (max-width: 900px) {
  .nav-mobile {
    position: fixed; top: 0; right: 0;
    width: 260px; height: 100vh;
    background: var(--card2);
    border-left: 1px solid var(--line);
    box-shadow: -4px 0 20px rgba(0,0,0,.5);
    display: flex; flex-direction: column;
    padding: 1.2rem; gap: .75rem;
    transform: translateX(100%);
    transition: transform .3s ease;
    z-index: 1001;
  }
  .nav-mobile.open { transform: translateX(0); }
  .nav-mobile a { color: var(--text); text-decoration: none; font-weight: 600; padding: .4rem 0; }
  .nav-mobile a:hover { color: var(--accent); }
  .nav-mobile .section {
    margin-top: .8rem; margin-bottom: .3rem;
    font-size: .8rem; color: var(--muted);
    text-transform: uppercase; letter-spacing: .05em;
  }
  .nav-backdrop {
    position: fixed; inset: 0;
    background: rgba(0,0,0,.6); backdrop-filter: blur(2px);
    display: none; z-index: 1000;
  }
  .nav-backdrop.show { display: block; }
}

/* ── Footer ───────────────────────────────────────────────── */
.app-footer {
  background: var(--card);
  border-top: 1px solid var(--line);
  color: var(--text);
  margin-top: 3rem;
  flex-shrink: 0;
}
.footer-accent-line {
  height: 2px;
  background: linear-gradient(90deg, transparent 0%, var(--accent) 40%, var(--accent) 60%, transparent 100%);
  opacity: .3;
}
.footer-inner {
  max-width: 1200px; margin: 0 auto;
  padding: 2rem 1.5rem 1.25rem;
  display: flex; align-items: center;
  justify-content: space-between; gap: 2rem;
}
@media (max-width: 700px) {
  .footer-inner { flex-direction: column; align-items: flex-start; gap: 1.25rem; padding: 1.75rem 1.25rem 1rem; }
  .footer-legal { align-items: flex-start; }
}
.footer-brand-link { display: inline-block; margin-bottom: .5rem; }
.footer-logo { height: 38px; width: auto; display: block; opacity: .9; transition: .15s; }
.footer-brand-link:hover .footer-logo { opacity: 1; }
.footer-tagline { color: var(--muted); font-size: .82rem; line-height: 1.5; margin: 0; }
.footer-legal { display: flex; flex-direction: column; gap: .35rem; align-items: flex-end; }
.footer-legal a { color: var(--muted); text-decoration: none; font-size: .82rem; transition: color .15s; }
.footer-legal a:hover { color: var(--text); }
.footer-bottom {
  max-width: 1200px; margin: 0 auto; padding: .9rem 1.5rem;
  border-top: 1px solid var(--line);
  font-size: .82rem; color: var(--muted);
  display: flex; align-items: center; justify-content: center;
}

/* ── Light mode ───────────────────────────────────────────── */
html.light-mode {
  --bg:    #f0f4f8;
  --card:  #ffffff;
  --card2: #f1f5f9;
  --line:          rgba(0,0,0,.08);
  --border:        rgba(0,0,0,.08);
  --border-strong: rgba(0,0,0,.18);
  --text:  #0f172a;
  --muted: #64748b;
  --accent:  #059669;
  --accent2: #0284c7;
  --danger:  #dc2626;
  --shadow:    0 4px 20px rgba(0,0,0,.08);
  --shadow-sm: 0 1px 6px rgba(0,0,0,.06);
  --ring:      0 0 0 3px rgba(5,150,105,.25);
}
html.light-mode body   { background: #f0f4f8; color: #0f172a; }
html.light-mode a      { color: #059669; }

/* Cards */
html.light-mode .card        { background: #fff; border-color: rgba(0,0,0,.08); }
html.light-mode .card--title .card-title { background: linear-gradient(135deg,#ecfdf5,#eff6ff); color: #0f172a; }
html.light-mode .card--subtle { background: #f1f5f9; }

/* Buttons */
html.light-mode .btn-ghost,
html.light-mode .btn--ghost  { background: rgba(0,0,0,.04); color: #0f172a; border-color: rgba(0,0,0,.1); }
html.light-mode .btn-ghost:hover,
html.light-mode .btn--ghost:hover { background: rgba(0,0,0,.08); }

/* Forms */
html.light-mode input[type="text"], html.light-mode input[type="email"],
html.light-mode input[type="password"], html.light-mode input[type="number"],
html.light-mode input[type="url"], html.light-mode input[type="search"],
html.light-mode input[type="date"], html.light-mode textarea, html.light-mode select {
  background: #fff; color: #0f172a; border-color: rgba(0,0,0,.12);
}
html.light-mode input:focus, html.light-mode textarea:focus, html.light-mode select:focus {
  border-color: #059669; background: rgba(5,150,105,.03);
}
html.light-mode label { color: #475569; }
html.light-mode select option { background: #fff; color: #0f172a; }

/* Tables */
html.light-mode .table  { background: #fff; border-color: rgba(0,0,0,.08); }
html.light-mode .table th { background: #f8fafc; color: #64748b; border-bottom-color: rgba(0,0,0,.08); }
html.light-mode .table td { border-bottom-color: rgba(0,0,0,.06); }
html.light-mode .table tr:hover td { background: rgba(0,0,0,.02); }

/* Badges */
html.light-mode .chip, html.light-mode .badge { background: rgba(0,0,0,.06); color: #475569; }

/* Alerts */
html.light-mode .alert-ok,
html.light-mode .alert-success { background: #f0fdf4; border-color: #bbf7d0; color: #14532d; }
html.light-mode .alert-err,
html.light-mode .alert-error   { background: #fef2f2; border-color: #fecaca; color: #7f1d1d; }

/* Hero */
html.light-mode .hero {
  background:
    radial-gradient(1100px 400px at 5% -10%, rgba(5,150,105,.08), transparent 60%),
    radial-gradient(900px 400px at 95% 120%, rgba(2,132,199,.06), transparent 60%),
    linear-gradient(180deg, #e8edf3 0%, #f0f4f8 100%);
  border-color: rgba(0,0,0,.08);
}
html.light-mode .hero .lead { color: #64748b; }
html.light-mode .hero h1, html.light-mode .hero h2 { color: #0f172a; }

/* Accordion */
html.light-mode .accordion { background: #f8fafc; border-color: rgba(0,0,0,.08); }
html.light-mode .accordion__btn { color: #0f172a; }
html.light-mode .accordion__panel { color: #475569; border-color: rgba(0,0,0,.06); }

/* Footer */
html.light-mode .app-footer { background: #e8edf3; border-top-color: rgba(0,0,0,.07); }
html.light-mode .footer-tagline, html.light-mode .footer-legal a { color: #94a3b8; }
html.light-mode .footer-legal a:hover { color: #475569; }
html.light-mode .footer-bottom { color: #94a3b8; border-top-color: rgba(0,0,0,.06); }

/* Nav mobile */
html.light-mode .nav-mobile { background: #fff; border-left-color: rgba(0,0,0,.08); }
html.light-mode .nav-mobile a { color: #0f172a; }
html.light-mode .nav-mobile a:hover { color: #059669; }
html.light-mode .nav-mobile .section { color: #64748b; }

/* Stat */
html.light-mode .stat { background: #fff; border-color: rgba(0,0,0,.08); }
