/* ==========================================================================
   Kadre — charte MyProjekt (petit frere de K7)
   Le theme suit le reglage clair/sombre de l appareil ; un choix manuel le fige
   via l attribut data-theme sur <html>.
   ========================================================================== */

/* --------------------------------------------------------------- jetons */
:root {
  /* Couleurs de marque — reprises du logo Kadre */
  --marque-1: #201f54;   /* indigo nuit */
  --marque-2: #5c3b8a;   /* violet */
  --marque-3: #2162a1;   /* bleu */
  --violet: #7c57b0;
  --indigo: #6b5bd2;     /* accent : liens, focus, selection */
  --bleu: #2f7dc7;
  --degrade-marque: linear-gradient(125deg, var(--marque-1) 0%, var(--marque-2) 52%, var(--marque-3) 100%);
  --degrade-rail: linear-gradient(180deg, var(--marque-1) 0%, var(--marque-2) 55%, var(--marque-3) 100%);
  /* Meme famille que le logo, un cran plus lumineux : sur un bouton ou une
     pastille, le degrade exact du logo manquerait de peche a l'ecran. */
  --degrade-vif: linear-gradient(125deg, #3a3891 0%, #7d54bd 50%, #2f86d6 100%);

  /* Etats */
  --succes: #22c55e;
  --alerte: #f59e0b;
  --danger: #ef4444;
  --info: #38bdf8;

  /* Rayons / ombres / espacements */
  --r-xs: 8px;
  --r-sm: 10px;
  --r-md: 14px;
  --r-lg: 20px;
  --r-pilule: 999px;
  --ombre-1: 0 1px 2px rgba(8, 10, 20, .28);
  --ombre-2: 0 8px 24px -8px rgba(8, 10, 20, .45);
  --ombre-3: 0 24px 60px -20px rgba(8, 10, 20, .6);
  --transition: 160ms cubic-bezier(.4, 0, .2, 1);

  /* Typo */
  --police-ui: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
}

/* Sombre (applique quand le systeme est en sombre, ou par choix manuel) */
:root,
:root[data-theme="sombre"] {
  color-scheme: dark;
  --fond: #0a0b11;
  --fond-voile: rgba(10, 11, 17, .72);
  --surface: #13151f;
  --surface-2: #1a1d2a;
  --surface-3: #222637;
  --bord: #272b3c;
  --bord-doux: #1e2231;
  --texte: #eef0f7;
  --texte-doux: #99a0b6;
  --texte-faible: #6b7288;
  --damier-a: #1a1d2a;
  --damier-b: #14161f;
}

/* Clair */
:root[data-theme="clair"] {
  color-scheme: light;
  --fond: #f5f6fb;
  --fond-voile: rgba(245, 246, 251, .72);
  --surface: #ffffff;
  --surface-2: #f1f3f9;
  --surface-3: #e8ebf4;
  --bord: #e2e6f0;
  --bord-doux: #edf0f7;
  --texte: #141826;
  --texte-doux: #5d6580;
  --texte-faible: #8a91a6;
  --damier-a: #e9ecf4;
  --damier-b: #f6f7fb;
  --ombre-2: 0 8px 24px -10px rgba(30, 40, 80, .18);
  --ombre-3: 0 24px 60px -22px rgba(30, 40, 80, .28);
}

/* --------------------------------------------------------------- base */
* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--fond);
  color: var(--texte);
  font-family: var(--police-ui);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

h1, h2, h3, h4 { margin: 0; font-weight: 700; letter-spacing: -.01em; }
h1 { font-size: 26px; }
h2 { font-size: 19px; }
h3 { font-size: 16px; }
p { margin: 0 0 10px; }
a { color: var(--indigo); text-decoration: none; }
a:hover { text-decoration: underline; }

.doux { color: var(--texte-doux); }
.faible { color: var(--texte-faible); font-size: 13px; }
.mini { font-size: 12.5px; }
.gras { font-weight: 600; }
.centre { text-align: center; }
.cache { display: none !important; }
.pleine-largeur { width: 100%; }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--surface-3); border-radius: var(--r-pilule); border: 2px solid var(--fond); }
::-webkit-scrollbar-thumb:hover { background: var(--texte-faible); }

/* --------------------------------------------------------------- mise en page */
.appli { display: flex; min-height: 100vh; }

.rail {
  width: 74px;
  flex: 0 0 74px;
  background: var(--degrade-rail);
  border-radius: 0 var(--r-lg) var(--r-lg) 0;
  padding: 14px 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  position: sticky;
  top: 0;
  height: 100vh;
}

.rail-logo {
  width: 46px; height: 46px;
  border-radius: 13px;
  background: rgba(255, 255, 255, .12);
  display: grid; place-items: center;
  margin-bottom: 10px;
  border: 1px solid rgba(255, 255, 255, .18);
  padding: 4px;
}
.rail-logo img { width: 100%; height: 100%; display: block; }

.rail-item {
  width: 46px; height: 46px;
  border: 0; background: transparent;
  border-radius: 13px;
  color: rgba(255, 255, 255, .62);
  display: grid; place-items: center;
  cursor: pointer;
  transition: var(--transition);
}
.rail-item:hover { background: rgba(255, 255, 255, .12); color: #fff; }
.rail-item.actif { background: rgba(255, 255, 255, .2); color: #fff; }
.rail-item svg { width: 21px; height: 21px; }

.zone { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.entete {
  display: flex; align-items: center; gap: 14px;
  padding: 20px 28px 12px;
}
.entete h1 { flex: 1; }

.contenu { padding: 8px 28px 40px; flex: 1; }
.contenu-etroit { max-width: 1080px; margin: 0 auto; width: 100%; }

.grille { display: grid; gap: 14px; }
.grille-2 { grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.grille-3 { grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); }
.rangee { display: flex; gap: 10px; align-items: center; }
.rangee-fin { justify-content: flex-end; }
.rangee-entre { justify-content: space-between; }
.rangee-souple { flex-wrap: wrap; }
.espace { flex: 1; }
.pile { display: flex; flex-direction: column; gap: 10px; }

/* --------------------------------------------------------------- logo */
.logo-kadre { display: inline-flex; align-items: center; flex: 0 0 auto; }
.logo-kadre img { display: block; height: 100%; width: auto; }
:root[data-theme="sombre"] .logo-kadre .logo-clair,
:root[data-theme="clair"] .logo-kadre .logo-sombre { display: none; }

/* --------------------------------------------------------------- cartes */
.carte {
  background: var(--surface);
  border: 1px solid var(--bord);
  border-radius: var(--r-md);
  padding: 16px;
  box-shadow: var(--ombre-1);
}
.carte-titre { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.carte-titre h2 { flex: 1; }

.heros {
  background: var(--degrade-marque);
  border-radius: var(--r-lg);
  padding: 26px 28px;
  color: #fff;
  box-shadow: var(--ombre-2);
}
.heros h1 { color: #fff; }
.heros p { color: rgba(255, 255, 255, .86); max-width: 60ch; }

.pastille {
  width: 40px; height: 40px; border-radius: 12px;
  display: grid; place-items: center; color: #fff; flex: 0 0 auto;
  background: var(--degrade-vif);
}
.pastille svg { width: 20px; height: 20px; }

/* --------------------------------------------------------------- boutons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  padding: 9px 16px;
  border-radius: var(--r-pilule);
  border: 1px solid var(--bord);
  background: var(--surface-2);
  color: var(--texte);
  font: inherit; font-size: 14px; font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  white-space: nowrap;
}
.btn:hover { background: var(--surface-3); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .45; cursor: not-allowed; transform: none; }
.btn svg { width: 16px; height: 16px; }

.btn-primaire {
  background: var(--degrade-vif);
  border-color: transparent;
  color: #fff;
  box-shadow: 0 6px 18px -8px rgba(107, 91, 210, .9);
}
.btn-primaire:hover { filter: brightness(1.1); background: var(--degrade-vif); }

.btn-fantome { background: transparent; border-color: transparent; color: var(--texte-doux); }
.btn-fantome:hover { background: var(--surface-2); color: var(--texte); }

.btn-danger { color: #fff; background: var(--danger); border-color: transparent; }
.btn-danger:hover { background: #dc2626; }

.btn-petit { padding: 6px 11px; font-size: 13px; }
.btn-icone { padding: 8px; width: 34px; height: 34px; border-radius: var(--r-sm); }
.btn-icone svg { width: 17px; height: 17px; }

/* --------------------------------------------------------------- badges */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 10px;
  border-radius: var(--r-pilule);
  font-size: 12px; font-weight: 600;
  background: var(--surface-2);
  color: var(--texte-doux);
  border: 1px solid var(--bord);
  white-space: nowrap;
}
.badge-violet { background: rgba(124, 87, 176, .16); color: #a78bfa; border-color: rgba(124, 87, 176, .3); }
.badge-succes { background: rgba(34, 197, 94, .15); color: #4ade80; border-color: rgba(34, 197, 94, .3); }
.badge-alerte { background: rgba(245, 158, 11, .15); color: #fbbf24; border-color: rgba(245, 158, 11, .3); }
.badge-info   { background: rgba(56, 189, 248, .15); color: #38bdf8; border-color: rgba(56, 189, 248, .3); }
.badge-danger { background: rgba(239, 68, 68, .15); color: #f87171; border-color: rgba(239, 68, 68, .3); }

/* --------------------------------------------------------------- formulaires */
.champ { display: flex; flex-direction: column; gap: 5px; }
.champ > label { font-size: 12.5px; font-weight: 600; color: var(--texte-doux); }

input[type="text"], input[type="email"], input[type="tel"], input[type="date"],
input[type="number"], input[type="password"], input[type="search"], select, textarea {
  width: 100%;
  padding: 9px 12px;
  border-radius: var(--r-sm);
  border: 1px solid var(--bord);
  background: var(--surface-2);
  color: var(--texte);
  font: inherit; font-size: 14px;
  transition: var(--transition);
}
textarea { resize: vertical; min-height: 78px; }
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--indigo);
  box-shadow: 0 0 0 3px rgba(107, 91, 210, .22);
}
input::placeholder, textarea::placeholder { color: var(--texte-faible); }
input[type="color"] {
  padding: 2px; height: 36px; width: 46px; cursor: pointer;
  border-radius: var(--r-sm); border: 1px solid var(--bord); background: var(--surface-2);
}
input[type="range"] { width: 100%; accent-color: var(--indigo); }
input[type="checkbox"] { accent-color: var(--indigo); width: 15px; height: 15px; cursor: pointer; }
select {
  appearance: none;
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Cpath d='M2 4.5 6 8.5 10 4.5' fill='none' stroke='%2399a0b6' stroke-width='1.6' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center; background-size: 12px;
  padding-right: 30px;
}

.case { display: flex; align-items: center; gap: 8px; font-size: 13.5px; cursor: pointer; user-select: none; }

/* --------------------------------------------------------------- tableaux */
.tableau-boite { overflow: auto; border: 1px solid var(--bord); border-radius: var(--r-md); background: var(--surface); }
table.tableau { width: 100%; border-collapse: collapse; font-size: 14px; }
table.tableau th {
  text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: .06em;
  color: var(--texte-faible); font-weight: 700;
  padding: 11px 14px; border-bottom: 1px solid var(--bord); background: var(--surface-2);
  white-space: nowrap; position: sticky; top: 0; z-index: 1;
}
table.tableau td { padding: 12px 14px; border-bottom: 1px solid var(--bord-doux); vertical-align: middle; }
table.tableau tr:last-child td { border-bottom: 0; }
table.tableau tbody tr:hover { background: var(--surface-2); }

/* --------------------------------------------------------------- etapes */
.etapes { display: flex; align-items: center; gap: 0; }
.etape { display: flex; align-items: center; gap: 9px; flex: 1; min-width: 0; }
.etape:last-child { flex: 0 0 auto; }
.etape-rond {
  width: 30px; height: 30px; flex: 0 0 auto; border-radius: 50%;
  display: grid; place-items: center;
  font-size: 13px; font-weight: 700;
  background: var(--surface-2); color: var(--texte-faible);
  border: 1px solid var(--bord);
  transition: var(--transition);
}
.etape-nom { font-size: 13px; color: var(--texte-faible); white-space: nowrap; font-weight: 600; }
.etape-trait { flex: 1; height: 2px; background: var(--bord); margin: 0 12px; border-radius: 2px; min-width: 16px; }
.etape.faite .etape-rond { background: var(--degrade-vif); color: #fff; border-color: transparent; }
.etape.faite .etape-nom { color: var(--texte-doux); }
.etape.faite + .etape .etape-trait, .etape.faite .etape-trait { background: var(--indigo); }
.etape.active .etape-rond { background: var(--surface); color: var(--indigo); border-color: var(--indigo); box-shadow: 0 0 0 4px rgba(107, 91, 210, .18); }
.etape.active .etape-nom { color: var(--texte); }

/* --------------------------------------------------------------- damier (transparence) */
.damier {
  background-image:
    linear-gradient(45deg, var(--damier-a) 25%, transparent 25%),
    linear-gradient(-45deg, var(--damier-a) 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, var(--damier-a) 75%),
    linear-gradient(-45deg, transparent 75%, var(--damier-a) 75%);
  background-size: 16px 16px;
  background-position: 0 0, 0 8px, 8px -8px, -8px 0;
  background-color: var(--damier-b);
}

/* --------------------------------------------------------------- toasts */
.toasts {
  position: fixed; right: 18px; bottom: 18px; z-index: 900;
  display: flex; flex-direction: column; gap: 9px; align-items: flex-end;
  pointer-events: none;
}
.toast {
  background: var(--surface-3);
  border: 1px solid var(--bord);
  border-left: 3px solid var(--indigo);
  color: var(--texte);
  padding: 11px 15px; border-radius: var(--r-sm);
  box-shadow: var(--ombre-2);
  font-size: 14px; max-width: 380px;
  animation: toast-entre 220ms ease-out;
  pointer-events: auto;
}
.toast.succes { border-left-color: var(--succes); }
.toast.erreur { border-left-color: var(--danger); }
.toast.alerte { border-left-color: var(--alerte); }
@keyframes toast-entre { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* --------------------------------------------------------------- modale */
.voile {
  position: fixed; inset: 0; z-index: 800;
  background: rgba(6, 7, 14, .68);
  backdrop-filter: blur(3px);
  display: grid; place-items: center;
  padding: 22px;
  animation: fondu 140ms ease-out;
}
@keyframes fondu { from { opacity: 0; } to { opacity: 1; } }
.modale {
  background: var(--surface);
  border: 1px solid var(--bord);
  border-radius: var(--r-lg);
  box-shadow: var(--ombre-3);
  width: min(680px, 100%);
  max-height: 90vh;
  display: flex; flex-direction: column;
  overflow: hidden;
}
.modale-entete { display: flex; align-items: center; gap: 12px; padding: 16px 18px; border-bottom: 1px solid var(--bord); }
.modale-entete h2 { flex: 1; }
.modale-corps { padding: 18px; overflow: auto; }
.modale-pied { padding: 14px 18px; border-top: 1px solid var(--bord); display: flex; gap: 9px; justify-content: flex-end; background: var(--surface-2); }

/* --------------------------------------------------------------- barre du bas */
.barre-bas {
  position: sticky; bottom: 0; z-index: 20;
  background: var(--fond-voile);
  backdrop-filter: blur(10px);
  border-top: 1px solid var(--bord);
  padding: 12px 28px;
  display: flex; align-items: center; gap: 10px;
}

/* --------------------------------------------------------------- divers */
.vide {
  text-align: center; padding: 46px 20px; color: var(--texte-doux);
  border: 1px dashed var(--bord); border-radius: var(--r-md);
}
.vide h3 { color: var(--texte); margin-bottom: 6px; }

.chargeur {
  width: 17px; height: 17px; border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, .3); border-top-color: #fff;
  animation: tourne .7s linear infinite; display: inline-block;
}
@keyframes tourne { to { transform: rotate(360deg); } }

.sep { height: 1px; background: var(--bord); margin: 14px 0; border: 0; }

/* --------------------------------------------------------------- responsive */
@media (max-width: 720px) {
  .rail { width: 100%; flex: none; height: auto; position: static; flex-direction: row; border-radius: 0; padding: 8px 12px; }
  .rail-logo { margin-bottom: 0; width: 38px; height: 38px; border-radius: 11px; font-size: 11px; }
  .rail-item { width: 40px; height: 40px; }
  .appli { flex-direction: column; }
  .entete, .contenu, .barre-bas { padding-left: 16px; padding-right: 16px; }
  h1 { font-size: 21px; }
}
