/*
 * Maple Admin — mise en page des écrans communs aux deux rôles : connexion (E-03), menu du
 * compte et tiroir du cadre (E-01), page en cours de livraison, squelettes de chargement,
 * supervision (E-02, E-10), confirmations (E-17), clients (E-04, E-05, E-06), cadrages (E-07, E-08,
 * E-09), recherche globale et historique des bilans (E-11).
 * Aucun composant n'y est redéfini. Référence : docs/architecture/adminweb.md.
 */

/* ---- Connexion ---- */

.signin {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-height: 100vh;
  padding: 120px var(--space-5) var(--space-7);
  background: var(--bg);
}

.signin__column { display: flex; flex-direction: column; gap: var(--space-5); width: min(400px, 100%); }
.signin__brand { display: flex; align-items: center; gap: 10px; }
.signin__brand .brand__name { color: var(--text); }
.signin__brand .badge { margin-left: auto; }
.signin__card { border: 1px solid var(--border); border-radius: var(--radius-panel); background: var(--surface); }
.signin__body { display: flex; flex-direction: column; gap: var(--space-5); padding: var(--space-6); }
.signin__form { display: flex; flex-direction: column; gap: var(--space-4); }
.signin__form .btn { margin-top: var(--space-2); }

.spinner {
  width: 14px;
  height: 14px;
  border: 2px solid rgba(255, 255, 255, 0.45);
  border-top-color: #FFFFFF;
  border-radius: 50%;
  animation: spinner-turn 0.8s linear infinite;
}

@keyframes spinner-turn {
  to { transform: rotate(360deg); }
}

@media (max-width: 640px) {
  .signin { padding-top: var(--space-7); }
}

/* ---- Menu du compte, ouvert au-dessus du bouton de l'utilisateur ---- */

.account { position: relative; }

.account .menu {
  position: absolute;
  right: var(--space-2);
  bottom: calc(100% + var(--space-1));
  left: var(--space-2);
  z-index: 2;
  min-width: 0;
}

.account .menu[hidden] { display: none; }
.account .segmented { margin: 2px 10px 6px; }
.menu__identity { padding: 8px 10px 6px; }
.menu__identity .small { overflow-wrap: anywhere; }
.menu__item { width: 100%; font-size: var(--text-14); }

/* ---- Contenu de page ---- */

.page-body { display: flex; flex-direction: column; gap: var(--space-5); }
.page--narrow { max-width: 720px; }

/* ---- Squelettes : largeurs fixes, aucun style en ligne ---- */

.skeleton-row td { height: var(--row-height); }
.skeleton--w20 { width: 20%; }
.skeleton--w35 { width: 35%; }
.skeleton--w50 { width: 50%; }
.skeleton--w65 { width: 65%; }
.skeleton--w80 { width: 80%; }

/* ---- Supervision : tableau de bord (E-02) et bilans en cours (E-10) ---- */

.dashboard,
.live { display: flex; flex-direction: column; gap: var(--space-5); }

.production .panel__header { align-items: flex-end; padding-top: var(--space-4); padding-bottom: var(--space-4); }
.production__queue { border-top: 1px solid var(--border); }

.production__queue-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-3);
  padding: var(--space-4) var(--space-5) var(--space-3);
}

.production__queue .table th { position: static; }

.queue-pos {
  width: 56px;
  color: var(--text-3);
  font-family: var(--font-display);
  font-size: var(--text-16);
  font-weight: 600;
}

.bay__client { display: flex; align-items: center; gap: var(--space-2); }
.bay__eta { color: var(--text-2); font-size: var(--text-12); line-height: 16px; font-variant-numeric: tabular-nums; }
.bay__meta { display: flex; flex-direction: column; gap: 2px; }
.bay__note { color: var(--attention-ink); font-size: var(--text-12); line-height: 16px; }
.progress__label .pct { color: var(--text); font-weight: 600; }
/* Origine et auteur sur une ligne : la hauteur d'une ligne de file ne dépend pas de l'auteur. */
.origin { display: flex; flex-wrap: nowrap; align-items: center; gap: var(--space-2); white-space: nowrap; }
.reason { max-width: 40ch; color: var(--text-2); }
.reason--inline { display: none; }
.side-stack { display: flex; flex-direction: column; gap: var(--space-5); }
/* Un nom long passe à la ligne sans glisser sous le niveau. */
.timeline__item > .stack { min-width: 0; overflow-wrap: break-word; }

/* Colonne principale resserrée (tiroir ouvert à droite, fenêtre de 960 à 1 180 px) : le tableau de bord et les bilans en
   cours suivent la largeur de leur conteneur, pas celle de la fenêtre ; à pleine largeur, rien ne change. Emplacements,
   comptes et grille : components.css, avant ses règles de fenêtre étroite. */
.dashboard,
.live { container: supervision / inline-size; }

@container supervision (max-width: 900px) {
  /* File : identifiant et durée estimée masqués, la table tient dans sa carte. */
  .queue-table .col-id,
  .queue-table .col-eta { display: none; }
  /* Bilans en erreur : la raison passe sous le cadrage, l'action garde sa place. */
  .reason--col { display: none; }
  .reason--inline { display: block; max-width: none; margin-top: var(--space-1); font-size: var(--text-12); line-height: 16px; }
}
.scheduler-state .status { font-family: var(--font-display); font-size: var(--text-21); font-weight: 600; }

/* Barre de progression native : la valeur est un attribut, aucun style en ligne. */
.progress__meter {
  display: block;
  width: 100%;
  height: 6px;
  overflow: hidden;
  border: 0;
  border-radius: var(--radius-pill);
  background: var(--surface-sunken);
  box-shadow: inset 0 0 0 1px var(--border);
  color: var(--accent);
  appearance: none;
}

.progress__meter::-webkit-progress-bar { border-radius: inherit; background: var(--surface-sunken); box-shadow: inset 0 0 0 1px var(--border); }
.progress__meter::-webkit-progress-value { border-radius: inherit; background: var(--accent); }
.progress__meter::-moz-progress-bar { border-radius: inherit; background: var(--accent); }
.progress--attention .progress__meter::-webkit-progress-value { background: var(--attention); }
.progress--attention .progress__meter::-moz-progress-bar { background: var(--attention); }

/* ---- Confirmations (E-17) : l'objet d'abord, puis ses conséquences ---- */

.subject { display: flex; flex-direction: column; gap: 2px; }
.subject__name { font-family: var(--font-display); font-size: var(--text-18); font-weight: 600; line-height: 24px; }

.subject__meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-1) var(--space-2);
  color: var(--text-3);
  font-size: var(--text-12);
  line-height: 20px;
}

.transition { display: inline-flex; flex-wrap: wrap; align-items: center; gap: var(--space-1) var(--space-2); }
.transition > .icon { color: var(--text-3); }
.impact strong { font-weight: 600; }

/* ---- Clients : liste (E-04), fiche (E-05), formulaire en feuille latérale (E-06) ---- */

.client-search { width: 420px; max-width: 100%; }
.filters { display: flex; flex-wrap: wrap; align-items: center; align-self: flex-start; gap: var(--space-2) var(--space-5); }
.filter { display: flex; align-items: center; gap: var(--space-2); }
.filter__label { color: var(--text-3); font-size: var(--text-12); }
.filter .select-wrap { width: 168px; }
.col-id { width: 214px; }
.col-count { width: 104px; }
.col-created { width: 150px; }
.col-run { width: 210px; }
.col-date { width: 190px; }
.last-run { display: flex; flex-direction: column; gap: 2px; }
.page-size { display: flex; align-items: center; gap: var(--space-2); }
.page-size .select-wrap { width: 76px; }

.client-detail { display: flex; flex-direction: column; gap: var(--space-5); }
/* Domaine d'un client : lien vers son site, ouvert à part, icône après le nom. */
.domain-link .icon { margin-left: var(--space-1); }
.overview { display: grid; grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); gap: var(--space-5); }
.overview .panel { display: flex; flex-direction: column; }
.overview .panel__body { flex: 1 1 auto; }
.kv dd .copy-id { margin-top: -4px; }
.count { margin-left: var(--space-1); color: var(--text-3); font-weight: 500; }
.col-start { width: 240px; }
.run { display: flex; flex-direction: column; gap: 6px; min-width: 240px; max-width: 300px; }

/* La page sous la feuille reste visible, atténuée ; la feuille garde le focus (le reste est inerte).
   Dans la colonne réduite, la fiche passe sur une colonne. */
.page--backdrop { opacity: 0.55; }
.app--sheet .overview { grid-template-columns: minmax(0, 1fr); }
/* Ses tableaux se resserrent pour tenir dans la colonne réduite ; plus large, un tableau défile dans sa carte. */
.app--sheet .page .table th,
.app--sheet .page .table td { padding-right: var(--space-2); padding-left: var(--space-2); }
.app--sheet .page .table th:first-child,
.app--sheet .page .table td:first-child { padding-left: var(--space-3); }
.app--sheet .col-id,
.app--sheet .col-count,
.app--sheet .col-created,
.app--sheet .col-run,
.app--sheet .col-date,
.app--sheet .col-start { width: auto; }
.app--sheet .run { min-width: 128px; }
.run .progress__label { flex-wrap: wrap; column-gap: var(--space-3); row-gap: 2px; }
.sheet .sheet__body { display: flex; flex-direction: column; gap: var(--space-5); }
/* Sans alerte, la première section n'a pas de filet au-dessus d'elle. */
.sheet__body > [hidden]:first-child + .form-section { padding-top: 0; border-top: 0; }

.resource-head,
.resource-row { display: grid; grid-template-columns: 140px minmax(0, 1fr) 32px; gap: var(--space-2); align-items: center; }
.resource-head { color: var(--text-3); font-size: var(--text-12); line-height: 16px; }
.resource-row .field__error { grid-column: 1 / -1; }
.resource-row.field--error .input[aria-invalid="true"] { border-color: var(--danger); }
.sheet__footer .cluster { margin-left: auto; }

/* ---- Cadrages : liste (E-07), fiche (E-08), formulaire en feuille large (E-09) ---- */

.target-search { width: 480px; max-width: 100%; }
/* Filtres de la liste sur une ligne : client, niveau, fréquence, dernier bilan, puis le tri à droite. */
.target-filters { flex: 1 1 auto; align-self: stretch; column-gap: var(--space-2); }
.client-filter { width: 200px; }
.target-filters > .select-wrap { width: 184px; }
.filter--end { margin-left: auto; }
.filter--end .select-wrap { width: 200px; }
/* La sélection avancée a son propre bouton d'effacement : celui du champ de recherche natif est masqué. */
.combobox input[type="search"]::-webkit-search-cancel-button { display: none; appearance: none; }
.targets th,
.targets td { padding-right: var(--space-3); padding-left: var(--space-3); }
.targets th:first-child,
.targets td:first-child { padding-left: var(--space-4); }
.col-tier { width: 76px; }
.col-last { width: 250px; }
.target-cell { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; }
.plain-link { color: var(--text-2); text-decoration: none; }
.plain-link:hover { color: var(--accent-strong); text-decoration: underline; }

.target-detail { display: flex; flex-direction: column; gap: var(--space-5); }
.target-summary { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)) minmax(0, 1.25fr); }
.target-summary .fact { justify-content: space-between; padding: var(--space-4); border-right: 1px solid var(--border); }
.target-summary .fact:first-child { padding-left: var(--space-5); }
.target-summary .fact:last-child { border-right: 0; }
.target-summary .fact__value { display: flex; align-items: center; min-height: 24px; white-space: nowrap; }
.main-stack { display: flex; flex-direction: column; gap: var(--space-5); }
.params { gap: var(--space-4) var(--space-6); }
.params dt { color: var(--text-2); }
.params .key { display: block; color: var(--text-3); font-family: var(--font-mono); font-size: var(--text-12); line-height: 16px; }
.tight { padding-top: var(--space-1); padding-bottom: var(--space-1); }

/* Bilan en cours d'un cadrage : en tête de ses bilans, liseré d'accent. */
.current {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-3) var(--space-5);
  padding: var(--space-4) var(--space-5);
  border-bottom: 1px solid var(--border);
  background: linear-gradient(var(--accent), var(--accent)) left / 3px 100% no-repeat;
}

.current .run { flex: 1 1 280px; max-width: none; }
.current__actions { margin-left: auto; }

.field__key { margin-left: var(--space-2); color: var(--text-3); font-family: var(--font-mono); font-size: var(--text-12); font-weight: 400; }
.tiers { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--space-2); }

.tier-option {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  height: 44px;
  padding: 0 var(--space-3);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-control);
  background: var(--surface);
  cursor: pointer;
}

.tier-option input { margin: 0; accent-color: var(--accent); }
.tier-option:has(input:checked) { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); background: var(--accent-tint); }
.next-dates { display: flex; flex-wrap: wrap; gap: var(--space-2); list-style: none; }
.form-section > .field__error { margin-top: var(--space-2); }

/* Sous la feuille large, la page se resserre : la fiche passe sur une colonne (son résumé aussi, par la requête de
   conteneur plus bas) ; la liste ne garde que le cadrage et son niveau, sans filtres ni pagination. */
.app--sheet-wide .grid--main-side { grid-template-columns: minmax(0, 1fr); }
.app--sheet-wide .targets :is(th, td):not(:first-child):not(:nth-child(3)) { display: none; }
.app--sheet-wide .page .target-filters,
.app--sheet-wide .page .pagination { display: none; }

/* Synthèse : le target ID à la taille et au contraste de la maquette. */
.target-summary .id { color: var(--text); font-size: var(--text-14); }

/* ---- Textes longs : une ligne, jamais coupée au trait d'union ; texte complet en title ---- */

/* Domaine : une ligne, ellipse. */
.one-line { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* Fil d'Ariane : une ligne, le dernier segment en ellipse. */
.breadcrumb { flex-wrap: nowrap; min-width: 0; }
.breadcrumb > [aria-current="page"] { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* Identifiants : une ligne, en ellipse quand la carte se resserre sous une feuille. */
.copy-id { min-width: 0; }
.copy-id > .id { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.target-summary .fact__value { min-width: 0; }
.app--sheet .page .id,
.app--sheet-wide .page .id { display: inline-block; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; vertical-align: bottom; }
.app--sheet-wide .col-exec { display: none; }

/* ---- Page resserrée : conteneur « page » (frame.css) ---- */

/* Une feuille ouverte laisse à la page 584 px (feuille) ou 384 px (feuille large) à 1 440 px, une fenêtre étroite moins
   de 720 px : fiches et listes suivent la largeur de la page, pas celle de la fenêtre ; à pleine largeur, rien ne change.
   Colonnes secondaires repliées (col-fold : Client ID et création de la liste des clients, fréquence des cadrages d'une
   fiche client) et colonne d'action en icône (le libellé reste son nom accessible, et son title). */
@container page (max-width: 720px) {
  .table .col-fold { display: none; }
  .table col { width: auto; }
  .table .is-actions .btn__label {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
  }
}

/* Page de la feuille large : en-tête sur deux lignes (fil d'Ariane et titre entiers, actions dessous), synthèse d'un
   cadrage sur une colonne (target ID entier), paramètres aux libellés resserrés (domaine entier). */
@container page (max-width: 520px) {
  .page-header { flex-direction: column; align-items: flex-start; }
  .target-summary { grid-template-columns: minmax(0, 1fr); }
  .target-summary .fact { padding-left: var(--space-5); border-right: 0; border-bottom: 1px solid var(--border); }
  .target-summary .fact:last-child { border-bottom: 0; }
  .params { grid-template-columns: minmax(0, 140px) minmax(0, 1fr); column-gap: var(--space-4); }
}

/* ---- Recherche globale ---- */

.search-box { width: min(560px, 80vw); }

/* ---- Historique des bilans (E-11) ---- */

.tabs-bar { padding: 0 var(--space-5); }
.history-filters { align-self: stretch; column-gap: var(--space-2); }
.history-filters .combobox { width: 320px; max-width: 100%; }
.history .cell-title { white-space: nowrap; }
/* Un nom de client court tient sur une ligne ; un nom long passe à la ligne. */
.history .client { min-width: 15ch; }
/* Avec les colonnes de l'extension du rôle, les cellules se resserrent et les actions d'une ligne ne gardent que leur
   icône, à la taille d'un bouton d'icône (libellé lu et dans le title, comme sur une page resserrée) : le tableau tient
   dans sa carte à 1 440 px, sans défilement, et la raison garde de quoi se lire sur deux lignes. */
.history--compact th,
.history--compact td { padding-right: 6px; padding-left: 6px; }
.history--compact th:first-child,
.history--compact td:first-child { padding-left: var(--space-4); }
.history--compact .is-actions .btn { width: var(--control-height-sm); padding: 0; }
.history--compact .is-actions .btn__label {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}
.row-actions { display: inline-flex; align-items: center; gap: var(--space-1); }
/* Titre d'une page suivi de son statut, sur la même ligne. */
.title-row { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-1) var(--space-3); }
.title-row .status { font-family: var(--font-display); font-size: var(--text-18); font-weight: 600; }

/* ---- Démarrer un bilan (E-18) ---- */

.start { display: flex; flex-direction: column; gap: var(--space-4); }
/* Dans le dialogue, la liste des suggestions suit le champ dans le flux : le dialogue grandit avec elle. */
.start .combobox__panel { position: static; margin-top: var(--space-1); }
.finder-foot { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); color: var(--text-3); font-size: var(--text-12); }
.finder-foot .cluster { gap: var(--space-2); }
.option__sub > .status { margin-left: var(--space-2); }
/* Récapitulatif : identité du cadrage, puis valeurs de démarrage ; la position prévue porte le seul accent. */
.recap {
  display: flex; flex-direction: column; gap: var(--space-4);
  padding: var(--space-4); border: 1px solid var(--border); border-radius: var(--radius-panel);
  background: var(--surface-sunken);
}
.recap__head { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--space-3); }
.recap__identity { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.recap__name { font-family: var(--font-display); font-size: var(--text-21); font-weight: 600; line-height: 28px; }
.recap__facts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-4) var(--space-5); }
.recap__position { font-family: var(--font-display); font-size: var(--text-24); line-height: 28px; color: var(--accent-strong); }
.recap__run { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-1) var(--space-2); color: var(--text-3); font-size: var(--text-12); line-height: 16px; }
/* Planificateur en pause : le bilan part à la reprise. */
.recap__note { display: flex; align-items: center; gap: var(--space-2); color: var(--attention-ink); font-size: var(--text-12); line-height: 16px; }

/* ---- Planning (E-12) ---- */

.planning-undated > .alert { margin-bottom: var(--space-5); }
.planning-filters .combobox { width: 280px; max-width: 100%; }
/* Dernier bilan compact : statut et pourcentage sur une ligne ; « Aucun bilan » à la taille des statuts, sans pastille. */
.last__head { display: inline-flex; align-items: baseline; gap: var(--space-2); white-space: nowrap; }
.last__head .pct { color: var(--text); font-weight: 600; font-variant-numeric: tabular-nums; }
.status--none { color: var(--text-2); }
.status--none::before { display: none; }
.filter__key { flex: none; color: var(--text-3); }
.level { display: inline-flex; align-items: center; gap: var(--space-2); }
.planning-dates { display: flex; gap: var(--space-2); color: var(--text-2); font-size: var(--text-12); font-variant-numeric: tabular-nums; white-space: nowrap; }
.planning-dates time { min-width: 48px; }
/* Cadrages sans date : nom, cause, action, une ligne chacun. */
.cause { display: grid; grid-template-columns: minmax(0, 15rem) minmax(0, 1fr) auto; gap: var(--space-4); align-items: center; padding: var(--space-2) 0; }
.cause + .cause { border-top: 1px solid var(--border); }
.cause .cell-title,
.cause .cell-sub { display: block; }

@media (max-width: 1180px) {
  .overview { grid-template-columns: minmax(0, 1fr); }
  .target-summary { grid-template-columns: minmax(0, 1fr); }
  .target-summary .fact { border-right: 0; border-bottom: 1px solid var(--border); }
}

@media (max-width: 640px) {
  .client-search,
  .target-search,
  .client-filter,
  .history-filters .combobox,
  .planning-filters .combobox { width: 100%; }
  .recap__facts { grid-template-columns: minmax(0, 1fr); }
  .cause { grid-template-columns: minmax(0, 1fr); gap: var(--space-1); }
}
