/* RESET & BASE STYLES */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

:root {
    --bg-color: #FFFAFA;
    --text-color: #303235;
    --bot-bubble-bg: #FFFFFF;
    --bot-bubble-border: rgba(0, 0, 0, 0.06);
    --user-bubble-bg: #303235;
    --user-bubble-color: #FFFFFF;
    --accent-color: #25D366; /* Green for online status */
    --font-primary: 'Inter', sans-serif;
    --font-header: 'Outfit', sans-serif;
    --border-radius-large: 18px;
    --border-radius-small: 6px;
    --shadow-subtle: 0 2px 8px rgba(0, 0, 0, 0.04);
    --shadow-button: 0 4px 12px rgba(48, 50, 53, 0.12);
}

body, html {
    width: 100%;
    height: 100%;
    height: 100dvh;
    font-family: var(--font-primary);
    background-color: #f0f2f5;
    color: var(--text-color);
    overflow: hidden;
    display: flex;
    justify-content: center;
    align-items: center;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
}

input, textarea {
    -webkit-user-select: text;
    -moz-user-select: text;
    -ms-user-select: text;
    user-select: text;
}

/* CHATCONTAINER */
#chat-container {
    width: 100%;
    height: 100%;
    max-width: 640px;
    background-color: var(--bg-color);
    display: flex;
    flex-direction: column;
    position: relative;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.05);
}

@media (min-width: 641px) {
    #chat-container {
        height: 92vh;
        border-radius: 20px;
        overflow: hidden;
        border: 1px solid rgba(0, 0, 0, 0.05);
    }
}

/* HEADER */
#chat-header {
    background-color: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    padding: 14px 20px;
    padding-top: calc(14px + env(safe-area-inset-top, 0px));
    border-bottom: 1px solid rgba(0, 0, 0, 0.06);
    z-index: 10;
    display: flex;
    align-items: center;
    position: sticky;
    top: 0;
}

.header-profile {
    display: flex;
    align-items: center;
    gap: 12px;
}

.avatar-container {
    position: relative;
    width: 42px;
    height: 42px;
}

#header-avatar {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid #fff;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
}

.status-dot {
    position: absolute;
    bottom: 1px;
    right: 1px;
    width: 10px;
    height: 10px;
    background-color: var(--accent-color);
    border-radius: 50%;
    border: 2px solid #fff;
    animation: pulse-green 2s infinite;
}

.profile-info {
    display: flex;
    flex-direction: column;
}

#header-title {
    font-family: var(--font-header);
    font-size: 1.05rem;
    font-weight: 700;
    color: #1a1a1a;
    letter-spacing: -0.01em;
}

#header-status {
    font-size: 0.75rem;
    font-weight: 500;
    color: #8c8c8c;
}

/* CHAT BODY */
#chat-body {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    scroll-behavior: smooth;
}

/* Hide scrollbar for Chrome, Safari and Opera */
#chat-body::-webkit-scrollbar {
    display: none;
}

/* Hide scrollbar for IE, Edge and Firefox */
#chat-body {
    -ms-overflow-style: none;  /* IE and Edge */
    scrollbar-width: none;  /* Firefox */
}

#messages-container {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

/* BUBBLE CONTAINERS & LAYOUT */
.chat-bubble-container {
    display: flex;
    width: 100%;
    margin-bottom: 4px;
    opacity: 0;
    transform: translateY(12px);
    animation: bubble-appear 0.3s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes bubble-appear {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.bot-message-container {
    justify-content: flex-start;
    align-items: flex-end;
    gap: 8px;
}

.user-message-container {
    justify-content: flex-end;
    align-items: flex-end;
}

.avatar-wrapper {
    width: 32px;
    height: 32px;
    flex-shrink: 0;
    margin-bottom: 2px;
}

.chat-avatar {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
}

/* BUBBLE STYLES */
.chat-bubble {
    padding: 12px 16px;
    font-size: 0.95rem;
    line-height: 1.45;
    max-width: 80%;
    white-space: pre-wrap;
    word-break: break-word;
}

.bot-bubble {
    background-color: var(--bot-bubble-bg);
    color: var(--text-color);
    border-radius: var(--border-radius-large) var(--border-radius-large) var(--border-radius-large) var(--border-radius-small);
    border: 1px solid var(--bot-bubble-border);
    box-shadow: var(--shadow-subtle);
}

.user-bubble {
    background-color: var(--user-bubble-bg);
    color: var(--user-bubble-color);
    border-radius: var(--border-radius-large) var(--border-radius-large) var(--border-radius-small) var(--border-radius-large);
    box-shadow: var(--shadow-subtle);
}

.chat-bubble p {
    margin-bottom: 6px;
}

.chat-bubble p:last-child {
    margin-bottom: 0;
}

.chat-bubble strong {
    font-weight: 700;
}

.chat-bubble u {
    text-decoration: underline;
}

/* IMAGES & VIDEOS IN BUBBLES */
.media-content {
    margin-top: 6px;
    max-width: 100%;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

.bubble-image {
    width: 100%;
    max-height: 280px;
    object-fit: cover;
    display: block;
}

.bubble-image-standalone {
    max-width: 75%;
    max-height: 280px;
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    display: block;
    object-fit: contain;
    margin-bottom: 4px;
}

/* TYPING INDICATOR */
.typing-bubble {
    background-color: var(--bot-bubble-bg);
    border: 1px solid var(--bot-bubble-border);
    border-radius: var(--border-radius-large) var(--border-radius-large) var(--border-radius-large) var(--border-radius-small);
    padding: 14px 20px;
    display: flex;
    align-items: center;
    gap: 5px;
    box-shadow: var(--shadow-subtle);
}

.typing-bubble .dot {
    width: 7px;
    height: 7px;
    background-color: #8c96a0;
    border-radius: 50%;
    animation: typing-bounce 1.4s infinite ease-in-out both;
}

.typing-bubble .dot:nth-child(1) { animation-delay: -0.32s; }
.typing-bubble .dot:nth-child(2) { animation-delay: -0.16s; }

@keyframes typing-bounce {
    0%, 80%, 100% { transform: scale(0.6); opacity: 0.5; }
    40% { transform: scale(1); opacity: 1; }
}

/* FOOTER & INPUT OPTIONS */
#chat-footer {
    padding: 16px 20px;
    padding-bottom: calc(16px + env(safe-area-inset-bottom, 0px));
    background-color: rgba(255, 255, 255, 0.95);
    border-top: 1px solid rgba(0, 0, 0, 0.06);
    z-index: 10;
}

#input-container {
    width: 100%;
    display: flex;
    flex-direction: column;
    animation: footer-fade 0.25s ease-out;
}

@keyframes footer-fade {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

/* CHOICE BUTTONS */
.choice-button {
    font-family: var(--font-primary);
    background-color: var(--user-bubble-bg);
    color: var(--user-bubble-color);
    font-size: 0.95rem;
    font-weight: 600;
    border: none;
    border-radius: 12px;
    padding: 14px 20px;
    margin-bottom: 8px;
    cursor: pointer;
    width: 100%;
    text-align: center;
    transition: background-color 0.15s, transform 0.1s, box-shadow 0.15s;
    box-shadow: var(--shadow-button);
    display: flex;
    justify-content: center;
    align-items: center;
}

.choice-button:hover {
    background-color: #43464a;
}

.choice-button:active {
    transform: scale(0.985);
}

.choice-button:last-child {
    margin-bottom: 0;
}

/* NUMERIC/TEXT FORM */
.input-form {
    display: flex;
    width: 100%;
    gap: 8px;
    margin-top: 4px;
}

.form-input {
    flex: 1;
    font-family: var(--font-primary);
    font-size: 16px;
    padding: 14px 16px;
    border: 2px solid #e2e8f0;
    border-radius: 12px;
    background-color: #fff;
    color: var(--text-color);
    outline: none;
    transition: border-color 0.15s ease-in-out;
}

.form-input:focus {
    border-color: var(--user-bubble-bg);
}

.form-submit-btn {
    font-family: var(--font-primary);
    font-size: 16px;
    font-weight: 600;
    background-color: var(--user-bubble-bg);
    color: var(--user-bubble-color);
    border: none;
    border-radius: 12px;
    padding: 14px 22px;
    cursor: pointer;
    transition: background-color 0.15s, transform 0.1s;
    box-shadow: var(--shadow-button);
}

.form-submit-btn:hover {
    background-color: #43464a;
}

.form-submit-btn:active {
    transform: scale(0.98);
}

/* UTILITIES */
.hidden {
    display: none !important;
}

@keyframes pulse-green {
    0% { box-shadow: 0 0 0 0 rgba(37, 211, 102, 0.5); }
    70% { box-shadow: 0 0 0 5px rgba(37, 211, 102, 0); }
    100% { box-shadow: 0 0 0 0 rgba(37, 211, 102, 0); }
}

/* ==========================================================================
   AVISO DO MODO TESTE
   Só aparece quando CONFIG.checkoutUrl está vazio (nenhum redirecionamento).
   Não faz parte do funil original: é um apoio para validar o funil antes de
   plugar o checkout definitivo.
   ========================================================================== */
#test-notice {
    position: fixed;
    left: 50%;
    bottom: 24px;
    transform: translateX(-50%);
    width: calc(100% - 32px);
    max-width: 480px;
    background-color: #303235;
    color: #fff;
    border-radius: 14px;
    padding: 16px 18px;
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.25);
    font-size: 0.85rem;
    line-height: 1.45;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 6px;
    animation: bubble-appear 0.3s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

#test-notice strong {
    font-family: var(--font-header);
    font-size: 0.95rem;
    font-weight: 700;
}

#test-notice code {
    display: block;
    font-size: 0.78rem;
    background-color: rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    padding: 8px 10px;
    word-break: break-all;
    user-select: text;
}

.test-notice-actions {
    display: flex;
    gap: 8px;
    margin-top: 6px;
}

.test-notice-actions button {
    flex: 1;
    font-family: var(--font-primary);
    font-size: 0.85rem;
    font-weight: 600;
    border: none;
    border-radius: 10px;
    padding: 10px 12px;
    cursor: pointer;
    background-color: rgba(255, 255, 255, 0.14);
    color: #fff;
    transition: background-color 0.15s;
}

.test-notice-actions button:hover {
    background-color: rgba(255, 255, 255, 0.24);
}

/* V5: entrada do nome e transição de preparação; mantém o chat original. */
.name-form { flex-direction: column; }
.form-input { min-width: 0; }
.plan-loading { position:absolute; inset:0; z-index:20; background:var(--bg-color); display:grid; place-items:center; padding:24px; }
.plan-loading-inner { width:100%; max-width:360px; text-align:center; }
.plan-loading h2 { font:700 1.35rem var(--font-header); margin:18px 0 12px; }
.plan-loading p { font-size:.92rem; color:#555; margin-bottom:20px; }
.plan-spinner { width:44px; height:44px; border:3px solid #ddd; border-top-color:var(--text-color); border-radius:50%; margin:auto; animation:plan-spin .8s linear infinite; }
@keyframes plan-spin { to { transform:rotate(360deg); } }
.plan-progress { height:7px; border-radius:8px; background:#e6e6e6; overflow:hidden; }
.plan-progress > div { width:0; height:100%; border-radius:8px; background:var(--text-color); transition:width .35s ease; }
.plan-summary { white-space:normal; width:min(80%, 430px); }
.plan-summary h3 { font-size:.95rem; margin:4px 0 10px; }
.plan-summary dl { display:grid; grid-template-columns:1fr 1fr; gap:8px; margin-bottom:16px; font-size:.83rem; }
.plan-summary dt { color:#626262; }
.plan-summary dd { margin:0; font-weight:600; overflow-wrap:anywhere; }
.weight-goal { display:flex; align-items:center; gap:8px; justify-content:space-between; background:#f2f3f4; border-radius:12px; padding:12px; margin-bottom:8px; }
.weight-goal div { min-width:0; display:flex; flex-direction:column; gap:4px; }
.weight-goal small, .plan-note { font-size:.72rem; color:#666; }
.weight-goal strong { font-size:1rem; }
.weight-arrow { color:#646464; }
.plan-note { display:block; margin-bottom:16px; }
.plan-summary p { font-size:.85rem; margin:0 0 8px; }
@media (prefers-reduced-motion:reduce) { .plan-spinner { animation:none; } .plan-progress > div { transition:none; } }

/* V6: leitura das respostas reais durante a preparação e no resumo. */
.plan-loading { overflow-y:auto; }
.plan-loading-inner { min-width:0; max-height:100%; }
.plan-loading h2 { overflow-wrap:anywhere; }
.plan-loading-count { margin:8px 0 12px; font-size:.75rem; color:#666; font-variant-numeric:tabular-nums; }
.plan-loading-answers { max-height:min(35dvh,220px); overflow-y:auto; overscroll-behavior:contain; text-align:left; border-radius:12px; background:#fff; border:1px solid var(--bot-bubble-border); }
.loading-answer { display:flex; align-items:center; gap:10px; padding:9px 12px; border-bottom:1px solid #f0f0f0; }
.loading-answer:last-child { border-bottom:0; }
.loading-answer > div { display:flex; flex-direction:column; gap:3px; min-width:0; overflow-wrap:anywhere; }
.loading-check { color:#208044; font-weight:700; flex-shrink:0; }
.loading-answer small { color:#666; font-size:.73rem; }
.loading-answer strong { font-size:.84rem; font-weight:600; }
.plan-summary dl { grid-template-columns:minmax(0,1fr) minmax(0,1.1fr); row-gap:12px; }
.plan-summary dt { overflow-wrap:anywhere; }
@media (max-height:440px) { .plan-loading { padding:12px; place-items:start center; } .plan-loading h2 { font-size:1.1rem; margin:8px 0; } .plan-loading p { margin-bottom:10px; } }

/* V10: gráfico dinâmico no estilo da referência. */
.goal-chart { width:min(80%,430px); background:#f4f5f6; white-space:normal; padding:12px; }
.goal-chart h3 { font-size:.94rem; font-weight:600; margin:0 0 4px; }
.goal-chart svg { display:block; width:100%; height:auto; overflow:visible; font-family:var(--font-primary); }

.goal-chart .scenario-detail { font-size:.9rem; line-height:1.45; margin:8px 0 10px; }
.goal-chart .scenario-note { font-size:.75rem; line-height:1.4; color:#606267; margin:6px 0 0; }
