/* ═══ Chat do assistente virtual (/chat/assistente) ═══
   Folha GLOBAL de propósito: as mensagens são criadas por chat.js, e o CSS isolado do Blazor
   (Componente.razor.css) não alcança elementos criados em tempo de execução. */

.chat-app {
    --chat-bot-bg: rgba(20, 58, 88, 0.72);
    --chat-user-bg: linear-gradient(135deg, #2F6A9A 0%, #1F5683 100%);
    display: flex; flex-direction: column;
    height: clamp(520px, calc(100dvh - 240px), 760px);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-xl);
    background: linear-gradient(180deg, rgba(13, 46, 71, 0.82), rgba(8, 30, 48, 0.92));
    box-shadow: 0 32px 80px rgba(0, 0, 0, 0.35), inset 0 1px 0 rgba(171, 204, 216, 0.08);
    overflow: hidden;
}

/* Cabeçalho */
.chat-head { display: flex; align-items: center; gap: 12px; padding: 14px 18px; border-bottom: 1px solid var(--border-subtle, rgba(171,204,216,.10)); background: rgba(6, 24, 39, 0.45); }
.chat-avatar { flex: none; width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; color: #fff;
    background: linear-gradient(135deg, #2F6A9A, #5AA3CC); box-shadow: 0 0 0 3px rgba(90,163,204,.18); }
.chat-head-title { margin: 0; font-family: var(--font-primary); font-size: 1rem !important; font-weight: 600; letter-spacing: 0; color: var(--text-primary); line-height: 1.2; }
.chat-head-sub { margin: 2px 0 0; font-size: .8rem; color: var(--text-muted); display: flex; align-items: center; gap: 6px; }
.chat-dot { width: 8px; height: 8px; border-radius: 50%; background: #4CC38A; box-shadow: 0 0 0 3px rgba(76,195,138,.18); }
.chat-head-actions { margin-left: auto; display: flex; gap: 8px; }
.chat-btn-ghost { display: inline-flex; align-items: center; gap: 6px; padding: 8px 12px; border-radius: 999px; border: 1px solid var(--border-default);
    background: transparent; color: var(--text-light); font: inherit; font-size: .85rem; cursor: pointer; text-decoration: none; }
.chat-btn-ghost:hover { background: rgba(90,163,204,.12); color: var(--text-primary); }

/* Consentimento (antes da 1ª mensagem) */
.chat-consent-panel { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; gap: 16px; padding: 32px 24px; }
.chat-consent-icon { width: 56px; height: 56px; border-radius: 50%; display: grid; place-items: center; background: rgba(90,163,204,.14); color: var(--brand-cyan-light, #85CDE6); }
.chat-consent-panel h2 { margin: 0; font-size: 1.25rem !important; font-family: var(--font-primary); letter-spacing: 0; }
.chat-consent-panel p { margin: 0; max-width: 520px; color: var(--text-light); line-height: 1.6; font-size: .95rem; }
.chat-app.is-ready .chat-consent-panel { display: none; }
.chat-app:not(.is-ready) .chat-main { display: none; }

/* Mensagens */
.chat-main { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.chat-log { flex: 1; min-height: 0; overflow-y: auto; padding: 20px 18px 8px; display: flex; flex-direction: column; gap: 14px; scroll-behavior: smooth; }
.chat-log:focus-visible { outline: 2px solid var(--brand-cyan-light, #85CDE6); outline-offset: -2px; }
.chat-row { display: flex; gap: 10px; align-items: flex-end; max-width: 100%; animation: chat-in .22s ease-out; }
.chat-row--user { flex-direction: row-reverse; }
.chat-row .chat-avatar { width: 30px; height: 30px; box-shadow: none; }
.chat-bubble { max-width: min(78%, 620px); padding: 11px 15px; border-radius: 18px; line-height: 1.55; font-size: .97rem; overflow-wrap: anywhere; }
.chat-row--bot .chat-bubble { background: var(--chat-bot-bg); color: var(--text-primary); border: 1px solid var(--border-default); border-bottom-left-radius: 6px; }
.chat-row--user .chat-bubble { background: var(--chat-user-bg); color: #fff; border-bottom-right-radius: 6px; }
.chat-row--error .chat-bubble { background: rgba(232,185,74,.10); border-color: rgba(232,185,74,.45); }
.chat-bubble p { margin: 0 0 .6em; } .chat-bubble p:last-child { margin-bottom: 0; }
.chat-bubble ul, .chat-bubble ol { margin: .3em 0 .6em 1.2em; padding: 0; } .chat-bubble li { margin: .15em 0; }
.chat-bubble code { padding: 1px 6px; border-radius: 6px; background: rgba(0,0,0,.28); font-size: .88em; }
.chat-bubble a { color: inherit; text-decoration: underline; font-weight: 600; }
.chat-time { display: block; margin-top: 4px; font-size: .72rem; opacity: .65; }
.chat-row--user .chat-time { text-align: right; }
.chat-retry { margin-top: 8px; }

/* Digitando */
.chat-typing .chat-bubble { display: inline-flex; gap: 5px; padding: 14px 16px; }
.chat-typing i { width: 7px; height: 7px; border-radius: 50%; background: var(--text-muted); animation: chat-dot 1.2s infinite ease-in-out; }
.chat-typing i:nth-child(2) { animation-delay: .15s; } .chat-typing i:nth-child(3) { animation-delay: .3s; }

/* Sugestões */
.chat-chips { display: flex; flex-wrap: wrap; gap: 8px; padding: 4px 18px 12px; }
.chat-chip { padding: 8px 14px; border-radius: 999px; border: 1px solid var(--border-accent, rgba(90,163,204,.4)); background: rgba(90,163,204,.08);
    color: var(--text-primary); font: inherit; font-size: .88rem; cursor: pointer; }
.chat-chip:hover { background: rgba(90,163,204,.2); }

/* Entrada */
.chat-form { display: flex; gap: 10px; align-items: flex-end; padding: 12px 18px 8px; border-top: 1px solid var(--border-subtle, rgba(171,204,216,.10)); background: rgba(6, 24, 39, 0.35); }
.chat-input { flex: 1; resize: none; min-height: 46px; max-height: 140px; padding: 12px 14px; border-radius: 14px; border: 1px solid var(--border-default);
    background: rgba(6, 24, 39, 0.8); color: var(--text-primary); font: inherit; line-height: 1.4; }
.chat-input::placeholder { color: var(--text-muted); }
.chat-input:focus-visible, .chat-chip:focus-visible, .chat-btn-ghost:focus-visible, .chat-send:focus-visible { outline: 2px solid var(--brand-cyan-light, #85CDE6); outline-offset: 2px; }
.chat-send { flex: none; width: 46px; height: 46px; border-radius: 50%; border: 0; display: grid; place-items: center; cursor: pointer; color: #fff; background: var(--chat-user-bg); }
.chat-send:disabled { opacity: .45; cursor: not-allowed; }
.chat-foot { margin: 0; padding: 0 18px 12px; font-size: .75rem; color: var(--text-muted); display: flex; justify-content: space-between; gap: 12px; }
.chat-count[data-warn="true"] { color: #E8B94A; }
.chat-status { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

@keyframes chat-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@keyframes chat-dot { 0%, 80%, 100% { transform: translateY(0); opacity: .45; } 40% { transform: translateY(-4px); opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .chat-row, .chat-typing i { animation: none; } .chat-log { scroll-behavior: auto; } }
@media (max-width: 600px) {
    .chat-app { height: calc(100dvh - 190px); min-height: 480px; border-radius: var(--radius-lg); }
    .chat-bubble { max-width: 88%; }
    .chat-btn-ghost span { display: none; }
    .chat-head { padding: 12px 14px; } .chat-log { padding: 16px 12px 6px; } .chat-form { padding: 10px 12px 6px; } .chat-chips { padding: 4px 12px 10px; } .chat-foot { padding: 0 12px 10px; }
}
.chat-app [hidden] { display: none !important; }
.chat-btn-ghost svg { flex: none; }

.chat-name-form { display: flex; flex-direction: column; gap: 10px; width: 100%; max-width: 340px; text-align: left; }
.chat-name-form label { font-weight: 600; font-size: .95rem; }
.chat-name-form input { width: 100%; padding: 12px 14px; font-size: 16px; border-radius: 12px; border: 1px solid rgba(133,205,230,.35); background: rgba(255,255,255,.06); color: inherit; }
.chat-name-form input:focus { outline: 2px solid var(--brand-cyan-light, #85CDE6); outline-offset: 1px; }
.chat-name-error { color: #ff9b9b; font-size: .85rem; }
