/* Composants : boutons, champs, puces, pastilles, cartes, bandeaux, boites de dialogue, messages. */

.icone {
  width: 1.25em;
  height: 1.25em;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.icone--petite {
  width: 1rem;
  height: 1rem;
}

.icone--grande {
  width: 1.75rem;
  height: 1.75rem;
}

.icone--geante {
  width: 2.5rem;
  height: 2.5rem;
}

.icone--ligne {
  vertical-align: -0.2em;
}

/* ---------- boutons ---------- */

.bouton {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  min-height: 48px;
  padding: 0 1.25rem;
  border: 1.5px solid transparent;
  border-radius: 14px;
  background: transparent;
  font-size: 1rem;
  font-weight: 650;
  line-height: 1.1;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  transition: transform 120ms ease-out, background-color 150ms ease-out, border-color 150ms ease-out, opacity 150ms;
}

.bouton:active:not(:disabled) {
  transform: scale(0.97);
}

.bouton:disabled {
  opacity: 0.55;
  cursor: default;
}

.bouton--principal {
  background: var(--accent);
  color: var(--accent-sur);
}

.bouton--principal:active:not(:disabled) {
  background: var(--accent-fort);
}

.bouton--secondaire {
  background: var(--surface);
  color: var(--accent);
  border-color: var(--accent);
}

.bouton--secondaire:active:not(:disabled) {
  background: var(--accent-fond);
}

.bouton--discret {
  color: var(--accent);
}

.bouton--discret:active:not(:disabled) {
  background: var(--accent-fond);
}

.bouton--danger {
  background: var(--perime);
  color: #fff;
}

.bouton--danger-doux {
  background: var(--perime-fond);
  color: var(--perime);
}

.bouton--clair {
  background: #fff;
  color: #1f4d3a;
}

.bouton--large {
  width: 100%;
}

.bouton--compact {
  min-height: 44px;
  padding: 0 1rem;
  font-size: 0.95rem;
}

.bouton-rond {
  flex: none;
  display: inline-grid;
  place-items: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 1px solid var(--bord);
  border-radius: 50%;
  background: var(--surface);
  color: var(--texte);
  text-decoration: none;
  cursor: pointer;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
  transition: transform 120ms ease-out, background-color 150ms ease-out;
}

.bouton-rond:active {
  transform: scale(0.94);
  background: var(--surface-2);
}

.bouton-rond--plein {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-sur);
}

.bouton-rond--plein:active {
  background: var(--accent-fort);
}

.bouton-rond--petit {
  border-color: transparent;
  background: transparent;
  color: var(--doux);
}

.bouton-rond:disabled {
  opacity: 0.55;
}

@media (hover: hover) and (pointer: fine) {
  .bouton--principal:hover:not(:disabled) {
    background: var(--accent-fort);
  }

  .bouton--secondaire:hover:not(:disabled),
  .bouton--discret:hover:not(:disabled) {
    background: var(--accent-fond);
  }

  .bouton--danger:hover:not(:disabled) {
    filter: brightness(1.08);
  }

  .bouton-rond:hover {
    background: var(--surface-2);
  }

  .bouton-rond--plein:hover {
    background: var(--accent-fort);
  }

  .carte-med:hover {
    border-color: var(--accent);
    transform: translateY(-1px);
  }

  .puce--filtre:hover,
  .puce--suggestion:hover {
    border-color: var(--accent);
  }
}

/* ---------- champs de formulaire ---------- */

.champ {
  display: grid;
  gap: 6px;
  margin-bottom: 16px;
}

.champ__label {
  font-weight: 650;
  font-size: 0.95rem;
}

.champ__aide {
  color: var(--doux);
  font-size: 0.85rem;
}

.champ__erreur {
  color: var(--perime);
  font-weight: 600;
  font-size: 0.9rem;
}

.champ__avec-bouton {
  display: flex;
  align-items: center;
  gap: 8px;
}

.saisie {
  width: 100%;
  min-height: 48px;
  padding: 0.65rem 0.9rem;
  border: 1.5px solid var(--bord);
  border-radius: 12px;
  background: var(--surface);
  color: var(--texte);
  font-size: 1rem; /* 16 px minimum : sinon iPhone zoome sur le champ */
  line-height: 1.4;
  transition: border-color 150ms ease-out, box-shadow 150ms ease-out;
}

.saisie::placeholder {
  color: var(--doux);
  opacity: 0.8;
}

.saisie:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 25%, transparent);
}

.saisie--zone {
  resize: vertical;
  min-height: 5.5rem;
}

.saisie--grande {
  min-height: 54px;
  font-size: 1.1rem;
}

.date-champ {
  display: grid;
  grid-template-columns: 3fr 2fr;
  gap: 8px;
}

.case {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 44px;
  cursor: pointer;
}

.case input {
  width: 22px;
  height: 22px;
  accent-color: var(--accent);
}

.choix {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.choix__option {
  position: relative;
  display: block;
  cursor: pointer;
}

.choix__option input {
  position: absolute;
  opacity: 0;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  cursor: pointer;
}

.choix__option span {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  padding: 0 12px;
  border: 1.5px solid var(--bord);
  border-radius: 12px;
  background: var(--surface);
  text-align: center;
  font-weight: 600;
  transition: border-color 150ms ease-out, background-color 150ms ease-out;
}

.choix__option input:checked + span {
  border-color: var(--accent);
  background: var(--accent-fond);
  color: var(--accent-fort);
}

.choix__option input:focus-visible + span {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}

/* ---------- puces ---------- */

.puces {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.puce {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-height: 36px;
  padding: 0 14px;
  border: 1px solid var(--bord);
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--texte);
  font-size: 0.92rem;
  line-height: 1.2;
  white-space: nowrap;
}

button.puce {
  min-height: 44px;
  cursor: pointer;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
  transition: transform 120ms ease-out, background-color 150ms, border-color 150ms, color 150ms;
}

button.puce:active {
  transform: scale(0.96);
}

.puce--lecture {
  min-height: 32px;
  font-size: 0.88rem;
  background: var(--accent-fond);
  border-color: transparent;
  color: var(--accent-fort);
}

.puce--suggestion {
  background: transparent;
  border-style: dashed;
  color: var(--doux);
}

.puce--filtre {
  background: var(--surface);
}

.puce--active {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-sur);
  font-weight: 650;
}

.puce__texte {
  white-space: normal;
}

.puce__retirer {
  display: inline-grid;
  place-items: center;
  width: 44px;
  height: 44px;
  margin: -4px -12px -4px -6px;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--doux);
  cursor: pointer;
  touch-action: manipulation;
}

.puces-champ {
  display: grid;
  gap: 10px;
}

.puces-champ__saisie {
  display: flex;
  gap: 8px;
}

.puces--suggestions {
  gap: 6px;
}

/* ---------- pastilles d'etat ---------- */

.pastille {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  max-width: 100%;
  padding: 4px 11px 4px 9px;
  border-radius: 999px;
  font-size: 0.82rem;
  font-weight: 650;
  line-height: 1.25;
}

.pastille__point {
  flex: none;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: currentColor;
}

.pastille--ok {
  background: var(--ok-fond);
  color: var(--ok);
}

.pastille--bientot {
  background: var(--bientot-fond);
  color: var(--bientot);
}

.pastille--perime {
  background: var(--perime-fond);
  color: var(--perime);
}

.pastille--inconnu {
  background: var(--inconnu-fond);
  color: var(--inconnu);
}

.badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 11px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--doux);
  font-size: 0.82rem;
  font-weight: 650;
}

.badge--ordonnance {
  background: var(--bientot-fond);
  color: var(--bientot);
}

.badge--attention {
  background: var(--bientot-fond);
  color: var(--bientot);
}

/* ---------- en-tete d'ecran ---------- */

.entete {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 18px;
}

.entete__titres {
  flex: 1;
  min-width: 0;
}

.entete__titre {
  font-size: 1.75rem;
  font-weight: 760;
  letter-spacing: -0.022em;
  overflow-wrap: anywhere;
}

.entete__sous {
  margin-top: 2px;
  color: var(--doux);
  font-size: 0.95rem;
}

.entete__actions {
  flex: none;
}

/* ---------- cartes de medicaments ---------- */

.liste-cartes {
  display: grid;
  gap: 12px;
  grid-template-columns: minmax(0, 1fr);
}

@media (min-width: 900px) {
  .liste-cartes {
    grid-template-columns: repeat(auto-fill, minmax(21rem, 1fr));
  }
}

.carte-med {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  min-height: 44px;
  padding: 14px;
  border: 1px solid var(--bord);
  border-radius: var(--rayon);
  background: var(--surface);
  box-shadow: var(--ombre);
  color: inherit;
  text-decoration: none;
  touch-action: manipulation;
  -webkit-touch-callout: none;
  transition: transform 150ms ease-out, border-color 150ms ease-out, background-color 150ms;
}

.carte-med:active {
  transform: scale(0.985);
  background: var(--surface-2);
}

.carte-med__corps {
  flex: 1;
  min-width: 0;
  display: grid;
  gap: 4px;
  justify-items: start;
}

.carte-med__titre {
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  overflow-wrap: anywhere;
}

.carte-med__usage {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  overflow: hidden;
  margin-bottom: 4px;
  color: var(--doux);
  font-size: 0.92rem;
  line-height: 1.4;
}

.carte-med--compacte {
  padding: 10px;
  box-shadow: none;
  align-items: center;
}

.carte-med--compacte .vignette {
  width: 52px;
  height: 52px;
  border-radius: 12px;
}

.vignette {
  flex: none;
  width: 76px;
  height: 76px;
  border-radius: 16px;
  overflow: hidden;
  background: var(--accent-fond);
}

.vignette img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.vignette--vide {
  display: grid;
  place-items: center;
  color: var(--accent);
}

/* ---------- etats : vide, erreur, chargement ---------- */

.etat-vide {
  display: grid;
  justify-items: center;
  gap: 14px;
  padding: 40px 16px;
  text-align: center;
}

.etat-vide__rond {
  display: grid;
  place-items: center;
  width: 88px;
  height: 88px;
  border-radius: 50%;
  background: var(--accent-fond);
  color: var(--accent);
}

.etat-vide__rond--erreur {
  background: var(--perime-fond);
  color: var(--perime);
}

.etat-vide__titre {
  font-size: 1.3rem;
  font-weight: 720;
}

.etat-vide__texte {
  max-width: 24rem;
  color: var(--doux);
}

.squelette {
  background: linear-gradient(90deg, var(--surface-2) 25%, var(--bord) 50%, var(--surface-2) 75%);
  background-size: 200% 100%;
  animation: lueur 1.4s ease-in-out infinite;
  border-radius: 10px;
}

.squelette--ligne {
  height: 16px;
  width: 80%;
}

.squelette--courte {
  width: 45%;
}

.carte-med--squelette .carte-med__corps {
  gap: 10px;
  padding-top: 8px;
}

@keyframes lueur {
  from {
    background-position: 200% 0;
  }
  to {
    background-position: -200% 0;
  }
}

.rond-attente {
  display: inline-block;
  width: 18px;
  height: 18px;
  border: 3px solid color-mix(in srgb, currentColor 25%, transparent);
  border-top-color: currentColor;
  border-radius: 50%;
  animation: tourner 0.9s linear infinite;
}

.rond-attente--grand {
  width: 44px;
  height: 44px;
  border-width: 4px;
  color: var(--accent);
}

@keyframes tourner {
  to {
    transform: rotate(360deg);
  }
}

/* ---------- bandeaux ---------- */

.bandeau {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 16px;
  padding: 12px 14px;
  border-radius: 14px;
  background: var(--accent-fond);
  color: var(--texte);
  font-size: 0.95rem;
}

.bandeau__icone {
  margin-top: 2px;
  color: var(--accent);
}

.bandeau--attention {
  background: var(--bientot-fond);
}

.bandeau--attention .bandeau__icone {
  color: var(--bientot);
}

.bandeau--danger {
  background: var(--perime-fond);
}

.bandeau--danger .bandeau__icone {
  color: var(--perime);
}

.bandeau__texte {
  min-width: 0;
}

.bandeau-alerte {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 52px;
  margin-bottom: 14px;
  padding: 10px 16px;
  border: 0;
  border-radius: 14px;
  text-align: left;
  font-size: 1rem;
  cursor: pointer;
  touch-action: manipulation;
  transition: transform 120ms ease-out;
}

.bandeau-alerte:active {
  transform: scale(0.99);
}

.bandeau-alerte--perime {
  background: var(--perime-fond);
  color: var(--perime);
}

.bandeau-alerte--bientot {
  background: var(--bientot-fond);
  color: var(--bientot);
}

.bandeau-alerte__aide {
  font-weight: 500;
  opacity: 0.9;
}

.bandeau-maj {
  position: fixed;
  z-index: 60;
  top: 0;
  left: 0;
  right: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: calc(env(safe-area-inset-top, 0px) + 8px) 16px 8px;
  background: var(--bandeau-fond);
  color: var(--bandeau-texte);
  font-weight: 600;
  box-shadow: var(--ombre);
}

/* ---------- boite de dialogue ---------- */

.dialogue {
  width: min(92vw, 26rem);
  padding: 0;
  border: 0;
  border-radius: 22px;
  background: var(--surface);
  color: var(--texte);
  box-shadow: var(--ombre-forte);
}

.dialogue::backdrop {
  background: rgba(10, 20, 15, 0.55);
}

.dialogue[open] {
  animation: apparition 180ms ease-out;
}

@keyframes apparition {
  from {
    opacity: 0;
    transform: translateY(8px) scale(0.98);
  }
}

.dialogue__corps {
  display: grid;
  gap: 10px;
  padding: 22px;
}

.dialogue__titre {
  font-size: 1.2rem;
  font-weight: 720;
}

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

.dialogue__actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 8px;
}

/* ---------- messages courts ---------- */

#toasts {
  position: fixed;
  z-index: 70;
  left: 0;
  right: 0;
  bottom: calc(env(safe-area-inset-bottom, 0px) + 76px);
  display: grid;
  justify-items: center;
  gap: 8px;
  padding: 0 16px;
  pointer-events: none;
}

@media (min-width: 900px) {
  #toasts {
    bottom: 28px;
  }
}

.toast {
  max-width: 28rem;
  padding: 12px 18px;
  border-radius: 14px;
  background: var(--texte);
  color: var(--fond);
  font-weight: 600;
  box-shadow: var(--ombre-forte);
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 180ms ease-out, transform 180ms ease-out;
}

.toast--visible {
  opacity: 1;
  transform: none;
}

.toast--erreur {
  background: var(--urgence);
  color: #fff;
}

/* ---------- divers ---------- */

.liste-simple {
  margin: 0;
  padding-left: 1.2rem;
  display: grid;
  gap: 6px;
}

.etat-ok {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--ok);
  font-weight: 650;
}

.details summary {
  min-height: 44px;
  display: flex;
  align-items: center;
  color: var(--accent);
  font-weight: 650;
  cursor: pointer;
}

.details__bloc {
  padding: 4px 0 8px;
}

.mention {
  margin-top: 8px;
  color: var(--doux);
  font-size: 0.82rem;
  text-align: center;
}
