/* ============================================================
   App Rando Classe — feuille de style (mobile-first, responsive)
   ============================================================ */

:root {
  --vert: #2f6f4f;
  --vert-fonce: #235640;
  --vert-clair: #e7f2ec;
  --orange: #e08a1e;
  --rouge: #c0392b;
  --gris: #8a8f98;
  --gris-clair: #eef1f4;
  --texte: #1f2a26;
  --texte-doux: #5b6660;
  --fond: #f5f7f6;
  --carte: #ffffff;
  --bord: #e2e7e4;
  --ombre: 0 1px 3px rgba(0, 0, 0, 0.08), 0 1px 2px rgba(0, 0, 0, 0.04);
  --radius: 12px;
  --tabbar-h: 64px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--fond);
  color: var(--texte);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 16px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { margin: 0 0 0.4em; }
a { color: var(--vert); }

/* ---------- Layout connecté ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 12px 16px;
  padding-top: max(12px, env(safe-area-inset-top));
  background: var(--vert);
  color: #fff;
  box-shadow: var(--ombre);
}
.topbar__title { font-weight: 700; font-size: 1.05rem; }
.topbar__right { display: flex; align-items: center; gap: 10px; }
.topbar__user { font-size: 0.9rem; opacity: 0.95; display: flex; align-items: center; gap: 6px; }
.badge-admin {
  background: var(--orange);
  color: #fff;
  font-size: 0.7rem;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 6px;
  text-transform: uppercase;
}

.view {
  max-width: 760px;
  margin: 0 auto;
  padding: 16px 16px calc(var(--tabbar-h) + 24px);
}
.view--auth {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 16px;
}
.view__titre { font-size: 1.4rem; }
.view__sous-titre { font-size: 1.05rem; color: var(--texte-doux); margin-top: 0.2em; }

/* ---------- Barre d'onglets (bas) ---------- */
.tabbar {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  z-index: 10;
  display: flex;
  background: var(--carte);
  border-top: 1px solid var(--bord);
  padding-bottom: env(safe-area-inset-bottom);
  box-shadow: 0 -1px 4px rgba(0,0,0,0.05);
}
.tab {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 8px 2px;
  text-decoration: none;
  color: var(--gris);
  font-size: 0.68rem;
  height: var(--tabbar-h);
  justify-content: center;
}
.tab__icone { font-size: 1.3rem; line-height: 1; }
.tab--active { color: var(--vert); font-weight: 700; }
.tab--active .tab__icone { transform: translateY(-1px); }

/* ---------- Cartes & blocs ---------- */
.card {
  background: var(--carte);
  border: 1px solid var(--bord);
  border-radius: var(--radius);
  padding: 16px;
  margin: 14px 0;
  box-shadow: var(--ombre);
}
.card--admin { border-color: var(--orange); background: #fff9f0; }

.vide { color: var(--texte-doux); font-style: italic; padding: 8px 0; }

/* ---------- Boutons ---------- */
.btn {
  border: 1px solid var(--bord);
  background: var(--carte);
  color: var(--texte);
  border-radius: 10px;
  padding: 10px 16px;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, opacity 0.15s, transform 0.05s;
}
.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn--primary { background: var(--vert); color: #fff; border-color: var(--vert); }
.btn--primary:hover { background: var(--vert-fonce); }
.btn--ghost { background: transparent; }
.btn--danger { background: #fff; color: var(--rouge); border-color: var(--rouge); }
.btn--small { padding: 7px 12px; font-size: 0.85rem; }
.btn--block { width: 100%; }
.btn--ghost.btn--small { color: #fff; border-color: rgba(255,255,255,0.5); }
.topbar .btn--ghost { color: #fff; border-color: rgba(255,255,255,0.55); }

/* ---------- Formulaires ---------- */
.form { display: flex; flex-direction: column; gap: 12px; }
.form-row { display: flex; gap: 12px; }
.form-row .field { flex: 1; }
.field { display: flex; flex-direction: column; gap: 5px; }
.field > span { font-size: 0.85rem; font-weight: 600; color: var(--texte-doux); }
input, select, textarea {
  font: inherit;
  padding: 11px 12px;
  border: 1px solid var(--bord);
  border-radius: 10px;
  background: #fff;
  color: var(--texte);
  width: 100%;
}
input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--vert);
  box-shadow: 0 0 0 3px var(--vert-clair);
}
.form-inline { display: flex; gap: 10px; }
.form-inline input { flex: 1; }

/* ---------- Alertes & loaders ---------- */
.alert { border-radius: 10px; padding: 11px 14px; margin: 10px 0; font-size: 0.9rem; }
.alert--error { background: #fdecea; color: var(--rouge); border: 1px solid #f5c6c0; }
.alert--warning { background: #fef6e7; color: #92600a; border: 1px solid #f5dca0; }
.alert--info { background: var(--vert-clair); color: var(--vert-fonce); border: 1px solid #c5e0d3; }
.loader { padding: 24px; text-align: center; color: var(--texte-doux); }
.loader--plein { min-height: 60vh; display: flex; align-items: center; justify-content: center; }

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--tabbar-h) + 16px);
  transform: translateX(-50%) translateY(20px);
  background: #222;
  color: #fff;
  padding: 11px 18px;
  border-radius: 10px;
  font-size: 0.9rem;
  box-shadow: 0 4px 12px rgba(0,0,0,0.25);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
  z-index: 100;
  max-width: 90vw;
  text-align: center;
}
.toast--visible { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast--error { background: var(--rouge); }
.toast--success { background: var(--vert); }

/* ---------- Chips ---------- */
.chip {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 20px;
  font-size: 0.8rem;
  margin: 2px;
  background: var(--gris-clair);
}
.chip--ok { background: var(--vert-clair); color: var(--vert-fonce); }
.chip--vide { color: var(--gris); font-style: italic; background: transparent; }

/* ============================================================
   Auth
   ============================================================ */
.auth-card {
  width: 100%;
  max-width: 400px;
  background: var(--carte);
  border-radius: 16px;
  box-shadow: var(--ombre);
  padding: 28px 24px;
}
.auth-card__titre { text-align: center; font-size: 1.5rem; }
.auth-card__sous { text-align: center; color: var(--texte-doux); margin-bottom: 18px; }
.auth-tabs { display: flex; background: var(--gris-clair); border-radius: 10px; padding: 4px; margin-bottom: 18px; }
.auth-tab {
  flex: 1;
  border: none;
  background: transparent;
  padding: 9px;
  border-radius: 8px;
  font: inherit;
  font-weight: 600;
  color: var(--texte-doux);
  cursor: pointer;
}
.auth-tab--active { background: #fff; color: var(--vert); box-shadow: var(--ombre); }
#auth-error:not([hidden]) { display: block; }

/* ============================================================
   Participation
   ============================================================ */
.compteur {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--vert);
  color: #fff;
  border-radius: var(--radius);
  padding: 16px 20px;
  margin: 12px 0;
}
.compteur__nombre { font-size: 2.4rem; font-weight: 800; line-height: 1; }
.compteur__label { font-size: 0.95rem; opacity: 0.95; }

.tri-etat { display: flex; gap: 10px; margin: 12px 0 4px; }
.tri-btn {
  flex: 1;
  border: 2px solid var(--bord);
  background: #fff;
  border-radius: 12px;
  padding: 14px 6px;
  font-weight: 700;
  font-size: 0.95rem;
  cursor: pointer;
  color: var(--texte-doux);
  transition: all 0.15s;
}
.tri-btn:disabled { opacity: 0.55; cursor: not-allowed; }
.tri-btn--oui.tri-btn--actif { background: var(--vert); border-color: var(--vert); color: #fff; }
.tri-btn--non.tri-btn--actif { background: var(--rouge); border-color: var(--rouge); color: #fff; }
.tri-btn--peut_etre.tri-btn--actif { background: var(--orange); border-color: var(--orange); color: #fff; }

.liste-participants { list-style: none; margin: 8px 0 0; padding: 0; }
.participant {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 11px 4px;
  border-bottom: 1px solid var(--bord);
}
.participant:last-child { border-bottom: none; }
.participant__nom { font-weight: 500; }
.participant__nom em { color: var(--vert); font-style: normal; font-size: 0.82rem; }

.statut-badge {
  font-size: 0.78rem;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 20px;
  white-space: nowrap;
}
.statut-badge--oui { background: var(--vert-clair); color: var(--vert-fonce); }
.statut-badge--non { background: #fdecea; color: var(--rouge); }
.statut-badge--peut_etre { background: #fef6e7; color: #92600a; }
.statut-badge--non_repondu { background: var(--gris-clair); color: var(--gris); }

/* ============================================================
   Équipement
   ============================================================ */
.check-liste { list-style: none; margin: 0; padding: 0; }
.check-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 4px;
  border-bottom: 1px solid var(--bord);
}
.check-item:last-child { border-bottom: none; }
.check-item__nom { font-weight: 500; }
.check-item__actions { display: flex; align-items: center; gap: 8px; }
.toggle {
  border: 2px solid var(--bord);
  background: #fff;
  border-radius: 20px;
  padding: 6px 14px;
  font-weight: 700;
  font-size: 0.82rem;
  cursor: pointer;
  color: var(--texte-doux);
  min-width: 92px;
}
.toggle--on { background: var(--vert); border-color: var(--vert); color: #fff; }
.btn-suppr {
  border: none;
  background: transparent;
  font-size: 1rem;
  cursor: pointer;
  padding: 4px;
  opacity: 0.6;
}
.btn-suppr:hover { opacity: 1; }

/* Matrice desktop (table) / mobile (liste) : on bascule selon la largeur */
.matrice-desktop { overflow-x: auto; }
.matrice { border-collapse: collapse; width: 100%; font-size: 0.85rem; }
.matrice th, .matrice td { border: 1px solid var(--bord); padding: 7px 9px; text-align: center; }
.matrice__coin, .matrice__nom { text-align: left; position: sticky; left: 0; background: var(--carte); font-weight: 600; }
.matrice__pers { font-weight: 700; color: var(--texte-doux); }
.matrice__cell.is-ok { background: var(--vert-clair); color: var(--vert-fonce); font-weight: 700; }
.matrice__cell.is-non { color: var(--bord); }

.matrice-mobile { display: none; }
.mobile-equip { padding: 10px 0; border-bottom: 1px solid var(--bord); }
.mobile-equip:last-child { border-bottom: none; }
.mobile-equip__titre { font-weight: 600; margin-bottom: 6px; }
.mobile-equip__compte { color: var(--texte-doux); font-weight: 400; font-size: 0.85rem; }

/* En dessous de 640px : on masque la table, on montre la liste par objet */
@media (max-width: 640px) {
  .matrice-desktop { display: none; }
  .matrice-mobile { display: block; }
}

/* ============================================================
   Covoiturage
   ============================================================ */
.liste-voitures { display: flex; flex-direction: column; gap: 12px; }
.voiture {
  border: 1px solid var(--bord);
  border-radius: var(--radius);
  padding: 14px;
  background: #fff;
}
.voiture--pleine { opacity: 0.8; background: #fafbfb; }
.voiture__entete { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.voiture__conducteur { font-weight: 700; }
.voiture__conducteur em { color: var(--vert); font-style: normal; font-size: 0.8rem; }
.voiture__places {
  font-size: 0.8rem; font-weight: 700;
  background: var(--vert-clair); color: var(--vert-fonce);
  padding: 3px 10px; border-radius: 20px;
}
.voiture__places.is-pleine { background: #fdecea; color: var(--rouge); }
.voiture__infos { display: flex; gap: 16px; flex-wrap: wrap; color: var(--texte-doux); font-size: 0.9rem; margin-bottom: 8px; }
.voiture__passagers { font-size: 0.88rem; margin-bottom: 10px; }
.voiture__passagers-label { color: var(--texte-doux); font-weight: 600; }
.voiture__actions { display: flex; justify-content: flex-end; }

/* ============================================================
   Parcours & infos
   ============================================================ */
.dates-cles { display: flex; gap: 12px; margin: 12px 0; }
.date-cle {
  flex: 1;
  border-radius: var(--radius);
  padding: 14px;
  color: #fff;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.date-cle--rando { background: var(--vert); }
.date-cle--limite { background: var(--orange); }
.date-cle__label { font-size: 0.8rem; opacity: 0.95; }
.date-cle__valeur { font-size: 1.05rem; font-weight: 700; text-transform: capitalize; }

.fiche { display: grid; grid-template-columns: auto 1fr; gap: 8px 16px; margin: 0; }
.fiche dt { color: var(--texte-doux); font-weight: 600; }
.fiche dd { margin: 0; text-align: right; }

.fiche__itineraire { margin: 0; line-height: 1.6; }
.fiche__itineraire--vide { color: var(--texte-doux); }

.carte-rando {
  height: 360px;
  margin-top: 16px;
  border-radius: 12px;
  overflow: hidden;
  z-index: 0; /* reste sous les overlays de l'app */
}
.carte-rando__stats { margin: 8px 0 0; color: var(--texte-doux); font-size: 0.9rem; }
.carte-pin {
  position: relative;
  font-size: 22px;
  line-height: 1;
  text-align: center;
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.4));
}
.carte-pin__ico { display: inline-block; }
.carte-pin__n {
  position: absolute;
  top: -7px;
  right: -7px;
  width: 17px;
  height: 17px;
  border-radius: 50%;
  background: #2f6f4f;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  line-height: 17px;
  text-align: center;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
}

.meteo__msg { color: var(--texte-doux); }
.meteo__carte { display: flex; align-items: center; gap: 16px; }
.meteo__icone { font-size: 3rem; }
.meteo__libelle { font-weight: 700; font-size: 1.1rem; }
.meteo__temps { display: flex; gap: 10px; align-items: baseline; }
.meteo__max { font-size: 1.6rem; font-weight: 800; color: var(--rouge); }
.meteo__min { font-size: 1.2rem; color: var(--gris); }
.meteo__pluie { color: var(--texte-doux); font-size: 0.9rem; }
.meteo__note { color: var(--texte-doux); font-size: 0.8rem; margin: 10px 0 0; text-transform: capitalize; }

/* ============================================================
   Chat
   ============================================================ */
.chat-fil {
  height: calc(100vh - var(--tabbar-h) - 230px);
  min-height: 240px;
  overflow-y: auto;
  background: var(--carte);
  border: 1px solid var(--bord);
  border-radius: var(--radius);
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.msg { max-width: 80%; align-self: flex-start; }
.msg--moi { align-self: flex-end; text-align: right; }
.msg__entete { display: flex; gap: 8px; align-items: baseline; font-size: 0.75rem; margin-bottom: 2px; }
.msg--moi .msg__entete { flex-direction: row-reverse; }
.msg__prenom { font-weight: 700; color: var(--vert); }
.msg__heure { color: var(--gris); }
.msg__contenu {
  display: inline-block;
  background: var(--gris-clair);
  padding: 9px 13px;
  border-radius: 14px;
  word-break: break-word;
  text-align: left;
}
.msg--moi .msg__contenu { background: var(--vert); color: #fff; }

.chat-form { display: flex; gap: 10px; margin-top: 12px; }
.chat-form input { flex: 1; }

/* ---------- Desktop : on remonte un peu et on aère ---------- */
@media (min-width: 760px) {
  .view { padding-top: 22px; }
}
