/* ============================================================
   Plateforme bénévoles — design system
   Palette : indigo (primaire) + ambre (accent), thème clair.
   ============================================================ */

:root {
  --primary:       #4f46e5;
  --primary-dark:  #3c34c4;
  --primary-100:   #eef2ff;   /* fond teinté */
  --primary-200:   #e0e4fb;   /* piste des jauges (même gamme que le remplissage) */
  --accent:        #f59e0b;

  --ink:    #1c1c28;
  --ink-2:  #4f4f5e;
  --muted:  #75757f;

  --page:   #f5f5f9;
  --card:   #ffffff;
  --line:   #e4e4ec;
  --hairline: rgba(28, 28, 40, 0.08);

  /* Statuts (réservés : toujours icône/libellé + couleur, jamais couleur seule) */
  --good:         #0ca30c;
  --good-bg:      #e6f6e6;
  --good-ink:     #0a6b0a;
  --warn-bg:      #fdf3d7;
  --warn-ink:     #7a5b00;
  --critical:     #d03b3b;
  --critical-bg:  #fbe7e7;
  --critical-ink: #a32e2e;

  --radius:    14px;
  --radius-sm: 9px;
  --shadow: 0 1px 2px rgba(20, 20, 40, 0.05), 0 4px 18px rgba(20, 20, 40, 0.07);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.55;
  color: var(--ink);
  background: var(--page);
}

img { max-width: 100%; }

a { color: var(--primary); }
a:hover { color: var(--primary-dark); }

h1, h2, h3 { line-height: 1.25; }

.container {
  max-width: 1080px;
  margin: 0 auto;
  padding: 0 16px;
}

.main { padding-top: 24px; padding-bottom: 56px; min-height: 60vh; }

/* ---------------- En-tête du site ---------------- */

.site-header {
  background: var(--card);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 50;
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding-top: 10px;
  padding-bottom: 10px;
}

.brand {
  font-weight: 750;
  font-size: 1.06rem;
  text-decoration: none;
  color: var(--ink);
  white-space: nowrap;
}
.brand-mark { margin-right: 2px; }

.site-nav {
  display: flex;
  align-items: center;
  gap: 4px 14px;
  flex-wrap: wrap;
}
.site-nav a {
  text-decoration: none;
  color: var(--ink-2);
  font-weight: 550;
  font-size: 0.95rem;
  padding: 6px 2px;
}
.site-nav a:hover { color: var(--ink); }
.site-nav a.active { color: var(--primary); box-shadow: 0 2px 0 var(--primary); }
.site-nav a.nav-admin { color: var(--primary); font-weight: 650; }

.admin-topbar { background: #23233a; border-bottom-color: #23233a; }
.admin-topbar .brand,
.admin-topbar .site-nav a { color: #d6d6e8; }
.admin-topbar .site-nav a:hover { color: #ffffff; }
.admin-topbar .site-nav a.active { color: #ffffff; box-shadow: 0 2px 0 var(--accent); }
.admin-topbar .linklike { color: #d6d6e8; }

.inline-form { display: inline; }

.linklike {
  background: none;
  border: 0;
  padding: 6px 2px;
  font: inherit;
  font-weight: 550;
  font-size: 0.95rem;
  color: var(--ink-2);
  cursor: pointer;
}
.linklike:hover { color: var(--ink); text-decoration: underline; }

.pill {
  display: inline-block;
  min-width: 20px;
  padding: 1px 7px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 700;
  text-align: center;
  font-variant-numeric: tabular-nums;
}
.pill-alert { background: var(--accent); color: #3d2b00; }

/* ---------------- Pied de page ---------------- */

.site-footer {
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.9rem;
  padding: 20px 0 32px;
  background: var(--card);
}
.site-footer a { color: var(--muted); }

/* ---------------- Titres de page ---------------- */

.page-head { margin: 8px 0 20px; }
.page-head h1 { margin: 0 0 4px; font-size: 1.6rem; }
.page-head .subtitle { color: var(--ink-2); margin: 0; }
.page-head-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------------- Cartes et grilles ---------------- */

.card {
  background: var(--card);
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.card-pad { padding: 20px; }
.card + .card { margin-top: 16px; }

.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
@media (max-width: 800px) {
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
}

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

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  font: inherit;
  font-size: 0.95rem;
  font-weight: 650;
  text-decoration: none;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
  white-space: nowrap;
}
.btn:focus-visible { outline: 3px solid var(--primary-200); outline-offset: 1px; }

.btn-primary { background: var(--primary); color: #ffffff; }
.btn-primary:hover { background: var(--primary-dark); color: #ffffff; }

.btn-secondary {
  background: var(--card);
  color: var(--ink);
  border-color: var(--line);
}
.btn-secondary:hover { border-color: var(--muted); }

.btn-success { background: var(--good); color: #ffffff; }
.btn-success:hover { background: var(--good-ink); color: #ffffff; }

.btn-danger { background: var(--critical); color: #ffffff; }
.btn-danger:hover { background: var(--critical-ink); color: #ffffff; }

.btn-danger-outline {
  background: transparent;
  color: var(--critical-ink);
  border-color: var(--critical);
}
.btn-danger-outline:hover { background: var(--critical-bg); }

.btn-sm { padding: 5px 11px; font-size: 0.87rem; }
.btn-block { display: flex; width: 100%; }
.btn[disabled], .btn.disabled { opacity: 0.55; cursor: not-allowed; }

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

.badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 650;
  white-space: nowrap;
}
.badge-pending   { background: var(--warn-bg);     color: var(--warn-ink); }
.badge-confirmed { background: var(--good-bg);     color: var(--good-ink); }
.badge-declined  { background: var(--critical-bg); color: var(--critical-ink); }
.badge-cancelled { background: #ececf1;            color: var(--ink-2); }
.badge-free      { background: var(--primary-100); color: var(--primary-dark); }
.badge-full      { background: #ececf1;            color: var(--ink-2); }
.badge-draft     { background: #ececf1;            color: var(--ink-2); }
.badge-published { background: var(--good-bg);     color: var(--good-ink); }
.badge-archived  { background: #ececf1;            color: var(--muted); }
.badge-admin     { background: var(--primary-100); color: var(--primary-dark); }

/* ---------------- Jauge de remplissage (meter) ---------------- */

.meter {
  height: 8px;
  border-radius: 999px;
  background: var(--primary-200);   /* piste : pas clair de la même gamme */
  overflow: hidden;
  min-width: 70px;
}
.meter-fill {
  height: 100%;
  border-radius: 999px;
  background: var(--primary);
  transition: width 0.3s;
}
.meter-full .meter-fill { background: var(--good); } /* complet = équipe au complet */
.meter-count {
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  font-size: 0.92rem;
  white-space: nowrap;
}
.meter-count .of { color: var(--muted); font-weight: 500; }

/* ---------------- Tuiles de statistiques (dashboard) ---------------- */

.stat-tiles {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px;
  margin-bottom: 22px;
}
.stat-tile {
  background: var(--card);
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px 18px;
}
.stat-value {
  font-size: 2rem;
  font-weight: 750;
  line-height: 1.1;
  color: var(--ink);
}
.stat-label { color: var(--ink-2); font-size: 0.92rem; margin-top: 2px; }
.stat-hint  { color: var(--muted); font-size: 0.82rem; margin-top: 4px; }
.stat-tile-alert { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent), var(--shadow); }

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

.form-group { margin-bottom: 16px; }
.form-group label {
  display: block;
  font-weight: 650;
  font-size: 0.93rem;
  margin-bottom: 5px;
}
.help-text { color: var(--muted); font-size: 0.85rem; margin-top: 4px; }

input[type="text"], input[type="email"], input[type="password"],
input[type="tel"], input[type="date"], input[type="time"],
input[type="number"], select, textarea {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  font: inherit;
  font-size: 0.97rem;
  color: var(--ink);
  background: var(--card);
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-200);
}
input[type="color"] {
  width: 52px;
  height: 38px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--card);
  cursor: pointer;
}
textarea { min-height: 96px; resize: vertical; }

.form-row { display: flex; gap: 12px; flex-wrap: wrap; }
.form-row .form-group { flex: 1 1 160px; margin-bottom: 12px; }
.form-actions {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  margin-top: 18px;
}
.checkbox-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 500;
  cursor: pointer;
}
.checkbox-label input { width: auto; }

/* ---------------- Messages flash ---------------- */

.flash {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  margin-bottom: 14px;
  font-weight: 550;
  border: 1px solid transparent;
  transition: opacity 0.4s;
}
.flash-hide { opacity: 0; }
.flash-success { background: var(--good-bg);     color: var(--good-ink);     border-color: #bfe5bf; }
.flash-error   { background: var(--critical-bg); color: var(--critical-ink); border-color: #f0c4c4; }
.flash-info    { background: var(--primary-100); color: var(--primary-dark); border-color: var(--primary-200); }
.flash-close {
  background: none;
  border: 0;
  font-size: 1.2rem;
  line-height: 1;
  cursor: pointer;
  color: inherit;
  opacity: 0.6;
  padding: 0 2px;
}
.flash-close:hover { opacity: 1; }

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

.table-wrap { overflow-x: auto; }
.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.94rem;
  background: var(--card);
}
.table th, .table td {
  text-align: left;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}
.table th {
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  font-weight: 700;
}
.table tr:last-child td { border-bottom: 0; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }
.table-actions { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }

/* ---------------- Planning public ---------------- */

.event-hero { margin-bottom: 20px; }
.event-hero h1 { margin: 0 0 6px; font-size: 1.7rem; }
.event-meta {
  display: flex;
  gap: 6px 18px;
  flex-wrap: wrap;
  color: var(--ink-2);
  font-weight: 550;
}

.day-nav {
  position: sticky;
  top: 54px;
  z-index: 40;
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 10px 2px;
  margin: 0 0 16px;
  background: var(--page);
}
.day-nav a {
  flex-shrink: 0;
  padding: 6px 14px;
  border-radius: 999px;
  background: var(--card);
  border: 1px solid var(--line);
  text-decoration: none;
  color: var(--ink-2);
  font-weight: 650;
  font-size: 0.9rem;
}
.day-nav a:hover { border-color: var(--primary); color: var(--primary); }

.day-section { margin-bottom: 30px; scroll-margin-top: 110px; }
.day-title {
  font-size: 1.2rem;
  margin: 0 0 12px;
  text-transform: capitalize;
}

.activity-card { margin-bottom: 14px; overflow: hidden; }
.activity-head {
  display: flex;
  align-items: baseline;
  gap: 10px;
  flex-wrap: wrap;
  padding: 14px 18px 10px;
}
.activity-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  flex-shrink: 0;
  align-self: center;
}
.activity-name { font-weight: 750; font-size: 1.02rem; }
.activity-desc { color: var(--ink-2); font-size: 0.92rem; }
.activity-resp { color: var(--muted); font-size: 0.87rem; margin-left: auto; }
.activity-staffing {
  padding: 0 18px 10px;
  color: var(--ink-2);
  font-size: 0.92rem;
}

/* Admin : blocs de sous-activités dans la fiche événement */
.sub-block { border-top: 1px solid var(--line); }
.sub-head {
  display: flex;
  align-items: baseline;
  gap: 10px;
  flex-wrap: wrap;
  padding: 12px 18px 6px;
}
.sub-head-plain { border-top: 1px solid var(--line); }
.sub-name { font-weight: 700; font-size: 0.95rem; }
.sub-empty { padding: 0 18px 12px; margin: 0; }
.table tr.slot-row td {
  background: var(--primary-100);
  border-top: 1px solid var(--line);
}
.table .shift-indent { width: 26px; color: var(--muted); text-align: center; }

.shift-gauge { display: flex; align-items: center; gap: 10px; }
.shift-gauge .meter { flex: 0 1 160px; }

/* Grille de cartes de créneaux (sélection visuelle) */
.shift-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 12px;
  padding: 4px 18px 16px;
}
.shift-card {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 14px;
  border: 2px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--card);
  scroll-margin-top: 110px;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.shift-card.is-available { border-color: var(--primary-200); }
.shift-card.is-available:hover {
  border-color: var(--primary);
  box-shadow: 0 2px 10px rgba(79, 70, 229, 0.14);
}
.shift-card.is-mine {
  border-color: var(--primary);
  background: var(--primary-100);
}
.shift-card.is-full { background: #fafafc; }
.shift-card.is-past { opacity: 0.55; background: #fafafc; }
.shift-card-time { font-weight: 700; font-variant-numeric: tabular-nums; font-size: 1.05rem; }
.shift-card-note { display: block; font-weight: 500; font-size: 0.8rem; color: var(--muted); }
.shift-card-names { display: flex; gap: 6px; flex-wrap: wrap; }
.shift-card-foot { margin-top: auto; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding-top: 4px; }

/* Sous-activités (rôles) du planning public */
.subactivity-block { padding: 4px 18px 14px; }
.subactivity-head {
  display: flex;
  align-items: baseline;
  gap: 10px;
  flex-wrap: wrap;
  padding: 8px 0 8px;
}
.subactivity-name { font-weight: 700; font-size: 0.98rem; }
.subactivity-name::before { content: '◦ '; color: var(--muted); }

/* Cartes de créneau (plage globale) : une par ligne, avec frise horaire */
.slot-grid {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.slot-card {
  border: 2px solid var(--primary-200);
  border-radius: var(--radius-sm);
  background: var(--card);
  padding: 12px 14px;
  scroll-margin-top: 110px;
}
.slot-card.is-past { opacity: 0.55; background: #fafafc; border-color: var(--line); }
.slot-card-head {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  padding-bottom: 8px;
}
.slot-time { font-weight: 750; font-variant-numeric: tabular-nums; font-size: 1.05rem; }
.slot-card-head .meter { flex: 0 1 90px; min-width: 50px; }
.slot-notes { margin: 0 0 6px; font-size: 0.82rem; color: var(--muted); }

/* Frise horaire : les shifts sont positionnés proportionnellement au temps.
   Si le créneau compte beaucoup de shifts, la frise défile horizontalement
   (min-width posée en ligne : ~76 px par shift). */
.tl-scroll { overflow-x: auto; padding-bottom: 2px; }
.tl-track {
  position: relative;
  height: 60px;
  border-radius: var(--radius-sm);
  background:
    repeating-linear-gradient(90deg, transparent 0, transparent calc(100% / 12 - 1px), var(--line) calc(100% / 12 - 1px), var(--line) calc(100% / 12)),
    #f7f7fb;
}
.tl-seg {
  position: absolute;
  top: 3px;
  bottom: 3px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  padding: 2px 4px;
  border-radius: 8px;
  border: 2px solid transparent;
  overflow: hidden;
  text-align: center;
  cursor: pointer;
  transition: box-shadow 0.12s, background 0.12s;
}
.tl-seg-time {
  font-weight: 750;
  font-size: 0.85rem;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
}
.tl-seg-info {
  font-size: 0.74rem;
  font-weight: 550;
  white-space: nowrap;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
}
.tl-seg.is-available {
  background: var(--card);
  border-color: var(--primary);
  color: var(--primary-dark);
}
.tl-seg.is-available:hover { background: var(--primary-100); }
.tl-seg.is-available .tl-seg-info { color: var(--good-ink); }
.tl-seg.is-full {
  background: #ececf1;
  border-color: #dcdce4;
  color: var(--muted);
}
.tl-seg.is-mine {
  background: var(--primary);
  border-color: var(--primary-dark);
  color: #ffffff;
}
.tl-seg.is-past {
  background: #f1f1f5;
  border-color: transparent;
  color: var(--muted);
  opacity: 0.7;
}
.tl-seg.is-selected {
  box-shadow: 0 0 0 3px var(--accent);
  z-index: 2;
}

/* Panneaux de détail : radio caché + panneau juste après (pur CSS) */
.tl-panels { position: relative; }
.tl-radio {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
  pointer-events: none;
}
.tl-panel { display: none; }
.tl-radio:checked + .tl-panel { display: block; }
.tl-hint {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 0.85rem;
}
div.tl-panel {
  margin-top: 10px;
  padding: 12px 14px;
  background: var(--page);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  scroll-margin-top: 130px;
}
.tl-panel-head {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.tl-panel-head strong { font-size: 1.02rem; font-variant-numeric: tabular-nums; }
.tl-close {
  margin-left: auto;
  cursor: pointer;
  color: var(--muted);
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 6px;
}
.tl-close:hover { background: #ececf1; color: var(--ink); }
.tl-panel-chips { display: flex; gap: 6px; flex-wrap: wrap; margin: 8px 0; }
.tl-panel-action { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.signup-form-open { margin-top: 0; }

/* Puces avec le nom des personnes inscrites */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: #f0f0f6;
  border-radius: 999px;
  padding: 2px 10px;
  font-size: 0.84rem;
  font-weight: 550;
  color: var(--ink-2);
}
.chip-pending { background: var(--warn-bg); color: var(--warn-ink); }
.chip-me { background: var(--primary-100); color: var(--primary-dark); box-shadow: inset 0 0 0 1px var(--primary-200); }
.chip-free {
  background: transparent;
  border: 1px dashed #c4c4d2;
  color: var(--muted);
  font-weight: 500;
}

/* Boîte d'inscription repliable (bouton « S'inscrire ») */
.signup-box summary {
  list-style: none;
  cursor: pointer;
  display: inline-flex;
}
.signup-box summary::-webkit-details-marker { display: none; }
.signup-box[open] summary .btn { background: var(--primary-dark); }
.signup-form {
  margin-top: 10px;
  padding: 12px;
  background: var(--primary-100);
  border-radius: var(--radius-sm);
  max-width: 420px;
}
.signup-form .form-group { margin-bottom: 10px; }

/* Cartes d'événement (accueil) */
.event-card { display: flex; flex-direction: column; }
.event-card .card-pad { display: flex; flex-direction: column; gap: 10px; flex: 1; }
.event-card h2 { margin: 0; font-size: 1.18rem; }
.event-card .event-dates { color: var(--primary-dark); font-weight: 650; font-size: 0.93rem; }
.event-card .event-desc { color: var(--ink-2); font-size: 0.94rem; }
.event-card .event-foot { margin-top: auto; display: flex; flex-direction: column; gap: 10px; }

/* ---------------- Divers ---------------- */

.empty-state {
  text-align: center;
  color: var(--muted);
  padding: 46px 16px;
}
.empty-state .empty-icon { font-size: 2rem; display: block; margin-bottom: 8px; }

.auth-card { max-width: 430px; margin: 24px auto; }
.auth-card h1 { font-size: 1.4rem; margin-top: 0; }
.auth-alt { text-align: center; color: var(--ink-2); font-size: 0.93rem; margin-top: 14px; }

.text-muted { color: var(--muted); }
.text-small { font-size: 0.87rem; }
.mt-0 { margin-top: 0; }
.mb-0 { margin-bottom: 0; }

.section-title { font-size: 1.15rem; margin: 26px 0 12px; }

/* ---------------- Impression ---------------- */

@media print {
  .site-header, .site-footer, .day-nav, .shift-card-foot, .flash, .page-actions { display: none !important; }
  body { background: #ffffff; }
  .card { box-shadow: none; border-color: #cccccc; }
}
