/* ===================== COMPOSANTS PARTAGÉS ===================== */

/* --- Cartes --- */
.carte {
  background: var(--surface);
  border: 1px solid var(--trait);
  border-radius: var(--r-lg);
  box-shadow: var(--ombre-1);
}
.carte--pad { padding: 20px; }

/* --- Statistiques --- */
.grille-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }
.stat {
  background: var(--surface); border: 1px solid var(--trait);
  border-radius: var(--r-lg); padding: 18px 18px 16px;
  position: relative; overflow: hidden;
}
.stat::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--bleu); }
.stat__val { font-family: var(--serif); font-size: 34px; font-weight: 600; line-height: 1; color: var(--encre); }
.stat__lib { font-size: 12.5px; color: var(--gris); margin-top: 8px; letter-spacing: .01em; }
.stat__ic {
  position: absolute; right: 14px; top: 14px;
  width: 44px; height: 44px; border-radius: 13px;
  display: grid; place-items: center;
  background: var(--bleu-clair); color: var(--bleu);
}
.stat--or::before { background: var(--or); }
.stat--or .stat__ic { background: var(--or-clair); color: #9a6f1f; }
.stat--vert::before { background: var(--vert); }
.stat--vert .stat__ic { background: #e1f0ee; color: var(--vert); }
.stat--violet::before { background: #5B3A8C; }
.stat--violet .stat__ic { background: #ece6f5; color: #5B3A8C; }

/* --- Boutons --- */
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  font-family: var(--sans); font-size: 14px; font-weight: 600;
  padding: 10px 16px; border-radius: var(--r-sm);
  border: 1px solid transparent; cursor: pointer;
  transition: background .15s, border-color .15s, box-shadow .15s, transform .05s;
  text-decoration: none; line-height: 1;
}
.btn:active { transform: translateY(1px); }
.btn--primaire { background: var(--bleu); color: #fff; }
.btn--primaire:hover { background: #001b86; text-decoration: none; color:#fff; }
.btn--sec { background: var(--surface); color: var(--bleu); border-color: var(--trait-fort); }
.btn--sec:hover { background: var(--surface-2); text-decoration: none; }
.btn--fantome { background: transparent; color: var(--gris); border-color: var(--trait); }
.btn--fantome:hover { background: var(--surface-2); text-decoration: none; }
.btn--or { background: var(--or); color: #3a2905; }
.btn--or:hover { background: #b8831f; text-decoration:none; }
.btn--bloc { width: 100%; justify-content: center; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* --- Badges --- */
.badge {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 11.5px; font-weight: 600; letter-spacing: .02em;
  padding: 4px 10px; border-radius: 999px;
  background: var(--bleu-clair); color: var(--bleu);
}
.badge--point::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.badge--dispo { background: #E4F3EC; color: #1E6A63; }
.badge--bientot { background: #F3EEE0; color: #9A6B12; }

/* --- Champ de recherche --- */
.recherche { position: relative; }
.recherche input {
  width: 100%; height: 42px;
  padding: 0 14px 0 40px;
  border: 1px solid var(--trait); border-radius: var(--r-sm);
  background: var(--surface); font-family: var(--sans); font-size: 14px; color: var(--encre);
}
.recherche input:focus { outline: none; border-color: var(--bleu); box-shadow: 0 0 0 3px var(--bleu-clair); }
.recherche svg { position: absolute; left: 13px; top: 50%; transform: translateY(-50%); color: var(--gris-clair); }

/* Résultats de recherche globale (menu déroulant) */
.res-recherche {
  position: absolute; left: 0; right: 0; top: calc(100% + 8px);
  background: var(--surface); border: 1px solid var(--trait);
  border-radius: var(--r-md); box-shadow: var(--ombre-3);
  max-height: 60vh; overflow-y: auto; z-index: 60; padding: 6px;
}
.res-item { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: var(--r-sm); cursor: pointer; }
.res-item:hover, .res-item.survol { background: var(--surface-2); }
.res-item__pastille { flex: 0 0 34px; height: 34px; border-radius: 8px; display: grid; place-items: center; color: #fff; font-weight: 600; font-size: 12px; }
.res-item__txt b { display: block; font-size: 13.5px; }
.res-item__txt small { color: var(--gris); font-size: 12px; }
.res-groupe-titre { font-size: 10.5px; text-transform: uppercase; letter-spacing: .12em; color: var(--gris-clair); padding: 10px 12px 4px; }
.res-vide { padding: 22px; text-align: center; color: var(--gris); font-size: 13.5px; }

/* --- Grille de fiches --- */
.grille-fiches { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }
.fiche-carte {
  background: var(--surface); border: 1px solid var(--trait);
  border-radius: var(--r-lg); padding: 18px; display: flex; flex-direction: column;
  transition: box-shadow .18s, border-color .18s, transform .18s;
}
.fiche-carte:hover { box-shadow: var(--ombre-2); border-color: var(--trait-fort); transform: translateY(-2px); }
.fiche-carte__haut { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; margin-bottom: 10px; }
.fiche-num {
  font-family: var(--serif); font-size: 12px; font-weight: 600;
  color: var(--gris); border: 1px solid var(--trait); border-radius: 6px; padding: 3px 8px;
}
.fiche-carte h3 { font-size: 16.5px; margin: 2px 0 8px; line-height: 1.25; }
.fiche-carte p { font-size: 13px; color: var(--gris); margin: 0 0 16px; flex: 1; }
.fiche-carte__pied { display: flex; align-items: center; justify-content: space-between; gap: 10px; }

/* --- Onglets thématiques --- */
.onglets { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 22px; }
.onglet {
  border: 1px solid var(--trait); background: var(--surface);
  padding: 8px 14px; border-radius: 999px; font-size: 13.5px; font-weight: 600;
  color: var(--gris); cursor: pointer; display: inline-flex; align-items: center; gap: 8px;
  transition: all .15s;
}
.onglet:hover { border-color: var(--trait-fort); }
.onglet.actif { background: var(--encre); color: #fff; border-color: var(--encre); }
.onglet__pastille { width: 9px; height: 9px; border-radius: 50%; }
.onglet__compte { font-size: 11px; opacity: .8; }

/* --- Formulaires --- */
.champ { margin-bottom: 16px; }
.champ label { display: block; font-size: 13px; font-weight: 600; color: var(--encre); margin-bottom: 6px; }
.champ .requis { color: var(--rouge); margin-left: 3px; }
.saisie,
.champ input[type=text], .champ input[type=password], .champ input[type=email], .champ input[type=tel], .champ input[type=date], .champ input[type=number], .champ input[type=time], .champ input[type=search], .champ input[type=url], .champ select, .champ textarea {
  width: 100%; padding: 10px 12px;
  border: 1px solid var(--trait); border-radius: var(--r-sm);
  font-family: var(--sans); font-size: 14px; color: var(--encre); background: var(--surface);
}
/* Liste déroulante : flèche personnalisée pour un rendu homogène (sinon le
   select natif paraît « brut » à côté des champs de saisie). */
select.saisie,
.champ select {
  appearance: none; -webkit-appearance: none; -moz-appearance: none;
  padding-right: 34px; cursor: pointer;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%235A6577' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'><polyline points='6 9 12 15 18 9'/></svg>");
  background-repeat: no-repeat; background-position: right 12px center;
}
textarea.saisie,
.champ textarea { min-height: 90px; resize: vertical; }
.saisie:focus,
.champ input:focus, .champ select:focus, .champ textarea:focus { outline: none; border-color: var(--bleu); box-shadow: 0 0 0 3px var(--bleu-clair); }
.champ__aide { font-size: 12px; color: var(--gris-clair); margin-top: 5px; }
.champ-radios { display: flex; flex-wrap: wrap; gap: 8px; }
.champ-radios label {
  display: inline-flex; align-items: center; gap: 7px; font-weight: 500;
  border: 1px solid var(--trait); border-radius: var(--r-sm); padding: 8px 12px; cursor: pointer; margin: 0;
}
.champ-radios label:has(input:checked) { border-color: var(--bleu); background: var(--bleu-clair); }
.grille-champs { display: grid; grid-template-columns: 1fr 1fr; gap: 0 18px; }
.grille-champs .plein { grid-column: 1 / -1; }

/* Tableau éditable dans les formulaires */
.tbl-editable { width: 100%; border-collapse: collapse; font-size: 13px; }
.tbl-scroll { overflow-x: auto; }
.tbl-scroll .tbl-editable { min-width: 560px; }
.tbl-editable th { text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: .04em; color: var(--gris); padding: 6px 8px; border-bottom: 1px solid var(--trait); }
.tbl-editable td { padding: 4px; border-bottom: 1px solid var(--surface-2); }
.champ .tbl-editable input { width: 100%; border: 1px solid transparent; padding: 7px 8px; border-radius: 5px; font-family: var(--sans); font-size: 13px; background: var(--surface-2); }
.champ .tbl-editable input:focus { outline: none; border-color: var(--bleu); background: #fff; }
.champ .tbl-editable td.verrou input { background: var(--bleu-clair); color: var(--bleu); font-weight: 600; }
.tbl-actions { display: flex; gap: 8px; margin-top: 10px; }
.btn-ligne { border: 1px dashed var(--trait-fort); background: transparent; color: var(--gris); border-radius: var(--r-sm); padding: 7px 12px; font-size: 13px; font-weight: 600; cursor: pointer; }
.btn-ligne:hover { border-color: var(--bleu); color: var(--bleu); }
.btn-suppr { border: none; background: transparent; color: var(--gris-clair); cursor: pointer; padding: 4px; border-radius: 4px; }
.btn-suppr:hover { color: var(--rouge); background: #fbe9ec; }

/* --- État vide --- */
.vide { text-align: center; padding: 60px 20px; color: var(--gris); }
.vide svg { color: var(--trait-fort); margin-bottom: 14px; }
.vide h3 { color: var(--encre); }

/* --- Séparateur de section --- */
.section-titre { display: flex; align-items: center; gap: 12px; margin: 8px 0 16px; }
.section-titre h2 { font-size: 19px; margin: 0; }
.section-titre .ligne { flex: 1; height: 1px; background: var(--trait); }

@media (max-width: 640px) {
  .grille-stats { grid-template-columns: 1fr 1fr; }
  .grille-champs { grid-template-columns: 1fr; }
}

/* Annuaire alimenté par le SIGE : la provenance remplace le bouton d'ajout. */
.etiquette-source {
  font-family: var(--sans); font-size: .74rem; font-weight: 600;
  letter-spacing: .03em; color: var(--gris, #5A6577);
  background: var(--surface-2, #eef1f6); border: 1px solid var(--bord, #dbe1ea);
  border-radius: 999px; padding: 7px 14px; white-space: nowrap;
}

/* Formulaire d'annuaire en volets : la trentaine de champs alignés sur le SIGE
   se lit par blocs — identité, naissance, scolarité, adresse, parents. */
.form-volet { border: 1px solid var(--bord, #dbe1ea); border-radius: var(--r-2, 8px); margin-bottom: 10px; background: #fff; }
.form-volet > summary {
  cursor: pointer; padding: 11px 14px; font-family: var(--sans); font-weight: 600;
  font-size: .9rem; color: var(--bleu, #00209F); list-style: none;
  display: flex; align-items: center; gap: 8px;
}
.form-volet > summary::-webkit-details-marker { display: none; }
.form-volet > summary::before { content: '▸'; transition: transform .15s; display: inline-block; }
.form-volet[open] > summary::before { transform: rotate(90deg); }
.form-volet > summary:hover { background: rgba(0,32,159,.04); }
.form-volet > .form-grille { padding: 4px 14px 14px; }

/* Choix multiple : le périmètre d'un inspecteur, une case par école. */
.champ-multi {
  display: flex; flex-direction: column; gap: 6px;
  max-height: 190px; overflow-y: auto;
  border: 1px solid var(--bord, #dbe1ea); border-radius: var(--r-2, 8px);
  padding: 10px 12px; background: #fff;
}
.champ-multi label { display: flex; align-items: center; gap: 8px; font-size: .88rem; cursor: pointer; }
.champ-multi input { margin: 0; }
.champ-multi--vide { color: var(--gris, #5A6577); font-style: italic; font-size: .85rem; }

/* Champ renseigné par le SIGE : affiché, non modifiable. */
.etiquette-sige {
  font-family: var(--sans); font-size: .62rem; font-weight: 700;
  letter-spacing: .06em; color: #8a6114; background: rgba(200,145,42,.16);
  border-radius: 999px; padding: 2px 7px; margin-left: 6px; vertical-align: middle;
}
.champ input[readonly] {
  background: var(--surface-2, #eef1f6); color: var(--gris, #5A6577); cursor: default;
}
