/* Atendimento virtual — botão flutuante e janela de chat (estilo mensageiro) */
.chat { position: fixed; right: 20px; bottom: calc(20px + env(safe-area-inset-bottom)); z-index: 70; font-family: var(--font); }
.chat-launcher { position: relative; width: 62px; height: 62px; border: 0; border-radius: 50%; color: #fff; background: linear-gradient(135deg, var(--brand), var(--brand-2)); box-shadow: 0 12px 28px -8px rgba(240,86,44,.75); display: grid; place-items: center; transition: transform .15s; }
.chat-launcher:hover { transform: scale(1.06); }
.chat-launcher .ic-close { display: none; }
.chat-launcher[aria-expanded="true"] .ic-open { display: none; }
.chat-launcher[aria-expanded="true"] .ic-close { display: block; }
.chat-badge { position: absolute; top: -4px; right: -4px; min-width: 22px; height: 22px; padding: 0 6px; border-radius: 11px; background: #ef4444; color: #fff; font-size: 12px; font-weight: 800; display: grid; place-items: center; border: 2px solid #fff; }
.chat-badge[hidden] { display: none; }

.chat-panel { position: absolute; right: 0; bottom: 78px; width: 370px; max-width: calc(100vw - 40px); height: 540px; max-height: calc(100dvh - 130px); display: flex; flex-direction: column; background: #fff; border-radius: 18px; overflow: hidden; box-shadow: var(--shadow-lg); border: 1px solid var(--line); }
.chat-panel[hidden] { display: none; }
.chat-head { display: flex; align-items: center; gap: 12px; padding: 14px 16px; background: linear-gradient(135deg, var(--brand), var(--brand-2)); color: #fff; flex: none; }
.chat-avatar { width: 40px; height: 40px; border-radius: 50%; background: rgba(255,255,255,.22); display: grid; place-items: center; font-weight: 800; font-size: 18px; flex: none; }
.chat-head-text { flex: 1; min-width: 0; line-height: 1.25; }
.chat-head-text strong { display: block; font-size: 15px; }
.chat-head-text small { opacity: .9; font-size: 12px; }
.chat-head-text small::before { content: ''; display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: #4ade80; margin-right: 6px; }
.chat-min { background: rgba(255,255,255,.18); border: 0; color: #fff; width: 32px; height: 32px; border-radius: 50%; font-size: 22px; line-height: 1; }

.chat-view { flex: 1; min-height: 0; overflow-y: auto; }
.chat-view[hidden] { display: none; }
.chat-intro { padding: 36px 26px; text-align: center; display: grid; gap: 12px; justify-items: center; }
.chat-intro-icon { font-size: 44px; }
.chat-intro h3 { font-size: 20px; }
.chat-intro p { margin: 0 0 8px; color: var(--muted); font-size: 14px; }
.chat-start { padding: 20px 22px 24px; display: grid; gap: 12px; }
.chat-start p { margin: 0; color: var(--ink-2); font-size: 14px; }
.chat-start label { display: grid; gap: 4px; font-size: 13px; font-weight: 600; color: var(--ink-2); }
.chat-start input { border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; font: inherit; font-weight: 400; color: var(--ink); }
.chat-start input.invalid { border-color: #ef4444; }
.chat-start .field-error { color: #dc2626; font-size: 12px; font-style: normal; font-weight: 500; }
.chat-start .form-error { color: #dc2626; font-size: 13px; }
.chat-start .hp { position: absolute; left: -9999px; }

.chat-room { display: flex; flex-direction: column; background: #efeae2; }
.chat-room[hidden] { display: none; }
.chat-thread { flex: 1; min-height: 0; overflow-y: auto; padding: 14px 12px; display: flex; flex-direction: column; gap: 6px; }
.chat-msg { max-width: 82%; padding: 7px 10px 4px; border-radius: 10px; background: #fff; color: #111b21; font-size: 14px; line-height: 1.4; box-shadow: 0 1px 1px rgba(0,0,0,.13); word-break: break-word; white-space: pre-wrap; align-self: flex-start; }
.chat-msg.is-mine { align-self: flex-end; background: #d9fdd3; }
.chat-msg time { display: block; text-align: right; font-size: 11px; color: #667781; margin-top: 2px; white-space: normal; }
.chat-msg .tick { margin-left: 4px; }
.chat-msg .tick.is-read { color: #34b7f1; }
.chat-sys { align-self: center; max-width: 90%; text-align: center; background: rgba(255,244,196,.95); color: #54656f; font-size: 12.5px; padding: 6px 12px; border-radius: 10px; }

.chat-closed { flex: none; display: flex; justify-content: center; align-items: center; gap: 10px; padding: 10px; background: #f0f2f5; font-size: 13px; color: var(--muted); }
.chat-closed[hidden] { display: none; }
.chat-closed button { border: 0; background: none; color: var(--brand-2); font-weight: 700; text-decoration: underline; padding: 0; }
.chat-compose { flex: none; display: flex; gap: 8px; align-items: flex-end; padding: 10px; background: #f0f2f5; }
.chat-compose[hidden] { display: none; }
.chat-compose textarea { flex: 1; resize: none; max-height: 110px; border: 0; border-radius: 20px; padding: 10px 14px; font: inherit; font-size: 14px; line-height: 1.35; }
.chat-compose textarea:focus { outline: 2px solid color-mix(in srgb, var(--brand) 45%, white); }
.chat-compose button { flex: none; width: 42px; height: 42px; border: 0; border-radius: 50%; background: #00a884; color: #fff; display: grid; place-items: center; }

@media (max-width: 520px) {
    .chat { right: 14px; bottom: calc(14px + env(safe-area-inset-bottom)); }
    .chat-panel { position: fixed; inset: 0; width: auto; max-width: none; height: auto; max-height: none; border-radius: 0; border: 0; }
    .chat-launcher[aria-expanded="true"] { display: none; }
}
