/* Portail Fatras — style unique, sans framework. Palette sobre, lisible,
 * pensé pour un usage perso au quotidien (desktop et mobile). */

:root {
  --fond: #f6f4ef;
  --carte: #ffffff;
  --encre: #2c2a26;
  --encre-douce: #7a756c;
  --accent: #7a5c3d;          /* brun "osier" */
  --accent-fonce: #5d452c;
  --accent-clair: #ede4d8;
  --bord: #e2ddd3;
  --ok: #4c8f4f;
  --alerte: #d9822b;
  --erreur: #c0392b;
  --ombre: 0 1px 3px rgba(60, 50, 30, .12);
  --rayon: 10px;

  /* Couleurs isolées ici (plutôt qu'en dur dans les règles) uniquement
   * parce que le mode sombre doit pouvoir les redéfinir. */
  --fond-champ: #fff;
  --resume-txt: #4d493f;
  --fond-code: #f4f1ea;
  --voyant-defaut: #bbb;
  --score-faible: #a9a397;
  --fond-avertissement: #fdf3e4;
  --fond-erreur-douce: #fdeae7;
  --toast-fond: #2c2a26;   /* volontairement fixe (indépendant du thème) */
}

/* ------------------------------ Mode sombre ----------------------------- */
:root[data-theme="sombre"] {
  --fond: #1c1a17;
  --carte: #262320;
  --encre: #e9e4da;
  --encre-douce: #a89f8f;
  --accent: #c99a5b;
  --accent-fonce: #e3bb84;
  --accent-clair: #3a3126;
  --bord: #3d382f;
  --ok: #5fae63;
  --alerte: #d99b45;
  --erreur: #d9695b;
  --ombre: 0 1px 4px rgba(0, 0, 0, .5);

  --fond-champ: #211e1a;
  --resume-txt: #c9c2b4;
  --fond-code: #201d19;
  --voyant-defaut: #5a5548;
  --score-faible: #6b6558;
  --fond-avertissement: #3a2f1a;
  --fond-erreur-douce: #3a1f1c;
}

* { box-sizing: border-box; }

html, body {
  margin: 0; padding: 0;
  background: var(--fond); color: var(--encre);
  font: 16px/1.55 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  transition: background-color .15s, color .15s;
}

.cache { display: none !important; }
.discret { color: var(--encre-douce); font-size: .88em; }
.centre { text-align: center; }
.erreur { color: var(--erreur); }
.lien { color: var(--accent); text-decoration: underline; cursor: pointer; }

button {
  font: inherit; cursor: pointer;
  background: var(--accent); color: #fff;
  border: none; border-radius: 7px; padding: .5em 1.1em;
}
button:hover { background: var(--accent-fonce); }
button.secondaire {
  background: transparent; color: var(--accent);
  border: 1px solid var(--accent);
}
button.secondaire:hover { background: var(--accent-clair); }
button:disabled { opacity: .45; cursor: default; }

input[type="text"], input[type="url"], input[type="search"],
input[type="password"], select, textarea {
  font: inherit; color: var(--encre);
  background: var(--fond-champ); border: 1px solid var(--bord); border-radius: 7px;
  padding: .5em .8em; width: 100%;
}
input:focus, textarea:focus, [contenteditable]:focus {
  outline: 2px solid var(--accent-clair); border-color: var(--accent);
}

/* ------------------------------ Connexion ------------------------------ */
#ecran-connexion {
  display: flex; align-items: center; justify-content: center;
  min-height: 100vh;
}
#ecran-connexion.cache { display: none !important; }
#formulaire-connexion {
  background: var(--carte); border-radius: var(--rayon);
  box-shadow: var(--ombre); padding: 2.2em 2.6em; width: 340px;
  text-align: center;
}
#formulaire-connexion h1 { margin: 0 0 .1em; }
#formulaire-connexion input { margin: 1.2em 0 .8em; }
#formulaire-connexion button { width: 100%; }

/* ------------------------------- Header -------------------------------- */
header {
  display: flex; align-items: center; gap: 1.2em;
  background: var(--carte); border-bottom: 1px solid var(--bord);
  padding: .55em 1.2em; position: sticky; top: 0; z-index: 20;
  flex-wrap: wrap;
}
.titre-app { font-size: 1.25em; }
/* Logo panier (remplace l'émoji 🧺) : même taille que lui — 1em du contexte.
 * Source 64×64 pour rester net sur écran HiDPI (affiché 20 à 32 px). */
.logo-panier { height: 1em; width: auto; vertical-align: -.12em; }
#onglets { display: flex; gap: .3em; flex: 1; }
#onglets button {
  background: transparent; color: var(--encre-douce);
  border-radius: 7px 7px 0 0; border-bottom: 3px solid transparent;
  padding: .4em .9em;
}
#onglets button:hover { color: var(--encre); background: var(--accent-clair); }
#onglets button.actif {
  color: var(--accent-fonce); font-weight: 600;
  border-bottom-color: var(--accent);
}
.header-droite { display: flex; gap: .5em; align-items: center; }
/* Boutons emoji de l'en-tête (🧩 extensions, 🔑 changer le mot de passe,
 * 🚪 quitter, ❓ politique de confidentialité) : même gabarit que le bouton
 * thème, l'infobulle (title) porte le sens. 🧩 et ❓ sont des LIENS
 * habillés pareil. */
#bouton-mot-de-passe, #bouton-deconnexion, #bouton-extensions,
#bouton-confidentialite {
  background: transparent; border: none; font-size: 1.15em; line-height: 1;
  padding: 0 .3em;
}
#bouton-extensions, #bouton-confidentialite {
  text-decoration: none; display: inline-block;
}
#bouton-mot-de-passe:hover, #bouton-deconnexion:hover,
#bouton-extensions:hover, #bouton-confidentialite:hover {
  background: transparent; transform: scale(1.15);
}

#bouton-theme {
  background: transparent; border: none; font-size: 1.15em; line-height: 1;
  padding: 0 .3em; color: var(--encre-douce);
}
#bouton-theme:hover { background: transparent; color: var(--encre); }

#voyant-sante {
  background: transparent; border: none; font-size: 1.5em; line-height: 1;
  padding: 0 .2em; color: var(--voyant-defaut);
}
#voyant-sante.ok { color: var(--ok); }
#voyant-sante.degrade { color: var(--alerte); }
#voyant-sante.hors-ligne { color: var(--erreur); }

#panneau-sante {
  background: var(--carte); border-bottom: 1px solid var(--bord);
  padding: .8em 1.4em; font-size: .9em;
  display: flex; gap: 2em; flex-wrap: wrap;
}
#panneau-sante .sonde-ko { color: var(--erreur); font-weight: 600; }

.badge-nombre {
  background: var(--erreur); color: #fff; border-radius: 9px;
  font-size: .75em; padding: 0 .5em; vertical-align: 1px;
}
/* Le compte "En attente" n'est pas une anomalie : couleur neutre. */
.badge-nombre.attente { background: var(--accent); }

/* Bouton ⚙️ "indexer maintenant" : le bouton EST l'indicateur.
 * inactif = rien à indexer, a-indexer = des captures attendent (cliquable),
 * en-cours = indexation en cours (animation). */
#bouton-indexer {
  background: transparent; border: none; font-size: 1.15em; line-height: 1;
  padding: 0 .3em;
}
#bouton-indexer:hover { background: transparent; }
#bouton-indexer.inactif { opacity: .3; cursor: default; }
#bouton-indexer.a-indexer {
  filter: drop-shadow(0 0 4px var(--alerte));
}
#bouton-indexer.a-indexer:hover { transform: scale(1.15); }
#bouton-indexer.en-cours {
  animation: rotation-indexer 2.2s linear infinite; cursor: default;
}
@keyframes rotation-indexer { to { transform: rotate(360deg); } }

/* ------------------------------- Onglets ------------------------------- */
main.onglet { max-width: 880px; margin: 1.4em auto 4em; padding: 0 1em; }

.carte {
  background: var(--carte); border-radius: var(--rayon);
  box-shadow: var(--ombre); padding: 1.1em 1.4em; margin-bottom: 1.2em;
}
.carte h2 { margin: 0 0 .6em; font-size: 1.05em; color: var(--accent-fonce); }

.rangee { display: flex; gap: .6em; margin-bottom: .6em; }
.rangee input { flex: 1; }
.rangee-droite { justify-content: flex-end; margin-top: .6em; margin-bottom: 0; }

/* ------------------------------- Dépôt --------------------------------- */
#zone-depot {
  border: 2px dashed var(--bord); border-radius: var(--rayon);
  padding: 1.6em; text-align: center; cursor: pointer;
  transition: border-color .15s, background .15s;
}
#zone-depot:hover, #zone-depot.survol {
  border-color: var(--accent); background: var(--accent-clair);
}
#zone-depot p { margin: .2em 0; }

#zone-collage {
  min-height: 7em; max-height: 22em; overflow: auto;
  background: var(--fond-champ); border: 1px solid var(--bord); border-radius: 7px;
  padding: .7em 1em;
}
#zone-collage:empty::before {
  content: attr(data-invite); color: var(--encre-douce);
}
#zone-collage img { max-width: 100%; }

#journal-depot { list-style: none; margin: 0; padding: 0; }
#journal-depot li {
  padding: .45em 0; border-bottom: 1px dashed var(--bord); font-size: .92em;
}
#journal-depot li:last-child { border-bottom: none; }
#journal-depot .picto { margin-right: .5em; }

/* ------------------------------ Recherche ------------------------------ */
.filtres {
  display: grid; grid-template-columns: 1fr 1fr; gap: 1em 2em;
  margin-top: .8em;
}
.filtre label { display: block; font-size: .88em; color: var(--encre-douce); margin-bottom: .25em; }
.filtre output { color: var(--encre); font-weight: 600; }
@media (max-width: 640px) { .filtres { grid-template-columns: 1fr; } }

input[type="range"] { accent-color: var(--accent); }
.glissiere-simple { display: flex; align-items: center; gap: .6em; }
.glissiere-simple input { flex: 1; min-width: 0; }
.glissiere-simple .borne { font-size: .78em; color: var(--encre-douce); }
/* Plage d'ancienneté : libellés alignés des deux curseurs. */
.glissiere-simple .borne-fixe { width: 6.2em; text-align: right; }
.glissiere-simple .valeur-cran {
  width: 4.2em; font-weight: 600; color: var(--encre);
  font-size: .82em; white-space: nowrap;
}

/* ------------------------------ Résultats ------------------------------ */
.barre-resultats {
  display: flex; justify-content: flex-end; align-items: center;
  gap: .5em; margin-bottom: .6em; font-size: .88em; color: var(--encre-douce);
}
.barre-resultats.cache { display: none !important; }
.barre-resultats select { width: auto; padding: .3em .6em; }

.groupe-tag {
  font-size: .78em; font-weight: 600; color: var(--encre-douce);
  text-transform: uppercase; letter-spacing: .04em;
  margin: 1.2em 0 .4em; padding-left: .1em;
}
.groupe-tag:first-child { margin-top: 0; }

.resultat {
  background: var(--carte); border-radius: var(--rayon);
  box-shadow: var(--ombre); padding: .9em 1.2em; margin-bottom: .8em;
  cursor: pointer; transition: transform .06s;
}
.resultat:hover { transform: translateY(-1px); box-shadow: 0 3px 8px rgba(60,50,30,.16); }
.resultat .ligne-titre { display: flex; gap: .7em; align-items: baseline; flex-wrap: wrap; }
.resultat h3 { margin: 0; font-size: 1.02em; flex: 1; min-width: 12em; }
.resultat .resume { margin: .35em 0 .3em; font-size: .92em; color: var(--resume-txt); }
.resultat .pied { display: flex; gap: .8em; align-items: center; flex-wrap: wrap; font-size: .82em; }

.badge-type {
  background: var(--accent-clair); color: var(--accent-fonce);
  padding: .05em .6em; border-radius: 9px; font-size: .78em; white-space: nowrap;
}
.badge-score {
  font-variant-numeric: tabular-nums; font-size: .8em; font-weight: 700;
  padding: .05em .5em; border-radius: 9px; color: #fff; white-space: nowrap;
}
.badge-score.fort { background: var(--ok); }
.badge-score.moyen { background: var(--alerte); }
.badge-score.faible { background: var(--score-faible); }

.tag {
  color: var(--accent); cursor: pointer; white-space: nowrap;
}
.tag:hover { text-decoration: underline; }
.date-resultat { color: var(--encre-douce); margin-left: auto; white-space: nowrap; }

#pagination {
  display: flex; gap: 1em; align-items: center; justify-content: center;
  margin: 1.2em 0;
}
#pagination.cache { display: none !important; }

/* Corbeille discrète, à droite des cartes (résultats, échecs, en attente). */
.bouton-corbeille {
  background: transparent; border: none; color: var(--encre-douce);
  font-size: 1em; line-height: 1; padding: .1em .35em; margin-left: auto;
  opacity: .35; align-self: center;
}
.resultat:hover .bouton-corbeille { opacity: .85; }
.bouton-corbeille:hover {
  background: transparent; color: var(--erreur); opacity: 1;
  transform: scale(1.15);
}

/* Titre cliquable (item issu d'un lien) : sobre, souligné au survol. */
.resultat h3 a { color: inherit; text-decoration: none; }
.resultat h3 a:hover { color: var(--accent); text-decoration: underline; }

/* Boutons "danger" (suppression) et boîte de confirmation. */
button.danger {
  background: transparent; color: var(--erreur);
  border: 1px solid var(--erreur);
}
button.danger:hover:not(:disabled) { background: var(--erreur); color: #fff; }
button.danger:disabled { opacity: .45; }

.voile-confirmation {
  position: fixed; inset: 0; background: rgba(40, 34, 24, .55);
  display: flex; align-items: center; justify-content: center;
  padding: 1em; z-index: 80;   /* au-dessus de la fiche détail (50) */
}
.boite-confirmation {
  background: var(--fond); border-radius: var(--rayon);
  box-shadow: 0 8px 30px rgba(0,0,0,.35); padding: 1.2em 1.4em;
  max-width: 28em; width: 100%;
}
.boite-confirmation p { margin: 0 0 1em; }
/* Boîte de changement de mot de passe (mêmes classes que la confirmation). */
.boite-confirmation input[type="password"] { margin-bottom: .6em; }
.boite-confirmation p.erreur { margin: 0 0 .6em; }

/* ------------------------------ En attente ------------------------------ */
.barre-attente {
  align-items: center; justify-content: space-between;
  margin: .8em 0 0; border-top: 1px dashed var(--bord); padding-top: .8em;
}
.barre-attente.cache { display: none !important; }
.barre-attente label { cursor: pointer; }

.attente-item { display: flex; gap: .8em; align-items: flex-start; cursor: default; }
.attente-item:hover { transform: none; box-shadow: var(--ombre); }
.attente-item .corps-attente { flex: 1; min-width: 0; }
.attente-item .resume { margin-bottom: 0; }
.attente-item .case-attente,
.attente-item .case-attente-place { margin-top: .3em; }
.attente-item .case-attente { width: auto; cursor: pointer; }
.attente-item.en-cours { border-left: 4px solid var(--alerte); }
.attente-item h3 a { word-break: break-all; }

/* -------------------------------- Échecs ------------------------------- */
.echec-item { border-left: 4px solid var(--erreur); }

/* ------------------------------- Détail -------------------------------- */
#voile-detail {
  position: fixed; inset: 0; background: rgba(40, 34, 24, .55);
  display: flex; align-items: flex-start; justify-content: center;
  padding: 3vh 1em; z-index: 50; overflow-y: auto;
}
#voile-detail.cache { display: none !important; }
#fiche-detail {
  background: var(--fond); border-radius: var(--rayon);
  max-width: 860px; width: 100%; margin-bottom: 3vh;
  padding: 1.4em 1.7em; position: relative;
  box-shadow: 0 8px 30px rgba(0,0,0,.35);
}
#fermer-detail {
  position: absolute; top: .7em; right: .7em;
  background: transparent; color: var(--encre-douce);
  font-size: 1.1em; padding: .2em .5em;
}
#fermer-detail:hover { color: var(--erreur); background: transparent; }

#contenu-detail h2 { margin: 0 2em .35em 0; }
.meta-detail {
  display: flex; gap: .8em 1.4em; flex-wrap: wrap; align-items: center;
  font-size: .88em; color: var(--encre-douce); margin-bottom: .9em;
}
.actions-detail { display: flex; gap: .6em; flex-wrap: wrap; margin: .8em 0 1em; }
.actions-detail a, .actions-detail button {
  text-decoration: none; font-size: .92em;
}
.actions-detail a {
  background: var(--accent); color: #fff; border-radius: 7px; padding: .45em 1em;
}
.actions-detail a.secondaire {
  background: transparent; color: var(--accent); border: 1px solid var(--accent);
}
.actions-detail a:hover { background: var(--accent-fonce); color: #fff; }

.section-detail {
  background: var(--carte); border-radius: var(--rayon);
  box-shadow: var(--ombre); padding: .9em 1.2em; margin-bottom: .9em;
}
.section-detail h3 { margin: 0 0 .5em; font-size: .95em; color: var(--accent-fonce); }
.section-detail pre {
  background: var(--fond-code); border-radius: 7px; padding: .8em 1em;
  overflow-x: auto; font-size: .82em; line-height: 1.45;
  white-space: pre-wrap; word-break: break-word;
}
details.section-detail > summary {
  cursor: pointer; font-weight: 600; color: var(--accent-fonce); font-size: .95em;
}
details.section-detail[open] > summary { margin-bottom: .6em; }

.rendu-md :first-child { margin-top: 0; }
.rendu-md :last-child { margin-bottom: 0; }
.rendu-md code { background: var(--fond-code); border-radius: 4px; padding: .05em .3em; }

#editeur-notes textarea {
  min-height: 9em; font-family: ui-monospace, "Cascadia Code", Consolas, monospace;
  font-size: .88em;
}
.avertissement {
  background: var(--fond-avertissement); border-left: 4px solid var(--alerte);
  border-radius: 5px; padding: .5em .9em; font-size: .88em; margin: .4em 0;
}
.erreur-traitement {
  background: var(--fond-erreur-douce); border-left: 4px solid var(--erreur);
  border-radius: 5px; padding: .5em .9em; font-size: .88em; margin: .4em 0;
  white-space: pre-wrap; word-break: break-word;
}

/* -------------------------------- Toasts ------------------------------- */
#zone-toasts {
  position: fixed; bottom: 1.2em; left: 50%; transform: translateX(-50%);
  display: flex; flex-direction: column; gap: .5em; z-index: 100;
  align-items: center; pointer-events: none;
}
.toast {
  background: var(--toast-fond); color: #fff; border-radius: 8px;
  padding: .55em 1.2em; box-shadow: var(--ombre); font-size: .92em;
  animation: toast-entree .18s ease-out;
  max-width: 90vw;
}
.toast.ok { background: var(--ok); }
.toast.erreur { background: var(--erreur); }
.toast.alerte { background: var(--alerte); }
@keyframes toast-entree {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: none; }
}
