/* ==========================================================================
   Carnet de santé — style.css
   Palette calme teal / corail, gros textes, forts contrastes.
   Pensé pour une personne peu à l'aise avec la technologie.
   ========================================================================== */

:root {
  /* Couleurs */
  --teal-900: #123a35;
  --teal-700: #1f5a52;
  --teal-600: #256b61;
  --teal-100: #e4f1ee;
  --teal-050: #f4f9f8;
  --corail-600: #e35f3f;
  --corail-500: #f07a5e;
  --corail-100: #fde7e0;
  --alerte-bg: #fdeceb;
  --alerte-bord: #c94a3b;
  --alerte-texte: #7a2418;
  --succes-bg: #e7f5ec;
  --succes-texte: #256b45;
  --texte-fort: #1c2b29;
  --texte-doux: #4b5f5b;
  --bord: #d7e3e0;
  --fond: #faf8f5;
  --carte: #ffffff;
  --ombre: 0 2px 10px rgba(18, 58, 53, 0.08);

  /* Typo */
  --police: "Atkinson Hyperlegible", -apple-system, "Segoe UI", Roboto,
    "Helvetica Neue", Arial, sans-serif;
  --taille-base: 19px;

  /* Formes */
  --rayon: 16px;
  --rayon-lg: 22px;
}

* {
  box-sizing: border-box;
}

html {
  font-size: var(--taille-base);
}

body {
  margin: 0;
  font-family: var(--police);
  background: var(--fond);
  color: var(--texte-fort);
  line-height: 1.5;
  -webkit-text-size-adjust: 100%;
}

button,
input,
select,
textarea {
  font-family: inherit;
  font-size: 1rem;
}

a {
  color: var(--teal-700);
}

/* Focus clavier toujours visible */
a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
[tabindex]:focus-visible {
  outline: 3px solid var(--corail-600);
  outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.001ms !important;
    transition-duration: 0.001ms !important;
  }
}

/* ---------- Structure générale ---------- */

.app-header {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--teal-700);
  color: #fff;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  box-shadow: var(--ombre);
}

.app-header h1 {
  font-size: 1.15rem;
  margin: 0;
  font-weight: 700;
  flex: 1;
}

.btn-retour,
.btn-accueil {
  background: rgba(255, 255, 255, 0.16);
  color: #fff;
  border: none;
  border-radius: 12px;
  padding: 10px 14px;
  font-size: 1rem;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  min-height: 44px;
}

.btn-retour:hover,
.btn-accueil:hover {
  background: rgba(255, 255, 255, 0.28);
}

main#app {
  padding: 18px 16px 48px;
  max-width: 720px;
  margin: 0 auto;
}

.offline-banner {
  background: #fff3cd;
  color: #6b5300;
  border: 1px solid #e3c766;
  padding: 10px 14px;
  border-radius: var(--rayon);
  margin-bottom: 16px;
  font-weight: 600;
  font-size: 0.95rem;
}

/* ---------- Tableau de bord ---------- */

.patient-bandeau {
  background: var(--carte);
  border-radius: var(--rayon-lg);
  padding: 18px 20px;
  box-shadow: var(--ombre);
  margin-bottom: 16px;
}

.patient-bandeau h2 {
  margin: 0 0 4px;
  font-size: 1.5rem;
  color: var(--teal-900);
}

.patient-bandeau .sous-titre {
  color: var(--texte-doux);
  margin: 0;
}

.alerte-allergies {
  margin-top: 14px;
  background: var(--alerte-bg);
  border: 2px solid var(--alerte-bord);
  color: var(--alerte-texte);
  border-radius: var(--rayon);
  padding: 12px 14px;
  font-weight: 700;
  font-size: 1.02rem;
  display: flex;
  gap: 10px;
  align-items: flex-start;
}

.widget-prochain-rdv {
  display: flex;
  align-items: center;
  gap: 14px;
  background: var(--teal-100);
  border: 2px solid var(--teal-600);
  border-radius: var(--rayon-lg);
  padding: 14px 16px;
  margin-bottom: 16px;
  text-decoration: none;
  color: var(--texte-fort);
}

.widget-prochain-rdv .icone {
  font-size: 1.8rem;
  line-height: 1;
}

.widget-prochain-rdv .widget-titre {
  margin: 0 0 2px;
  font-weight: 700;
  color: var(--teal-900);
  font-size: 0.92rem;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

.widget-prochain-rdv .widget-detail {
  margin: 0;
  font-size: 1.02rem;
  font-weight: 600;
}

.grille-tuiles {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px;
}

@media (max-width: 420px) {
  .grille-tuiles {
    grid-template-columns: 1fr;
  }
}

.tuile {
  background: var(--carte);
  border: none;
  border-radius: var(--rayon-lg);
  box-shadow: var(--ombre);
  padding: 20px 16px;
  text-align: left;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 112px;
  color: var(--texte-fort);
  text-decoration: none;
}

.tuile:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 18px rgba(18, 58, 53, 0.14);
}

.tuile .icone {
  font-size: 2rem;
  line-height: 1;
}

.tuile .libelle {
  font-size: 1.08rem;
  font-weight: 700;
}

.tuile.tuile-accent {
  background: var(--teal-700);
  color: #fff;
}

.tuile.tuile-corail {
  background: var(--corail-500);
  color: #fff;
}

/* ---------- Listes ---------- */

.barre-actions {
  display: flex;
  gap: 10px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.onglets {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
  background: var(--teal-100);
  padding: 6px;
  border-radius: 14px;
}

.onglet {
  flex: 1;
  border: none;
  background: transparent;
  padding: 10px 8px;
  border-radius: 10px;
  font-weight: 700;
  font-size: 1rem;
  cursor: pointer;
  color: var(--teal-900);
  min-height: 44px;
}

.onglet.actif {
  background: var(--teal-700);
  color: #fff;
}

.puces {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
}

.puce {
  border: 2px solid var(--bord);
  background: #fff;
  color: var(--texte-fort);
  padding: 9px 14px;
  border-radius: 999px;
  font-weight: 700;
  font-size: 0.92rem;
  cursor: pointer;
  min-height: 40px;
}

.puce:hover {
  border-color: var(--teal-600);
}

.puce.puce-active {
  background: var(--teal-700);
  border-color: var(--teal-700);
  color: #fff;
}

.champ-recherche {
  width: 100%;
  padding: 14px 16px;
  border: 2px solid var(--bord);
  border-radius: var(--rayon);
  margin-bottom: 16px;
  background: var(--carte);
}

.liste-cartes {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.carte-item {
  background: var(--carte);
  border-radius: var(--rayon);
  box-shadow: var(--ombre);
  padding: 16px 18px;
  display: block;
  text-decoration: none;
  color: var(--texte-fort);
  cursor: pointer;
  border: none;
  text-align: left;
  width: 100%;
}

.carte-item .titre-item {
  font-size: 1.12rem;
  font-weight: 700;
  margin: 0 0 4px;
  color: var(--teal-900);
}

.carte-item .detail-item {
  color: var(--texte-doux);
  font-size: 0.98rem;
  margin: 2px 0;
}

.badge {
  display: inline-block;
  font-size: 0.82rem;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 999px;
  margin-top: 6px;
}

.badge-encours {
  background: var(--succes-bg);
  color: var(--succes-texte);
}

.badge-termine {
  background: #eee;
  color: #666;
}

.etat-vide {
  text-align: center;
  color: var(--texte-doux);
  padding: 40px 16px;
  background: var(--carte);
  border-radius: var(--rayon);
}

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

.formulaire {
  background: var(--carte);
  border-radius: var(--rayon-lg);
  box-shadow: var(--ombre);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.champ {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.champ label {
  font-weight: 700;
  font-size: 1rem;
  color: var(--teal-900);
}

.champ .aide {
  font-size: 0.88rem;
  color: var(--texte-doux);
}

.champ input,
.champ select,
.champ textarea {
  padding: 13px 14px;
  border: 2px solid var(--bord);
  border-radius: 12px;
  background: #fff;
  color: var(--texte-fort);
  width: 100%;
}

.champ input:focus,
.champ select:focus,
.champ textarea:focus {
  border-color: var(--teal-600);
}

.champ-case {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-direction: row;
}

.champ-case input {
  width: 22px;
  height: 22px;
}

.champ-resume-medecin {
  background: var(--teal-050);
  border: 2px solid var(--teal-100);
  border-radius: var(--rayon);
  padding: 14px;
}

.champ-resume-medecin label {
  color: var(--teal-900);
}

.etoiles {
  display: flex;
  gap: 6px;
}

.etoile-btn {
  background: none;
  border: none;
  font-size: 1.8rem;
  cursor: pointer;
  color: #d8d8d8;
  padding: 4px;
  min-width: 44px;
  min-height: 44px;
}

.etoile-btn.pleine {
  color: var(--corail-500);
}

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

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 50px;
  padding: 13px 20px;
  border-radius: 14px;
  font-weight: 700;
  font-size: 1.02rem;
  border: none;
  cursor: pointer;
  text-decoration: none;
}

.btn-principal {
  background: var(--teal-700);
  color: #fff;
}

.btn-principal:hover {
  background: var(--teal-900);
}

.btn-principal:disabled {
  background: #9db6b1;
  cursor: not-allowed;
}

.btn-corail {
  background: var(--corail-500);
  color: #fff;
}

.btn-corail:hover {
  background: var(--corail-600);
}

.btn-discret {
  background: var(--teal-100);
  color: var(--teal-900);
}

.btn-discret:hover {
  background: #d6e9e5;
}

.btn-danger {
  background: #fff;
  color: var(--alerte-bord);
  border: 2px solid var(--alerte-bord);
}

.btn-danger:hover {
  background: var(--alerte-bg);
}

.btn-large {
  width: 100%;
}

.rangee-boutons {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

/* ---------- Toast / confirmation ---------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  background: var(--teal-900);
  color: #fff;
  padding: 14px 22px;
  border-radius: 999px;
  font-weight: 700;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.25);
  z-index: 100;
  max-width: 90vw;
  text-align: center;
}

.toast.erreur {
  background: var(--alerte-bord);
}

/* ---------- Fiche "Préparer la consultation" ---------- */

.fiche-section {
  background: var(--carte);
  border-radius: var(--rayon);
  box-shadow: var(--ombre);
  padding: 16px 18px;
  margin-bottom: 14px;
}

.fiche-section h3 {
  margin: 0 0 10px;
  color: var(--teal-900);
  font-size: 1.08rem;
  border-bottom: 2px solid var(--teal-100);
  padding-bottom: 8px;
}

.fiche-ligne {
  padding: 6px 0;
  border-bottom: 1px dashed var(--bord);
  font-size: 0.98rem;
}

.fiche-ligne:last-child {
  border-bottom: none;
}

.zone-notes-medecin {
  min-height: 160px;
  border: 2px dashed var(--bord);
  border-radius: var(--rayon);
  background: #fff;
}

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

@media print {
  body * {
    visibility: hidden;
  }
  .app-header,
  .no-print {
    display: none !important;
  }
  .zone-impression,
  .zone-impression * {
    visibility: visible;
  }
  .zone-impression {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    padding: 0;
  }
  .fiche-section {
    box-shadow: none;
    border: 1px solid #ccc;
    break-inside: avoid;
  }
}

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

.section-titre {
  font-size: 1.3rem;
  color: var(--teal-900);
  margin: 0 0 14px;
}

.sous-section-titre {
  font-size: 1.05rem;
  color: var(--teal-900);
  margin: 18px 0 10px;
}

.texte-doux {
  color: var(--texte-doux);
}

datalist {
  display: none;
}
