/* ==========================================================================
   Group Valérian — Rendez-vous  ·  thème sombre
   1. Variables   2. Base   3. Mise en page   4. Composants
   5. Formulaires 6. Tableaux 7. Agenda public 8. Admin   9. Responsive
   ========================================================================== */

/* 1. Variables ------------------------------------------------------------ */
:root {
  color-scheme: dark;                 /* champs date/heure, barres de défilement */

  --blue: #2563eb;
  --blue-dark: #1d4fc4;
  --blue-light: #8db4ff;              /* texte / liens sur fond sombre */
  --blue-soft: rgba(59, 130, 246, .16);
  --red: #e2514a;

  --ink: #e6ebf7;
  --muted: #8d99b5;
  --line: #27334f;
  --bg: #0d1424;
  --surface: #121a2e;                 /* champs, survols */
  --card: #172036;
  --header: #14306e;

  --radius: 14px;
  --radius-sm: 8px;
  --shadow: 0 4px 18px rgba(0, 0, 0, .35);
}

/* 2. Base ----------------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }

body {
  min-height: 100vh;
  margin: 0;
  display: flex;
  flex-direction: column;
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--ink);
  background: var(--bg);
}

h1 { margin: .2em 0 .6em; font-size: 1.7rem; line-height: 1.25; }
h2 { margin: 1.4em 0 .6em; font-size: 1.1rem; }
a { color: var(--blue-light); }
code { padding: 2px 6px; border-radius: 6px; background: var(--surface); word-break: break-all; }

:focus-visible { outline: 2px solid var(--blue-light); outline-offset: 2px; }

.muted  { color: var(--muted); }
.small  { font-size: .82rem; }
.center { text-align: center; }
.hp     { position: absolute; left: -9999px; width: 1px; height: 1px; opacity: 0; } /* champ anti-robot */

/* 3. Mise en page --------------------------------------------------------- */
.top {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 24px;
  color: #fff;
  background: var(--header);
  border-bottom: 1px solid var(--line);
}
.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 1.2rem;
  font-weight: 700;
  color: #fff;
  text-decoration: none;
}
.brand img { border-radius: 50%; }

.top nav { display: flex; flex-wrap: wrap; gap: 6px; }
.top nav a {
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  color: #dfe7fb;
  text-decoration: none;
}
.top nav a:hover, .top nav a.on { color: #fff; background: rgba(255, 255, 255, .14); }

main { flex: 1; width: 100%; max-width: 1000px; margin: 0 auto; padding: 24px 16px; }
footer { padding: 18px; text-align: center; font-size: .85rem; color: var(--muted); }

.hero { padding: 10px 0 20px; text-align: center; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 16px; }

/* 4. Composants ----------------------------------------------------------- */
.card {
  margin: 0 0 20px;
  padding: 24px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.card.narrow { max-width: 460px; margin: 30px auto; }

.person {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  text-align: center;
  text-decoration: none;
  color: inherit;
  transition: transform .15s, border-color .15s;
}
.person:hover { transform: translateY(-3px); border-color: var(--blue); }

.avatar {
  display: grid;
  place-items: center;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  font-size: 1.6rem;
  font-weight: 700;
  color: #fff;
  background: var(--blue);
}

.btn {
  display: inline-block;
  padding: 10px 18px;
  border: 1px solid var(--blue);
  border-radius: var(--radius-sm);
  font: inherit;
  font-weight: 600;
  color: #fff;
  background: var(--blue);
  text-decoration: none;
  cursor: pointer;
  transition: background .15s;
}
.btn:hover { background: var(--blue-dark); border-color: var(--blue-dark); }
.btn.ghost { color: var(--blue-light); background: transparent; border-color: #3a4a70; }
.btn.ghost:hover { background: var(--blue-soft); border-color: var(--blue-light); }
.btn.danger { background: var(--red); border-color: var(--red); }
.btn.danger:hover { background: #c4423c; border-color: #c4423c; }
.btn.sm { padding: 5px 10px; font-size: .85rem; }

.alert { margin-bottom: 16px; padding: 12px 16px; border: 1px solid; border-radius: 10px; }
.alert.ok   { color: #b6f0cc; background: rgba(26, 159, 85, .16);  border-color: rgba(26, 159, 85, .5); }
.alert.err  { color: #ffc9c6; background: rgba(226, 81, 74, .16); border-color: rgba(226, 81, 74, .5); }
.alert.warn { color: #ffe9a6; background: rgba(236, 190, 60, .14); border-color: rgba(236, 190, 60, .45); }

.badge { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: .8rem; font-weight: 700; color: var(--ink); background: #2a3555; }
.badge.pending   { color: #ffd76a; background: rgba(236, 190, 60, .18); }
.badge.confirmed { color: #7be0a3; background: rgba(26, 159, 85, .2); }
.badge.refused,
.badge.cancelled { color: #ff9a95; background: rgba(226, 81, 74, .2); }

.steps { padding-left: 20px; color: var(--muted); }
.qr { display: flex; justify-content: center; margin: 12px 0; }
.qr svg { padding: 8px; background: #fff; border-radius: var(--radius-sm); }   /* le QR code doit rester clair pour être lu */

/* 5. Formulaires ---------------------------------------------------------- */
label { display: block; margin: 0 0 14px; font-size: .9rem; font-weight: 600; }

input, select, textarea {
  display: block;
  width: 100%;
  margin-top: 6px;
  padding: 10px 12px;
  font: inherit;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
}
input::placeholder, textarea::placeholder { color: #5d6a88; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--blue); border-color: transparent; }

.cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 0 14px; }

form.inline { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px; }
form.inline label { flex: 1 1 150px; margin: 0; }

/* 6. Tableaux ------------------------------------------------------------- */
.tablewrap { overflow-x: auto; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 10px 14px; text-align: left; vertical-align: top; border-bottom: 1px solid var(--line); }
th { font-size: .8rem; text-transform: uppercase; color: var(--muted); }
tr:last-child td { border-bottom: 0; }
tbody tr:hover td, tr:hover > td { background: rgba(255, 255, 255, .02); }
.actions form { display: flex; flex-wrap: wrap; gap: 6px; }

/* 7. Agenda public -------------------------------------------------------- */
.agenda { display: grid; grid-template-columns: 270px 1fr; gap: 20px; align-items: start; margin-bottom: 40px; }
#reservation { scroll-margin-top: 16px; }

/* mini calendrier */
.mini { margin: 0; padding: 16px; }
.minihead { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.minihead a { padding: 0 10px; border-radius: var(--radius-sm); font-size: 1.4rem; text-decoration: none; }
.minihead a:hover { background: var(--surface); }

.cal { display: grid; grid-template-columns: repeat(7, 1fr); gap: 3px; text-align: center; }
.cal .dow { font-size: .72rem; font-weight: 700; color: var(--muted); }
.cal .d {
  display: grid;
  place-items: center;
  aspect-ratio: 1;
  border-radius: 50%;
  font-size: .88rem;
  color: #4a5675;
  text-decoration: none;
}
.cal .d.free { font-weight: 700; color: var(--blue-light); background: var(--blue-soft); }
.cal .d.free:hover { background: rgba(59, 130, 246, .3); }
.cal .d.today { outline: 1px solid var(--blue-light); }
.cal .d.sel { color: #fff; background: var(--blue); }

/* semaine */
.weekcard { margin: 0; padding: 16px; }
.weekhead { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 14px; }
.week { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 8px; }

.wd { display: flex; flex-direction: column; gap: 6px; min-height: 120px; padding: 8px 6px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); }
.wd.sel { background: #1b2a4d; border-color: var(--blue); }
.wh { display: flex; flex-direction: column; text-align: center; font-size: .78rem; color: var(--muted); }
.wh b { font-size: 1.15rem; color: var(--ink); }

.slot {
  padding: 6px 0;
  border: 1px solid var(--blue);
  border-radius: var(--radius-sm);
  font-size: .88rem;
  font-weight: 600;
  text-align: center;
  color: var(--blue-light);
  text-decoration: none;
}
.slot:hover, .slot.on { color: #fff; background: var(--blue); }
.none { text-align: center; color: #3a4666; }

/* 8. Admin ---------------------------------------------------------------- */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 14px; margin-bottom: 18px; }
.stat { display: flex; flex-direction: column; padding: 14px 18px; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.stat b { font-size: 1.8rem; line-height: 1.1; color: var(--blue-light); }
.stat span { font-size: .85rem; color: var(--muted); }

.tabs { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.tab { padding: 7px 14px; border: 1px solid var(--line); border-radius: 999px; color: var(--ink); background: var(--card); text-decoration: none; }
.tab:hover { border-color: var(--blue); }
.tab.on { color: #fff; background: var(--blue); border-color: var(--blue); }

.filters { margin-bottom: 14px; }

/* 9. Responsive ----------------------------------------------------------- */
@media (max-width: 820px) {
  .agenda { grid-template-columns: 1fr; }
  .week { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 520px) {
  .top { padding: 10px 14px; }
  .card { padding: 18px; }
  h1 { font-size: 1.4rem; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}

/* 10. Cases à cocher des jours + aperçu hebdomadaire ------------------------ */
.days { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.days label { margin: 0; }
.days input { position: absolute; width: 1px; height: 1px; margin: 0; opacity: 0; }
.days span {
  display: inline-block;
  min-width: 96px;
  padding: 8px 12px;
  border: 1px solid var(--blue);
  border-radius: var(--radius-sm);
  font-weight: 600;
  text-align: center;
  color: var(--blue-light);
  cursor: pointer;
}
.days span:hover { background: var(--blue-soft); }
.days input:checked + span { color: #fff; background: var(--blue); }
.days input:focus-visible + span { outline: 2px solid var(--blue-light); outline-offset: 2px; }

.weektable th, .weektable td { padding: 3px 6px; text-align: center; }
.weektable td.t { width: 56px; text-align: right; font-size: .75rem; color: var(--muted); }
.weektable td.cell { height: 20px; border-left: 1px solid var(--line); }
.weektable td.cell.on { background: rgba(37, 99, 235, .45); }
.weektable td.cell.off { background: rgba(226, 81, 74, .6); }
