/* =========================================================
   Assistente IA (/assistente) — usa os tokens de cor do app.css
   ========================================================= */
.ai { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.app > .ai { grid-column: 1 / -1; }

.ai-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.ai-sub { margin-top: 4px; color: var(--muted); font-size: calc(14px * var(--fs, 1)); max-width: 60ch; }
.ai-new { min-height: 44px; padding: 0 14px; font-size: calc(14px * var(--fs, 1)); flex-shrink: 0; }
.ai-muted { color: var(--muted); font-size: calc(14px * var(--fs, 1)); }

/* Aviso de desligado */
.ai-off { display: flex; gap: 16px; align-items: flex-start; }
.ai-off h2 { font-size: calc(18px * var(--fs, 1)); font-weight: 800; margin-bottom: 6px; }
.ai-off p + p { margin-top: 8px; }
.ai-off-icon {
    flex-shrink: 0; width: 52px; height: 52px; border-radius: 16px;
    display: grid; place-items: center; background: var(--amber-soft); color: var(--amber);
}

/* Conversa */
.ai-chat { display: flex; flex-direction: column; gap: 14px; padding: 16px; }
.ai-thread {
    display: flex; flex-direction: column; gap: 12px;
    min-height: 260px; max-height: min(62dvh, 640px); overflow-y: auto;
    padding: 4px 2px; overscroll-behavior: contain;
}
.ai-hello { margin: auto 0; text-align: center; color: var(--ink-2); padding: 12px; }
.ai-hello p + p { margin-top: 6px; color: var(--muted); font-size: calc(14px * var(--fs, 1)); }
.ai-avatar {
    width: 48px; height: 48px; margin: 0 auto 10px; border-radius: 50%;
    display: grid; place-items: center; background: var(--brand-soft); color: var(--brand);
}

.ai-msg { display: flex; }
.ai-user { justify-content: flex-end; }
.ai-bubble {
    max-width: min(85%, 640px); padding: 10px 14px; border-radius: 18px;
    font-size: calc(15px * var(--fs, 1)); line-height: 1.5; overflow-wrap: anywhere;
}
.ai-user .ai-bubble { background: var(--brand); color: #fff; border-bottom-right-radius: 6px; white-space: pre-wrap; }
.ai-bot .ai-bubble { background: var(--surface-2); color: var(--ink); border: 1px solid var(--line); border-bottom-left-radius: 6px; }

.ai-text p + p, .ai-text ul + p, .ai-text p + ul { margin-top: 8px; }
.ai-text ul { padding-left: 20px; list-style: disc; }
.ai-text li + li { margin-top: 4px; }
.ai-text strong { font-weight: 700; }
.ai-source {
    margin-top: 10px !important; padding-top: 8px; border-top: 1px dashed var(--line);
    font-size: calc(13px * var(--fs, 1)); color: var(--muted);
}

.ai-steps { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.ai-step {
    display: inline-flex; align-items: center; gap: 4px; padding: 3px 8px; border-radius: 999px;
    font-size: calc(12px * var(--fs, 1)); font-weight: 600; background: var(--brand-soft); color: var(--brand-deep);
}
.ai-error { display: flex; gap: 6px; align-items: flex-start; color: var(--out); font-size: calc(14px * var(--fs, 1)); }

.ai-typing { display: inline-flex; gap: 4px; padding: 6px 0; }
.ai-typing i { width: 7px; height: 7px; border-radius: 50%; background: var(--muted); animation: ai-blink 1.2s infinite ease-in-out; }
.ai-typing i:nth-child(2) { animation-delay: .15s; }
.ai-typing i:nth-child(3) { animation-delay: .3s; }
@keyframes ai-blink { 0%, 80%, 100% { opacity: .25; } 40% { opacity: 1; } }

/* Sugestões */
.ai-chips { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 2px; scrollbar-width: none; }
.ai-chips::-webkit-scrollbar { display: none; }
.ai-chip {
    flex-shrink: 0; min-height: 44px; padding: 8px 16px; border-radius: 999px; border: 1.5px solid var(--brand);
    background: var(--surface); color: var(--brand-deep); font: inherit; font-size: calc(14px * var(--fs, 1)); font-weight: 600;
    cursor: pointer; white-space: nowrap; transition: background .15s;
}
@media (hover: hover) and (pointer: fine) { .ai-chip:hover:not([disabled]) { background: var(--brand-soft); } }
.ai-chip[disabled] { opacity: .5; cursor: not-allowed; }

.ai-note { font-size: calc(13px * var(--fs, 1)); color: var(--amber); }

/* Campo de pergunta */
.ai-form { display: flex; gap: 8px; align-items: flex-end; }
.ai-input {
    flex: 1; min-width: 0; min-height: 48px; max-height: 140px; resize: none; field-sizing: content;
    padding: 12px 14px; border-radius: 14px; border: 1.5px solid var(--line); background: var(--surface);
    font: inherit; font-size: calc(16px * var(--fs, 1)); color: var(--ink);
}
.ai-input:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
.ai-input[disabled] { background: var(--surface-2); }
.ai-send { width: 48px; padding: 0; flex-shrink: 0; }

.ai-foot { display: flex; flex-direction: column; gap: 4px; font-size: calc(12px * var(--fs, 1)); color: var(--muted); }

@media (max-width: 1023px) {
    .ai-head h1 { font-size: calc(22px * var(--fs, 1)); }
    .ai-thread { max-height: none; min-height: 200px; }
    .ai-bubble { max-width: 92%; }
}

@media (prefers-reduced-motion: reduce) {
    .ai-typing i { animation: none; opacity: .6; }
}
