/*
 * Design system partagé des 4 espaces (technicien, manager, admin, client) —
 * palette propre à ces pages « app », distincte de --dark-bg/--brand-purple
 * du thème (feuille de style du site marketing), pour ne jamais confondre
 * les deux. Chargée uniquement sur les pages des espaces, voir
 * includes/shared/class-espace-shell.php.
 */

:root {
    --esp-bg: #17141a;
    --esp-card: #241f29;
    --esp-card-2: #1d1921;
    --esp-nav: #1d1921;
    --esp-border: #3a3340;
    --esp-chip: #2f2935;
    --esp-text: #f4efe9;
    --esp-muted: #b9afbe;
    --esp-muted-2: #d6cdd9;
    --esp-faint: #8f8596;
    --esp-purple: #8b4fd9;
    --esp-pink: #e5487a;
    --esp-pink-text: #f2a6c2;
    --esp-green: #9fe0bf;
    --esp-green-text: #0f3a25;
    --esp-orange: #f5b942;
    --esp-gradient: linear-gradient(135deg, var(--esp-purple), var(--esp-pink));
    --esp-font-display: 'Cormorant Garamond', serif;
    --esp-font-body: 'DM Sans', sans-serif;
}

/* html/body plutôt que .esp-shell seul (bug trouvé le 20/10/2026 en
   testant sur mobile) : un bandeau blanc apparaissait au-dessus de
   l'habillage sombre, le temps que .esp-shell démarre — html/body n'avaient
   eux-mêmes aucune couleur de fond (celle du navigateur par défaut, blanche)
   avant que la div .esp-shell ne commence plus bas dans la page. */
html, body { background: var(--esp-bg); }
.esp-shell, .esp-shell * { box-sizing: border-box; }
.esp-shell {
    background: var(--esp-bg);
    color: var(--esp-text);
    font-family: var(--esp-font-body);
    min-height: 100vh;
}
/* :where() garde la spécificité à zéro pour le sélecteur "a" : un lien-bouton
   (.esp-btn, .esp-nav__link...) garde sa propre couleur au lieu d'être
   écrasé par cette couleur de lien générique (bug trouvé le 19/10/2026 en
   testant l'espace admin — menu et boutons secondaires affichaient du rose
   au lieu du blanc prévu). */
.esp-shell :where(a) { color: var(--esp-pink-text); text-decoration: none; }
.esp-shell :where(a):hover { color: #ffd0e0; }
.esp-shell button { font-family: inherit; cursor: pointer; }
.esp-shell h1, .esp-shell h2, .esp-shell h3 { font-family: var(--esp-font-display); font-weight: 700; margin: 0; }
.esp-shell input, .esp-shell select, .esp-shell textarea {
    font-family: inherit;
    background: var(--esp-card-2);
    color: var(--esp-text);
    border: 1px solid var(--esp-border);
    border-radius: 12px;
    padding: 0.65rem 0.85rem;
    width: 100%;
}
.esp-shell input:focus, .esp-shell select:focus, .esp-shell textarea:focus {
    outline: 2px solid var(--esp-pink-text);
    outline-offset: 1px;
}

/* --- Coquille sidebar (manager, admin) --- */
.esp-layout--sidebar { display: flex; flex-wrap: wrap; }
.esp-nav {
    flex: 1 1 240px;
    box-sizing: border-box;
    background: var(--esp-nav);
    border-right: 1px solid var(--esp-border);
    padding: 24px 16px;
    display: flex;
    flex-direction: column;
    gap: 22px;
}
.esp-nav__brand { display: flex; flex-direction: column; gap: 2px; padding: 0 8px; }
.esp-nav__brand-name { font-family: var(--esp-font-display); font-size: 30px; font-weight: 700; line-height: 1; }
.esp-nav__brand-label { font-size: 13px; color: var(--esp-muted); }
.esp-nav__brand-label--admin { color: var(--esp-pink-text); font-weight: 700; }
.esp-nav__links { display: flex; flex-wrap: wrap; gap: 6px; }
.esp-nav__link {
    flex: 1 1 200px;
    min-height: 48px;
    padding: 0 14px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    gap: 12px;
    color: var(--esp-muted-2);
    font-size: 15px;
}
.esp-nav__link svg { flex: none; }
.esp-nav__link.is-active { background: var(--esp-chip); color: var(--esp-text); font-weight: 700; }
.esp-nav__link.is-active svg { stroke: var(--esp-pink-text); }
.esp-nav__badge {
    margin-left: auto;
    font-size: 12px;
    font-weight: 700;
    background: var(--esp-pink-text);
    color: #3a0f22;
    padding: 2px 8px;
    border-radius: 99px;
}
.esp-main {
    flex: 999 1 560px;
    min-width: 0;
    box-sizing: border-box;
    padding: 32px clamp(16px, 3vw, 44px) 48px;
    display: flex;
    flex-direction: column;
    gap: 26px;
}
.esp-main__header { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 16px; }
.esp-main__header h1 { font-size: 44px; line-height: 1; }
.esp-main__eyebrow { font-size: 15px; color: var(--esp-muted); }

/* --- Coquille mobile (technicien, client) --- */
.esp-layout--mobile {
    max-width: 480px;
    margin: 0 auto;
    padding: 16px 16px 40px;
    display: flex;
    flex-direction: column;
    gap: 18px;
}
.esp-retour {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-height: 44px;
    color: var(--esp-text);
    font-size: 16px;
    align-self: flex-start;
}
.esp-mobile-header { display: flex; align-items: center; justify-content: space-between; }
.esp-mobile-header__brand { font-family: var(--esp-font-display); font-size: 28px; font-weight: 700; }
.esp-avatar {
    width: 44px; height: 44px; border-radius: 22px;
    background: var(--esp-chip); color: var(--esp-text);
    display: flex; align-items: center; justify-content: center;
}

/* --- Composants --- */
.esp-card {
    background: var(--esp-card);
    border: 1px solid var(--esp-border);
    border-radius: 20px;
    padding: 20px;
}
.esp-card--nested { background: var(--esp-card-2); border-radius: 12px; padding: 10px 12px; }

.esp-btn {
    min-height: 48px;
    padding: 0 18px;
    border-radius: 14px;
    border: 0;
    font-size: 15px;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}
.esp-btn--primary { background: var(--esp-gradient); color: #fff; }
.esp-btn--secondary { background: var(--esp-chip); color: var(--esp-text); }
.esp-btn--success { background: var(--esp-green); color: var(--esp-green-text); }
.esp-btn--ghost { background: transparent; color: var(--esp-pink-text); border: 0; }
.esp-btn--lg { min-height: 56px; border-radius: 16px; font-size: 16px; width: 100%; }
.esp-btn:disabled { opacity: 0.5; cursor: not-allowed; }

.esp-badge {
    display: inline-flex;
    align-self: flex-start;
    font-size: 12px;
    font-weight: 700;
    background: var(--esp-pink-text);
    color: #3a0f22;
    padding: 4px 10px;
    border-radius: 99px;
}
.esp-status {
    display: inline-flex;
    font-size: 13px;
    font-weight: 700;
    padding: 2px 0;
}
.esp-status--positive { color: var(--esp-green); }
.esp-status--attention { color: var(--esp-orange); }
.esp-status--accent { color: var(--esp-pink-text); }
.esp-status--muted { color: var(--esp-muted); font-weight: 400; }

.esp-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px; }
.esp-stat {
    background: var(--esp-card);
    border: 1px solid var(--esp-border);
    border-radius: 20px;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.esp-stat__label { font-size: 14px; color: var(--esp-muted); }
.esp-stat__value { font-size: 40px; font-weight: 700; line-height: 1; font-family: var(--esp-font-body); }
.esp-stat--sm .esp-stat__value { font-size: 28px; line-height: 1.1; }

.esp-progress { height: 10px; border-radius: 5px; background: var(--esp-chip); overflow: hidden; }
.esp-progress--lg { height: 14px; border-radius: 7px; }
.esp-progress__fill { height: 100%; border-radius: inherit; background: var(--esp-purple); }
.esp-progress__fill--gradient { background: var(--esp-gradient); }

.esp-timeline { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.esp-timeline__item { display: flex; gap: 14px; }
.esp-timeline__rail { display: flex; flex-direction: column; align-items: center; }
.esp-timeline__dot {
    width: 28px; height: 28px; border-radius: 14px;
    display: flex; align-items: center; justify-content: center;
    flex: none;
}
.esp-timeline__dot--done { background: var(--esp-green); color: var(--esp-green-text); }
.esp-timeline__dot--current { background: var(--esp-gradient); box-shadow: 0 0 0 5px #3d2030; }
.esp-timeline__dot--pending { border: 2px solid #4a4250; box-sizing: border-box; }
.esp-timeline__line { width: 2px; flex: 1; min-height: 18px; }
.esp-timeline__line--done { background: var(--esp-green); }
.esp-timeline__line--pending { background: var(--esp-border); }
.esp-timeline__body { padding-bottom: 16px; display: flex; flex-direction: column; gap: 2px; }

.esp-stepper { display: flex; align-items: center; gap: 14px; }
.esp-stepper__btn {
    width: 44px; height: 44px; border-radius: 12px; border: 1px solid var(--esp-border);
    background: var(--esp-card-2); color: var(--esp-text); font-size: 20px; font-weight: 700;
    display: flex; align-items: center; justify-content: center;
}
.esp-stepper__value { font-size: 20px; font-weight: 700; min-width: 2ch; text-align: center; }

.esp-stars { display: inline-flex; gap: 4px; }
.esp-stars__star { width: 28px; height: 28px; color: var(--esp-border); }
.esp-stars__star.is-filled { color: var(--esp-pink-text); }

.esp-list-row {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 12px 0;
    border-bottom: 1px solid var(--esp-chip);
}
.esp-list-row:last-child { border-bottom: 0; }
.esp-list-row__icon {
    width: 40px; height: 40px; flex: none; border-radius: 12px;
    display: flex; align-items: center; justify-content: center;
}
.esp-list-row__body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }

.esp-wizard-bar { display: grid; gap: 4px; grid-template-columns: repeat(var(--esp-wizard-steps, 4), 1fr); }
.esp-wizard-bar__seg { height: 6px; border-radius: 3px; background: var(--esp-border); }
.esp-wizard-bar__seg.is-done { background: var(--esp-pink); }

.esp-tile {
    min-height: 72px;
    border-radius: 16px;
    padding: 14px 16px;
    border: 1px solid var(--esp-border);
    background: var(--esp-card);
    color: var(--esp-text);
    font-size: 16px;
    text-align: left;
    display: flex;
    align-items: center;
}
.esp-tile.is-active { border: 2px solid var(--esp-pink-text); background: #3d2030; font-weight: 700; }
.esp-tile--chip { min-height: 56px; border-radius: 14px; font-size: 15px; justify-content: center; }

.esp-choice-card {
    width: 100%;
    border-radius: 18px;
    padding: 16px;
    border: 1px solid var(--esp-border);
    background: var(--esp-card);
    color: var(--esp-text);
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
    text-align: left;
}
.esp-choice-card.is-active { border: 2px solid var(--esp-pink-text); background: #3d2030; }
.esp-choice-card__row { display: flex; justify-content: space-between; align-items: center; width: 100%; gap: 10px; }

.esp-radio-dot { width: 22px; height: 22px; border-radius: 11px; border: 2px solid #6b6172; box-sizing: border-box; flex: none; }
.esp-radio-dot.is-active { border: 6px solid var(--esp-pink-text); }

.esp-upload-box {
    min-height: 72px;
    border-radius: 18px;
    border: 2px dashed var(--esp-border);
    background: var(--esp-card-2);
    color: var(--esp-text);
    font-size: 16px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    width: 100%;
}
.esp-photo-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.esp-photo-grid__item { height: 96px; border-radius: 12px; background: var(--esp-chip); display: flex; align-items: center; justify-content: center; overflow: hidden; position: relative; }
.esp-photo-grid__item img { width: 100%; height: 100%; object-fit: cover; }
.esp-photo-grid__remove { position: absolute; top: 4px; right: 4px; width: 22px; height: 22px; border-radius: 11px; background: rgba(23,20,26,0.8); color: var(--esp-text); border: 0; font-size: 13px; line-height: 1; display: flex; align-items: center; justify-content: center; }

/* --- Responsive ---
 * Bug trouvé le 19/10/2026 (signalé par l'utilisateur : « tous les espaces
 * ne sont pas mobile responsive ») : en-dessous de 860px, .esp-nav devenait
 * un enfant flex en colonne SANS largeur imposée — par défaut, un enfant
 * flex ne rétrécit jamais sous la largeur naturelle de son contenu
 * (min-width: auto implicite), donc .esp-nav (et .esp-main) grandissaient
 * pour contenir leurs liens/cartes au lieu de se limiter à la largeur de
 * l'écran, et toute la page défilait horizontalement. `width: 100%` +
 * `min-width: 0` sur les deux cassent cette règle implicite. `overflow-x:
 * hidden` sur .esp-shell est un filet de sécurité : aucun élément interne
 * ne doit plus jamais forcer un défilement horizontal de la page entière,
 * les défilements voulus (nav, tableaux) restent locaux via leur propre
 * `overflow-x: auto`.
 */
.esp-shell { overflow-x: hidden; }
@media (max-width: 860px) {
    .esp-layout--sidebar { flex-direction: column; }
    .esp-nav {
        flex: none;
        width: 100%;
        min-width: 0;
        box-sizing: border-box;
        border-right: 0;
        border-bottom: 1px solid var(--esp-border);
    }
    .esp-nav__links { flex-wrap: nowrap; overflow-x: auto; min-width: 0; }
    .esp-nav__link { flex: none; }
    .esp-main { flex: none; width: 100%; min-width: 0; box-sizing: border-box; }
}
@media (prefers-reduced-motion: reduce) {
    .esp-shell * { transition: none !important; }
}
