/*
 * Palette, timings and orb states extracted from the validated
 * mockup (design/assistant-mockup.html, see SCOPE_ASSISTANT.md §4).
 * Migrated from an inline <style> block (see git history) into the
 * AssetMapper pipeline - see SCOPE_ASSISTANT.md §4 for the Twig +
 * Turbo + Stimulus target architecture.
 */

:root {
    --bg: #f6f6f4;
    --bg-elevated: #ffffff;
    --bg-sunken: #edece9;
    --border: #dedcd7;
    --text: #1c1d20;
    --text-secondary: #6c6e74;
    --agent-jarvis: #128560;
    --agent-sarah: #c13e82;
    --agent-john: #8b6a16;
    --error: #a1442b;
}

[data-theme="dark"] {
    --bg: #15161b;
    --bg-elevated: #1c1e25;
    --bg-sunken: #0f1013;
    --border: #2b2d35;
    --text: #e8e9ed;
    --text-secondary: #92959f;
    --agent-jarvis: #7ce7b8;
    --agent-sarah: #f793c4;
    /* John (jaune) est le cas delicat du SCOPE_ASSISTANT.md §4 - doit rester
       lisible sans virer au fluo sur fond sombre. Valeur exacte de la
       maquette validee (design/assistant-mockup.html AGENTS[2].accentDark). */
    --agent-john: #e5b84d;
    --error: #c96a52;
}

* { box-sizing: border-box; }

html, body {
    height: 100%;
    margin: 0;
}

body {
    font-family: -apple-system, 'Segoe UI', system-ui, sans-serif;
    background: var(--bg);
    color: var(--text);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background .3s ease, color .3s ease;
}

.shell {
    width: min(1180px, 96vw);
    height: min(760px, 92vh);
    border-radius: 18px;
    border: 1px solid var(--border);
    box-shadow: 0 30px 70px rgba(0, 0, 0, .25);
    overflow: hidden;
    display: flex;
    background: var(--bg-elevated);
    position: relative;
}

/* --- Agent rail --- */

.rail {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 14px;
    width: 76px;
    flex-shrink: 0;
    padding: 20px 0;
    border-right: 1px solid var(--border);
    background: var(--bg-sunken);
}

.theme-toggle {
    margin-top: auto;
    border: 1px solid var(--border);
    background: transparent;
    color: var(--text-secondary);
    border-radius: 999px;
    padding: 5px 9px;
    font-size: 11px;
    font-family: inherit;
    cursor: pointer;
}

/* --- Settings menu (gear icon + dropdown, used in both the legacy
   thread-header and the immersive .orb-links) --- */

.settings-menu { position: relative; }

.settings-gear {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    border: 1px solid var(--border);
    background: var(--bg-elevated);
    color: var(--text-secondary);
    cursor: pointer;
    list-style: none;
}

.settings-gear::-webkit-details-marker { display: none; }

.settings-gear:hover { background: var(--bg-sunken); color: var(--text); }

.settings-dropdown {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 180px;
    padding: 6px;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: 10px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, .2);
    z-index: 30;
}

.settings-item {
    display: flex;
    align-items: center;
    gap: 7px;
    width: 100%;
    padding: 8px 10px;
    border: none;
    border-radius: 6px;
    background: transparent;
    color: var(--text);
    text-decoration: none;
    font-size: 13px;
    font-family: inherit;
    text-align: left;
    cursor: pointer;
}

.settings-item:hover { background: var(--bg-sunken); }

.settings-theme-row { display: flex; align-items: center; justify-content: space-between; }

.settings-theme-row .theme-toggle { margin-top: 0; }

/* --- "Thème" submenu (interface picker: Aality/Orbe/Iron Man/Vocal/Legacy),
   listed under the settings-theme-row above (now labelled "Apparence") -
   see BRIEF_JUNIE_INTERFACE_AALITY.md. --- */

.settings-section-label {
    padding: 8px 10px 2px;
    font-size: 10.5px;
    letter-spacing: .06em;
    text-transform: uppercase;
    color: var(--text-secondary);
}

.settings-item.active { background: color-mix(in srgb, var(--agent-accent) 16%, transparent); color: var(--text); }

/* --- Main column --- */

.main {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

/* Deux battements par cycle (lub, dub) plutot qu'un seul pic sinusoidal -
   c'est ce double temps qui donne l'effet "coeur" plutot que "respiration". */

@keyframes orb-heartbeat {
    0% { transform: scale(1); }
    12% { transform: scale(1.09); }
    22% { transform: scale(.99); }
    32% { transform: scale(1.14); }
    45% { transform: scale(1); }
    100% { transform: scale(1); }
}

@keyframes orb-ripple {
    0% { transform: scale(.72); opacity: .5; }
    70% { opacity: .12; }
    100% { transform: scale(1.55); opacity: 0; }
}

@keyframes orb-error-shake {
    0%, 100% { transform: translateX(0); }
    20% { transform: translateX(-3px); }
    40% { transform: translateX(3px); }
    60% { transform: translateX(-2px); }
    80% { transform: translateX(2px); }
}

.error-banner {
    margin: 12px 22px 0;
    padding: 9px 13px;
    border-radius: 9px;
    background: var(--bg-sunken);
    border: 1px solid var(--error);
    color: var(--error);
    font-size: 13px;
    display: none;
}

.error-banner.visible { display: block; animation: orb-error-shake .5s ease; }

#messages {
    flex: 1;
    overflow-y: auto;
    padding: 22px 22px 8px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    scrollbar-width: thin;
    /* Fondu repris de docs/reflexion-interface/jarvis-interface.html
       (.chat-zone, mask-image) : les messages qui defilent sous le header
       s'estompent au lieu d'etre coupes net par une bordure - c'est la
       partie "chat borderless" du prototype qui se transpose sans conflit
       avec le cadre (rail/actions/panneau) qui doit rester. */
    -webkit-mask-image: linear-gradient(to bottom, transparent 0, black 24px, black calc(100% - 8px), transparent 100%);
    mask-image: linear-gradient(to bottom, transparent 0, black 24px, black calc(100% - 8px), transparent 100%);
}

.msg {
    font-size: 14px;
    line-height: 1.55;
    animation: msg-in .35s ease;
}

@keyframes msg-in {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

.msg-user {
    align-self: flex-end;
    max-width: 72%;
    /* Teinte de l'accent de l'agent plutot qu'un gris neutre - repris du
       ton des bulles du prototype (rgba(139,107,255,.14) sur fond sombre),
       sans reprendre le fond totalement transparent : les bulles restent
       lisibles sur les deux themes. */
    background: color-mix(in srgb, var(--agent-accent) 14%, var(--bg-sunken));
    padding: 10px 15px;
    border-radius: 16px;
}

.msg-assistant {
    align-self: flex-start;
    max-width: 80%;
    display: flex;
    gap: 10px;
    align-items: flex-start;
}

.msg-assistant .avatar-dot {
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: var(--agent-accent);
    margin-top: 6px;
    flex-shrink: 0;
}

/* Rendu du Markdown de la reponse (render-markdown.js) : par defaut le
   navigateur n'a aucun style pour p/ul/table/code, ce qui rendait les
   tableaux et le code des reponses illisibles (pipes/JSON bruts a plat). */

.msg-assistant .text > :first-child {
    margin-top: 0;
}

.msg-assistant .text > :last-child {
    margin-bottom: 0;
}

.msg-assistant .text p,
.msg-assistant .text ul,
.msg-assistant .text ol,
.msg-assistant .text pre,
.msg-assistant .text table,
.msg-assistant .text blockquote {
    margin: 0 0 10px;
}

.msg-assistant .text ul,
.msg-assistant .text ol {
    padding-left: 20px;
}

.msg-assistant .text li + li {
    margin-top: 2px;
}

.msg-assistant .text code {
    font-family: 'SF Mono', 'Cascadia Code', ui-monospace, monospace;
    font-size: 0.9em;
    background: var(--bg-sunken);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 1px 5px;
}

.msg-assistant .text pre {
    background: var(--bg-sunken);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 10px 12px;
    overflow-x: auto;
}

.msg-assistant .text pre code {
    background: none;
    border: none;
    padding: 0;
}

.msg-assistant .text table {
    border-collapse: collapse;
    width: 100%;
    font-size: 0.95em;
}

.msg-assistant .text th,
.msg-assistant .text td {
    border: 1px solid var(--border);
    padding: 5px 9px;
    text-align: left;
}

.msg-assistant .text th {
    background: var(--bg-sunken);
}

.msg-assistant .text blockquote {
    border-left: 3px solid var(--agent-accent);
    padding-left: 10px;
    color: var(--text-secondary);
}

.msg-assistant .text a {
    color: var(--agent-accent);
}

.msg-tool {
    align-self: flex-start;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 11px;
    border-radius: 8px;
    background: var(--bg-sunken);
    border: 1px solid var(--border);
    font-family: 'SF Mono', 'Cascadia Code', ui-monospace, monospace;
    font-size: 12px;
    color: var(--text-secondary);
    width: fit-content;
}

.msg-tool .tool-spinner {
    width: 9px;
    height: 9px;
    border-radius: 50%;
    border: 2px solid color-mix(in srgb, var(--agent-accent) 35%, transparent);
    border-top-color: var(--agent-accent);
    animation: tool-spin .8s linear infinite;
    flex-shrink: 0;
}

@keyframes tool-spin { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }

.msg-error {
    align-self: flex-start;
    background: var(--bg-sunken);
    border: 1px solid var(--error);
    color: var(--error);
    padding: 8px 12px;
    border-radius: 10px;
}

/* --- Quick actions --- */

.quick-actions {
    padding: 0 22px 12px;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    flex-shrink: 0;
}

/* --- Composer --- */

.composer {
    padding: 12px 22px 18px;
    display: flex;
    gap: 10px;
    align-items: flex-end;
    border-top: 1px solid var(--border);
    flex-shrink: 0;
}

.composer textarea {
    flex: 1;
    resize: none;
    background: var(--bg-sunken);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 11px 13px;
    color: var(--text);
    font-size: 14px;
    font-family: inherit;
    min-height: 22px;
    max-height: 100px;
    outline: none;
}

.composer textarea:focus { border-color: var(--agent-accent); }

.send-btn {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    border: none;
    background: var(--border);
    color: var(--bg-elevated);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 16px;
    cursor: default;
}

.send-btn.enabled { background: var(--agent-accent); cursor: pointer; }

/* --- Quick action side panel --- */

.panel {
    position: absolute;
    top: 0;
    right: 0;
    height: 100%;
    width: min(340px, 92%);
    background: var(--bg-elevated);
    border-left: 1px solid var(--border);
    box-shadow: -20px 0 40px rgba(0, 0, 0, .2);
    transform: translateX(100%);
    transition: transform .4s cubic-bezier(.2, .8, .2, 1);
    display: flex;
    flex-direction: column;
    z-index: 30;
}

.panel.open { transform: translateX(0); }

.orb-cloud-toggle { display: flex; align-items: center; gap: 6px; color: var(--text-secondary); cursor: pointer; }

/* --- Orbe ball + rings, sized for the full-screen stage (vs. the 52px/96px
   header orb-wrapper reused as-is in Legacy) --- */

.stage-orb { position: relative; width: 340px; height: 340px; }

.stage-orb .ring {
    position: absolute;
    inset: 0;
    border-radius: 50%;
    border: 1px solid color-mix(in srgb, var(--agent-accent) 35%, transparent);
    animation: orb-ripple 2.4s cubic-bezier(0.2, 0.6, 0.3, 1) infinite;
    opacity: 0;
}

.stage-orb .ring.r2 { animation-delay: 0.8s; }

.stage-orb .ring.r3 { animation-delay: 1.6s; }

.stage-orb.state-thinking .ring { animation-duration: 1.3s; }

.stage-orb.state-responding .ring { animation-duration: 1.8s; }

.stage-orb.state-error .ring { animation: orb-ripple 1.4s cubic-bezier(0.2, 0.6, 0.3, 1) infinite, orb-error-shake 0.5s ease; }

.orb-ball {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 176px;
    height: 176px;
    margin: -88px 0 0 -88px;
    border-radius: 50%;
    background:
        radial-gradient(circle at 35% 30%, rgba(255, 255, 255, 0.9),
            color-mix(in srgb, var(--agent-accent) 55%, white) 22%,
            color-mix(in srgb, var(--agent-accent) 65%, transparent) 45%,
            color-mix(in srgb, var(--agent-accent) 45%, #8b6bff) 75%,
            rgba(10, 16, 30, 0.2) 100%);
    box-shadow:
        0 0 40px 6px color-mix(in srgb, var(--agent-accent) 55%, transparent),
        0 0 90px 20px color-mix(in srgb, var(--agent-accent) 28%, transparent),
        0 0 160px 60px rgba(139, 107, 255, 0.18),
        inset 0 0 40px rgba(255, 255, 255, 0.35);
    filter: saturate(1.15);
    animation: orb-heartbeat 2.6s ease-in-out infinite;
}

.orb-ball::after {
    content: '';
    position: absolute;
    inset: 14%;
    border-radius: 50%;
    background: radial-gradient(circle at 40% 35%, rgba(255, 255, 255, 0.55), transparent 60%);
    mix-blend-mode: screen;
}

.stage-orb.state-thinking .orb-ball { animation-duration: 1.3s; }

.stage-orb.state-responding .orb-ball { animation-duration: 1.9s; }

@media (max-width: 640px) {
    .stage-orb { width: 200px; height: 200px; }
    .orb-ball { width: 110px; height: 110px; margin: -55px 0 0 -55px; }
}

@media (prefers-reduced-motion: reduce) {
    .orb-ball,
.stage-orb .ring {
        animation: none !important;
    }
}

.widget {
    position: absolute;
    width: 216px;
    background: var(--glass);
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    padding: 14px 16px;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.35);
    pointer-events: auto;
}

.widget h4 { font-size: 10px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--text-secondary); margin: 0 0 10px; font-weight: 500; }

/*
 * --- Aality (nouvelle interface par defaut, BRIEF_JUNIE_INTERFACE_AALITY.md,
 * 2026-09-16) --- Tableau de bord (cards / orbe / chat), palette "Indigo
 * Pulse" fixe (independante du toggle clair/sombre "Apparence", comme les
 * modes immersifs), Poppins (titres) / Inter (corps) via Google Fonts (voir
 * templates/_pwa_head.html.twig pour le <link>).
 */

body.ui-aality {
    --aality-violet: #6A48E5;
    --aality-sky: #6CA0EA;
    --aality-indigo: #1D1242;
    --bg: var(--aality-indigo);
    --bg-elevated: #241a52;
    --bg-sunken: #170c38;
    --border: rgba(180, 160, 255, 0.18);
    --text: #ece8fb;
    --text-secondary: #a79bd6;
    background:
        radial-gradient(ellipse 70% 50% at 50% 0%, rgba(106, 72, 229, 0.28), transparent 60%),
        radial-gradient(ellipse 60% 50% at 100% 100%, rgba(108, 160, 234, 0.16), transparent 65%),
        var(--aality-indigo);
    color: var(--text);
    font-family: 'Inter', -apple-system, 'Segoe UI', system-ui, sans-serif;
    overflow: hidden;
    display: block;
}

.aality-shell { height: 100vh; padding: 22px; }

.aality-main { display: flex; flex-direction: column; height: 100%; gap: 18px; }

.aality-topbar { display: flex; align-items: center; gap: 18px; flex-shrink: 0; }

.aality-logo { display: flex; align-items: center; }

.aality-agent { font-family: 'Poppins', 'Inter', sans-serif; font-weight: 600; font-size: 15px; }

.aality-domain { font-weight: 400; color: var(--text-secondary); font-size: 13px; }

.aality-links { display: flex; align-items: center; gap: 16px; margin-left: auto; }

/* Grille 25% / 50% / 25% : minmax(0, Nfr) plutot que des pourcentages pour que
   les deux gouttieres de 20px soient deduites au lieu de faire deborder. */

.aality-body {
    flex: 1;
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 2fr) minmax(0, 1fr);
    gap: 20px;
    min-height: 0;
}

.aality-body > .dash-zone[data-column="left"] { grid-column: 1; }

.aality-body > .aality-center { grid-column: 2; }

.aality-body > .dash-zone[data-column="right"] { grid-column: 3; }

/* Colonne centrale : mascotte au-dessus, fil de conversation dessous. */

.aality-center { display: flex; flex-direction: column; gap: 14px; min-width: 0; min-height: 0; }

/* Zones de widgets (gauche/droite) : grille FIXE de 2 colonnes x 6 lignes (elle
   ne grandit jamais, voir DashboardLayouts::MAX_ROWS) ; une tuile occupe 1 ou 2
   colonnes (data-cols) et 1 ou 2 lignes (data-rows). Les 6 lignes se partagent
   la hauteur disponible, avec un minimum : en dessous, la zone defile. */

.dash-zone {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    grid-template-rows: repeat(6, minmax(104px, 1fr));
    gap: 14px;
    align-content: start;
    min-height: 0;
    overflow-y: auto;
    scrollbar-width: thin;
}

.dash-tile { grid-column: span 1; grid-row: span 1; display: flex; flex-direction: column; min-width: 0; overflow: hidden; }

.dash-tile[data-cols="2"] { grid-column: span 2; }

.dash-tile[data-rows="2"] { grid-row: span 2; }

.dash-tile-head { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }

.dash-tile-head h4 { margin: 0; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.dash-tile-body { flex: 1; min-height: 0; overflow: hidden; }

/* Outils de tuile (taille / retrait) : visibles seulement en mode "Personnaliser". */

.dash-tile-tools { display: none; gap: 4px; }

.dash-tool {
    background: none;
    border: 1px solid var(--border);
    color: var(--text-secondary);
    border-radius: 6px;
    width: 22px;
    height: 22px;
    line-height: 1;
    cursor: pointer;
    font-size: 13px;
}

.dash-tool:hover { color: var(--text); border-color: var(--agent-accent); }

.dash-editing .dash-tile-tools { display: inline-flex; }

/* Clic long pour deplacer : curseur "attrape", pas de selection de texte, pas de scroll tactile. */

.dash-editing .dash-tile { border-style: dashed; border-color: var(--agent-accent); cursor: grab; user-select: none; -webkit-user-select: none; touch-action: none; }

.dash-editing .dash-zone { min-height: 140px; }

/* Cartes "+" : une par emplacement libre (mode Personnaliser). */

.dash-slot {
    display: none;
    align-items: center;
    justify-content: center;
    min-height: 104px;
    background: transparent;
    color: var(--text-secondary);
    border: 2px dashed var(--border);
    border-radius: 16px;
    font-size: 28px;
    font-weight: 300;
    cursor: pointer;
    font-family: inherit;
    transition: border-color 0.15s, color 0.15s, background 0.15s;
}

.dash-editing .dash-slot { display: flex; }

.dash-slot:hover, .dash-slot-active { border-color: var(--agent-accent); color: var(--agent-accent); background: color-mix(in srgb, var(--agent-accent) 8%, transparent); }

/* Deplacement : copie flottante, tuile d'origine estompee, cible surlignee. */

.dash-ghost { opacity: 0.92; box-shadow: 0 18px 40px rgba(0, 0, 0, 0.4); transform: rotate(1.2deg); cursor: grabbing; }

.dash-dragging { opacity: 0.3; }

.dash-drop-target { border-color: var(--agent-accent) !important; background: color-mix(in srgb, var(--agent-accent) 14%, var(--bg-elevated)); color: var(--agent-accent); }

body.dash-drag-active, body.dash-drag-active * { cursor: grabbing !important; user-select: none; -webkit-user-select: none; }

/* Selecteur de widget (ouvert par une carte "+"). */

.dash-picker {
    position: fixed;
    z-index: 900;
    width: 240px;
    max-height: 70vh;
    overflow-y: auto;
    padding: 8px;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: 14px;
    box-shadow: 0 18px 40px rgba(0, 0, 0, 0.35);
}

.dash-picker[hidden] { display: none; }

.dash-picker-title { padding: 4px 8px 8px; font-size: 10.5px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--text-secondary); }

.dash-picker-item {
    display: block;
    width: 100%;
    text-align: left;
    background: none;
    color: var(--text);
    border: none;
    border-radius: 8px;
    padding: 8px 10px;
    font-size: 13px;
    font-family: inherit;
    cursor: pointer;
}

.dash-picker-item:hover { background: color-mix(in srgb, var(--agent-accent) 16%, transparent); }

/* Reglages du widget monitoring : mode edition seulement, dans un panneau
   flottant ouvert par le bouton engrenage de la tuile (une tuile d'une ligne
   est trop basse pour les contenir ; sa position est calculee par
   widget_controller.js). */

.dash-config { display: none; font-size: 11px; color: var(--text-secondary); }

.dash-editing .dash-config.dash-config-open {
    display: block;
    position: fixed;
    z-index: 950;
    width: 250px;
    max-height: 80vh;
    overflow-y: auto;
    padding: 12px;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: 14px;
    box-shadow: 0 18px 40px rgba(0, 0, 0, 0.35);
    cursor: default;
}

.dash-config > label { display: block; margin-bottom: 6px; }

.dash-config select {
    width: 100%;
    margin-top: 3px;
    background: var(--bg-sunken);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 3px 6px;
    font-size: 11px;
}

.dash-config-title { margin: 8px 0 4px; letter-spacing: 0.04em; }

.dash-config-metric { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 4px; }

.dash-config-metric label { display: inline-flex; align-items: center; gap: 4px; }

.dash-threshold input {
    width: 52px;
    background: var(--bg-sunken);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 2px 4px;
    font-size: 11px;
    text-align: right;
}

.dash-edit-toggle {
    background: transparent;
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 999px;
    padding: 4px 11px;
    font-size: 12px;
    cursor: pointer;
    font-family: inherit;
}

.dash-edit-toggle:hover { border-color: var(--agent-accent); }

.dash-edit-toggle[aria-pressed="true"] { background: var(--agent-accent); border-color: var(--agent-accent); color: #fff; }

.dash-status { font-size: 12px; color: var(--text-secondary); }

/* Alertes monitoring : bandeau global + barre rouge + liseré sur la tuile. */

.dash-alert-banner { flex-shrink: 0; display: flex; flex-direction: column; gap: 4px; }

.dash-alert-banner[hidden] { display: none; }

.dash-alert { padding: 8px 14px; border-radius: 10px; background: rgba(224, 69, 69, 0.16); border: 1px solid rgba(224, 69, 69, 0.55); color: var(--text); font-size: 12.5px; }

.dash-alert strong { color: #ff6b6b; }

.dash-alert-inline { margin-bottom: 8px; padding: 4px 8px; border-radius: 8px; background: rgba(224, 69, 69, 0.16); color: #ff6b6b; font-size: 11px; font-weight: 500; }

.dash-tile-alert { border-color: rgba(224, 69, 69, 0.7); }

.aality-bar.over i { background: linear-gradient(90deg, #f0a13a, #e04545); }

/* Contenu des widgets. */

.dash-muted { font-size: 12px; color: var(--text-secondary); }

.dash-link { color: var(--agent-accent); }

.dash-big { font-family: 'Poppins', 'Inter', sans-serif; font-size: 30px; font-weight: 600; line-height: 1.1; margin-bottom: 4px; }

.dash-sub { font-size: 11.5px; color: var(--text-secondary); margin-bottom: 8px; }

.quick-actions-buttons { display: flex; gap: 8px; flex-wrap: wrap; }

.quick-action-button, .quick-action-form button { border: 1px solid var(--border-color); border-radius: 8px; background: var(--surface); color: var(--text-primary); padding: 7px 9px; cursor: pointer; }

.quick-action-form { display: grid; gap: 7px; margin-top: 10px; }

.quick-action-form label { display: grid; gap: 3px; font-size: 11px; color: var(--text-secondary); }

.quick-action-form input, .quick-action-form textarea { width: 100%; box-sizing: border-box; border: 1px solid var(--border-color); border-radius: 6px; padding: 5px; background: var(--surface); color: var(--text-primary); }

.quick-action-form textarea { min-height: 38px; resize: vertical; }

.quick-action-form-buttons { display: flex; gap: 7px; }

.quick-action-form button[type="submit"] { background: var(--accent); color: #fff; }

.quick-action-status { min-height: 1em; margin: 8px 0 0; font-size: 11px; color: var(--text-secondary); }

.dash-line { font-size: 12px; margin-top: 5px; color: var(--text-secondary); }

.dash-line strong { color: var(--text); font-weight: 500; }

.dash-clock-time { font-family: 'Poppins', 'Inter', sans-serif; font-size: 34px; font-weight: 600; line-height: 1.1; }

.dash-clock-date { font-size: 12px; color: var(--text-secondary); text-transform: capitalize; margin-top: 4px; }

.dash-days { display: flex; gap: 6px; align-items: flex-end; height: 44px; margin-top: 6px; }

.dash-day { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 3px; height: 100%; font-size: 9.5px; color: var(--text-secondary); }

.dash-day-bar { flex: 1; width: 100%; display: flex; align-items: flex-end; background: rgba(255, 255, 255, 0.06); border-radius: 3px; overflow: hidden; }

.dash-day-bar i { display: block; width: 100%; background: linear-gradient(0deg, var(--aality-violet), var(--aality-sky)); border-radius: 3px; }

.dash-day.today span { color: var(--text); font-weight: 600; }

.dash-mail { margin-bottom: 8px; min-width: 0; }

.dash-mail-from { font-size: 12px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.dash-mail-subject { font-size: 11.5px; color: var(--text-secondary); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Reglages : choix de mascotte / couleur / apparence. */

.dash-choice-row { display: flex; flex-wrap: wrap; gap: 10px; }

.dash-choice { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; font-size: 13px; }

.dash-swatch { display: inline-block; width: 14px; height: 14px; border-radius: 50%; vertical-align: -2px; margin-right: 4px; }

/* Editeur de Wobbi (Mon interface) : apercu a gauche, champs a droite. */

.mascot-editor-top { display: grid; grid-template-columns: 200px minmax(0, 1fr); gap: 18px; align-items: start; }

.mascot-editor-preview { display: flex; flex-direction: column; gap: 8px; position: sticky; top: 8px; }

.mascot-editor-stage { width: 200px; height: 200px; border: 1px solid var(--border); border-radius: 16px; background: var(--bg-sunken); padding: 8px; box-sizing: border-box; }

.mascot-editor-fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px 12px; }

.mascot-editor-fields > .field:first-child { grid-column: 1 / -1; }

.mascot-editor-fields > .field { margin-bottom: 0; }

.mascot-editor select {
    width: 100%;
    background: var(--bg-sunken);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 7px 8px;
    color: var(--text);
    font-size: 13px;
    font-family: inherit;
}

.mascot-editor input[type="color"] { width: 30px; height: 26px; padding: 0; border: 1px solid var(--border); border-radius: 6px; background: transparent; cursor: pointer; }

@media (max-width: 520px) {
    .mascot-editor-top { grid-template-columns: 1fr; }
    .mascot-editor-preview { position: static; }
}

.aality-card {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 14px 16px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25);
}

.aality-card h4 {
    margin: 0 0 10px;
    font-family: 'Poppins', 'Inter', sans-serif;
    font-size: 10.5px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-secondary);
    font-weight: 500;
}

.aality-card-row { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; font-size: 11px; }

.aality-card-row span:first-child { width: 34px; color: var(--text-secondary); }

.aality-card-row span:last-child { width: 30px; text-align: right; color: var(--text-secondary); }

.aality-bar { flex: 1; height: 5px; border-radius: 4px; background: rgba(255, 255, 255, 0.08); overflow: hidden; }

.aality-bar i { display: block; height: 100%; border-radius: 4px; background: linear-gradient(90deg, var(--aality-sky), var(--aality-violet)); }

.aality-card-line { font-size: 13px; font-weight: 500; margin-bottom: 4px; }

.aality-card-sub { font-size: 11.5px; color: var(--text-secondary); }

.aality-orb-column { display: flex; align-items: center; justify-content: center; flex-direction: column; gap: 10px; min-width: 0; flex-shrink: 0; }

.aality-orb-column .stage-orb { width: clamp(130px, 24vh, 260px); height: clamp(130px, 24vh, 260px); }

.aality-orb-column .orb-ball { width: 52%; height: 52%; margin: -26% 0 0 -26%; }

.aality-orb-column .error-banner { margin: 0; }

.aality-chat { flex: 1; display: flex; flex-direction: column; min-width: 0; min-height: 0; gap: 12px; }

.aality-chat-zone {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 6px 4px;
    overflow-y: auto;
    scrollbar-width: thin;
}

.aality-composer { flex-shrink: 0; border-top: none; padding: 0; }

.aality-composer textarea::placeholder { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

@media (max-width: 1100px) {
    /* Une seule colonne : zones de widgets en bandes horizontales defilantes
       au-dessus, conversation (qui prend la hauteur restante) en dessous. */
    .aality-body { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto auto minmax(0, 1fr); }
    .aality-body > .dash-zone[data-column="left"] { grid-column: 1; grid-row: 1; }
    .aality-body > .dash-zone[data-column="right"] { grid-column: 1; grid-row: 2; }
    .aality-body > .aality-center { grid-column: 1; grid-row: 3; }
    .dash-zone { grid-template-columns: none; grid-auto-flow: column; grid-auto-columns: minmax(200px, 1fr); grid-auto-rows: minmax(160px, auto); overflow-x: auto; overflow-y: hidden; }
    .dash-tile[data-widget="monitoring"] { min-height: 220px; }
    .dash-tile, .dash-tile[data-cols="2"], .dash-tile[data-rows="2"] { grid-column: auto; grid-row: auto; }
    .dash-zone:empty { display: none; }
}

/* Palette claire de l'interface Aality (choix "Clair" dans Mon interface) :
   la palette sombre ci-dessus reste la valeur par defaut. */

html[data-theme="light"] body.ui-aality {
    --aality-indigo: #f4f2fc;
    --bg: #f4f2fc;
    --bg-elevated: #ffffff;
    --bg-sunken: #ece8f8;
    --border: rgba(80, 60, 160, 0.16);
    --text: #1d1242;
    --text-secondary: #5f5690;
    background:
        radial-gradient(ellipse 70% 50% at 50% 0%, rgba(106, 72, 229, 0.12), transparent 60%),
        radial-gradient(ellipse 60% 50% at 100% 100%, rgba(108, 160, 234, 0.12), transparent 65%),
        var(--aality-indigo);
}

html[data-theme="light"] body.ui-aality .aality-card { box-shadow: 0 6px 18px rgba(60, 40, 140, 0.08); }

/* Le lettrage du logo est blanc en dur dans le SVG : illisible sur fond clair. */

html[data-theme="light"] body.ui-aality .aality-logo svg [fill="#fff"],
html[data-theme="light"] body.ui-aality .page-logo svg [fill="#fff"] { fill: var(--text); }

html[data-theme="light"] body.ui-aality .aality-bar,
html[data-theme="light"] body.ui-aality .dash-day-bar { background: rgba(60, 40, 140, 0.08); }

/* --- Conversations multiples : bouton "Nouvelle conversation" et panneau
   "Historique" (BRIEF_CONVERSATIONS_MULTIPLES.md), dans la topbar Aality. --- */

.conv-history > summary { list-style: none; }

.conv-history > summary::-webkit-details-marker { display: none; }

.conv-dropdown { width: 320px; max-height: 60vh; overflow-y: auto; }

.conv-row { display: flex; align-items: center; gap: 4px; border-radius: 6px; }

.conv-row:hover { background: var(--bg-sunken); }

.conv-row.active { background: color-mix(in srgb, var(--agent-accent) 16%, transparent); }

.conv-item {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 8px 10px;
    color: var(--text);
    text-decoration: none;
}

.conv-title { font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.conv-meta { font-size: 11px; color: var(--text-secondary); }

.conv-delete {
    flex-shrink: 0;
    padding: 4px 8px;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    font-size: 13px;
    cursor: pointer;
    border-radius: 6px;
    opacity: .6;
}

.conv-delete:hover { opacity: 1; background: var(--bg-elevated); }

.conv-empty { padding: 10px; font-size: 12px; color: var(--text-secondary); }

/*
 * --- Mobile (<= 700px) : carrousel ---
 * Wobbi compact fixe en haut, une seule slide (conversation ou un widget) au
 * centre, navigation fleches/swipe (assets/controllers/carousel_controller.js),
 * composer ancre en bas. .aality-body/.aality-center/.aality-chat passent en
 * display: contents pour que tout soit enfant direct de .aality-main et se
 * reordonne avec "order".
 */

.aality-carousel-nav { display: none; }

.hide-sm { display: inline; }

@media (max-width: 700px) {
    .aality-shell { height: 100dvh; padding: 10px 12px calc(10px + env(safe-area-inset-bottom)); }
    .aality-main { gap: 8px; }
    .aality-body, .aality-center, .aality-chat, .dash-zone { display: contents; }
    .aality-topbar { order: 0; position: relative; gap: 10px; }
    .aality-logo svg, .aality-custom-logo { width: 64px; height: 28px; }
    .aality-agent .aality-domain, .dash-status, .orb-cloud-toggle, [data-dashboard-target="editButton"], .conv-new .hide-sm { display: none; }
    .aality-agent { font-size: 14px; }
    .aality-links { gap: 8px; }
    .aality-links .settings-menu { position: static; }
    .aality-links .settings-dropdown { left: 0; right: 0; top: 100%; width: auto; min-width: 0; }
    .conv-dropdown { width: auto; }
    .settings-gear { width: 44px; height: 44px; }
    .dash-edit-toggle { min-height: 44px; display: inline-flex; align-items: center; padding: 0 14px; }
    .settings-item { min-height: 44px; }
    .dash-alert-banner, .pwa-offline-banner { order: 1; }
    .aality-orb-column { order: 2; flex-direction: row; gap: 8px; }
    .aality-orb-column .stage-orb { width: 96px; height: 96px; }
    /* Une seule slide visible. */
    .aality-chat-zone, .dash-tile { display: none; order: 3; }
    .aality-chat-zone.is-slide-active { display: flex; flex: 1; min-height: 0; }
    .dash-tile.is-slide-active {
        display: flex;
        flex: 1;
        min-height: 0;
        overflow-y: auto;
        grid-column: auto;
        grid-row: auto;
    }
    .dash-tile .dash-tile-body { overflow-y: auto; }
    .aality-carousel-nav { order: 4; display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-shrink: 0; }
    .aality-nav-btn {
        width: 44px; height: 44px; border-radius: 50%;
        border: 1px solid var(--border); background: var(--bg-elevated); color: var(--text);
        font-size: 22px; line-height: 1; cursor: pointer;
    }
    .aality-nav-mid { display: flex; flex-direction: column; align-items: center; gap: 6px; min-width: 0; }
    .aality-nav-label { font-size: 12px; color: var(--text-secondary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 55vw; }
    .aality-nav-dots { display: flex; gap: 7px; }
    .aality-nav-dots i { width: 7px; height: 7px; border-radius: 4px; background: var(--border); }
    .aality-nav-dots i.on { width: 18px; background: var(--aality-sky); }
    .aality-composer { order: 5; }
    .aality-composer textarea, .aality-composer .send-btn { min-height: 44px; font-size: 16px; }
}

/* --- PWA : hors ligne --- */

.pwa-offline-banner {
    flex-shrink: 0;
    padding: 8px 14px;
    border-radius: 12px;
    background: rgba(224, 69, 69, 0.16);
    border: 1px solid rgba(224, 69, 69, 0.5);
    font-size: 13px;
    text-align: center;
}

.pwa-offline-banner[hidden] { display: none; }

body.is-offline .send-btn { opacity: 0.4; pointer-events: none; }

.settings-item[hidden] { display: none; }

/*
 * --- Pages hors chat (reglages, admin, login) ---
 * Meme habillage Aality que le tableau de bord (body.ui-aality, palette
 * Indigo Pulse + branding entreprise), mais en page qui defile : gabarit
 * commun templates/_page.html.twig. Remplace l'ancienne coquille .shell /
 * .thread-header / .panel-* qui n'avait ni fond, ni polices, ni branding.
 */

body.ui-page { height: auto; min-height: 100%; overflow: auto; }

.page-shell {
    max-width: 1080px;
    margin: 0 auto;
    padding: 22px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    gap: 22px;
}

.page-topbar { display: flex; align-items: center; gap: 18px; flex-shrink: 0; }

.page-logo { display: flex; align-items: center; text-decoration: none; }

.page-heading { min-width: 0; }

.page-title { font-family: 'Poppins', 'Inter', sans-serif; font-weight: 600; font-size: 15px; }

.page-subtitle { font-size: 13px; color: var(--text-secondary); }

.page-back {
    margin-left: auto;
    padding: 6px 12px;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--bg-elevated);
    color: var(--text);
    font-size: 12.5px;
    text-decoration: none;
    white-space: nowrap;
}

.page-back:hover { background: var(--bg-sunken); }

.page-layout { display: grid; grid-template-columns: 210px minmax(0, 1fr); gap: 22px; align-items: start; }

.page-layout.no-nav { grid-template-columns: minmax(0, 1fr); }

.page-nav { display: flex; flex-direction: column; gap: 2px; position: sticky; top: 22px; }

.page-nav a {
    padding: 9px 12px;
    border-radius: 10px;
    color: var(--text-secondary);
    font-size: 13.5px;
    text-decoration: none;
}

.page-nav a:hover { background: var(--bg-elevated); color: var(--text); }

.page-nav a.active {
    background: color-mix(in srgb, var(--aality-violet) 24%, transparent);
    color: var(--text);
    font-weight: 500;
}

.page-nav .page-nav-label {
    padding: 12px 12px 4px;
    font-size: 10.5px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-secondary);
}

.page-content { display: flex; flex-direction: column; gap: 18px; min-width: 0; max-width: 760px; }

.page-layout.wide .page-content { max-width: none; }

.page-card {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 18px 20px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25);
}

.page-card h2, .page-h1 {
    margin: 0 0 6px;
    font-family: 'Poppins', 'Inter', sans-serif;
    font-weight: 600;
    font-size: 15px;
}

.page-h1 { font-size: 18px; margin-bottom: 14px; }

.page-card .help, .page-help { margin: 0 0 14px; color: var(--text-secondary); font-size: 13px; line-height: 1.5; }

.page-card .help:last-child { margin-bottom: 0; }

.page-card code { font-size: 12px; background: var(--bg-sunken); padding: 1px 5px; border-radius: 5px; }

.page-card .status-ok { color: var(--agent-jarvis); }

.field { margin-bottom: 14px; }

.field > label { display: block; font-size: 12px; color: var(--text-secondary); margin-bottom: 6px; }

.field .help { font-size: 12px; margin: 6px 0 0; }

.field > label.dash-choice { display: inline-flex; margin-bottom: 0; font-size: 13px; color: var(--text); }

.field .form-error { color: var(--error); font-size: 12px; margin-top: 4px; }

.page-card input[type=text], .page-card input[type=password], .page-card input[type=email],
.page-card input[type=url], .page-card textarea, .page-card select {
    width: 100%;
    background: var(--bg-sunken);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 9px 11px;
    color: var(--text);
    font-size: 13.5px;
    font-family: inherit;
    outline: none;
}

.page-card input:focus, .page-card textarea:focus, .page-card select:focus {
    border-color: var(--aality-sky);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--aality-sky) 25%, transparent);
}

.page-card input[type=color] { width: 30px; height: 26px; padding: 0; border: 1px solid var(--border); border-radius: 6px; background: transparent; cursor: pointer; }

.btn-row { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-top: 4px; }

.btn {
    display: inline-block;
    padding: 8px 15px;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: transparent;
    color: var(--text);
    font-size: 13px;
    font-family: inherit;
    text-decoration: none;
    cursor: pointer;
}

.btn:hover { background: var(--bg-sunken); }

.btn-primary {
    border-color: transparent;
    background: linear-gradient(90deg, var(--aality-violet), var(--aality-sky));
    color: #fff;
    font-weight: 600;
}

.btn-primary:hover { background: linear-gradient(90deg, var(--aality-violet), var(--aality-sky)); filter: brightness(1.08); }

.btn-link-danger { padding: 0; border: none; background: none; color: var(--error); font: inherit; font-size: 13px; cursor: pointer; }

/* Admin : tableaux et actions de liste. */

table.admin-grid { width: 100%; border-collapse: collapse; }

table.admin-grid th, table.admin-grid td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border); font-size: 13.5px; }

table.admin-grid th { color: var(--text-secondary); font-weight: 500; font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em; }

table.admin-grid tr:last-child td { border-bottom: none; }

.admin-actions { display: flex; align-items: center; gap: 12px; }

.admin-actions a { color: var(--aality-sky); text-decoration: none; font-size: 13px; }

.admin-actions a:hover { text-decoration: underline; }

.admin-swatch { display: inline-block; width: 14px; height: 14px; border-radius: 4px; border: 1px solid var(--border); vertical-align: middle; margin-right: 6px; }

.admin-empty { color: var(--text-secondary); font-size: 14px; margin: 0; }

.page-card.flush { padding: 6px 8px; overflow-x: auto; }

@media (max-width: 760px) {
    .page-shell { padding: 12px 14px calc(12px + env(safe-area-inset-bottom)); gap: 14px; }
    .page-layout { grid-template-columns: minmax(0, 1fr); gap: 14px; }
    .page-nav { flex-direction: row; overflow-x: auto; position: static; padding-bottom: 2px; }
    .page-nav a { white-space: nowrap; }
    .page-nav .page-nav-label { display: none; }
    .page-subtitle { display: none; }
    .page-content { max-width: none; }
}

.admin-pre { white-space: pre-wrap; margin: 0; padding: 10px 12px; border-radius: 10px; background: var(--bg-sunken); border: 1px solid var(--border); font-size: 12.5px; }

/* Connexion : meme habillage Aality, carte centree. */

body.ui-login { overflow: auto; display: flex; align-items: center; justify-content: center; min-height: 100dvh; padding: clamp(1rem, 4vw, 2.5rem); }

.login-card { width: 100%; max-width: 400px; padding: clamp(1.5rem, 5vw, 2.5rem); text-align: center; }

.login-brand { min-height: 44px; margin: 0 auto 1rem; display: flex; align-items: center; justify-content: center; }

.login-logo { max-width: 150px; max-height: 44px; object-fit: contain; }

.login-wobbi { width: 104px; height: 104px; margin: 0 auto 1.25rem; }

.login-wobbi svg { overflow: visible; }

.login-card h1 { font-family: 'Poppins', 'Inter', sans-serif; font-size: 1.15rem; font-weight: 600; margin: 0 0 .35rem; }

.login-card .subtitle { font-size: .85rem; color: var(--text-secondary); margin: 0 0 1.5rem; }

.google-btn {
    display: flex; align-items: center; justify-content: center; gap: 10px;
    width: 100%; min-height: 3rem; padding: .75rem 1rem;
    border: 1px solid var(--border); border-radius: 12px;
    background: var(--bg-sunken); color: var(--text);
    font-weight: 500; font-size: .9rem; text-decoration: none;
    transition: border-color .2s ease;
}

.google-btn:hover { border-color: var(--aality-sky); }

.google-btn:focus-visible { outline: 3px solid color-mix(in srgb, var(--aality-sky) 35%, transparent); outline-offset: 3px; }

.google-icon { width: 18px; height: 18px; flex-shrink: 0; }

.login-error {
    margin-top: 1rem; padding: .6rem .8rem; border-radius: 10px;
    background: var(--bg-sunken); border: 1px solid var(--error); color: var(--error); font-size: .8rem;
}

.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

.page-card input[type=radio], .page-card input[type=checkbox] { accent-color: var(--aality-violet); }

.page-card input[type=file] { color: var(--text-secondary); font-size: 13px; }

.page-card input[type=file]::file-selector-button {
    margin-right: 10px; padding: 7px 12px; border: 1px solid var(--border); border-radius: 10px;
    background: var(--bg-sunken); color: var(--text); font: inherit; cursor: pointer;
}
