/* ============================================================
   STYLE.CSS — Styles de l'application Café Perché Bénévolat
   Mobile-first : on pense d'abord au petit écran

   Palette officielle Café Perché :
     --vert-vif  : #43b104  (actions, boutons primaires)
     --brun-fort : #4c352f  (en-tête, titres forts)
     --brun-beige: #926347  (accents secondaires, retour)
     --blanc     : #ffffff
   ============================================================ */

/* --- Variables de couleurs --- */
:root {
  --vert-vif:        #43b104;
  --vert-light:      #edf7e0;
  --vert-mid:        #c5e89a;
  --vert-dark:       #2a5c08;
  --brun-fort:       #4c352f;
  --brun-light:      #f5ede9;
  --brun-mid:        #d4c4bc;
  --brun-beige:      #926347;
  --brun-beige-light:#f7efe8;
  --fond:            #f5f0eb;
  --texte:           #2a1e1a;
  --texte-doux:      #7a6058;
  --blanc:           #ffffff;
  --surface:         #ffffff; /* fond des cartes et inputs — séparé de --blanc */
  --inscrit-bg:      #dcfce7; /* fond carte "déjà inscrit" */
  --slot-bg:         #f0fdf8; /* fond des sous-cartes de tranche (inner) */
}

/* --- Réinitialisation de base --- */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

/* --- Corps de la page --- */
html, body {
  height: 100%;
  overflow: hidden; /* le scroll se fait dans .container, pas dans la page */
}

body {
  font-family: system-ui, -apple-system, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  color: var(--texte);
  background: var(--fond);
}

/* --- Conteneur principal centré --- */
.container {
  max-width: 480px;
  margin: 0 auto;
  padding: 1rem;
  height: 100%;
  overflow-y: auto;   /* c'est lui qui scrolle sur mobile */
  overflow-x: hidden; /* empêche le scroll horizontal parasite */
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

/* --- En-tête de l'app --- */
.app-header {
  display: flex;
  align-items: center;
  background: var(--brun-fort);
  color: var(--blanc);
  margin: -1rem -1rem 0;
  padding: 0.9rem 1rem;
}

/* Flèche retour (← gauche) */
.header-back {
  background: none;
  border: none;
  color: var(--blanc);
  font-size: 1.5rem;
  cursor: pointer;
  padding: 0.2rem 0.4rem;
  line-height: 1;
  visibility: hidden; /* affiché par JS selon l'écran */
  flex-shrink: 0;
  width: 2.5rem;
}

/* Nom cliquable (centre) */
.header-nom {
  flex: 1;
  background: none;
  border: none;
  color: var(--blanc);
  font-size: 1.15rem;
  font-weight: 600;
  cursor: pointer;
  text-align: center;
  padding: 0;
  font-family: inherit;
}

/* Espace vide (droite) pour centrer le nom */
.header-spacer {
  width: 2.5rem;
  flex-shrink: 0;
}

/* --- Écrans (chaque étape du parcours) --- */
.screen {
  display: none; /* caché par défaut */
  flex-direction: column;
  gap: 1rem;
  flex: 1;
}

.screen.active {
  display: flex; /* visible quand actif */
}

/* --- Titre d'écran --- */
.screen-title {
  font-size: 1.2rem;
  font-weight: 600;
  color: var(--brun-fort);
}

.screen-sub {
  font-size: 0.9rem;
  color: var(--texte-doux);
  margin-top: -0.5rem;
}

/* --- Champs de formulaire --- */
.field {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.field label {
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--brun-fort);
}

.field input {
  border: 1.5px solid var(--brun-mid);
  border-radius: 10px;
  padding: 0.75rem 1rem;
  font-size: 1rem;
  background: var(--surface);
  width: 100%;
  transition: border-color 0.2s;
  color: var(--texte);
}

.field input:focus {
  outline: none;
  border-color: var(--vert-vif);
}

/* Empêche les inputs date/time de déborder sur iOS */
input[type="date"],
input[type="time"] {
  -webkit-appearance: none;
  appearance: none;
  max-width: 100%;
  min-width: 0;
}

.field .hint {
  font-size: 0.8rem;
  color: var(--texte-doux);
}

.field .optional {
  font-size: 0.75rem;
  color: #aaa;
  font-weight: 400;
}

/* --- Grille de récurrence --- */
.recur-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
}

.recur-opt {
  border: 1.5px solid var(--brun-mid);
  border-radius: 10px;
  padding: 0.6rem 0.8rem;
  font-size: 0.85rem;
  color: #555;
  text-align: center;
  cursor: pointer;
  background: var(--surface);
  transition: border-color 0.2s, background 0.2s;
}

.recur-opt:hover {
  border-color: var(--vert-vif);
}

.recur-opt.selected {
  border-color: var(--vert-vif);
  background: var(--vert-light);
  color: var(--vert-dark);
  font-weight: 500;
}

/* --- Groupe de choix radio personnalisés --- */
.radio-group {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.radio-option {
  border: 1.5px solid var(--brun-mid);
  border-radius: 12px;
  padding: 0.75rem 1rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  cursor: pointer;
  background: var(--surface);
  transition: border-color 0.2s, background 0.2s;
}

.radio-option:hover {
  border-color: var(--vert-vif);
}

.radio-option.selected {
  border-color: var(--vert-vif);
  background: var(--vert-light);
}

.radio-option input[type="radio"] {
  accent-color: var(--vert-vif);
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

.radio-option .option-text strong {
  display: block;
  font-size: 0.95rem;
  color: var(--texte);
}

.radio-option .option-text span {
  font-size: 0.8rem;
  color: var(--texte-doux);
}

/* --- Cartes de choix d'action --- */
.choice-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.choice-card {
  border: 1.5px solid var(--brun-mid);
  border-radius: 14px;
  padding: 1rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  cursor: pointer;
  background: var(--surface);
  transition: border-color 0.2s, background 0.2s;
  text-align: left;
  width: 100%;
}

.choice-card:hover {
  border-color: var(--vert-vif);
  background: var(--vert-light);
}

.choice-icon {
  width: 42px;
  height: 42px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.3rem;
  flex-shrink: 0;
}

.choice-card .choice-text strong {
  display: block;
  font-size: 0.95rem;
  color: var(--texte);
}

.choice-card .choice-text span {
  font-size: 0.8rem;
  color: var(--texte-doux);
}

/* --- Cartes de catégorie de service --- */
.category-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.category-card {
  border: 1.5px solid var(--brun-mid);
  border-radius: 14px;
  padding: 1rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  cursor: pointer;
  background: var(--surface);
  transition: border-color 0.2s;
  text-align: left;
  width: 100%;
}

.category-card:hover {
  border-color: var(--vert-vif);
  background: var(--vert-light);
}

.category-card .cat-info strong {
  display: block;
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--texte);
}

.category-card .cat-info span {
  font-size: 0.8rem;
  color: var(--texte-doux);
}

.category-card .arrow {
  margin-left: auto;
  color: var(--brun-mid);
  font-size: 1.2rem;
}

/* --- Cartes de créneau --- */
.creneau-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.creneau-card {
  border: 1.5px solid var(--brun-mid);
  border-radius: 14px;
  padding: 1rem;
  background: var(--surface);
}

.creneau-card .creneau-date {
  font-size: 0.8rem;
  color: var(--texte-doux);
  margin-bottom: 0.2rem;
}

.creneau-card .creneau-nom {
  font-size: 1rem;
  font-weight: 600;
  color: var(--texte);
}

.creneau-card .creneau-places {
  font-size: 0.85rem;
  color: var(--vert-dark);
  margin-top: 0.3rem;
}

.creneau-card .creneau-places.complet {
  color: #c0392b;
}

.creneau-card .creneau-referent {
  font-size: 0.8rem;
  color: var(--brun-beige);
  margin-top: 0.2rem;
}

/* --- Boutons --- */
.btn {
  border-radius: 12px;
  padding: 0.85rem 1.25rem;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  width: 100%;
  text-align: center;
  transition: opacity 0.2s, transform 0.1s;
}

.btn:active {
  transform: scale(0.98);
}

.btn-primary {
  background: var(--vert-vif);
  color: var(--blanc);
}

.btn-primary:hover {
  opacity: 0.9;
}

.btn-secondary {
  background: var(--surface);
  color: var(--brun-fort);
  border: 1.5px solid var(--brun-mid);
}

.btn-secondary:hover {
  background: var(--brun-light);
}

.btn-outline-green {
  background: transparent;
  color: var(--vert-vif);
  border: 1.5px solid var(--vert-vif);
  padding: 0.6rem 1rem;
  font-size: 0.9rem;
  width: auto;
}

.btn-outline-red {
  background: #fff5f5;
  color: #c0392b;
  border: 1.5px solid #f0a0a0;
  padding: 0.6rem 1rem;
  font-size: 0.9rem;
  width: auto;
}

.btn-calendar {
  background: var(--brun-light);
  color: var(--brun-fort);
  border: 1.5px solid var(--brun-mid);
  font-size: 0.9rem;
}

/* --- Lien retour --- */

/* --- Écran de confirmation --- */
.confirm-icon {
  width: 64px;
  height: 64px;
  background: var(--vert-light);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  margin: 0.5rem auto;
}

.confirm-box {
  background: var(--brun-light);
  border-radius: 12px;
  padding: 1rem;
}

.confirm-box .confirm-row {
  margin-bottom: 0.5rem;
}

.confirm-box .confirm-label {
  font-size: 0.8rem;
  color: var(--texte-doux);
}

.confirm-box .confirm-value {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--texte);
}

.sms-note {
  font-size: 0.8rem;
  color: #aaa;
  text-align: center;
}

/* --- Badges --- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.75rem;
  padding: 0.2rem 0.6rem;
  border-radius: 8px;
  font-weight: 500;
}

.badge-green  { background: var(--vert-light);       color: var(--vert-dark); }
.badge-purple { background: #eeecff;                 color: #4a3aaa; }
.badge-amber  { background: var(--brun-beige-light); color: #5a3318; }

/* --- Pastilles de filtre (vue chronologique) --- */
.filtres-chrono {
  display: flex;
  flex-wrap: wrap;              /* passe à la ligne sur petit écran */
  gap: 0.4rem;
  margin: 0.75rem 0 0.9rem;
}
.filtre-chip {
  font-size: 0.8rem;
  font-weight: 500;
  line-height: 1.2;
  padding: 0.35rem 0.75rem;
  border-radius: 999px;
  border: 1.5px solid var(--brun-mid);
  background: var(--surface);
  color: var(--texte-doux);
  cursor: pointer;
}
.filtre-chip:active { transform: scale(0.97); }
.filtre-chip.active {
  background: var(--vert-vif);
  border-color: var(--vert-vif);
  color: #fff;
}
[data-theme="bw"] .filtre-chip.active {
  background: #000;
  border-color: #000;
  color: #fff;
}

/* --- Sélecteur de semaine (vue chronologique) --- */
.chrono-semaine-select { display: flex; align-items: center; gap: 0.5rem; margin: 0 0 0.5rem; }
.chrono-semaine-select label { font-size: 0.85rem; color: var(--texte-doux); font-weight: 500; }
.chrono-semaine-select select {
  flex: 1; min-width: 0;
  font-size: 0.9rem; font-family: inherit; color: var(--texte);
  background: var(--surface); border: 1.5px solid var(--brun-mid);
  border-radius: 10px; padding: 0.45rem 0.6rem;
}

/* --- En-têtes de semaine (collant) et de jour --- */
.chrono-semaine {
  position: sticky; top: 0; z-index: 2;
  background: var(--fond);
  font-size: 0.8rem; font-weight: 700; color: var(--texte);
  text-transform: uppercase; letter-spacing: 0.03em;
  padding: 0.5rem 0.15rem 0.35rem;
  border-bottom: 2px solid var(--brun-mid);
}
.chrono-jour {
  font-size: 0.9rem; font-weight: 600; color: var(--texte);
  padding: 0.1rem 0.15rem 0;
  margin-top: 0.15rem;
}


/* --- Message d'erreur --- */
.error-msg {
  font-size: 0.85rem;
  color: #c0392b;
  padding: 0.6rem 0.8rem;
  background: #fff5f5;
  border-radius: 8px;
  border: 1px solid #f0a0a0;
}

/* --- Spacer flexible (pousse le bas vers le bas) --- */
.spacer { flex: 1; }

/* --- Spinner de chargement --- */
.loading {
  text-align: center;
  color: var(--texte-doux);
  font-size: 0.9rem;
  padding: 1rem;
}

/* ================================================================
   MODE NUIT
   Actif automatiquement si le téléphone est en mode sombre,
   ou si l'utilisateur clique sur le bouton 🌙/☀️.
   ================================================================ */

[data-theme="dark"] {
  --inscrit-bg:      #162808;
  --slot-bg:         #1e1614;
  --surface:         #251a16;
  --vert-light:      #162808;
  --vert-dark:       #a8e070;
  --brun-light:      #2d2018;
  --brun-mid:        #4a3530;
  --brun-beige:      #c4956a;
  --brun-beige-light:#2a1e1a;
  --fond:            #1a1210;
  --texte:           #f0ebe8;
  --texte-doux:      #9a7868;
  color-scheme: dark; /* contrôles natifs du navigateur en sombre */
}

/* En-tête */
[data-theme="dark"] .app-header {
  background: #2d1e18;
}

/* Titres et labels — passent en beige clair */
[data-theme="dark"] .screen-title {
  color: #d4b8a8;
}
[data-theme="dark"] .field label {
  color: #d4b8a8;
}

/* Bouton secondaire */
[data-theme="dark"] .btn-secondary {
  color: #d4b8a8;
}

/* Recur-opt — texte qui était en gris fixe */
[data-theme="dark"] .recur-opt {
  color: var(--texte-doux);
}

/* Cartes de confirmation */
[data-theme="dark"] .confirm-box {
  background: #2d2018;
}
[data-theme="dark"] .confirm-box .confirm-label {
  color: var(--texte-doux);
}
[data-theme="dark"] .confirm-box .confirm-value {
  color: var(--texte);
}

/* Badges */
[data-theme="dark"] .badge-green  { background: #162808;  color: var(--vert-dark); }
[data-theme="dark"] .badge-purple { background: #1a1830;  color: #9b8fe8; }
[data-theme="dark"] .badge-amber  { background: #2a1e1a;  color: #c4956a; }

/* Messages d'erreur */
[data-theme="dark"] .error-msg {
  background: #2a1010;
  border-color: #6a2020;
  color: #f08080;
}

/* Bouton calendrier */
[data-theme="dark"] .btn-calendar {
  background: #2d2018;
  color: #d4b8a8;
  border-color: #4a3530;
}

/* Séparateur "tu n'apparais pas" */
[data-theme="dark"] .separateur-creation {
  border-top-color: #3a2820;
}
[data-theme="dark"] .separateur-creation p {
  color: #6a5048;
}

/* Bouton créer profil (classe ajoutée dans le HTML) */
[data-theme="dark"] .btn-creer-profil {
  background: #162808 !important;
  border-color: #2d4a1a !important;
  color: #a8e070 !important;
}

/* Champ prénom (écran modifier profil) */
[data-theme="dark"] .mp-prenom-display {
  border-color: #3a2820 !important;
  background: #1e1410 !important;
  color: #9a7868 !important;
}

/* Bouton supprimer compte */
[data-theme="dark"] .btn-supprimer-compte {
  background: #2a1010 !important;
  color: #f08080 !important;
  border-color: #6a2020 !important;
}

/* Bouton inviter */
[data-theme="dark"] .btn-inviter {
  background: #0f1a2a !important;
  color: #7eb8f5 !important;
  border-color: #2a4a6a !important;
}

/* Texte secondaire inline */
[data-theme="dark"] .screen p,
[data-theme="dark"] .screen-sub {
  color: var(--texte-doux);
}

/* Bouton toggle mode nuit (pied de page discret) */
[data-theme="dark"] #btn-dark-toggle {
  color: #5a4840;
}

/* ================================================================
   MODE NOIR & BLANC
   Objectif : économie d'écran OLED (fond noir = pixels éteints)
   et réduction de la fatigue visuelle (pas de couleurs vives).
   Texte à #d0d0d0 plutôt que blanc pur : moins de contraste agressif.
   ================================================================ */

[data-theme="bw"] {
  --inscrit-bg:      #0a1a0a;
  --slot-bg:         #080808;
  --surface:         #0d0d0d;
  --vert-vif:        #cccccc;   /* vert → gris clair */
  --vert-light:      #1a1a1a;
  --vert-dark:       #d0d0d0;
  --brun-fort:       #d0d0d0;
  --brun-light:      #111111;
  --brun-mid:        #2a2a2a;
  --brun-beige:      #888888;
  --brun-beige-light:#111111;
  --fond:            #000000;   /* noir pur = pixels OLED éteints */
  --texte:           #d0d0d0;   /* blanc légèrement atténué */
  --texte-doux:      #666666;
  color-scheme: dark;
}

[data-theme="bw"] .app-header {
  background: #0a0a0a;
}

[data-theme="bw"] .screen-title,
[data-theme="bw"] .field label {
  color: #b0b0b0;
}


/* Bouton primaire : blanc sur noir au lieu de vert */
[data-theme="bw"] .btn-primary {
  background: #d0d0d0;
  color: #000000;
}

[data-theme="bw"] .btn-secondary {
  background: #0d0d0d;
  color: #b0b0b0;
  border-color: #2a2a2a;
}

[data-theme="bw"] .btn-calendar {
  background: #111111;
  color: #888888;
  border-color: #2a2a2a;
}

[data-theme="bw"] .recur-opt {
  color: #888888;
}

[data-theme="bw"] .recur-opt.selected {
  background: #1a1a1a;
  border-color: #888888;
  color: #d0d0d0;
}

[data-theme="bw"] .radio-option.selected,
[data-theme="bw"] .choice-card:hover,
[data-theme="bw"] .category-card:hover {
  background: #1a1a1a;
  border-color: #888888;
}

[data-theme="bw"] .confirm-box {
  background: #0d0d0d;
}

[data-theme="bw"] .badge-green,
[data-theme="bw"] .badge-purple,
[data-theme="bw"] .badge-amber {
  background: #1a1a1a;
  color: #888888;
}

[data-theme="bw"] .error-msg {
  background: #111111;
  border-color: #444444;
  color: #aaaaaa;
}

[data-theme="bw"] .separateur-creation {
  border-top-color: #1a1a1a;
}
[data-theme="bw"] .separateur-creation p {
  color: #444444;
}

[data-theme="bw"] .btn-creer-profil {
  background: #111111 !important;
  border-color: #333333 !important;
  color: #888888 !important;
}

[data-theme="bw"] .mp-prenom-display {
  border-color: #222222 !important;
  background: #080808 !important;
  color: #666666 !important;
}

[data-theme="bw"] .btn-supprimer-compte {
  background: #111111 !important;
  color: #888888 !important;
  border-color: #333333 !important;
}

[data-theme="bw"] .btn-inviter {
  background: #111111 !important;
  color: #888888 !important;
  border-color: #333333 !important;
}

[data-theme="bw"] .screen p,
[data-theme="bw"] .screen-sub {
  color: var(--texte-doux);
}

[data-theme="bw"] #btn-dark-toggle {
  color: #333333;
}

/* Icônes de la home : neutraliser les backgrounds colorés inline */
[data-theme="dark"] .choice-icon {
  background: #1a1a1a !important;
}

[data-theme="bw"] .choice-icon {
  background: #111111 !important;
}
