/* ============================================================
   Webchat - Conecta Sul Telecom
   Layout moderno: card centralizado no desktop, tela cheia no mobile.
   ============================================================ */

:root {
    --brand: #1e2a78;
    --brand-2: #3b4bc7;
    --accent: #6366f1;
    --bg: #eef1f6;
    --bot-bg: #ffffff;
    --bot-text: #1f2430;
    --cliente-bg: #6366f1;
    --cliente-text: #ffffff;
    --muted: #9aa3b2;
    --online: #34d399;
    --shadow: 0 10px 40px rgba(20, 28, 70, 0.18);
    --radius: 18px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html, body { height: 100%; }

body {
    font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
    background: linear-gradient(135deg, #e8ebf5 0%, #dfe4f2 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    color: var(--bot-text);
}

/* ---------- Janela do chat ---------- */
.chat-app {
    width: 100%;
    max-width: 420px;
    height: min(720px, 92vh);
    background: var(--bg);
    border-radius: 22px;
    box-shadow: var(--shadow);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* ---------- Cabeçalho ---------- */
.chat-header {
    background: linear-gradient(135deg, var(--brand) 0%, var(--brand-2) 100%);
    color: #fff;
    padding: 14px 18px;
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
    position: relative;
}
.chat-header .avatar {
    width: 44px; height: 44px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.18);
    border: 2px solid rgba(255, 255, 255, 0.35);
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 1.25rem;
    flex-shrink: 0;
    overflow: hidden;
}
.chat-header .avatar img {
    width: 100%; height: 100%;
    object-fit: cover;
    display: block;
}
.chat-header .info h3 { font-size: 1.05rem; font-weight: 600; line-height: 1.2; }
.chat-header .info .status {
    font-size: 0.78rem;
    color: rgba(255, 255, 255, 0.85);
    display: inline-flex; align-items: center; gap: 5px;
}
.chat-header .info .status::before {
    content: '';
    width: 8px; height: 8px;
    border-radius: 50%;
    background: var(--online);
    box-shadow: 0 0 0 0 rgba(52, 211, 153, 0.6);
    animation: live 2s infinite;
}
@keyframes live {
    0%   { box-shadow: 0 0 0 0 rgba(52, 211, 153, 0.6); }
    70%  { box-shadow: 0 0 0 6px rgba(52, 211, 153, 0); }
    100% { box-shadow: 0 0 0 0 rgba(52, 211, 153, 0); }
}
.chat-header .brand {
    margin-left: auto;
    font-size: 0.7rem;
    letter-spacing: 0.3px;
    text-transform: uppercase;
    color: rgba(255, 255, 255, 0.75);
    text-align: right;
    max-width: 110px;
    line-height: 1.2;
}

/* ---------- Área de mensagens ---------- */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 18px 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    scroll-behavior: smooth;
}
.chat-messages::-webkit-scrollbar { width: 6px; }
.chat-messages::-webkit-scrollbar-thumb { background: #c7cde0; border-radius: 3px; }
.chat-messages::-webkit-scrollbar-track { background: transparent; }

/* ---------- Bolhas de mensagem ---------- */
.msg-bot, .msg-cliente {
    max-width: 78%;
    padding: 11px 15px;
    font-size: 0.94rem;
    line-height: 1.5;
    word-wrap: break-word;
    white-space: pre-wrap;
    animation: pop 0.25s ease;
}
@keyframes pop {
    from { opacity: 0; transform: translateY(6px); }
    to   { opacity: 1; transform: translateY(0); }
}
.msg-bot {
    align-self: flex-start;
    background: var(--bot-bg);
    color: var(--bot-text);
    border-radius: 16px 16px 16px 5px;
    box-shadow: 0 1px 2px rgba(20, 28, 70, 0.08);
}
.msg-cliente {
    align-self: flex-end;
    background: linear-gradient(135deg, var(--accent) 0%, #818cf8 100%);
    color: var(--cliente-text);
    border-radius: 16px 16px 5px 16px;
    box-shadow: 0 2px 6px rgba(99, 102, 241, 0.28);
}

/* ---------- Indicador "digitando..." ---------- */
.typing {
    display: flex; gap: 5px;
    padding: 14px 16px !important;
    width: fit-content;
}
.typing span {
    width: 8px; height: 8px;
    border-radius: 50%;
    background: var(--muted);
    animation: blink 1.4s infinite both;
}
.typing span:nth-child(2) { animation-delay: 0.2s; }
.typing span:nth-child(3) { animation-delay: 0.4s; }
@keyframes blink { 0%, 60%, 100% { opacity: 0.25; transform: translateY(0); } 30% { opacity: 1; transform: translateY(-3px); } }

/* ---------- Botões de opção ---------- */
.opcoes-area { padding: 0 16px; flex-shrink: 0; }
.opcoes-container {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: flex-end;
    padding-bottom: 10px;
}
.opcao-btn {
    padding: 9px 16px;
    border-radius: 18px;
    border: 1.5px solid var(--accent);
    background: #fff;
    color: var(--accent);
    cursor: pointer;
    font-size: 0.88rem;
    font-weight: 500;
    transition: all 0.18s ease;
    animation: pop 0.25s ease;
}
.opcao-btn:hover { background: var(--accent); color: #fff; transform: translateY(-1px); box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3); }
.opcao-btn:active { transform: translateY(0); }

/* ---------- Área de input ---------- */
.chat-input-area {
    background: #fff;
    padding: 12px 14px;
    display: flex;
    gap: 10px;
    align-items: center;
    border-top: 1px solid #e7eaf3;
    flex-shrink: 0;
}
.chat-input-area input {
    flex: 1;
    padding: 12px 16px;
    border: 1.5px solid #e2e6f0;
    border-radius: 24px;
    font-size: 0.95rem;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
    background: #f7f8fc;
}
.chat-input-area input:focus { border-color: var(--accent); background: #fff; box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.12); }
.chat-input-area input:disabled { background: #f1f2f7; cursor: not-allowed; color: var(--muted); }
.chat-input-area button {
    width: 46px; height: 46px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent) 0%, #818cf8 100%);
    border: none;
    color: #fff;
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
    transition: transform 0.15s, opacity 0.2s, box-shadow 0.2s;
    box-shadow: 0 3px 10px rgba(99, 102, 241, 0.35);
}
.chat-input-area button:hover:not(:disabled) { transform: scale(1.06); }
.chat-input-area button:active:not(:disabled) { transform: scale(0.96); }
.chat-input-area button:disabled { background: #c4c9da; cursor: not-allowed; box-shadow: none; }
.chat-input-area button svg { margin-left: 2px; }

/* ---------- Bloco de pagamento PIX ---------- */
.pix-card {
    max-width: 88% !important;
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.pix-code {
    font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
    font-size: 0.78rem;
    line-height: 1.45;
    background: #f1f3fb;
    border: 1px dashed #c3c9e6;
    border-radius: 10px;
    padding: 10px 12px;
    color: #2b3252;
    word-break: break-all;
    max-height: 120px;
    overflow-y: auto;
    user-select: all;
}
.pix-copy-btn {
    align-self: stretch;
    padding: 11px 16px;
    border: none;
    border-radius: 12px;
    background: linear-gradient(135deg, var(--accent) 0%, #818cf8 100%);
    color: #fff;
    font-size: 0.92rem;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.15s, box-shadow 0.2s, background 0.2s;
    box-shadow: 0 3px 10px rgba(99, 102, 241, 0.3);
}
.pix-copy-btn:hover { transform: translateY(-1px); box-shadow: 0 5px 14px rgba(99, 102, 241, 0.38); }
.pix-copy-btn:active { transform: translateY(0); }
.pix-copy-btn.copiado { background: linear-gradient(135deg, #10b981 0%, #34d399 100%); box-shadow: 0 3px 10px rgba(16, 185, 129, 0.35); }
.pix-nota {
    font-size: 0.8rem;
    line-height: 1.4;
    color: #5b6478;
    background: #eef6f1;
    border-left: 3px solid var(--online);
    border-radius: 6px;
    padding: 8px 10px;
}

/* ---------- Responsivo (tela cheia no mobile) ---------- */
@media (max-width: 480px) {
    body { padding: 0; }
    .chat-app { max-width: 100%; height: 100vh; height: 100dvh; border-radius: 0; }
    .msg-bot, .msg-cliente { max-width: 85%; }
}
