/* ==========================================================================
   Corvus — components.css
   CATALOGUE DE COMPOSANTS PARTAGÉ (vitrine + dashboard).
   --------------------------------------------------------------------------
   Chargé APRÈS theme.css, AVANT dash.css / style.css.

   Toutes les règles de ce fichier sont extraites de dash.css (manage.php), qui
   fait autorité. Elles sont reproduites À L'IDENTIQUE : manage.php ne bouge pas
   d'un pixel. Les seules valeurs « littérales » remplacées par un token le sont
   à valeur strictement égale (--ring, --accent-line-weak, --shadow-*).

   dash.css et style.css chargent APRÈS et peuvent surcharger ce qui leur est
   propre (ex. .card-body passe en grille 2 colonnes côté dashboard).
   ========================================================================== */

/* ==========================================================================
   1. RESET / PRIMITIVES
   ========================================================================== */

* { box-sizing: border-box }

html { scroll-behavior: smooth }
body { margin: 0 }

a { color: inherit; text-decoration: none }
p { margin: 0 }
img { max-width: 100%; display: block }
code { font-family: var(--f-mono); font-size: .85em }

:focus-visible { outline: 2px solid var(--accent-2); outline-offset: 2px; border-radius: var(--r-xs) }

.brand-word { color: var(--accent); font-weight: 600 }
.ico { width: 18px; height: 18px }

/* ==========================================================================
   2. BOUTONS
   ========================================================================== */

.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    font-family: var(--f-display); font-weight: 500; font-size: 13.5px; line-height: 1;
    padding: 11px 20px; border-radius: 10px; border: 1px solid transparent; cursor: pointer;
    transition: background .2s var(--ease-out), border-color .2s var(--ease-out), color .2s var(--ease-out),
                transform .2s var(--ease-out), box-shadow .2s var(--ease-out), opacity .18s var(--ease);
    min-height: 40px; white-space: nowrap;
}
.btn:active { transform: translateY(1px) }
.btn:disabled { opacity: .45; cursor: not-allowed }

/* Tailles */
.btn.sm { padding: 8px 13px; min-height: 33px; font-size: 12.5px }
/* .lg / .block : utilisés par la vitrine (héros, cartes de prix), conservés. */
.btn.lg { padding: 15px 26px; min-height: 48px; font-size: 15px }
.btn.block { width: 100% }

/* Variantes */
.btn.primary { background: var(--accent); color: #fff; box-shadow: 0 12px 28px -14px rgba(91, 94, 240, .65) }
.btn.primary:hover:not(:disabled) { background: var(--accent-2); transform: translateY(-1px); box-shadow: var(--shadow-lift) }
.btn.ghost { border-color: var(--line); color: var(--text) }
.btn.ghost:hover { border-color: var(--accent); color: var(--accent-2); background: var(--accent-ghost) }
.btn.danger { background: var(--no); color: #fff; box-shadow: 0 12px 28px -14px rgba(224, 86, 90, .65) }
.btn.danger:hover:not(:disabled) { background: #e8696d; transform: translateY(-1px); box-shadow: 0 24px 48px -20px rgba(224, 86, 90, .4) }

.btn-icon {
    display: inline-flex; align-items: center; justify-content: center;
    width: 32px; height: 32px; border-radius: 8px; border: 1px solid var(--line);
    background: var(--surface-2); color: var(--muted); cursor: pointer;
    transition: color .16s var(--ease), border-color .16s var(--ease), background .16s var(--ease);
}
.btn-icon:hover { color: var(--text); border-color: var(--muted) }
.btn-icon--danger:hover { color: var(--no); border-color: var(--no); background: var(--no-ghost) }

.btn-chip {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 7px 13px; border-radius: 8px; border: 1px solid var(--line);
    background: var(--surface-2); color: var(--text-2); cursor: pointer;
    font-family: var(--f-body); font-size: 13.5px;
    transition: all .16s var(--ease);
}
.btn-chip .ico { width: 15px; height: 15px }
.btn-chip--ok:hover { color: var(--ok); border-color: var(--ok); background: var(--ok-ghost) }
.btn-chip--no:hover { color: var(--no); border-color: var(--no); background: var(--no-ghost) }

/* ==========================================================================
   3. CARTES  (coquille uniquement — l'anatomie interne reste propre à chaque
   contexte : .card-title/.card-desc côté dashboard, .card-t/.card-d vitrine)
   ========================================================================== */

.card {
    background: var(--surface); border: 1px solid var(--line); border-radius: var(--r);
    min-width: 0; overflow: hidden; box-shadow: var(--shadow-card);
    transition: border-color .22s var(--ease), box-shadow .22s var(--ease), opacity .2s var(--ease), transform .22s var(--ease);
}
.card:hover { border-color: var(--accent-line-weak) }
.card:focus-within { border-color: var(--accent); box-shadow: var(--shadow-card), var(--ring) }
.card[hidden] { display: none }

/* Rembourrage par défaut. dash.css le surcharge (18px 22px 22px + grille). */
.card-body { padding: var(--s-6) }

/* ==========================================================================
   4. CHAMPS
   ========================================================================== */

/* Sélecteurs volontairement typés : un `input` nu frapperait aussi les
   checkbox, radio et color, qui ont leur propre habillage. */
input[type=text], input[type=url], input[type=number], input[type=search], select, textarea {
    font-family: var(--f-body); font-size: 13.5px; color: var(--text); background: var(--surface-2);
    border: 1px solid var(--line); border-radius: 9px; padding: 10px 12px; width: 100%; min-height: 40px;
    transition: border-color .18s var(--ease), box-shadow .18s var(--ease), background .18s var(--ease);
}
input:hover, select:hover, textarea:hover { border-color: var(--muted) }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: var(--ring); background: var(--surface) }
input:disabled, select:disabled, textarea:disabled { opacity: .5; cursor: not-allowed }
textarea { resize: vertical; line-height: 1.6; min-height: 78px }
select {
    appearance: none; cursor: pointer; padding-right: 36px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23878d9a' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat; background-position: right 11px center; background-size: 16px;
}

/* ---------- Interrupteur ---------- */
.sw { position: relative; display: inline-flex; flex-shrink: 0; cursor: pointer; margin-top: 1px }
.sw input { position: absolute; opacity: 0; width: 0; height: 0 }
.sw-track {
    width: 38px; height: 22px; border-radius: 12px; background: var(--surface-3);
    border: 1px solid var(--line); display: flex; align-items: center; padding: 2px;
    transition: background .28s var(--ease-out), border-color .28s var(--ease-out), box-shadow .28s var(--ease-out);
}
.sw-thumb {
    width: 16px; height: 16px; border-radius: 50%; background: var(--muted);
    transition: transform .3s var(--ease-spring), background .2s var(--ease);
}
.sw input:checked ~ .sw-track { background: var(--accent); border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-ghost) }
.sw input:checked ~ .sw-track .sw-thumb { transform: translateX(16px); background: #fff }
.sw input:focus-visible ~ .sw-track { box-shadow: var(--ring) }
.sw:hover .sw-track { border-color: var(--muted) }
.sw:hover .sw-thumb { background: var(--text-2) }
.sw input:checked:hover ~ .sw-track { border-color: var(--accent-2) }
.sw input:checked:hover ~ .sw-track .sw-thumb { background: #fff }

/* ==========================================================================
   5. FEEDBACK
   ========================================================================== */

/* ---------- Notice (bandeau contextuel) ---------- */
.notice {
    background: var(--surface); border: 1px solid var(--line); border-left: 3px solid var(--accent);
    border-radius: var(--r-sm); padding: 13px 16px; margin-bottom: 16px;
    display: flex; align-items: flex-start; gap: 10px;
    animation: notice-in .4s var(--ease-out) both;
}
@keyframes notice-in { from { opacity: 0; transform: translateY(-6px) } to { opacity: 1; transform: none } }
.notice .ico { margin-top: 2px; flex-shrink: 0; color: var(--accent-2); width: 16px; height: 16px }
.notice p { font-size: 13px; color: var(--text-2); line-height: 1.6; overflow-wrap: break-word }
.notice a { color: var(--accent-2); font-weight: 500; text-decoration: underline; text-underline-offset: 3px }
.notice--ok { border-left-color: var(--ok) }
.notice--ok .ico { color: var(--ok) }
.notice--warn { border-left-color: var(--warn) }
.notice--warn .ico { color: var(--warn) }
.notice--error { border-left-color: var(--no) }
.notice--error .ico { color: var(--no) }
.notice.fade { opacity: 0; transform: translateY(-6px); transition: opacity .5s var(--ease), transform .5s var(--ease) }

/* ---------- Toast ---------- */
.toast {
    position: fixed; z-index: var(--z-toast); left: 50%; bottom: 26px; transform: translate(-50%, 12px);
    background: var(--surface-2); border: 1px solid var(--line); border-left: 3px solid var(--accent);
    border-radius: var(--r-sm); padding: 12px 20px; font-size: 13.5px; color: var(--text);
    box-shadow: var(--shadow-toast);
    opacity: 0; transition: opacity .28s var(--ease-out), transform .28s var(--ease-out); pointer-events: none;
}
.toast.is-in { opacity: 1; transform: translate(-50%, 0) }

/* ---------- Badge ---------- */
.pill {
    display: inline-block; padding: 2px 8px; border-radius: var(--r-xs); font-size: 11px; font-weight: 500;
    background: var(--surface-3); color: var(--text-2); white-space: nowrap;
}
.pill--ok { background: var(--ok-ghost); color: var(--ok) }
.pill--warn { background: var(--warn-ghost); color: var(--warn) }
.pill--no { background: var(--no-ghost); color: var(--no) }
.pill--neutral { background: var(--accent-ghost); color: var(--accent-2) }

/* ==========================================================================
   6. INFOBULLE  (§2 — rubriques de la sidebar)
   --------------------------------------------------------------------------
   NOUVEAU COMPOSANT. dash.css possédait déjà `.tip`, mais il est réservé au
   graphique d'activité : position fixed collée au curseur, pointer-events:none,
   white-space:nowrap, police mono, ni flèche ni gestion de débordement, et
   inaccessible au clavier. `.tip` est laissé strictement intact ; `.tt` est
   sa version « contenu », construite sur les mêmes tokens.
   ========================================================================== */

.tt {
    /* display explicite : c'est un <span>, il lui faut un bloc pour que le
       titre et la description s'empilent. .tt[hidden] reprend la main. */
    display: block;
    position: fixed; z-index: var(--z-tooltip);
    width: max-content; max-width: min(280px, calc(100vw - 24px));
    background: var(--surface-2); border: 1px solid var(--line);
    border-radius: var(--r-sm); padding: 11px 13px;
    box-shadow: var(--shadow-menu);
    /* Le survol de l'infobulle elle-même ne doit pas la faire disparaître,
       mais elle ne doit jamais voler le clic destiné à ce qu'il y a dessous. */
    pointer-events: none;
    opacity: 0; transform: translateY(-4px);
    transition: opacity .16s var(--ease-out), transform .16s var(--ease-out);
}
.tt[hidden] { display: none }
.tt.is-in { opacity: 1; transform: none }

.tt-title {
    display: block;
    font-family: var(--f-display); font-weight: 600; font-size: 12.5px;
    color: var(--text); line-height: 1.3; margin-bottom: 5px;
    /* La rubrique déclencheuse est en petites capitales espacées ; l'infobulle
       est du texte courant, on annule tout héritage venu de .side-group. */
    text-transform: none; letter-spacing: normal;
}
.tt-desc {
    display: block;
    font-family: var(--f-body);
    font-size: 11.5px; font-weight: 400; color: var(--text-2); line-height: 1.55;
    overflow-wrap: break-word;
    text-transform: none; letter-spacing: normal;
}

/* Flèche — repositionnée par ui.js selon le côté retenu */
.tt::after {
    content: ""; position: absolute; width: 8px; height: 8px;
    background: var(--surface-2); border: 1px solid var(--line);
    transform: rotate(45deg);
}
.tt[data-side="right"]::after { left: -5px; top: var(--tt-arrow, 16px); border-right: 0; border-top: 0 }
.tt[data-side="left"]::after  { right: -5px; top: var(--tt-arrow, 16px); border-left: 0; border-bottom: 0 }
.tt[data-side="bottom"]::after { top: -5px; left: var(--tt-arrow, 16px); border-right: 0; border-bottom: 0 }
.tt[data-side="top"]::after   { bottom: -5px; left: var(--tt-arrow, 16px); border-left: 0; border-top: 0 }

/* ==========================================================================
   7. MODALE  (§3 — reset du bot)
   --------------------------------------------------------------------------
   NOUVEAU COMPOSANT. manage.php n'avait aucune modale : il utilisait
   window.confirm(). La coquille est dérivée de .card (fond/trait/rayon), son
   ombre et son animation d'entrée de .pick-menu.

   Backdrop dédié plutôt que réutilisation de `.scrim` : `.scrim` est
   display:none hors du media query 900px (c'est le voile du tiroir mobile),
   la modale doit fonctionner à toutes les largeurs.
   ========================================================================== */

.modal {
    position: fixed; inset: 0; z-index: var(--z-modal);
    display: grid; place-items: center; padding: 20px;
}
.modal[hidden] { display: none }

.modal-backdrop {
    position: absolute; inset: 0;
    background: rgba(5, 6, 8, .72); backdrop-filter: blur(3px);
    opacity: 0; transition: opacity .2s var(--ease);
}
.modal.is-in .modal-backdrop { opacity: 1 }

.modal-box {
    position: relative; width: min(460px, 100%);
    max-height: calc(100dvh - 40px); overflow-y: auto;
    background: var(--surface); border: 1px solid var(--line);
    border-radius: var(--r); box-shadow: var(--shadow-menu);
    padding: 24px;
    opacity: 0; transform: translateY(8px) scale(.98);
    transition: opacity .2s var(--ease-out), transform .2s var(--ease-out);
}
.modal.is-in .modal-box { opacity: 1; transform: none }
.modal--danger .modal-box { border-color: rgba(224, 86, 90, .38) }

.modal-ico {
    display: inline-flex; align-items: center; justify-content: center;
    width: 38px; height: 38px; border-radius: 11px; margin-bottom: 14px;
    background: var(--accent-ghost); color: var(--accent-2);
}
.modal--danger .modal-ico { background: var(--no-ghost); color: var(--no) }
.modal-ico .ico { width: 20px; height: 20px }

.modal-title {
    font-family: var(--f-display); font-weight: 600; font-size: 17px;
    color: var(--text); line-height: 1.25; margin-bottom: 9px;
}
.modal-desc { font-size: 13px; color: var(--text-2); line-height: 1.6 }
.modal-desc + .modal-desc { margin-top: 9px }
.modal-desc strong { color: var(--text); font-weight: 600 }
.modal-desc code {
    background: var(--surface-2); padding: 2px 6px; border-radius: 5px;
    color: var(--accent-2); font-size: 12px;
}

.modal-body { margin-top: 16px }
.modal-label { display: block; font-size: 12.5px; color: var(--text-2); font-weight: 500; margin-bottom: 7px }

.modal-foot {
    display: flex; justify-content: flex-end; gap: 10px;
    margin-top: 20px; padding-top: 18px; border-top: 1px solid var(--line-soft);
}

/* Liste « ce qui est touché / ce qui ne l'est pas » */
.modal-scope { display: flex; flex-direction: column; gap: 6px; margin-top: 14px }
.modal-scope-row { display: flex; align-items: flex-start; gap: 8px; font-size: 12px; line-height: 1.5 }
.modal-scope-row .ico { width: 14px; height: 14px; flex-shrink: 0; margin-top: 2px }
.modal-scope-row--yes { color: var(--text-2) }
.modal-scope-row--yes .ico { color: var(--no) }
.modal-scope-row--no { color: var(--muted) }
.modal-scope-row--no .ico { color: var(--ok) }

@media (prefers-reduced-motion: reduce) {
    .tt, .modal-backdrop, .modal-box, .notice, .toast { animation: none; transition: none }
}
