:root {
  /* Accent principal : turquoise (comme la reference), orange en secondaire */
  --turquoise: #17B3B0;
  --turquoise-fonce: #0E8F8C;
  --orange: #FC4C02;
  --orange-clair: #FF6B35;
  /* Fond clair, cartes blanches */
  --fond: #F4F6F8;
  --carte: #FFFFFF;
  --carte-2: #F0F3F5;
  --bordure: #E2E7EB;
  /* Textes sombres pour la lisibilite */
  --texte: #1A2430;
  --texte-gris: #6B7885;
  --vert: #2E9E5B;
  --rouge: #E4453A;
  /* Couleur d'accent generique (pilotable) : turquoise */
  --accent: var(--turquoise);
  --accent-fonce: var(--turquoise-fonce);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  background: var(--fond);
  color: var(--texte);
  line-height: 1.5;
  /* reserve la hauteur de la barre de nav + la zone sure (encoche/bas iPhone) */
  padding-bottom: calc(80px + env(safe-area-inset-bottom, 0px));
  -webkit-font-smoothing: antialiased;
  /* NE PAS mettre overflow-x:hidden ici : sur iOS Safari cela casse le
     position:fixed de la barre de navigation (elle se retrouve au milieu de
     l'ecran). Le anti-debordement est applique sur .container a la place. */
}

.container {
  max-width: 640px;
  width: 100%;
  margin: 0 auto;
  padding: 16px;
  /* empeche un debordement horizontal (ex: carte Leaflet) de decaler le
     contenu, sans affecter le positionnement fixe de la nav (hors container) */
  overflow-x: hidden;
}

/* En-tete : degrade turquoise, grand et lisible */
.header {
  background: linear-gradient(135deg, var(--turquoise), var(--turquoise-fonce));
  border-radius: 18px;
  padding: 22px;
  margin-bottom: 18px;
  box-shadow: 0 6px 22px rgba(23, 179, 176, 0.28);
}
/* Couleur du header selon l'onglet (ajoute une identite visuelle par onglet) */
.header.h-accueil { background: linear-gradient(135deg, #17B3B0, #0E8F8C); box-shadow: 0 6px 22px rgba(23,179,176,0.28); }
.header.h-seances { background: linear-gradient(135deg, #5C6BC0, #3F51B5); box-shadow: 0 6px 22px rgba(92,107,192,0.28); }
.header.h-ressenti { background: linear-gradient(135deg, #EC407A, #C2185B); box-shadow: 0 6px 22px rgba(236,64,122,0.28); }
.header.h-evenement { background: linear-gradient(135deg, #FC4C02, #E23E00); box-shadow: 0 6px 22px rgba(252,76,2,0.28); }
.header.h-statistiques { background: linear-gradient(135deg, #F9A825, #F57F17); box-shadow: 0 6px 22px rgba(245,127,23,0.28); }
.header.h-analyse { background: linear-gradient(135deg, #7E57C2, #5E35B1); box-shadow: 0 6px 22px rgba(126,87,194,0.28); }
.header.h-compte { background: linear-gradient(135deg, #546E7A, #37474F); box-shadow: 0 6px 22px rgba(84,110,122,0.28); }
.header h1 { color: #fff; font-size: 24px; font-weight: 800; letter-spacing: -0.3px; }
.header .date { color: rgba(255,255,255,0.95); font-size: 13px; margin-top: 3px; }
.header .sous { color: rgba(255,255,255,0.9); font-size: 11px; text-transform: uppercase; letter-spacing: 1.5px; font-weight: 700; }

/* Cartes : blanches, ombre douce */
.carte {
  background: var(--carte);
  border: 1px solid var(--bordure);
  border-radius: 16px;
  padding: 18px;
  margin-bottom: 16px;
  box-shadow: 0 2px 10px rgba(26, 36, 48, 0.05);
}
.carte h2 {
  color: var(--accent-fonce);
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  margin-bottom: 14px;
}

/* Formulaires */
.champ { margin-bottom: 18px; }
.champ label {
  display: block;
  color: var(--texte);
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 8px;
}
.champ .aide { color: var(--texte-gris); font-size: 12px; font-weight: 400; }

input[type="text"], input[type="date"], input[type="password"],
input[type="email"], input[type="number"],
textarea, select {
  width: 100%;
  box-sizing: border-box;
  -webkit-appearance: none;
  appearance: none;
  background: var(--carte-2);
  border: 1px solid var(--bordure);
  border-radius: 10px;
  padding: 12px 14px;
  color: var(--texte);
  font-size: 15px;
  font-family: inherit;
  line-height: 1.2;
}
/* input date : forcer la meme hauteur que les autres champs (le widget natif
   iOS/Safari ajoute sinon une hauteur differente et un cartouche mal aligne). */
input[type="date"] {
  min-height: 46px;
  -webkit-appearance: none;
}
input[type="date"]::-webkit-date-and-time-value { text-align: left; }
textarea { min-height: 80px; resize: vertical; }
input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(23, 179, 176, 0.12);
}

/* Slider / echelle 1-10 */
.echelle { display: flex; gap: 6px; flex-wrap: wrap; }
/* Echelle d'intensite 1-10 : grille reguliere, cases de meme taille meme sur
   deux lignes (5 colonnes). */
.echelle-intensite {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
}
.echelle-intensite label { min-width: 0; margin: 0; }
.echelle input[type="radio"] { display: none; }
.echelle label {
  flex: 1;
  min-width: 36px;
  text-align: center;
  background: var(--carte-2);
  border: 1px solid var(--bordure);
  border-radius: 8px;
  padding: 10px 0;
  cursor: pointer;
  font-weight: 700;
  font-size: 15px;
  margin-bottom: 0;
  transition: all 0.15s;
}
.echelle input[type="radio"]:checked + label {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.echelle-bas {
  display: flex;
  justify-content: space-between;
  margin-top: 6px;
  color: var(--texte-gris);
  font-size: 11px;
}

/* Boutons */
.btn {
  display: inline-block;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 12px;
  padding: 14px 20px;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  text-decoration: none;
  text-align: center;
  width: 100%;
  font-family: inherit;
  box-shadow: 0 3px 10px rgba(23, 179, 176, 0.25);
  transition: transform 0.08s, opacity 0.15s;
}
.btn:active { transform: translateY(1px); opacity: 0.9; }
.btn-secondaire {
  background: var(--carte);
  border: 1px solid var(--bordure);
  color: var(--texte);
  box-shadow: none;
}
.btn-danger { background: var(--rouge); box-shadow: 0 3px 10px rgba(228, 69, 58, 0.25); }
.btn-petit { width: auto; padding: 8px 14px; font-size: 13px; box-shadow: none; }

/* Grille de boutons d'action accueil */
.actions { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 16px; }
.action-carte {
  background: var(--carte);
  border: 1px solid var(--bordure);
  border-radius: 16px;
  padding: 20px 16px;
  text-align: center;
  text-decoration: none;
  color: var(--texte);
  transition: border-color 0.15s, transform 0.08s;
  box-shadow: 0 2px 10px rgba(26, 36, 48, 0.05);
}
.action-carte:active { border-color: var(--accent); transform: translateY(1px); }
.action-carte .icone { font-size: 28px; display: block; margin-bottom: 8px; }
.action-carte .titre { font-weight: 700; font-size: 15px; }
.action-carte .desc { color: var(--texte-gris); font-size: 12px; margin-top: 2px; }

/* Liste historique */
.ligne-histo {
  background: var(--carte);
  border: 1px solid var(--bordure);
  border-radius: 12px;
  padding: 12px 14px;
  margin-bottom: 8px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-shadow: 0 1px 6px rgba(26, 36, 48, 0.04);
}
.ligne-histo .info { flex: 1; }
.ligne-histo .date-h { color: var(--accent-fonce); font-weight: 700; font-size: 14px; }
.ligne-histo .detail { color: var(--texte-gris); font-size: 12px; margin-top: 2px; }
.ligne-histo .actions-h { display: flex; gap: 6px; }

/* Badges */
.badge {
  display: inline-block;
  background: rgba(23, 179, 176, 0.12);
  color: var(--accent-fonce);
  font-size: 11px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 6px;
  margin-right: 4px;
}
.badge-vert { background: rgba(46, 158, 91, 0.14); color: var(--vert); }
.badge-orange { background: rgba(252, 76, 2, 0.12); color: var(--orange); }

/* Messages flash */
.flash {
  padding: 12px 16px;
  border-radius: 12px;
  margin-bottom: 16px;
  font-size: 14px;
  font-weight: 600;
}
.flash.succes { background: rgba(46, 158, 91, 0.12); color: var(--vert); border: 1px solid rgba(46, 158, 91, 0.28); }
.flash.erreur { background: rgba(228, 69, 58, 0.12); color: var(--rouge); border: 1px solid rgba(228, 69, 58, 0.28); }

/* Navigation basse (mobile) */
.nav-bas {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  background: var(--carte);
  border-top: 1px solid var(--bordure);
  display: flex;
  /* padding bas = marge normale + zone sure (barre iPhone) pour que la barre
     reste collee au vrai bas de l'ecran sans "sauter" quand la barre
     d'adresse du navigateur mobile apparait/disparait. */
  padding: 8px 0 calc(8px + env(safe-area-inset-bottom, 0px));
  /* au-dessus de tout, y compris les panneaux Leaflet (z-index ~400-1000) */
  z-index: 2000;
  box-shadow: 0 -2px 12px rgba(26, 36, 48, 0.06);
  /* promeut la barre sur sa propre couche : evite les repaints/sauts iOS */
  transform: translateZ(0);
  will-change: transform;
  -webkit-backface-visibility: hidden;
  backface-visibility: hidden;
}
.nav-bas a {
  flex: 1;
  text-align: center;
  color: var(--texte-gris);
  text-decoration: none;
  font-size: 11px;
  padding: 4px;
}
.nav-bas a .icone { display: block; margin-bottom: 3px; }
.nav-bas a .icone svg { width: 28px; height: 28px; display: block; margin: 0 auto; stroke-width: 2.5; }
.nav-bas a.actif .icone svg { stroke-width: 2.8; }
/* Onglet selectionne : l'icone prend la COULEUR DU BANDEAU de son onglet */
.nav-bas a.actif { color: var(--accent); }
.nav-bas a.nav-accueil.actif      { color: #17B3B0; }
.nav-bas a.nav-seances.actif      { color: #5C6BC0; }
.nav-bas a.nav-ressenti.actif     { color: #EC407A; }
.nav-bas a.nav-evenement.actif    { color: #FC4C02; }
.nav-bas a.nav-statistiques.actif { color: #F57F17; }
.nav-bas a.nav-analyse.actif      { color: #7E57C2; }

/* Login */
.login-box { max-width: 360px; margin: 80px auto 0; }

/* Resume valeurs : grands chiffres facon appli course */
.resume-grille { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.resume-item {
  background: var(--carte-2);
  border-radius: 12px;
  padding: 14px;
  text-align: center;
}
.resume-item .val { font-size: 26px; font-weight: 800; color: var(--texte); letter-spacing: -0.5px; }
.resume-item .lib { font-size: 11px; color: var(--texte-gris); text-transform: uppercase; margin-top: 2px; letter-spacing: 0.5px; }

.vide { color: var(--texte-gris); font-size: 14px; text-align: center; padding: 20px; }

/* Barre superieure : nom + historique versions */
/* Coin utilisateur : prenom + version, en haut a droite au-dessus du header */
/* Prenom + version dans la cartouche du titre (en haut a droite) */
.header-coin {
  position: absolute; top: 14px; right: 16px;
  display: flex; align-items: center; gap: 8px;
}
.header-prenom { font-weight: 700; font-size: 13px; color: #fff; }
.header-version {
  color: #fff; text-decoration: none; font-size: 11px; font-weight: 700;
  background: rgba(255,255,255,0.22); padding: 3px 9px; border-radius: 20px;
}
.pied-maj {
  text-align: center; color: var(--texte-gris); font-size: 11px;
  margin: 20px 0 8px; opacity: 0.8;
}

/* Overlay animation de mise a jour */
#overlay_maj {
  position: fixed; inset: 0; z-index: 1000;
  background: rgba(26,36,48,0.45);
  display: flex; align-items: center; justify-content: center;
  backdrop-filter: blur(2px);
}
.overlay-contenu {
  background: var(--carte); border-radius: 16px; padding: 28px 34px;
  text-align: center; box-shadow: 0 10px 40px rgba(0,0,0,0.2);
}
.spinner-maj {
  width: 46px; height: 46px; margin: 0 auto 14px;
  border: 4px solid var(--bordure); border-top-color: var(--accent);
  border-radius: 50%; animation: tourne-maj 0.85s linear infinite;
}
@keyframes tourne-maj { to { transform: rotate(360deg); } }
.overlay-texte { font-weight: 600; color: var(--texte); font-size: 14px; }
