/* ===== Assistente di viaggio (Fase 2A) — pannello laterale / schermo intero =====
   Proprietario: agente Fase 2A. Solo token di css/tokens.css; ombra solo perché è un overlay. */

:root { --asst-w: 400px; --z-assistant: 90; }   /* sotto modali/drawer (--z-overlay: 100) */

/* Bottone nella topbar (solo desktop/tablet; su mobile la voce è nel menu "Altro") */
.topbar__assistant.is-active { background: var(--surface-sunken); color: var(--text); }
@media (max-width: 767px) { .topbar__assistant { display: none; } }

.asst {
    position: fixed; top: 0; right: 0; bottom: 0;
    width: var(--asst-w); max-width: 100vw;
    display: flex; flex-direction: column;
    background: var(--surface);
    border-left: var(--bw) solid var(--border);
    box-shadow: var(--shadow-overlay);
    z-index: var(--z-assistant);
    transform: translateX(16px); opacity: 0;
    transition: transform var(--dur) var(--ease), opacity var(--dur) var(--ease);
}
.asst.is-open { transform: none; opacity: 1; }
.asst[hidden] { display: none; }

/* Schermi molto larghi: il contenuto si restringe invece di finire sotto il pannello
   (sotto i 1600px il pannello si sovrappone: le viste restano con la loro griglia piena) */
@media (min-width: 1600px) {
    html.has-assistant .shell { margin-right: var(--asst-w); }
    html.has-assistant .asst { box-shadow: none; }
}

.asst__head {
    display: flex; align-items: center; gap: var(--sp-2);
    min-height: var(--topbar-h);
    padding: var(--sp-3) var(--sp-3) var(--sp-3) var(--sp-5);
    border-bottom: var(--bw) solid var(--border);
}
.asst__heading { flex: 1; min-width: 0; }
.asst__title { font-size: var(--fs-md); font-weight: var(--fw-bold); letter-spacing: -0.01em; line-height: 1.2; }
.asst__ctx { font-size: var(--fs-xs); color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.asst__body {
    flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain;
    padding: var(--sp-5); display: flex; flex-direction: column; gap: var(--sp-4);
}

/* Introduzione e suggerimenti */
.asst-intro { display: flex; flex-direction: column; gap: var(--sp-3); margin-top: var(--sp-4); }
.asst-intro__title { font-size: var(--fs-lg); font-weight: var(--fw-bold); letter-spacing: -0.01em; }
.asst-intro__text { color: var(--text-2); font-size: var(--fs-sm); line-height: var(--lh-base); }
.asst-chips { display: flex; flex-direction: column; align-items: flex-start; gap: var(--sp-2); margin-top: var(--sp-2); }
.asst-chip { height: auto; min-height: 34px; padding: 6px var(--sp-3); text-align: left; white-space: normal; line-height: 1.35; font-size: var(--fs-sm); }

/* Messaggi */
.asst-msg { display: flex; max-width: 100%; }
.asst-msg--user { justify-content: flex-end; }
.asst-msg__bubble {
    max-width: 85%; padding: var(--sp-2) var(--sp-3);
    background: var(--surface-sunken); border-radius: var(--r-lg) var(--r-lg) var(--r-sm) var(--r-lg);
    font-size: var(--fs-sm); line-height: var(--lh-snug); white-space: pre-wrap; overflow-wrap: anywhere;
}
.asst-msg--model { flex-direction: column; gap: var(--sp-3); }
.asst-msg__text { font-size: var(--fs-sm); line-height: var(--lh-base); color: var(--text); overflow-wrap: anywhere; }
.asst-msg__text p + p, .asst-msg__text p + ul, .asst-msg__text p + ol, .asst-msg__text ul + p, .asst-msg__text ol + p { margin-top: var(--sp-2); }
.asst-msg__text ul, .asst-msg__text ol { padding-left: 1.25em; display: flex; flex-direction: column; gap: 2px; }
.asst-msg__text ul { list-style: disc; }
.asst-msg__text ol { list-style: decimal; }
.asst-msg__text strong { font-weight: var(--fw-semibold); }
.asst-msg__text code { font-family: var(--font-mono); font-size: var(--fs-xs); background: var(--surface-sunken); padding: 1px 4px; border-radius: 4px; }
.asst-thinking { color: var(--text-2); font-size: var(--fs-sm); }
.asst-err { font-size: var(--fs-sm); }
.asst-err > .fa-solid { margin-top: 3px; }

/* Azioni proposte */
.asst-acts { border: var(--bw) solid var(--border); border-radius: var(--r-lg); overflow: hidden; }
.asst-acts__head {
    display: flex; align-items: center; justify-content: space-between; gap: var(--sp-2); flex-wrap: wrap;
    padding: var(--sp-2) var(--sp-3); background: var(--surface-2); border-bottom: var(--bw) solid var(--border);
}
.asst-acts__label { font-size: var(--fs-micro); font-weight: var(--fw-semibold); text-transform: uppercase; letter-spacing: var(--tracking-micro); color: var(--text-2); }
.asst-acts__list { display: flex; flex-direction: column; }
.asst-act {
    display: grid; grid-template-columns: 28px minmax(0, 1fr) auto; gap: var(--sp-3); align-items: start;
    padding: var(--sp-3); border-top: var(--bw) solid var(--border);
}
.asst-act:first-child { border-top: 0; }
.asst-act__icon {
    width: 28px; height: 28px; border-radius: var(--r-sm); display: inline-flex; align-items: center; justify-content: center;
    background: var(--surface-sunken); color: var(--text-2); font-size: 13px;
}
.asst-act--stop .asst-act__icon { background: color-mix(in srgb, var(--stop) var(--stop-tint), var(--surface)); color: var(--stop); }
.asst-act__main { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.asst-act__kicker { font-size: var(--fs-micro); font-weight: var(--fw-semibold); text-transform: uppercase; letter-spacing: var(--tracking-micro); color: var(--text-2); }
.asst-act__title { font-size: var(--fs-sm); font-weight: var(--fw-semibold); color: var(--text); overflow-wrap: anywhere; }
.asst-act__meta { font-size: var(--fs-xs); color: var(--text-2); }
.asst-act__warn { display: inline-flex; gap: 6px; align-items: baseline; font-size: var(--fs-xs); color: var(--warn); margin-top: 2px; }
.asst-act__warn strong { color: var(--text); }
.asst-act__fix { display: block; margin-top: var(--sp-1); margin-left: calc(-1 * var(--sp-2)); }
.asst-act__btns { display: flex; align-items: center; gap: 2px; }
.asst-act__gone { font-size: var(--fs-xs); color: var(--text-3); }
.asst-act.is-discarded .asst-act__main, .asst-act.is-discarded .asst-act__icon { opacity: 0.5; }
.asst-act.is-discarded .asst-act__title { text-decoration: line-through; }

/* Composer */
.asst__composer {
    display: flex; align-items: flex-end; gap: var(--sp-2);
    margin: 0 var(--sp-4); padding: var(--sp-2);
    border: var(--bw) solid var(--border-strong); border-radius: var(--r-lg); background: var(--surface);
}
.asst__composer:focus-within { border-color: var(--accent); box-shadow: var(--focus-ring); }
.asst__input {
    flex: 1; min-height: 36px; max-height: 160px; resize: none; border: 0; outline: none; background: transparent;
    padding: 7px var(--sp-2); font: inherit; font-size: var(--fs-sm); line-height: 1.45; color: var(--text);
}
.asst__input::placeholder { color: var(--text-3); }
.asst__send { width: 36px; height: 36px; flex-shrink: 0; border-radius: var(--r); }
.asst__foot { padding: var(--sp-2) var(--sp-5) var(--sp-3); font-size: var(--fs-xs); color: var(--text-3); text-align: center; }

/* Mobile: schermo intero, sopra la barra in basso */
@media (max-width: 767px) {
    .asst { width: 100vw; border-left: 0; box-shadow: none; z-index: calc(var(--z-overlay) - 1); transform: translateY(12px); }
    .asst__head { min-height: var(--topbar-h-mobile); padding-left: var(--sp-4); }
    .asst__body { padding: var(--sp-4); }
    .asst__composer { margin: 0 var(--sp-3); }
    .asst__input { font-size: 16px; }   /* niente zoom automatico su iOS */
    .asst__foot { padding-bottom: calc(var(--sp-3) + var(--safe-bottom)); }
    html.has-assistant body { overflow: hidden; }
}
@media print { .asst { display: none !important; } }
