/* ════════════════════════════════════════════════════════════
   Panneau ADAM flottant — unique implémentation, partagée par les
   deux coquilles (core/base.html ET core/base_shell.html). Utilise
   les tokens de thème "de base" (--card-bg, --border, --text-*,
   --accent, --surface-elevated…) définis dans themes.css et
   disponibles dans les DEUX coquilles — jamais --shell-* seul, qui
   n'existe que côté nouvelle coquille (cf. mémoire
   project_shell_font_fluent_trap sur ce piège).
   Remplace l'ancien widget inline de core/base.html (2026-08-05) —
   texte simple, sans avatar 3D, avec les fonctionnalités jusque-là
   réservées au Hub plein-écran supprimé (confirmation de suppression,
   commandes slash, recherche d'historique, séparateurs de jour,
   chips d'action colorées par domaine).
════════════════════════════════════════════════════════════ */

/* ── Bouton flottant ────────────────────────────────────── */

#adam-widget-btn {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    z-index: 900;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    overflow: hidden;
    background: var(--accent);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    cursor: pointer;
    box-shadow: 0 4px 14px rgba(0,0,0,.25);
    transition: transform .15s, box-shadow .15s;
    user-select: none;
}
#adam-widget-btn:hover { transform: scale(1.08); box-shadow: 0 6px 20px rgba(0,0,0,.3); }
#adam-widget-panel.is-open ~ #adam-widget-btn,
body.adam-widget-open #adam-widget-btn { display: none; }

/* ── Panneau ────────────────────────────────────────────── */

#adam-widget-panel {
    position: fixed;
    right: 0;
    top: 0;
    bottom: 0;
    width: 400px;
    max-width: 100vw;
    z-index: 901;
    background: var(--bg-white, #fff);
    border-left: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    transform: translateX(100%);
    transition: transform .28s cubic-bezier(.4,0,.2,1);
    box-shadow: -6px 0 32px rgba(0,0,0,.12);
}
#adam-widget-panel.is-open { transform: translateX(0); }

.adam-widget-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 14px;
    height: 52px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
    background: var(--sidebar-bg, var(--card-bg));
}
.adam-widget-title {
    font-weight: 600;
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 7px;
    color: var(--text-primary);
}
.adam-widget-mood-dot {
    width: 7px; height: 7px;
    border-radius: 50%;
    background: var(--text-muted);
    flex-shrink: 0;
}
.adam-widget-mood-dot.mood-serein    { background: var(--color-success, #2da05a); }
.adam-widget-mood-dot.mood-attentif  { background: var(--color-warning, #f59e0b); }
.adam-widget-mood-dot.mood-preoccupe { background: var(--color-danger, #ef4444); }
.adam-widget-actions {
    display: flex;
    align-items: center;
    gap: 2px;
}
.adam-widget-actions button {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-muted);
    font-size: 13px;
    padding: 5px 7px;
    border-radius: 6px;
    transition: background .15s, color .15s;
}
.adam-widget-actions button:hover { background: var(--hover-bg, rgba(0,0,0,.05)); color: var(--text-primary); }
.adam-widget-actions button.is-active { color: var(--accent); }

/* ── Messages ───────────────────────────────────────────── */

.adam-widget-messages {
    flex: 1;
    overflow-y: auto;
    padding: 14px 12px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    scrollbar-width: thin;
    scrollbar-color: var(--scrollbar-thumb, var(--border)) transparent;
}
.adam-widget-welcome {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    height: 100%;
    color: var(--text-muted);
    font-size: 13px;
    text-align: center;
}
.adam-widget-welcome i { font-size: 2rem; opacity: .35; }
.adam-widget-welcome p { margin: 0; }

.aw-day-sep {
    text-align: center;
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: .04em;
    margin: 6px 0 2px;
}

.aw-msg { display: flex; gap: 8px; align-items: flex-start; }
.aw-msg.is-user { flex-direction: row-reverse; }
.aw-avatar {
    width: 26px; height: 26px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: 11px; font-weight: 700; flex-shrink: 0;
}
.aw-msg.is-adam .aw-avatar { background: var(--accent); color: #fff; }
.aw-msg.is-user .aw-avatar { background: var(--surface-elevated, var(--bg-lighter)); color: var(--text-secondary, var(--text-muted)); border: 1px solid var(--border); }
.aw-msg-col { display: flex; flex-direction: column; gap: 2px; max-width: 85%; }
.aw-msg.is-user .aw-msg-col { align-items: flex-end; }
.aw-bubble {
    padding: 8px 11px;
    border-radius: 10px;
    font-size: 13px;
    line-height: 1.55;
    border: 1px solid var(--border);
}
.aw-msg.is-adam .aw-bubble { background: var(--surface-elevated, var(--bg-lighter)); color: var(--text-primary); border-radius: 2px 10px 10px 10px; }
.aw-msg.is-user .aw-bubble { background: var(--accent); color: #fff; border-color: transparent; border-radius: 10px 2px 10px 10px; }
.aw-bubble.is-error { background: color-mix(in srgb, var(--color-danger, #ef4444) 10%, var(--bg-white, #fff)); color: var(--color-danger, #ef4444); border-color: var(--color-danger, #ef4444); }
.aw-bubble.is-action {
    background: color-mix(in srgb, var(--chip-color, var(--accent)) 10%, var(--bg-white, #fff));
    color: var(--chip-color, var(--accent));
    border-color: var(--chip-color, var(--accent));
    font-size: 12px; padding: 5px 9px; border-radius: 20px;
}
.aw-bubble p { margin: 0 0 .4em; } .aw-bubble p:last-child { margin: 0; }
.aw-bubble ul, .aw-bubble ol { margin: .3em 0 .3em 1.2em; padding: 0; }
.aw-bubble strong { font-weight: 600; }
.aw-bubble code { font-size: 11px; background: rgba(0,0,0,.07); padding: 1px 4px; border-radius: 3px; }
.aw-bubble h1, .aw-bubble h2, .aw-bubble h3 { font-size: 13px; font-weight: 700; margin: .5em 0 .2em; }
.aw-msg-time { font-size: 10px; color: var(--text-muted); padding: 0 2px; }

@keyframes aw-cursor-blink { 0%, 100% { opacity: 1; } 50% { opacity: 0; } }
.aw-cursor { display: inline-block; animation: aw-cursor-blink 1s step-start infinite; color: var(--accent); }

.aw-copy-btn {
    align-self: flex-start;
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 10.5px;
    cursor: pointer;
    padding: 2px 4px;
}
.aw-copy-btn:hover { color: var(--text-primary); }

.aw-suggestions { display: flex; flex-wrap: wrap; gap: 5px; padding-left: 34px; }
.aw-suggestion-chip {
    background: var(--surface-elevated, var(--bg-lighter));
    border: 1px solid var(--border);
    border-radius: 14px;
    font-size: 11.5px;
    padding: 4px 10px;
    cursor: pointer;
    color: var(--text-secondary, var(--text-muted));
    transition: background .15s, color .15s;
}
.aw-suggestion-chip:hover { background: var(--accent); color: #fff; border-color: var(--accent); }

/* ── Confirmation avant suppression (bulle inline) ─────────────── */
.aw-bubble.is-confirm p { margin: 0 0 8px; }
.aw-confirm-inline-actions { display: flex; gap: 6px; }
.aw-btn-confirm, .aw-btn-cancel {
    border: none;
    border-radius: 6px;
    padding: 5px 11px;
    font-size: 12px;
    cursor: pointer;
    font-family: inherit;
}
.aw-btn-confirm { background: var(--color-danger, #ef4444); color: #fff; }
.aw-btn-confirm:hover { filter: brightness(1.08); }
.aw-btn-cancel { background: var(--surface-elevated, var(--bg-lighter)); color: var(--text-primary); border: 1px solid var(--border); }
.aw-btn-confirm:disabled, .aw-btn-cancel:disabled { opacity: .5; cursor: default; }

/* ── Raccourcis contextuels ─────────────────────────────── */

.adam-widget-shortcuts {
    padding: 6px 10px;
    border-top: 1px solid var(--border-soft, var(--border));
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
}
.aw-shortcut {
    background: var(--surface-elevated, var(--bg-lighter));
    border: 1px solid var(--border);
    border-radius: 14px;
    font-size: 11.5px;
    padding: 4px 10px;
    cursor: pointer;
    color: var(--text-secondary, var(--text-muted));
    transition: background .15s, color .15s;
    white-space: nowrap;
}
.aw-shortcut:hover { background: var(--accent); color: #fff; border-color: var(--accent); }

/* ── Menu commandes slash ───────────────────────────────── */

.adam-widget-slash-menu {
    border-top: 1px solid var(--border-soft, var(--border));
    padding: 4px;
    max-height: 160px;
    overflow-y: auto;
}
.aw-slash-item {
    display: flex;
    align-items: baseline;
    gap: 8px;
    padding: 6px 9px;
    border-radius: 7px;
    cursor: pointer;
    font-size: 12.5px;
}
.aw-slash-item:hover, .aw-slash-item.is-active { background: var(--surface-elevated, var(--bg-lighter)); }
.aw-slash-item span { font-weight: 700; color: var(--accent); font-family: var(--shell-font-mono, monospace); }
.aw-slash-item small { color: var(--text-muted); }

/* ── Footer / saisie ────────────────────────────────────── */

.adam-widget-footer {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    padding: 10px 12px;
    border-top: 1px solid var(--border);
    flex-shrink: 0;
    background: var(--bg-white, #fff);
}
.adam-widget-input {
    flex: 1;
    resize: none;
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 8px 11px;
    font-size: 13px;
    background: var(--surface-elevated, var(--bg-lighter));
    color: var(--text-primary);
    font-family: inherit;
    line-height: 1.45;
    max-height: 120px;
    overflow-y: auto;
    outline: none;
    transition: border-color .15s;
}
.adam-widget-input:focus { border-color: var(--accent); }
#adam-widget-send {
    width: 34px; height: 34px;
    border-radius: 50%;
    background: var(--accent);
    color: #fff;
    border: none;
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    font-size: 13px;
    flex-shrink: 0;
    transition: opacity .15s;
}
#adam-widget-send:disabled { opacity: .45; cursor: default; }
#adam-widget-stt-btn {
    width: 30px; height: 30px;
    border-radius: 50%;
    background: none;
    border: 1px solid var(--border);
    color: var(--text-muted);
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    font-size: 12px;
    flex-shrink: 0;
    transition: background .15s, color .15s, border-color .15s;
}
#adam-widget-stt-btn:hover { background: var(--hover-bg, rgba(0,0,0,.05)); color: var(--text-primary); }
#adam-widget-stt-btn.is-recording { background: #dc2626; color: #fff; border-color: #dc2626; }

/* ── Recherche historique ───────────────────────────────── */

.adam-widget-history-panel {
    position: fixed;
    right: 0;
    top: 0;
    bottom: 0;
    width: 400px;
    max-width: 100vw;
    z-index: 902;
    background: var(--bg-white, #fff);
    border-left: 1px solid var(--border);
    flex-direction: column;
    box-shadow: -6px 0 32px rgba(0,0,0,.12);
}
.aw-history-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
}
.aw-history-header input {
    flex: 1;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 7px 10px;
    font-size: 13px;
    background: var(--surface-elevated, var(--bg-lighter));
    color: var(--text-primary);
    font-family: inherit;
}
.aw-history-header button {
    background: none; border: none; color: var(--text-muted); cursor: pointer; font-size: 15px; padding: 4px;
}
.aw-history-results { flex: 1; overflow-y: auto; padding: 8px; }
.aw-history-empty { color: var(--text-muted); font-size: 12.5px; text-align: center; padding: 1.5rem; }
.aw-history-item {
    padding: 8px 10px;
    border-radius: 8px;
    cursor: pointer;
    margin-bottom: 4px;
}
.aw-history-item:hover { background: var(--surface-elevated, var(--bg-lighter)); }
.aw-history-item-role { font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .03em; margin-bottom: 2px; }
.aw-history-item-role.is-user { color: var(--accent); }
.aw-history-item-role.is-assistant { color: var(--color-success, #2da05a); }
.aw-history-item-excerpt { font-size: 12.5px; color: var(--text-secondary, var(--text-muted)); line-height: 1.4; }

/* ── Confirmation (effacer / supprimer) ─────────────────── */

.aw-confirm-overlay {
    position: fixed;
    inset: 0;
    z-index: 950;
    display: none;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.45);
    padding: 1rem;
}
.aw-confirm-overlay.is-open { display: flex; }
.aw-confirm-box {
    width: min(360px, 100%);
    background: var(--bg-white, var(--card-bg));
    border: 1px solid var(--border);
    border-radius: var(--shell-radius, 10px);
    box-shadow: 0 12px 32px rgba(0,0,0,.18);
    padding: 1.1rem;
}
.aw-confirm-message { margin: 0 0 1rem; color: var(--text-primary); font-size: .92rem; line-height: 1.5; }
.aw-confirm-actions { display: flex; justify-content: flex-end; gap: .5rem; }

/* ── Orbe (indicateur d'humeur/état léger, sans avatar) ─── */

.adam-orb {
    position: relative;
    width: 42px; height: 42px;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
}
.adam-orb--sm { width: 26px; height: 26px; }
.adam-orb-core {
    width: 36px; height: 36px;
    border-radius: 50%;
    background: linear-gradient(135deg, #1e1b4b, #312e81);
    border: 2px solid var(--accent);
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 14px; color: var(--accent);
    position: relative; z-index: 2;
    transition: background .3s;
    font-family: inherit;
}
.adam-orb--sm .adam-orb-core { width: 22px; height: 22px; font-size: 9px; border-width: 1.5px; }
.adam-orb-ring {
    position: absolute; inset: -4px;
    border-radius: 50%;
    border: 2px solid var(--accent);
    opacity: 0; z-index: 1;
}
.adam-orb--sm .adam-orb-ring { inset: -3px; border-width: 1.5px; }
.adam-orb-bars {
    position: absolute; inset: 0;
    display: flex; align-items: center; justify-content: center;
    gap: 2px; z-index: 3; opacity: 0;
    pointer-events: none;
}
.adam-orb-bars span { display: block; width: 3px; border-radius: 2px; background: var(--accent); height: 6px; }
.adam-orb--sm .adam-orb-bars span { width: 2px; height: 4px; }

.adam-orb.is-idle .adam-orb-ring { opacity: .5; animation: adam-orb-pulse 2.5s ease-in-out infinite; }
.adam-orb.is-listening .adam-orb-core { background: linear-gradient(135deg, #1e3a2f, #14532d); border-color: #4ade80; color: #4ade80; }
.adam-orb.is-listening .adam-orb-ring { opacity: 1; border-color: #4ade80; animation: adam-orb-ripple 1s ease-out infinite; }
.adam-orb.is-thinking .adam-orb-core { background: linear-gradient(135deg, #1e1b4b, #4c1d95); }
.adam-orb.is-thinking .adam-orb-ring { opacity: 1; border-color: transparent; border-top-color: var(--accent); animation: adam-orb-spin .7s linear infinite; }
.adam-orb.is-speaking .adam-orb-core { background: linear-gradient(135deg, #1e1b4b, #7c3aed); border-color: #a78bfa; color: #a78bfa; opacity: .4; }
.adam-orb.is-speaking .adam-orb-bars { opacity: 1; }
.adam-orb.is-speaking .adam-orb-bars span:nth-child(1) { animation: adam-bar .6s ease-in-out -.2s infinite alternate; }
.adam-orb.is-speaking .adam-orb-bars span:nth-child(2) { animation: adam-bar .6s ease-in-out -.4s infinite alternate; }
.adam-orb.is-speaking .adam-orb-bars span:nth-child(3) { animation: adam-bar .6s ease-in-out -.1s infinite alternate; }
.adam-orb.is-speaking .adam-orb-bars span:nth-child(4) { animation: adam-bar .6s ease-in-out -.3s infinite alternate; }

@keyframes adam-orb-pulse { 0%, 100% { transform: scale(1); opacity: .4; } 50% { transform: scale(1.25); opacity: .15; } }
@keyframes adam-orb-ripple { 0% { transform: scale(1); opacity: .8; } 100% { transform: scale(1.6); opacity: 0; } }
@keyframes adam-orb-spin { to { transform: rotate(360deg); } }
@keyframes adam-bar { from { height: 4px; } to { height: 18px; } }

.adam-inline-chart { display: inline-flex; align-items: center; gap: 3px; margin-left: 6px; vertical-align: middle; }

/* ── Responsive ─────────────────────────────────────────── */

@media (max-width: 480px) {
    #adam-widget-panel, .adam-widget-history-panel { width: 100vw; }
}
