/* =========================================================
   Bilan de competences - composants d'interface transverses.

     1. menu deroulant de l'en-tete
     2. notifications en coin superieur droit
     3. rubriques de la FAQ

   Comme le reste du site : aucune couleur en dur, uniquement les
   variables de charte definies dans public/css/style.css, pour que
   /admin/apparence pilote aussi ces composants.
   ========================================================= */

/* --------------------------- Menu deroulant ----------------------------- */
/* Une seule barre de navigation dans le site : les sections de l'espace
   personnel sont regroupees ici, ouvertes au survol, au clic et au clavier. */

.nav-menu { position: relative; }

.nav-menu-btn {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  padding: .45rem .7rem;
  border: 0;
  background: none;
  border-radius: var(--radius-sm);
  font: inherit;
  font-size: .94rem;
  font-weight: 500;
  color: var(--header-text);
  cursor: pointer;
}
.nav-menu-btn:hover,
.nav-menu-btn.active,
.nav-menu[data-open] .nav-menu-btn {
  background: var(--header-hover-bg);
  color: var(--brand);
}
.nav-menu-btn:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }

.nav-menu-caret {
  width: 0; height: 0;
  border-left: 4px solid transparent;
  border-right: 4px solid transparent;
  border-top: 5px solid currentColor;
  transition: transform .18s ease;
}
.nav-menu[data-open] .nav-menu-caret { transform: rotate(180deg); }

.nav-menu-panel {
  position: absolute;
  top: calc(100% + .4rem);
  right: 0;
  min-width: 220px;
  display: flex;
  flex-direction: column;
  padding: .4rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  opacity: 0;
  visibility: hidden;
  transform: translateY(-6px);
  transition: opacity .16s ease, transform .16s ease, visibility .16s;
  z-index: 50;
}
.nav-menu:hover .nav-menu-panel,
.nav-menu:focus-within .nav-menu-panel,
.nav-menu[data-open] .nav-menu-panel {
  opacity: 1; visibility: visible; transform: translateY(0);
}
/* Bande invisible entre le bouton et le panneau : le survol ne se coupe pas. */
.nav-menu-panel::before { content: ""; position: absolute; inset: -.5rem 0 100% 0; }

.nav-menu-panel a {
  padding: .5rem .8rem;
  border-radius: var(--radius-sm);
  color: var(--ink);
  text-decoration: none;
  font-size: .93rem;
  white-space: nowrap;
}
.nav-menu-panel a:hover { background: var(--bg-brand-soft); color: var(--brand); }
.nav-menu-panel a.active { background: var(--bg-brand-soft); color: var(--brand); font-weight: 600; }

/* Sur mobile le menu est deplie : il n'y a pas de survol au doigt. */
@media (max-width: 760px) {
  .nav-menu { width: 100%; }
  .nav-menu-btn { width: 100%; justify-content: space-between; }
  .nav-menu-panel {
    position: static; opacity: 1; visibility: visible; transform: none;
    border: 0; box-shadow: none; padding: 0 0 0 .8rem; min-width: 0;
  }
  .nav-menu-panel::before { display: none; }
  .nav-menu-caret { display: none; }
}

/* ------------------------- 2. Notifications ----------------------------- */

.toasts {
  position: fixed;
  top: 5.4rem;
  right: 1rem;
  z-index: 90;
  display: flex;
  flex-direction: column;
  gap: .7rem;
  width: min(380px, calc(100vw - 2rem));
  pointer-events: none;
}

.toast {
  position: relative;
  display: flex;
  align-items: flex-start;
  gap: .75rem;
  padding: .9rem 2.4rem .9rem .9rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-left: 4px solid var(--muted);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  pointer-events: auto;
  opacity: 0;
  transform: translateX(24px);
  transition: opacity .28s ease, transform .28s cubic-bezier(.22, .61, .36, 1);
}
.toast.is-in { opacity: 1; transform: none; }
.toast.is-out { opacity: 0; transform: translateX(24px); }

.toast-icone {
  flex: 0 0 auto;
  width: 22px;
  height: 22px;
  margin-top: .1rem;
  display: grid;
  place-items: center;
  border-radius: 50%;
  font-size: .8rem;
  font-weight: 700;
  line-height: 1;
  color: var(--btn-text);
  background: var(--muted);
}
.toast-corps { min-width: 0; }
.toast-titre {
  display: block;
  font-size: .74rem;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--muted);
  margin-bottom: .15rem;
}
.toast-texte { margin: 0; font-size: .93rem; line-height: 1.45; color: var(--ink); }

.toast-fermer {
  position: absolute;
  top: .45rem;
  right: .45rem;
  width: 26px;
  height: 26px;
  border: 0;
  background: none;
  border-radius: 50%;
  color: var(--muted);
  font-size: 1.2rem;
  line-height: 1;
  cursor: pointer;
}
.toast-fermer:hover { background: var(--bg-soft); color: var(--ink); }
.toast-fermer:focus-visible { outline: 2px solid var(--brand); outline-offset: 1px; }

/* Minuteur : la barre se vide, et se met en pause au survol. */
.toast-minuteur {
  position: absolute;
  left: 0;
  bottom: 0;
  height: 3px;
  width: 100%;
  transform-origin: left center;
  background: var(--muted);
  opacity: .35;
}
.toast-minuteur.is-running { animation: toast-timer linear forwards; }
.toast:hover .toast-minuteur,
.toast:focus-within .toast-minuteur { animation-play-state: paused; }

@keyframes toast-timer {
  from { transform: scaleX(1); }
  to   { transform: scaleX(0); }
}

.toast-success { border-left-color: var(--ok); }
.toast-success .toast-icone { background: var(--ok); }
.toast-success .toast-minuteur { background: var(--ok); }

.toast-info { border-left-color: var(--brand-light); }
.toast-info .toast-icone { background: var(--brand-light); }
.toast-info .toast-minuteur { background: var(--brand-light); }

.toast-error { border-left-color: var(--err); }
.toast-error .toast-icone { background: var(--err); }
.toast-error .toast-minuteur { display: none; }

@media (max-width: 760px) {
  .toasts { top: auto; bottom: 1rem; right: 1rem; left: 1rem; width: auto; }
  .toast { transform: translateY(16px); }
  .toast.is-out { transform: translateY(16px); }
}

/* ---------------------------- 3. FAQ ------------------------------------ */

.faq-jump {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem;
  margin: 1.5rem 0 .5rem;
}
.faq-jump a {
  display: inline-flex;
  align-items: center;
  gap: .45rem;
  padding: .4rem .9rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--brand);
  text-decoration: none;
  font-size: .88rem;
  font-weight: 600;
}
.faq-jump a:hover { border-color: var(--accent); color: var(--accent-dark); }
.faq-count {
  min-width: 20px;
  padding: 0 .35rem;
  border-radius: 999px;
  background: var(--bg-brand-soft);
  color: var(--brand-light);
  font-size: .76rem;
  text-align: center;
}

.faq-cat {
  margin-top: 2.6rem;
  padding-bottom: .5rem;
  border-bottom: 2px solid var(--accent);
  scroll-margin-top: 90px;
  font-size: 1.35rem;
}
.faq-group { margin-top: 1rem; }

@media (prefers-reduced-motion: reduce) {
  .nav-menu-panel, .nav-menu-caret { transition: none; }
  .toast { transition: none; }
  .toast-minuteur.is-running { animation: none; }
}

@media print {
  .toasts, .faq-jump { display: none !important; }
}

/* ======================= 4. Champs enrichis =============================
   Selecteur de pays avec drapeaux, selection multiple, disponibilites.
   Le HTML natif reste dessous : ces styles n'habillent que la surface.
   ======================================================================= */

/* -------------------------- Selecteur de pays --------------------------- */

.pays { position: relative; }

/* Le <select> d'origine porte la valeur et la validation du navigateur :
   il reste focalisable pour que le message d'erreur natif s'affiche ici. */
.pays-natif {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  pointer-events: none;
}

.pays-btn {
  display: flex;
  align-items: center;
  gap: .6rem;
  width: 100%;
  padding: .7rem .85rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  font: inherit;
  font-size: 1rem;
  color: var(--ink);
  text-align: left;
  cursor: pointer;
}
.pays-btn:hover { border-color: var(--accent); }
.pays-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.pays-vide { color: var(--muted); }
.pays-caret {
  margin-left: auto;
  width: 0; height: 0;
  border-left: 5px solid transparent;
  border-right: 5px solid transparent;
  border-top: 6px solid var(--muted);
}

/* Le drapeau : image locale (paquet flag-icons), jamais un émoji —
   Windows n'affiche pas les drapeaux émoji. */
.pays-drapeau {
  flex: 0 0 auto;
  width: 24px;
  height: 18px;
  border-radius: 2px;
  background: var(--bg-soft) center / cover no-repeat;
  box-shadow: inset 0 0 0 1px rgba(16, 38, 63, .18);
}

.pays-panel {
  position: absolute;
  top: calc(100% + .3rem);
  left: 0;
  right: 0;
  z-index: 40;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: .5rem;
}
.pays-recherche {
  width: 100%;
  margin-bottom: .4rem;
  padding: .5rem .6rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  font: inherit;
  font-size: .95rem;
}
.pays-liste {
  list-style: none;
  margin: 0;
  padding: 0;
  max-height: 280px;
  overflow-y: auto;
}
.pays-groupe {
  padding: .5rem .6rem .25rem;
  font-size: .74rem;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--muted);
}
.pays-option {
  display: flex;
  align-items: center;
  gap: .6rem;
  padding: .45rem .6rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: .95rem;
}
.pays-option:hover,
.pays-option.is-actif { background: var(--bg-brand-soft); }
.pays-option[aria-selected="true"] { font-weight: 600; color: var(--brand); }
.pays-nom { flex: 1 1 auto; }
.pays-code { font-size: .76rem; color: var(--muted); letter-spacing: .05em; }
.pays-aucun { padding: .7rem .6rem; color: var(--muted); font-size: .93rem; }

/* Champ pré-rempli automatiquement : on le signale brièvement. */
.champ-prerempli input,
.champ-prerempli .pays-btn {
  animation: champ-signale 1.6s ease;
}
@keyframes champ-signale {
  0%, 70% { border-color: var(--accent); box-shadow: 0 0 0 3px var(--bg-brand-soft); }
  100%    { border-color: var(--line); box-shadow: none; }
}

/* -------------------------- Selection multiple -------------------------- */

.tags {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: .5rem;
  background: var(--surface);
}
.tags:focus-within { border-color: var(--accent); box-shadow: 0 0 0 2px var(--bg-brand-soft); }
.tags-puces { display: flex; flex-wrap: wrap; gap: .4rem; }
.tags-puces:not(:empty) { margin-bottom: .45rem; }
.tag-puce {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  padding: .25rem .3rem .25rem .7rem;
  border-radius: 999px;
  background: var(--accent);
  color: var(--btn-text);
  font-size: .88rem;
  font-weight: 600;
}
.tag-retirer {
  width: 20px;
  height: 20px;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, .22);
  color: inherit;
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
}
.tag-retirer:hover { background: rgba(255, 255, 255, .4); }
.tags-saisie {
  width: 100%;
  border: 0;
  padding: .3rem .2rem;
  font: inherit;
  font-size: .95rem;
  background: transparent;
  color: var(--ink);
}
.tags-saisie:focus { outline: none; }

/* --------------------------- Disponibilites ----------------------------- */

.dispos { display: flex; flex-direction: column; gap: .5rem; }
.dispo-jour {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
  padding: .6rem .8rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--bg-soft);
  transition: border-color .2s ease, background .2s ease;
}
.dispo-jour.is-on { border-color: var(--accent); background: var(--surface); }
.dispo-check {
  display: flex;
  align-items: center;
  gap: .5rem;
  min-width: 140px;
  font-weight: 600;
  color: var(--brand);
  cursor: pointer;
}
.dispo-heures { display: flex; align-items: center; gap: .8rem; margin-left: auto; }
.dispo-heures label { display: inline-flex; align-items: center; gap: .35rem; font-weight: 400; }
.dispo-legende { color: var(--muted); font-size: .88rem; }
.dispo-heures input[type="time"] { width: auto; padding: .35rem .5rem; }
.dispo-heures input:disabled { opacity: .45; }
.dispo-resume { margin-top: .6rem; }

.field-hint.est-valide { color: var(--ok); font-weight: 600; }
.field-hint.est-invalide { color: var(--err); font-weight: 600; }

/* Rappel de ce que le profil du beneficiaire dit deja sur une question du
   bilan. Volontairement discret : c'est une aide a la saisie, pas une reponse.
   Voir src/services/questionnaires.js. */
.profil-rappel {
  display: flex;
  flex-direction: column;
  gap: .15rem;
  margin: .1rem 0 .5rem;
  padding: .5rem .7rem;
  border-left: 3px solid var(--accent);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  background: var(--bg-soft);
  font-size: .88rem;
  line-height: 1.45;
}
.profil-rappel-titre {
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .04em;
  font-size: .76rem;
  color: var(--muted);
}
.profil-rappel-item { color: var(--ink); }

/* ------------------------------------------------------------------ */
/* Avancement : ce qui reste a completer                              */
/*                                                                    */
/* Trois etats, du plus a faire au plus abouti :                      */
/*   jaune  — rien de saisi ;                                         */
/*   orange — une valeur est proposee depuis le profil, pas confirmee ;*/
/*   vert   — la reponse est enregistree.                             */
/* La couleur ne porte jamais seule l'information : chaque bloc affiche*/
/* aussi le libelle de son etat, lisible sans distinguer les teintes.  */
/* ------------------------------------------------------------------ */
.etat { border-left: 4px solid var(--line); padding-left: .9rem; }
.etat-vide { border-left-color: var(--todo); }
.etat-partiel { border-left-color: var(--warn); }
.etat-complet { border-left-color: var(--ok); }

.etat-badge {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  padding: .1rem .5rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: .76rem;
  font-weight: 600;
  letter-spacing: .02em;
  white-space: nowrap;
}
.etat-badge::before {
  content: "";
  width: .5rem;
  height: .5rem;
  border-radius: 50%;
  background: currentColor;
}
.etat-vide > .etat-badge,
.etat-badge.etat-vide { color: var(--todo); border-color: var(--todo-line); background: var(--todo-bg); }
.etat-partiel > .etat-badge,
.etat-badge.etat-partiel { color: var(--warn); border-color: var(--warn-line); background: var(--warn-bg); }
.etat-complet > .etat-badge,
.etat-badge.etat-complet { color: var(--ok); border-color: var(--ok-line); background: var(--ok-bg); }

/* En-tete d'une question : le numero et le libelle a gauche, l'etat a droite. */
.field-etat {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: .8rem;
  flex-wrap: wrap;
}

/* Carte de questionnaire coloree sur toute sa bordure gauche. */
.card.etat { padding-left: 1.1rem; }

/* Legende des couleurs, en tete de questionnaire. */
.etat-legende {
  display: flex;
  flex-wrap: wrap;
  gap: .4rem .7rem;
  margin: 0 0 1rem;
  padding: 0;
  list-style: none;
}

@media (max-width: 640px) {
  .dispo-jour { flex-direction: column; align-items: stretch; }
  .dispo-heures { margin-left: 0; }
}

@media (prefers-reduced-motion: reduce) {
  .champ-prerempli input, .champ-prerempli .pays-btn { animation: none; }
}

/* ======================= 5. Connexion a un ERP ==========================
   Choix du connecteur : des cartes plutot qu'une liste deroulante, pour que
   la difference entre « aucun » et un ERP branche saute aux yeux.
   ======================================================================= */

.erp-choix {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: .8rem;
}
.erp-option {
  display: flex;
  align-items: flex-start;
  gap: .7rem;
  padding: .9rem 1rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  cursor: pointer;
  transition: border-color .18s ease, background .18s ease;
}
.erp-option:hover { border-color: var(--accent); }
.erp-option.is-on { border-color: var(--accent); background: var(--bg-brand-soft); }
.erp-option input { margin-top: .25rem; flex: 0 0 auto; }
.erp-option-corps { display: flex; flex-direction: column; gap: .15rem; }
.erp-option-corps strong { color: var(--brand); }
.erp-option-corps .muted { font-size: .88rem; }

.card.is-ok { border-left: 4px solid var(--ok); }
.card.is-warn { border-left: 4px solid var(--warn); }

.erp-bloc[hidden] { display: none; }

/* ======================= 6. Signature manuscrite ========================
   Cadre de signature de l'acceptation d'un devis.
   ======================================================================= */

.signature-mention {
  margin: 0 0 .6rem;
  padding: .7rem .9rem;
  background: var(--bg-soft);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius-sm);
  font-size: .9rem;
  font-style: italic;
  color: var(--ink);
}

.signature {
  position: relative;
  border: 2px dashed var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--signature-paper); /* le trace est enregistre sur fond blanc */
  transition: border-color .2s ease;
}
.signature.is-signe { border-style: solid; border-color: var(--accent); }
.signature.est-manquante { border-color: var(--err); }

.signature-zone {
  display: block;
  width: 100%;
  height: 170px;
  cursor: crosshair;
  border-radius: var(--radius-sm);
}

/* Ligne de signature, comme sur un document papier. */
.signature-ligne {
  position: absolute;
  left: 8%;
  right: 8%;
  bottom: 34px;
  border-bottom: 1px solid var(--line);
  pointer-events: none;
}
.signature-invite {
  position: absolute;
  left: 8%;
  bottom: 12px;
  font-size: .82rem;
  color: var(--muted);
  pointer-events: none;
  letter-spacing: .04em;
}

.signature-actions {
  display: flex;
  align-items: center;
  gap: .8rem;
  flex-wrap: wrap;
  margin-top: .6rem;
}

/* Trace conserve, affiche apres la decision et dans l'administration. */
.signature-vue {
  max-width: 260px;
  height: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--signature-paper);
  padding: .2rem;
}
.signature-preuve { font-size: .84rem; color: var(--muted); }
.signature-preuve dt { font-weight: 600; color: var(--brand); }
.signature-preuve dd { margin: 0 0 .4rem; word-break: break-word; }

@media (max-width: 640px) {
  .signature-zone { height: 200px; }
}
