/* Kit de connexion : page de connexion, mot de passe oublié, demande d'accès, nouveau mot de passe.
   Autonome (aucune bibliothèque), mobile d'abord, mode clair et sombre.
   Style : body[data-forme="tableau|sobre|expressif"]   Thème : html[data-theme="light|dark"]
   Les couleurs de l'organisation (--cx-marque, --cx-bouton, --cx-lien, --cx-degrade-*) sont posées par la page (connexion_ui.php). */

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }

/* ============ 1. Variables ============ */
:root {
  color-scheme: light;
  --cx-police: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --cx-police-titre: var(--cx-police);
  --cx-marque: #1e4d40;
  --cx-bouton: #1e4d40;
  --cx-bouton-texte: #ffffff;
  --cx-lien: #1e4d40;
  --cx-anneau: rgba(30, 77, 64, 0.3);
  --cx-accent: #c9a24b;
  --cx-degrade-a: #1e4d40;
  --cx-degrade-b: #143229;
  --cx-fond: #f1f4f3;
  --cx-carte: #ffffff;
  --cx-bord-carte: #dce3e1;
  --cx-texte: #1c2523;
  --cx-doux: #55625f;
  --cx-bord: #c3cdca;
  --cx-bord-fort: #86938f;
  --cx-champ: #ffffff;
  --cx-erreur: #b3261e;
  --cx-erreur-fond: #fdecea;
  --cx-erreur-anneau: rgba(179, 38, 30, 0.25);
  --cx-info: #174a85;
  --cx-info-fond: #e7f0fb;
  --cx-avert: #7a4f00;
  --cx-avert-fond: #fff3d1;
  --cx-ok: #1b6a32;
  --cx-ok-fond: #e5f4e9;
  --cx-ombre: 0 22px 48px -18px rgba(12, 20, 18, 0.35), 0 2px 8px rgba(12, 20, 18, 0.1);
  --cx-rayon: 14px;
  --cx-rayon-champ: 10px;
  --cx-h: 48px;
}
html[data-theme="dark"] {
  color-scheme: dark;
  --cx-fond: #0e1312;
  --cx-carte: #1a211f;
  --cx-bord-carte: #2b3532;
  --cx-texte: #e8eeec;
  --cx-doux: #a9b6b2;
  --cx-bord: #44514d;
  --cx-bord-fort: #6d7c77;
  --cx-champ: #121817;
  --cx-erreur: #ff958b;
  --cx-erreur-fond: #3b1e1c;
  --cx-erreur-anneau: rgba(255, 149, 139, 0.3);
  --cx-info: #a3c8f6;
  --cx-info-fond: #14283f;
  --cx-avert: #ffd67a;
  --cx-avert-fond: #3a2e0c;
  --cx-ok: #94d9a6;
  --cx-ok-fond: #13301c;
  --cx-ombre: 0 22px 48px -18px rgba(0, 0, 0, 0.75), 0 2px 8px rgba(0, 0, 0, 0.45);
}

/* ============ 2. Page, carte, en-tête ============ */
body.cx {
  margin: 0; min-height: 100vh; font: 1rem/1.5 var(--cx-police); color: var(--cx-texte); background: var(--cx-fond);
  -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale;
}
.cx a { color: var(--cx-lien); text-underline-offset: 3px; }
.cx a:hover { text-decoration-thickness: 2px; }
.cx :focus-visible { outline: 3px solid var(--cx-lien); outline-offset: 2px; }
.cx-page { min-height: 100vh; display: flex; flex-direction: column; }
@supports (min-height: 100dvh) { .cx-page { min-height: 100dvh; } }
.cx-zone { position: relative; flex: 1; display: flex; align-items: center; justify-content: center; padding: 64px 16px 28px; padding-bottom: max(28px, env(safe-area-inset-bottom)); }
.cx-carte {
  width: 100%; max-width: 420px; padding: 26px 22px 22px;
  background: var(--cx-carte); border: 1px solid var(--cx-bord-carte); border-radius: var(--cx-rayon); box-shadow: var(--cx-ombre);
}
@media (min-width: 480px) { .cx-carte { padding: 32px 32px 26px; } }

.cx-entete { text-align: center; margin-bottom: 20px; }
.cx-logo { display: block; margin: 0 auto 10px; max-width: 168px; max-height: 60px; width: auto; height: auto; object-fit: contain; border-radius: 8px; }
.cx-rond {
  display: grid; place-items: center; width: 56px; height: 56px; margin: 0 auto 10px; border-radius: 50%;
  background: var(--cx-bouton); color: var(--cx-bouton-texte); font: 700 1.5rem/1 var(--cx-police-titre);
}
.cx-nom { margin: 0; font: 700 1.2rem/1.25 var(--cx-police-titre); }
.cx-sous { margin: 2px 0 0; color: var(--cx-doux); font-size: 0.9rem; }
.cx-h1 { margin: 0 0 4px; font: 700 1.35rem/1.25 var(--cx-police-titre); }
.cx-intro { margin: 0 0 18px; color: var(--cx-doux); font-size: 0.95rem; }

/* Bouton d'apparence (automatique / clair / sombre) : caché tant que le script n'est pas chargé */
.cx-theme {
  position: absolute; top: 12px; right: 12px; width: 44px; height: 44px; padding: 0; display: grid; place-items: center;
  color: var(--cx-texte); background: var(--cx-carte); border: 1px solid var(--cx-bord-carte); border-radius: 50%; cursor: pointer;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12);
}
.cx-theme[hidden] { display: none; }
.cx-theme > span { display: none; }
.cx-theme svg { display: block; width: 22px; height: 22px; }
.cx-theme[data-mode="auto"] .i-auto, .cx-theme[data-mode="clair"] .i-clair, .cx-theme[data-mode="sombre"] .i-sombre { display: block; }
.cx svg { fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* ============ 3. Messages ============ */
.cx-alerte {
  display: flex; gap: 10px; align-items: flex-start; margin: 0 0 16px; padding: 12px 14px; border-radius: 10px;
  border-left: 4px solid currentColor; font-size: 0.92rem; line-height: 1.4;
}
.cx-alerte svg { flex: none; width: 20px; height: 20px; margin-top: 1px; }
.cx-alerte p { margin: 0; }
.cx-alerte-erreur { color: var(--cx-erreur); background: var(--cx-erreur-fond); }
.cx-alerte-info { color: var(--cx-info); background: var(--cx-info-fond); }
.cx-alerte-ok { color: var(--cx-ok); background: var(--cx-ok-fond); }
.cx-alerte-avert { color: var(--cx-avert); background: var(--cx-avert-fond); }

/* ============ 4. Champs ============ */
.cx-champ { margin-bottom: 16px; }
.cx-champ > label { display: block; margin-bottom: 6px; font-weight: 600; font-size: 0.92rem; }
.cx-opt { font-weight: 400; color: var(--cx-doux); }
.cx-champ input, .cx-champ select, .cx-champ textarea {
  display: block; width: 100%; min-height: var(--cx-h); padding: 10px 14px; margin: 0;
  font: inherit; color: var(--cx-texte); background: var(--cx-champ);
  border: 1px solid var(--cx-bord); border-radius: var(--cx-rayon-champ);
  -webkit-appearance: none; appearance: none; transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.cx-champ textarea { min-height: 96px; resize: vertical; }
.cx-champ input:hover, .cx-champ textarea:hover { border-color: var(--cx-bord-fort); }
.cx-champ input:focus, .cx-champ textarea:focus { outline: 0; border-color: var(--cx-lien); box-shadow: 0 0 0 3px var(--cx-anneau); }
.cx-champ input::placeholder, .cx-champ textarea::placeholder { color: var(--cx-doux); opacity: 0.75; }
.cx-champ [aria-invalid="true"] { border-color: var(--cx-erreur); }
.cx-champ [aria-invalid="true"]:focus { box-shadow: 0 0 0 3px var(--cx-erreur-anneau); }
.cx-champ input:-webkit-autofill, .cx-champ input:-webkit-autofill:hover, .cx-champ input:-webkit-autofill:focus {
  -webkit-text-fill-color: var(--cx-texte); -webkit-box-shadow: 0 0 0 1000px var(--cx-champ) inset; caret-color: var(--cx-texte);
}
.cx-aide { margin: 6px 0 0; color: var(--cx-doux); font-size: 0.84rem; }

.cx-mdp { position: relative; }
.cx-mdp input { padding-right: 52px; }
.cx-oeil {
  position: absolute; top: 0; right: 0; width: 48px; height: 100%; min-height: var(--cx-h); padding: 0; display: grid; place-items: center;
  color: var(--cx-doux); background: none; border: 0; border-radius: 0 var(--cx-rayon-champ) var(--cx-rayon-champ) 0; cursor: pointer;
}
.cx-oeil[hidden] { display: none; }
.cx-oeil:hover { color: var(--cx-lien); }
.cx-oeil svg { width: 22px; height: 22px; }
.cx-oeil .i-masquer, .cx-oeil[aria-pressed="true"] .i-voir { display: none; }
.cx-oeil[aria-pressed="true"] .i-masquer { display: block; }

.cx-erreur { display: flex; gap: 6px; align-items: flex-start; margin: 6px 0 0; color: var(--cx-erreur); font-size: 0.86rem; line-height: 1.35; }
.cx-erreur[hidden] { display: none; }
.cx-erreur::before {
  content: ""; flex: none; width: 16px; height: 16px; margin-top: 1px; background: currentColor;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.2' stroke-linecap='round'%3E%3Ccircle cx='12' cy='12' r='10'/%3E%3Cpath d='M12 7v6M12 16.5h.01'/%3E%3C/svg%3E") center / contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.2' stroke-linecap='round'%3E%3Ccircle cx='12' cy='12' r='10'/%3E%3Cpath d='M12 7v6M12 16.5h.01'/%3E%3C/svg%3E") center / contain no-repeat;
}

/* Avertissement du verrouillage des majuscules (zone vivante : annoncée par les lecteurs d'écran) */
.cx-maj { margin: 0; }
.cx-maj-msg {
  display: flex; gap: 8px; align-items: center; margin-top: 8px; padding: 8px 12px; border-radius: 8px;
  color: var(--cx-avert); background: var(--cx-avert-fond); font-size: 0.86rem; font-weight: 600;
}
.cx-maj-msg svg { flex: none; width: 18px; height: 18px; }

/* ============ 5. Boutons et liens ============ */
.cx-liens { display: flex; justify-content: flex-end; margin: -4px 0 16px; font-size: 0.92rem; }
.cx-bouton {
  position: relative; display: flex; align-items: center; justify-content: center; gap: 10px; width: 100%; min-height: 50px; padding: 12px 18px;
  font: 600 1rem/1.2 var(--cx-police); color: var(--cx-bouton-texte); background: var(--cx-bouton); border: 1px solid transparent;
  border-radius: var(--cx-rayon-champ); cursor: pointer; text-decoration: none; transition: filter 0.15s ease, transform 0.05s ease;
}
.cx .cx-bouton { color: var(--cx-bouton-texte); }
.cx-bouton:hover { filter: brightness(1.1); }
.cx-bouton:active { transform: translateY(1px); }
.cx-bouton svg { width: 20px; height: 20px; flex: none; }
.cx-bouton-2, .cx .cx-bouton-2 { color: var(--cx-lien); background: transparent; border-color: var(--cx-bord-fort); }
.cx-bouton-2:hover { filter: none; background: var(--cx-champ); }
.cx-bouton + .cx-bouton { margin-top: 10px; }
.cx-bouton[aria-busy="true"] { cursor: progress; pointer-events: none; filter: none; opacity: 0.92; }
.cx-spin {
  display: none; width: 18px; height: 18px; flex: none; border-radius: 50%; border: 2.5px solid currentColor; border-right-color: transparent;
  animation: cx-tourne 0.7s linear infinite;
}
.cx-bouton[aria-busy="true"] .cx-spin { display: inline-block; }
@keyframes cx-tourne { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) {
  .cx-spin { animation-duration: 1.8s; }
  .cx *, .cx *::before, .cx *::after { transition: none !important; }
}
.cx-pied { margin: 18px 0 0; text-align: center; color: var(--cx-doux); font-size: 0.92rem; }
.cx-retour { margin: 16px 0 0; text-align: center; font-size: 0.92rem; }
.cx-retour a { display: inline-flex; align-items: center; gap: 6px; }
.cx-retour svg { width: 16px; height: 16px; }
.cx-installer { margin: 14px 0 0; text-align: center; }
.cx-installer[hidden] { display: none; }
.cx-installer button {
  min-height: 40px; padding: 8px 16px; font: inherit; font-size: 0.88rem; color: var(--cx-doux); background: none;
  border: 1px solid var(--cx-bord); border-radius: 999px; cursor: pointer;
}
.cx-installer button:hover { color: var(--cx-lien); border-color: var(--cx-bord-fort); }

/* Page d'aide : message prêt à envoyer */
.cx-apercu { margin: 0 0 16px; padding: 12px 14px; color: var(--cx-doux); background: var(--cx-champ); border: 1px dashed var(--cx-bord-fort); border-radius: var(--cx-rayon-champ); font-size: 0.88rem; line-height: 1.45; white-space: pre-wrap; word-break: break-word; }
.cx-apercu-titre { margin: 0 0 6px; font-size: 0.8rem; font-weight: 700; letter-spacing: 0.05em; text-transform: uppercase; color: var(--cx-doux); }
.cx-etapes { margin: 0 0 18px; padding-left: 1.2rem; color: var(--cx-doux); font-size: 0.92rem; }
.cx-etapes li { margin-bottom: 4px; }

/* ============ 6. Panneau de marque (visible dans le style « Expressif ») ============ */
.cx-panneau { display: none; }

/* ============ 7. Style « Tableau de bord » (par défaut) : fond aux couleurs de l'organisation, carte nette ============ */
body.cx[data-forme="tableau"] { background: linear-gradient(135deg, var(--cx-degrade-a), var(--cx-degrade-b)) fixed; }
body.cx[data-forme="tableau"] .cx-carte { border-top: 4px solid var(--cx-accent); }

/* ============ 8. Style « Sobre » : fond neutre, traits fins ============ */
body.cx[data-forme="sobre"] { --cx-rayon: 8px; --cx-rayon-champ: 6px; --cx-h: 46px; }
body.cx[data-forme="sobre"] .cx-carte { box-shadow: none; }
body.cx[data-forme="sobre"] .cx-champ > label { font-weight: 500; }

/* ============ 9. Style « Expressif » : panneau coloré, champs soulignés ============ */
body.cx[data-forme="expressif"] { --cx-rayon-champ: 0; --cx-h: 50px; background: var(--cx-carte); }
body.cx[data-forme="expressif"] .cx-entete { display: none; }
body.cx[data-forme="expressif"] .cx-zone { background: var(--cx-carte); padding-top: 28px; }
body.cx[data-forme="expressif"] .cx-theme { background: transparent; box-shadow: none; }
body.cx[data-forme="expressif"] .cx-carte { background: transparent; border: 0; box-shadow: none; padding: 4px 4px 0; }
body.cx[data-forme="expressif"] .cx-champ input, body.cx[data-forme="expressif"] .cx-champ textarea {
  padding-left: 2px; padding-right: 2px; background: transparent; border-width: 0 0 2px; border-radius: 0;
}
body.cx[data-forme="expressif"] .cx-mdp input { padding-right: 50px; }
body.cx[data-forme="expressif"] .cx-champ input:focus, body.cx[data-forme="expressif"] .cx-champ textarea:focus { box-shadow: none; }
body.cx[data-forme="expressif"] .cx-champ > label { font-size: 0.76rem; letter-spacing: 0.06em; text-transform: uppercase; color: var(--cx-doux); }
body.cx[data-forme="expressif"] .cx-bouton { border-radius: 999px; }
body.cx[data-forme="expressif"] .cx-apercu { border-radius: 10px; }
body.cx[data-forme="expressif"] .cx-panneau {
  position: relative; display: flex; flex-direction: column; justify-content: space-between; overflow: hidden; padding: 22px 22px 20px;
  color: #ffffff; background: linear-gradient(160deg, var(--cx-degrade-a), var(--cx-degrade-b));
}
body.cx[data-forme="expressif"] .cx-panneau::before {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background-image: radial-gradient(rgba(255, 255, 255, 0.09) 1px, transparent 1.4px); background-size: 16px 16px;
}
.cx-panneau-in, .cx-panneau small { position: relative; }
.cx-panneau .cx-rond { margin: 0 0 12px; color: #2a2108; background: var(--cx-accent); }
.cx-panneau .cx-logo { margin: 0 0 12px; max-height: 52px; }
.cx-panneau h2 { margin: 0; font: 700 1.5rem/1.2 var(--cx-police-titre); }
.cx-panneau p { margin: 8px 0 0; max-width: 38ch; color: rgba(255, 255, 255, 0.88); }
.cx-panneau ul { display: grid; gap: 10px; margin: 22px 0 0; padding: 0; list-style: none; }
.cx-panneau li { display: flex; align-items: center; gap: 10px; }
.cx-panneau li::before { content: ""; flex: none; width: 8px; height: 8px; border-radius: 50%; background: var(--cx-accent); }
.cx-panneau small { margin-top: 20px; color: rgba(255, 255, 255, 0.72); }
@media (max-width: 899.98px) {
  body.cx[data-forme="expressif"] .cx-zone { align-items: flex-start; padding-top: 64px; }
  body.cx[data-forme="expressif"] .cx-panneau p, body.cx[data-forme="expressif"] .cx-panneau ul, body.cx[data-forme="expressif"] .cx-panneau small { display: none; }
  body.cx[data-forme="expressif"] .cx-panneau-in { display: flex; align-items: center; gap: 14px; }
  body.cx[data-forme="expressif"] .cx-panneau .cx-rond { flex: none; width: 46px; height: 46px; margin: 0; font-size: 1.2rem; }
  body.cx[data-forme="expressif"] .cx-panneau .cx-logo { flex: none; margin: 0; max-width: 120px; max-height: 44px; }
  body.cx[data-forme="expressif"] .cx-panneau h2 { font-size: 1.15rem; }
}
@media (min-width: 900px) {
  body.cx[data-forme="expressif"] .cx-page { flex-direction: row; }
  body.cx[data-forme="expressif"] .cx-panneau { flex: 1.1; padding: 56px 60px; }
  body.cx[data-forme="expressif"] .cx-panneau h2 { max-width: 14ch; font-size: 2.5rem; }
  body.cx[data-forme="expressif"] .cx-zone { flex: 1; padding: 32px; }
}
