/* ============================================================================
   Skillopolis Admin — couche d'ajustements sur le design system Atlas.

   Le systeme (jetons, reset, composants, coquille) vit dans
   `design/tokens.css`, `design/base.css`, `design/components.css`,
   `design/shell.css` (synchronises depuis ../skillopolis). Cette feuille ne
   contient plus que ce qui est propre a l'admin : ecran de connexion,
   editeur de carte, widget d'activite utilisateur, quelques utilitaires de
   mise en page. Le pont Bootstrap transitoire (etapes 4-6 du plan
   refont_plan.md) a ete retire une fois le markup entierement migre.
   ========================================================================= */

/* Racine de montage Vue : transparente pour la mise en page. Sans cette regle,
   `#app` (bloc par defaut) s'intercale entre `body.has-sidebar`/`body.auth`
   et `.app-sidebar`/`.app-content`/`.login-shell` qu'ils sont censes mettre
   en ligne — la coquille et le centrage de connexion se retrouvent alors
   empiles verticalement au lieu d'etre les enfants flex directs du body. */
#app { display: contents; }

/* Racine de la coquille (composant AppShell) : même rôle que #app — transparence
   de mise en page pour préserver le flex `body.has-sidebar`. */
.app-shell-root { display: contents; }

/* ============================================================
   Mock — ajouts a remonter (MOCK → a remonter)
   ============================================================ */

/* Recherche de menu (sidebar) — specifique admin */
.sidebar-search {
    display: flex;
    align-items: center;
    gap: 6px;
    margin: 12px 10px 14px;
    padding: 6px 10px;
    border: 1px solid var(--ui-border);
    border-radius: var(--radius-sm);
    background: var(--ui-bg);
}
.sidebar-search svg { flex-shrink: 0; color: var(--ui-fg-faint); }
.sidebar-search input {
    flex: 1;
    min-width: 0;
    border: none;
    background: none;
    color: var(--ui-fg);
    font-family: inherit;
    font-size: var(--text-body);
    outline: none;
}
.sidebar-search button {
    display: flex;
    border: none;
    background: none;
    padding: 2px;
    cursor: pointer;
    color: var(--ui-fg-faint);
}
.sidebar-empty { padding: 8px var(--space-2); color: var(--ui-fg-faint); font-size: var(--text-meta); }

/* Bascule de theme dans le pied — MOCK → a remonter */
.theme-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-2);
    padding: 2px 0;
}
.theme-row .theme-label { font-size: var(--text-label); font-weight: 600; color: var(--ui-fg-muted); text-transform: uppercase; letter-spacing: 0.04em; }
[data-theme-toggle] {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 8px;
    border: 1px solid var(--ui-border-strong);
    border-radius: var(--radius-full);
    background: var(--ui-bg);
    color: var(--ui-fg-muted);
    font-family: inherit;
    font-size: var(--text-eyebrow);
    font-weight: 600;
    cursor: pointer;
}
[data-theme-toggle]:hover { background: var(--ui-hover); color: var(--ui-fg); }

/* dash-section : sous-titre de section dashboard, pas encore promu (tuiles/tabs/pagination/row-actions le sont via components.css) */
.dash-section { margin: var(--space-2) 0 var(--space-1); font-size: 9.5px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--ui-fg-muted); }

/* Connexion */
.login-shell { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: var(--space-5); }
.login-card { width: min(380px, 92vw); }
.login-logo-row { display: flex; flex-direction: column; align-items: center; gap: 6px; text-align: center; margin-bottom: var(--space-4); }
.login-logo { width: 36px; height: 36px; border-radius: 9px; background: var(--ui-accent); }
.login-theme { position: fixed; top: 18px; right: 18px; }
/* État loginLoading (spec 5.1) — spinner sur currentColor */
.btn .spin { display: inline-block; width: 14px; height: 14px; border: 2px solid currentColor; border-top-color: transparent; border-radius: 50%; animation: spin .8s linear infinite; margin-right: 8px; vertical-align: -2px; }
.btn:disabled { opacity: 0.7; cursor: progress; }

/* Cartes minis (leaderboard / par-categorie) */
.mini-list { display: flex; flex-direction: column; }
.mini-row { display: flex; justify-content: space-between; align-items: center; gap: var(--space-3); padding: 7px 0; border-bottom: 1px solid var(--ui-border); }
.mini-row:last-child { border-bottom: none; }

/* Rendu sommaire des pages non mocquees */
[data-page] { display: none; }
[data-page].visible { display: flex; }
#pages > div[data-page] { flex: 1; min-width: 0; padding: var(--space-6) 40px; gap: var(--space-5); }

/* Machine d'états auth/app — login montré si .auth, app si .has-sidebar */
body.auth .login-shell { display: flex; }
body.auth { display: flex; min-height: 100vh; align-items: center; justify-content: center; }
body.auth .app-sidebar, body.auth .app-content, body.auth .sidebar-backdrop, body.auth header.mobile-bar { display: none; }
body.has-sidebar .login-shell { display: none; }

/* Utilitaires de mise en page (flexbox strict, pas de style= en ligne) */
.header-actions { display: flex; align-items: center; gap: var(--space-2); flex-wrap: wrap; }
.flex-row { display: flex; align-items: center; gap: var(--space-4); flex-wrap: wrap; }
.flex-row.gap-sm { gap: 6px; }
.flex-1 { flex: 1 1 0; min-width: 280px; }
.flex-row.row-between { justify-content: space-between; gap: var(--space-3); }
.flex-row.row-stretch { align-items: stretch; }
.row-top { margin-top: 12px; }
.card-min { flex: 1 1 0; min-width: 260px; }
.card-body.gap-3 { gap: var(--space-3); }
.card-body.stack-block { display: block; gap: 0; }
.faint { color: var(--ui-fg-faint); }
.bg-subtle { background: var(--ui-bg-subtle); }
tr.row-selected td { background: var(--ui-bg-subtle); font-weight: 600; }
.emoji-icon { font-size: 1.5rem; line-height: 1; }

/* Pile de notifications (remplace .toast Bootstrap) */
.toast-stack {
    position: fixed;
    bottom: var(--space-5);
    right: var(--space-5);
    z-index: var(--z-modal);
    width: min(340px, calc(100vw - 2 * var(--space-5)));
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
}
.toast-stack .banner { display: flex; align-items: flex-start; gap: var(--space-2); box-shadow: var(--ui-shadow); }
.toast-stack .close-btn { margin-left: auto; flex-shrink: 0; }
.th-sortable { cursor: pointer; }
.mt { margin-top: var(--space-3); }
.text-center { text-align: center; }
.table-scroll { overflow-x: auto; }
.lead-title { font-size: 17px; }
td.email { color: var(--ui-fg-muted); }
.meta { font-size: var(--text-meta); color: var(--ui-fg-muted); }
.th-sort { color: var(--ui-accent); }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12px; color: var(--ui-fg-muted); }
.swatch { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; box-shadow: inset 0 0 0 1px rgba(127, 129, 141, 0.4); }
.palette { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 7px; }
.palette .swatch-opt { width: 24px; height: 24px; border-radius: 6px; border: 2px solid transparent; outline: 1px solid var(--ui-border-strong); cursor: pointer; padding: 0; transition: transform .1s ease; }
.palette .swatch-opt:hover { transform: scale(1.12); }
.palette .swatch-opt.selected { outline: 2px solid var(--ui-fg); outline-offset: 1px; }
.palette-input { font-family: var(--font-mono, monospace); }

/* Heatmap — flexbox, un seul accent (opacités) */
.heatmap { display: flex; flex-wrap: wrap; gap: 3px; }
.heat { width: 11px; height: 11px; border-radius: 2px; background: var(--ui-border); }
.heat.l0 { background: var(--ui-border); }
.heat.l1 { background: color-mix(in srgb, var(--ui-accent) 22%, var(--ui-bg)); }
.heat.l2 { background: color-mix(in srgb, var(--ui-accent) 45%, var(--ui-bg)); }
.heat.l3 { background: color-mix(in srgb, var(--ui-accent) 70%, var(--ui-bg)); }
.heat.l4 { background: var(--ui-accent); }
.heat-legend { display: flex; align-items: center; gap: 4px; margin-top: var(--space-3); font-size: var(--text-meta); color: var(--ui-fg-muted); }
.heat-legend .heat { margin-right: 1px; }

/* ---- Éditeur de carte (grille par utilisateur) ---- */
.district-row { display: flex; align-items: center; gap: var(--space-3); flex-wrap: wrap; padding: var(--space-2) var(--space-3); border: 1px solid var(--ui-border); border-radius: var(--radius-md); background: var(--ui-surface-alt, var(--ui-panel)); }
.district-label { display: inline-flex; align-items: center; gap: 6px; font-size: var(--text-meta); font-weight: 600; color: var(--ui-fg-muted); }
.district-label svg { width: 13px; height: 13px; color: var(--ui-accent); }
.district-checks { display: flex; align-items: center; gap: var(--space-3); flex-wrap: wrap; }
.district-check { display: inline-flex; align-items: center; gap: 5px; font-size: var(--text-meta); font-weight: 600; color: var(--ui-fg); cursor: pointer; }
.district-check input { width: 14px; height: 14px; accent-color: var(--ui-accent); }
.district-check code { font-family: var(--font-mono); font-size: 10px; color: var(--ui-fg-muted); }
.map-sep { width: 1px; height: 20px; background: var(--ui-border); margin: 0 4px; }
.brush-opt { display: inline-flex; align-items: center; gap: 8px; }
.brush-opt label { font-size: var(--text-meta); font-weight: 600; color: var(--ui-fg-muted); }
.orientation-icons { display: inline-flex; gap: 3px; }
.orientation-btn.active { background: var(--ui-accent); border-color: var(--ui-accent); color: var(--ui-accent-fg, #fff); }
.map-grid-wrap { overflow: auto; max-height: 520px; border: 1px solid var(--ui-border); border-radius: var(--radius-md); background: var(--ui-bg); }
table.map-grid { border-collapse: collapse; }
.map-grid td, .map-grid th { width: 30px; min-width: 30px; height: 30px; padding: 0; }
.map-grid th.map-coord { position: sticky; top: 0; z-index: 2; font-size: 9.5px; color: var(--ui-fg-faint); background: var(--ui-surface-alt, var(--ui-panel)); text-align: center; border: 1px solid var(--ui-border); }
.map-grid td.map-coord { font-size: 9.5px; color: var(--ui-fg-faint); text-align: center; border: 1px solid var(--ui-border); background: var(--ui-surface-alt, var(--ui-panel)); position: sticky; left: 0; z-index: 1; }
.map-cell { border: 1px solid var(--ui-border); background: var(--ui-bg); text-align: center; cursor: pointer; padding: 0; vertical-align: middle; position: relative; }
.map-cell:hover { outline: 2px solid var(--ui-accent); outline-offset: -1px; z-index: 3; }
.cell-empty { color: var(--ui-fg-faint); }
.cell-building { background: var(--ui-accent-soft, rgba(86, 156, 255, .14)); }
.cell-road { background: var(--ui-surface-alt, var(--ui-panel)); color: var(--ui-accent); }
.cell-tree { background: rgba(74, 179, 90, .16); }
.cell-plot { background: repeating-linear-gradient(45deg, rgba(86, 156, 255, .12) 0 3px, transparent 3px 7px); }
.cell-domain { background: repeating-linear-gradient(45deg, rgba(123, 79, 224, .18) 0 3px, transparent 3px 7px); }
.cell-decoration { background: rgba(124, 93, 250, .12); color: var(--ui-fg-muted); }
.cell-special { background: rgba(201, 154, 40, .22); }
.cell-special.sp-university { background: rgba(62, 99, 221, .18); }
.cell-special.sp-city_hall { background: rgba(201, 154, 40, .24); }
.cell-special.sp-airport { background: rgba(45, 156, 219, .16); }
.cell-special.sp-retail { background: rgba(39, 174, 96, .18); }
.cell-special.sp-shop { background: rgba(39, 174, 96, .18); }
.cell-special .map-cell-occ, .cell-domain .map-cell-occ { color: var(--ui-accent); font-weight: 800; }
.map-cell-ico { display: inline-flex; }
.map-cell-ico img, .map-cell-ico svg { width: 14px; height: 14px; }
.map-cell-occ { position: absolute; left: 1px; right: 1px; bottom: 0; font-size: 7.5px; line-height: 1.1; overflow: hidden; white-space: nowrap; color: var(--ui-fg-muted); }
.map-cell-occ.district { color: var(--ui-accent); font-weight: 700; }
.map-cell-special-ico { display: inline-flex; }
.map-cell-special-ico svg { width: 15px; height: 15px; }
.map-cell-lv { position: absolute; top: 0; right: 0; font-size: 7.5px; line-height: 1.1; padding: 0 1px; background: var(--ui-fg); color: var(--ui-bg); border-radius: 0 0 0 3px; }
.road-svg { width: 22px; height: 22px; display: inline-block; transform-origin: center; }
.road-svg path { fill: none; stroke: var(--ui-accent); stroke-width: 4; stroke-linecap: round; stroke-linejoin: round; }
.road-orient-0 { transform: rotate(90deg); }
.road-orient-1 { transform: rotate(180deg); }
.road-orient-2 { transform: rotate(270deg); }
.road-orient-3 { transform: rotate(0deg); }

/* Barres d'activité hebdomadaire (profils x 7 jours) */
.bar-row { display: flex; align-items: center; gap: var(--space-3); padding: var(--space-2) 0; }
.bar-name { width: 110px; font-size: var(--text-body); }
.bar-container { display: flex; flex: 1; align-items: flex-end; gap: 3px; height: 56px; }
.bar { flex: 1; min-height: 2px; border-radius: 2px 2px 0 0; background: var(--ui-accent); }
.bar-total { width: 76px; font-size: var(--text-meta); color: var(--ui-fg-muted); }

/* Barres de progression (formations, dashboard) */
.bar-cell { min-width: 130px; display: flex; align-items: center; gap: var(--space-2); }
.bar-track { flex: 1; height: 6px; border-radius: 999px; background: var(--ui-border); overflow: hidden; }
.bar-fill { height: 100%; border-radius: 999px; background: var(--ui-accent); width: var(--w, 100%); }
.bar-pct { min-width: 36px; text-align: right; }
.bar-labels { display: flex; gap: 3px; }
.bar-labels small { flex: 1; text-align: center; }

/* Empilement vertical espace (widget d'activité utilisateur) */
.stack { display: flex; flex-direction: column; gap: var(--space-4); }
.stack-sm { display: flex; flex-direction: column; gap: var(--space-2); }

svg.mi { width: 16px; height: 16px; flex-shrink: 0; }
svg.mi-sm { width: 14px; height: 14px; }

/* Pastille de menu — nombre d'éléments en attente sur un écran.
   Sans notification dans ce produit, c'est le seul signal qu'il y a du travail :
   elle doit rester visible depuis n'importe quelle page. */
.sidebar-badge {
    margin-left: auto;
    min-width: 18px;
    padding: 0 6px;
    border-radius: var(--radius-full);
    background: var(--status-danger);
    color: #fff;
    font-size: var(--text-label);
    font-weight: 700;
    line-height: 18px;
    text-align: center;
    font-variant-numeric: tabular-nums;
}

/* En mode barre étroite (tablette), le libellé disparaît : sans cette règle la
   pastille serait poussée hors de la colonne par son `margin-left: auto`. */
@media (min-width: 768px) and (max-width: 1023px) {
    .sidebar-badge {
        margin-left: 0;
        position: absolute;
        transform: translate(14px, -10px);
    }
    .app-sidebar-link { position: relative; }
}

/* Colonnes de tableau : une quantité courte ne doit pas se casser sur trois
   lignes, un texte libre doit au contraire pouvoir respirer. */
.nowrap { white-space: nowrap; }
.cell-wide { min-width: 260px; }

/* --- Champ desactive ------------------------------------------------------
   Le design system ne donne aucun etat visuel a `input:disabled` : un champ
   verrouille se lit exactement comme un champ actif, ce qui est un mensonge —
   constate sur l'edition d'un pack deja vendu, ou la duree et le prix sont
   figes. La regle est posee ICI et non dans `design/components.css`, qui est
   vendorise depuis le depot skillopolis et porte « ne pas editer directement ».
   Le vrai correctif est a republier la-bas ; celui-ci vaut pour l'admin en
   attendant. */

.field input:disabled,
.field select:disabled,
.field textarea:disabled {
    background: var(--ui-bg-sunken);
    color: var(--ui-fg-muted);
    cursor: not-allowed;
}

/* Un bouton de choix fige (les raccourcis de duree) doit se retirer du regard
   sans disparaitre : il porte encore l'information de ce qui a ete vendu. */
.modal-body button:disabled {
    opacity: .5;
    cursor: not-allowed;
}

/* --- Jauge dans une cellule de tableau ------------------------------------
   `.bar-track` est concue pour un conteneur en LIGNE : son `flex: 1` y regle
   la largeur. Placee dans la colonne d'une `.name-cell`, la meme declaration
   s'applique a la HAUTEUR et ecrase `height: 6px` — la jauge se rend a zero
   pixel, donc invisible. On la remet a plat la ou elle sert de sous-titre
   graphique a un decompte (colonne « Licences » des packs). */

.name-cell > .bar-track {
    flex: none;
    width: 100%;
    height: 4px;
}
