/* Thème commun avec ElectroStock (même charte ENSEA, mêmes composants Bootstrap).
 * Source : ElectroStock/static/css/electrostock.css — conforme à la charte d'identité visuelle ENSEA (mars 2021).
 *
 * Couleurs (charte, « Web RVB » et « Colorimétrie des documents ») :
 *   rouge ENSEA  #A6004C  (R166 V0 B76, Pantone 207) — couleur principale
 *   gris ENSEA   #9C9B9B  (noir 50 %, Pantone 423)
 *   gris foncé   #706F6F  (noir 70 %)        noir  #1D1D1B (noir 100 %)
 *   secondaires  bleu #00AAD0 · vert #95C41F · jaune #DEDC00 · orange #E9511B
 * Typographie : Verdana (recommandée « pour faciliter la lecture ») ; Myriad Pro et
 * Geogrotesque sont des polices sous licence non diffusables sur le web.
 * Logo : fond clair, version couleur ; largeur web minimale 50 px.
 */
:root {
  /* Charte */
  --ensea-red: #a6004c;
  --ensea-red-700: #85003d;   /* survol */
  --ensea-red-800: #6e0033;   /* actif */
  --ensea-red-50: #f8e6ee;    /* teinte de fond */
  --ensea-grey: #9c9b9b;
  --ensea-grey-70: #706f6f;
  --ensea-black: #1d1d1b;
  --ensea-blue: #00aad0;
  --ensea-green: #95c41f;
  --ensea-yellow: #dedc00;
  --ensea-orange: #e9511b;

  /* Rôles de l'interface */
  --es-primary: var(--ensea-red);
  --es-ink: var(--ensea-black);
  --es-muted: #646363;        /* gris 70 % assombri : contraste ≥ 4,5:1 sur fond gris clair */
  --es-border: #dddcdc;
  --es-surface: #ffffff;
  --es-bg: #f5f5f4;           /* « noir 6 % » éclairci, fond neutre de la charte */
  --es-warning: #c2410c;      /* orange charte assombri pour le texte */
  --es-danger: #d92d20;       /* rouge d'erreur, plus orangé que le rouge ENSEA */
  --es-font: Verdana, "DejaVu Sans", "Bitstream Vera Sans", Geneva, Tahoma, sans-serif;

  --bs-primary: var(--es-primary);
  --bs-primary-rgb: 166, 0, 76;
  --bs-link-color: var(--ensea-red);
  --bs-link-color-rgb: 166, 0, 76;
  --bs-link-hover-color: var(--ensea-red-700);
  --bs-link-hover-color-rgb: 133, 0, 61;
  --bs-body-color: var(--es-ink);
  --bs-body-bg: var(--es-bg);
  --bs-border-color: var(--es-border);
  --bs-secondary-color: var(--es-muted);
  --bs-body-font-family: var(--es-font);
  --bs-body-font-size: 0.875rem;  /* Verdana est large : 14 px reste très lisible */
  --bs-body-line-height: 1.5;
  --bs-danger: var(--es-danger);
  --bs-danger-rgb: 217, 45, 32;
}

body { background: var(--es-bg); min-height: 100vh; display: flex; flex-direction: column; }
main { flex: 1; }
h1, h2, h3, h4, h5, h6, .h1, .h2, .h3, .h4, .h5, .h6 { font-family: var(--es-font); font-weight: 700; color: var(--es-ink); }
a { text-underline-offset: .15em; }
::selection { background: var(--ensea-red-50); }

/* --- En-tête : fond blanc, logo couleur (utilisation courante) ------------------------------ */
/* Zone de protection du logo (charte) : hauteur d'un « E » tout autour, ≈ 9 px pour un logo de 52 px. */
.es-topbar { background: var(--es-surface); border-bottom: 3px solid var(--ensea-red); padding-top: .6rem; padding-bottom: .6rem; }
.es-topbar .navbar-brand { display: flex; align-items: center; gap: .85rem; color: var(--es-ink); padding: 0; margin-right: 1.5rem; }
.es-logo { height: 52px; width: 52px; display: block; }  /* ≥ 50 px de large (charte) */
.es-brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.es-brand-text strong { color: var(--ensea-red); font-size: 1.15rem; letter-spacing: .01em; }
.es-brand-text small { color: var(--es-muted); font-size: .72rem; letter-spacing: .02em; }
.es-topbar .nav-link { color: var(--es-ink); font-weight: 400; border-bottom: 2px solid transparent; padding-left: .7rem; padding-right: .7rem; }
.es-topbar .nav-link:hover, .es-topbar .nav-link:focus { color: var(--ensea-red); }
.es-topbar .nav-link.active { color: var(--ensea-red); font-weight: 700; border-bottom-color: var(--ensea-red); }
.es-topbar .dropdown-menu { font-size: .85rem; border-color: var(--es-border); box-shadow: 0 4px 12px rgba(29, 29, 27, .08); }
.es-topbar .dropdown-item:active { background: var(--ensea-red); }
.es-topbar .badge-todo { background: var(--ensea-red); color: #fff; font-weight: 700; }
@media (min-width: 992px) {
  .es-topbar .navbar-nav .nav-link { padding-top: 1.1rem; padding-bottom: 1.05rem; }
}

/* --- Mise en page ------------------------------------------------------------------------------------ */
.page-header { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 1rem; margin: 1.75rem 0 1.25rem; }
.page-header h1 { font-size: 1.4rem; margin: 0; color: var(--ensea-red); }
.page-header h1 .text-muted { color: var(--es-muted) !important; }
.page-header .subtitle { color: var(--es-muted); margin: .3rem 0 0; }
.card { border-color: var(--es-border); border-radius: .375rem; box-shadow: 0 1px 2px rgba(29, 29, 27, .04); }
.card-header { background: var(--es-surface); font-weight: 700; font-size: .78rem; text-transform: uppercase; letter-spacing: .05em; border-bottom-color: var(--es-border); padding-top: .8rem; padding-bottom: .8rem; }
.card-header .fw-normal, .card-header .small { text-transform: none; letter-spacing: 0; }
.section-title { font-size: .72rem; text-transform: uppercase; letter-spacing: .07em; color: var(--ensea-red); font-weight: 700; margin-bottom: .5rem; }
.table { --bs-table-bg: transparent; --bs-table-hover-bg: #fbf3f6; margin-bottom: 0; }
.table thead th { font-size: .7rem; text-transform: uppercase; letter-spacing: .05em; color: var(--es-muted); font-weight: 700; border-bottom-width: 1px; white-space: nowrap; }
.table td { vertical-align: middle; }
.table a, .card-header a, .list-group-item a { text-decoration: none; }
.table a:hover, .card-header a:hover, .list-group-item a:hover { text-decoration: underline; }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "DejaVu Sans Mono", monospace; font-size: .9em; }
.table .mono { white-space: nowrap; }
.text-over { color: var(--es-danger) !important; font-weight: 700; }
.footer { color: var(--es-muted); font-size: .75rem; border-top: 1px solid var(--es-border); background: var(--es-surface); }
.footer strong { color: var(--ensea-red); }

/* --- Boutons, formulaires --------------------------------------------------------------------------- */
.btn { font-size: .85rem; }
.btn-primary {
  --bs-btn-bg: var(--ensea-red); --bs-btn-border-color: var(--ensea-red);
  --bs-btn-hover-bg: var(--ensea-red-700); --bs-btn-hover-border-color: var(--ensea-red-700);
  --bs-btn-active-bg: var(--ensea-red-800); --bs-btn-active-border-color: var(--ensea-red-800);
  --bs-btn-disabled-bg: var(--ensea-red); --bs-btn-disabled-border-color: var(--ensea-red);
  --bs-btn-focus-shadow-rgb: 166, 0, 76;
}
.btn-outline-primary {
  --bs-btn-color: var(--ensea-red); --bs-btn-border-color: var(--ensea-red);
  --bs-btn-hover-bg: var(--ensea-red); --bs-btn-hover-border-color: var(--ensea-red);
  --bs-btn-active-bg: var(--ensea-red-700); --bs-btn-active-border-color: var(--ensea-red-700);
  --bs-btn-focus-shadow-rgb: 166, 0, 76;
}
.btn-outline-secondary {
  --bs-btn-color: var(--ensea-black); --bs-btn-border-color: #bdbcbc;
  --bs-btn-hover-bg: #ededed; --bs-btn-hover-color: var(--ensea-black); --bs-btn-hover-border-color: var(--ensea-grey);
  --bs-btn-active-bg: #e2e2e2; --bs-btn-active-color: var(--ensea-black);
}
.btn-success {  /* actions de validation : vert de la charte assombri pour le contraste */
  --bs-btn-bg: #4d7a0f; --bs-btn-border-color: #4d7a0f;
  --bs-btn-hover-bg: #3f640c; --bs-btn-hover-border-color: #3f640c;
  --bs-btn-active-bg: #34530a; --bs-btn-active-border-color: #34530a;
}
.btn-danger, .btn-outline-danger { --bs-btn-focus-shadow-rgb: 217, 45, 32; }
.btn-outline-danger { --bs-btn-color: var(--es-danger); --bs-btn-border-color: var(--es-danger); --bs-btn-hover-bg: var(--es-danger); --bs-btn-hover-border-color: var(--es-danger); }
.btn-danger { --bs-btn-bg: var(--es-danger); --bs-btn-border-color: var(--es-danger); }
.form-label { font-weight: 700; font-size: .8rem; margin-bottom: .3rem; }
.form-text { color: var(--es-muted); font-size: .75rem; }
.form-control, .form-select { border-color: #cfcece; font-size: .875rem; }
.form-control:focus, .form-select:focus, .form-check-input:focus { border-color: var(--ensea-red); box-shadow: 0 0 0 .2rem rgba(166, 0, 76, .15); }
.form-check-input:checked { background-color: var(--ensea-red); border-color: var(--ensea-red); }
.form-control::placeholder { color: #a8a7a7; opacity: 1; }
.page-link { color: var(--ensea-red); }
.choices ul, .choices div { list-style: none; padding-left: 0; display: flex; gap: 1.25rem; flex-wrap: wrap; }
.choices input { margin-right: .35rem; }
.alert { font-size: .85rem; }

/* --- Indicateurs ------------------------------------------------------------------------------------- */
.kpi { padding: 1rem 1.25rem; border-top: 3px solid var(--ensea-red); }
.kpi .kpi-label { font-size: .7rem; color: var(--es-muted); text-transform: uppercase; letter-spacing: .06em; font-weight: 700; }
.kpi .kpi-value { font-size: 1.5rem; font-weight: 700; line-height: 1.25; font-variant-numeric: tabular-nums; }
.kpi .kpi-sub { font-size: .75rem; color: var(--es-muted); }
a.kpi-link { color: inherit; text-decoration: none; display: block; }
a.kpi-link:hover .card { box-shadow: 0 2px 8px rgba(166, 0, 76, .12); }

/* --- Page de connexion : logo Beyond Engineering + epsilon en filigrane (noir 6 %) ------------------- */
.login-page { position: relative; overflow: hidden; }
.login-page::before {
  content: ""; position: absolute; right: -6vw; bottom: -10vh; width: min(70vw, 760px); aspect-ratio: 600 / 573;
  background: url("../img/epsilon.27af75f06fd4.png") no-repeat center / contain; opacity: .06; pointer-events: none;
}
.login-wrapper { position: relative; max-width: 420px; margin: 6vh auto; }
.login-wrapper .card { padding: 1.75rem; border-top: 4px solid var(--ensea-red); }
.login-logo { width: 190px; height: auto; display: block; margin: 0 auto 1.5rem; }
.login-wrapper h1 { color: var(--ensea-red); font-size: 1.25rem; }

@media (max-width: 767.98px) {
  .page-header h1 { font-size: 1.2rem; }
  .kpi .kpi-value { font-size: 1.25rem; }
  .es-logo { width: 50px; height: 50px; }
  .es-brand-text small { display: none; }
}
@media print {
  .es-topbar, .footer, .btn, form.no-print { display: none !important; }
  body { background: #fff; }
}

/* =====================================================================================================
 * Inventaire D265 — éléments propres.
 * Signature minimaliste qui distingue l'inventaire d'ElectroStock : le « trait ».
 * Les meubles sont dessinés au trait fin (vue 3D et miniatures) : volumes blancs, arêtes noires à 1 px,
 * le rouge ENSEA réservé à l'interaction (survol, sélection) et le bleu à la recherche.
 * ===================================================================================================== */
:root { --trait: rgba(29, 29, 27, .72); --trait-leger: rgba(29, 29, 27, .18); }

.es-brand-text small { font-family: var(--es-font); }
.chip { display: inline-flex; align-items: center; gap: .35rem; padding: .1rem .55rem; border: 1px solid var(--es-border); border-radius: 999px; font-size: .72rem; background: #fff; white-space: nowrap; color: var(--es-ink); }
.chip .dot, .dot { width: .55rem; height: .55rem; border-radius: 50%; display: inline-block; flex: none; }
.loc { font-size: .78rem; white-space: nowrap; }
.loc i { color: var(--ensea-red); }
.loc.hors { color: var(--es-muted); }
.qty-input { width: 5.5rem; text-align: right; }
.empty-state { color: var(--es-muted); text-align: center; padding: 2rem 1rem; }

/* Miniatures au trait (cartes des meubles) */
.mini-trait { display: block; width: 100%; height: 120px; margin: .5rem 0 .75rem; }
.mini-trait * { vector-effect: non-scaling-stroke; }
.meuble-card { color: inherit; text-decoration: none; display: block; height: 100%; }
.meuble-card .card { height: 100%; transition: border-color .15s; }
.meuble-card:hover .card { border-color: var(--ensea-red); }
.meuble-card:hover .mini-trait .corps { stroke: var(--ensea-red); }

/* Vue 3D */
.stage { position: relative; height: min(70vh, 680px); min-height: 420px; background: #fff; border: 1px solid var(--es-border); border-radius: .375rem; overflow: hidden; }
.stage canvas { display: block; width: 100%; height: 100%; touch-action: none; }
.stage .toolbar { position: absolute; left: .75rem; top: .75rem; right: .75rem; display: flex; gap: .4rem; flex-wrap: wrap; pointer-events: none; }
.stage .toolbar > * { pointer-events: auto; }
.stage .toolbar .form-control { width: 15rem; background: rgba(255, 255, 255, .92); }
.stage .toolbar .btn { background: rgba(255, 255, 255, .92); }
.stage .hint { position: absolute; bottom: .6rem; left: .75rem; font-size: .72rem; color: var(--es-muted); pointer-events: none; }
.stage .tooltip-3d { position: absolute; pointer-events: none; background: var(--ensea-black); color: #fff; padding: .25rem .5rem; border-radius: .25rem; font-size: .75rem; transform: translate(12px, 12px); display: none; white-space: nowrap; z-index: 2; }
.panel-3d { max-height: min(70vh, 680px); overflow-y: auto; }
.panel-3d .item { border: 1px solid var(--es-border); border-radius: .375rem; padding: .5rem .65rem; margin-bottom: .5rem; cursor: pointer; background: #fff; }
.panel-3d .item:hover { border-color: var(--es-muted); }
.panel-3d .item.match { border-color: var(--ensea-blue); box-shadow: inset 3px 0 0 var(--ensea-blue); }
.panel-3d .item.active { border-color: var(--ensea-red); box-shadow: inset 3px 0 0 var(--ensea-red); }
.panel-3d .item ul { margin: .25rem 0 0; padding-left: 1rem; font-size: .8rem; }
.panel-3d .item ul li.match { font-weight: 700; }
@media (max-width: 991.98px) { .stage { height: 58vh; } .panel-3d { max-height: none; } }

/* Éditeur de grille (disposition des tiroirs, cases d'un tiroir) */
.grid-editor { position: relative; display: grid; user-select: none; touch-action: none; background: #fff; border: 1px solid var(--trait); border-radius: 2px; }
.grid-editor .cell { border-right: 1px dotted var(--trait-leger); border-bottom: 1px dotted var(--trait-leger); }
.grid-editor .rect { position: relative; margin: 2px; border: 1px solid var(--trait); border-radius: 2px; display: flex; flex-direction: column; justify-content: center; align-items: center; text-align: center; padding: 2px; overflow: hidden; font-size: .7rem; line-height: 1.2; color: var(--es-ink); z-index: 2; background: #fff; }
.grid-editor .rect a { color: inherit; text-decoration: none; }
.grid-editor .rect a:hover { color: var(--ensea-red); }
.grid-editor .rect .lbl { font-weight: 700; }
.grid-editor .rect .content { font-size: .62rem; max-width: 100%; overflow: hidden; overflow-wrap: anywhere; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; }
.grid-editor .rect .tools { position: absolute; top: 1px; right: 1px; display: flex; gap: 1px; opacity: 0; transition: opacity .15s; }
.grid-editor .rect:hover .tools, .grid-editor .rect:focus-within .tools { opacity: 1; }
.grid-editor .rect .tools a, .grid-editor .rect .tools button { background: #fff; border: 1px solid var(--es-border); border-radius: 2px; font-size: .66rem; padding: 0 .3rem; cursor: pointer; color: var(--es-ink); line-height: 1.4; }
.grid-editor .rect:hover { border-color: var(--ensea-red); }
.grid-editor .selection { border: 1.5px solid var(--ensea-red); background: rgba(166, 0, 76, .08); z-index: 3; pointer-events: none; margin: 1px; }
.grid-editor .selection.invalid { border-style: dashed; background: rgba(217, 45, 32, .08); }
.grid-editor.editable .cell { cursor: crosshair; }
.grid-axis { display: flex; justify-content: space-between; color: var(--es-muted); font-size: .72rem; margin: .25rem .1rem; }
.drawer-grid { aspect-ratio: var(--ratio, 1.5); }

/* Arborescence des catégories */
.arbre .noeud > summary { list-style: none; cursor: pointer; }
.arbre .noeud > summary::-webkit-details-marker { display: none; }
.arbre .ligne { display: flex; align-items: center; gap: .5rem; padding: .3rem .4rem; border-radius: .25rem; border-bottom: 1px dotted var(--trait-leger); }
.arbre .ligne:hover { background: #fbf3f6; }
.arbre .ligne.cible { box-shadow: inset 3px 0 0 var(--ensea-red); background: #fbf3f6; }
.arbre summary .ligne::before { content: "\F285"; font-family: "bootstrap-icons"; font-size: .7rem; color: var(--es-muted); width: .8rem; transition: transform .15s; }
.arbre details[open] > summary .ligne::before { transform: rotate(90deg); }
.arbre summary.feuille .ligne::before { content: ""; }
.arbre .enfants { margin-left: 1.1rem; padding-left: .6rem; border-left: 1px solid var(--trait-leger); }
.arbre .btn-link { color: var(--es-muted); }
.arbre .btn-link:hover { color: var(--ensea-red); }

/* Vue complète */
.explorateur-arbre .card-body { max-height: 75vh; overflow-y: auto; padding: .5rem .75rem; }
.feuille-composant { display: flex; justify-content: space-between; gap: .5rem; padding: .22rem .4rem; font-size: .8rem; color: var(--es-ink); text-decoration: none; border-radius: .25rem; min-width: 0; }
.feuille-composant:hover { background: #fbf3f6; color: var(--ensea-red); text-decoration: none; }
.feuille-composant.active { background: var(--ensea-red); color: #fff; }
.feuille-composant.active .text-muted, .feuille-composant.active .qte { color: #fff !important; }
.feuille-composant .qte { color: var(--es-muted); font-variant-numeric: tabular-nums; flex: none; }
.fiche-compacte dt { color: var(--es-muted); font-weight: 400; }
.fiche-compacte dd { margin-bottom: .35rem; }
#detail.htmx-request { opacity: .5; transition: opacity .2s; }
#detail .plan-salle { max-height: 340px; }

/* Plan de la salle et schémas au trait */
.plan-salle { width: 100%; height: auto; display: block; font-family: var(--es-font); }
.plan-salle .carroyage line { stroke: #ececeb; stroke-width: 1; }
.plan-salle .murs { fill: none; stroke: var(--ensea-black); stroke-width: 6; }
.plan-salle .cote { font-size: 16px; fill: var(--es-muted); }
.plan-salle .meuble .corps { fill: #fff; stroke: var(--trait); stroke-width: 2; }
.plan-salle .meuble .facade { stroke: var(--ensea-black); stroke-width: 5; }
.plan-salle .sigle { fill: var(--es-ink); pointer-events: none; }
.plan-salle a, .plan-salle a:hover { text-decoration: none; }
.plan-salle a:hover .corps { stroke: var(--ensea-red); }
.plan-salle .meuble.actif .corps { fill: rgba(166, 0, 76, .18); stroke: var(--ensea-red); stroke-width: 3; }
.plan-salle .meuble.actif .facade { stroke: var(--ensea-red); }
.plan-salle .meuble.actif + .sigle, .plan-salle a:has(.meuble.actif) .sigle { fill: var(--ensea-red); font-weight: 700; }
.plan-salle[data-editable] .meuble { cursor: move; }
.plan-salle .meuble.selection .corps { stroke: var(--ensea-red); stroke-width: 3; stroke-dasharray: 8 4; fill: rgba(166, 0, 76, .08); }
.schema { width: 100%; height: auto; max-height: 260px; display: block; font-family: var(--es-font); }
.schema rect { fill: #fff; stroke: var(--trait); stroke-width: 1; }
.schema text { fill: var(--es-muted); font-size: 8px; }
.schema .actif, .schema rect.actif { fill: rgba(166, 0, 76, .22); stroke: var(--ensea-red); stroke-width: 2; }
.schema text.actif { fill: var(--ensea-red); font-weight: 700; }
.schema.tiroir .bac { fill: #fff; stroke: var(--ensea-black); stroke-width: 1.5; }
.schema.tiroir .grille { stroke: #e4e4e3; stroke-width: .6; stroke-dasharray: 2 2; }
.schema.tiroir .case { fill: #fff; stroke: var(--trait); stroke-width: .8; }
.schema.tiroir .facade { stroke: var(--ensea-black); stroke-width: 3; }
