/* =============================================
   QUIZ FUNNEL — PREMIUM BRAND-DRIVEN THEME
   All accents driven by --primary-color CSS var
   ============================================= */

:root {
    --primary-color: #2563eb;
    --primary-hover: #1d4ed8;
    --primary-glow: rgba(37, 99, 235, 0.25);
    --primary-soft: rgba(37, 99, 235, 0.08);
    --primary-mid:  rgba(37, 99, 235, 0.15);

    --ai-bubble: #ffffff;
    --user-bubble: var(--primary-color);

    --bg-main: #f8fafc;
    --bg-surface: #ffffff;

    --text-main: #0f172a;
    --text-muted: #64748b;
    --border-color: #e2e8f0;
    --border-primary: color-mix(in srgb, var(--primary-color) 30%, transparent);

    --radius-lg: 1rem;
    --radius-xl: 1.5rem;
    --radius-full: 9999px;
    --transition: 300ms cubic-bezier(0.16, 1, 0.3, 1);

    --shadow-card: 0 4px 6px -1px rgba(0,0,0,0.07), 0 2px 4px -1px rgba(0,0,0,0.04);
    --shadow-lifted: 0 20px 60px -15px rgba(0,0,0,0.18);
    --shadow-brand: 0 8px 30px var(--primary-glow);
}

*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Outfit', sans-serif;
}

/* ── BODY: subtle brand-tinted radial mesh ── */
body, html {
    height: 100%;
    overflow: hidden;
    color: var(--text-main);
}

body {
    background-color: var(--bg-main);
    background-image:
        radial-gradient(ellipse 80% 60% at 50% -20%, var(--primary-glow), transparent),
        radial-gradient(ellipse 60% 40% at 100% 100%, var(--primary-soft), transparent);
    background-attachment: fixed;
}

/* ── WRAPPER: floating premium card ── */
.chat-wrapper {
    display: flex;
    flex-direction: column;
    height: 100%;
    max-width: 600px;
    margin: 0 auto;
    position: relative;
    background: rgba(255,255,255,0.97);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-left: 1px solid rgba(255,255,255,0.8);
    border-right: 1px solid rgba(255,255,255,0.8);
    box-shadow:
        0 0 0 1px var(--border-color),
        0 30px 80px -20px rgba(0,0,0,0.12),
        0 0 40px var(--primary-soft);
}

/* ── HEADER: glassmorphic with brand accent ── */
.chat-header {
    padding: 1rem 1.5rem;
    background: rgba(255,255,255,0.90);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-bottom: 1px solid var(--border-color);
    z-index: 10;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: relative;
}

/* Brand color top edge line */
.chat-header::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--primary-color), color-mix(in srgb, var(--primary-color) 60%, #a78bfa));
    border-radius: 0 0 2px 2px;
}

.ai-profile {
    display: flex;
    align-items: center;
    gap: 0.85rem;
}

/* Avatar: brand color ring + glow */
.ai-avatar {
    width: 42px;
    height: 42px;
    border-radius: var(--radius-full);
    background: var(--primary-color);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 0.9rem;
    color: white;
    box-shadow: 0 0 0 3px white, 0 0 0 5px var(--primary-color), var(--shadow-brand);
    transition: box-shadow var(--transition);
}

.ai-avatar:hover {
    box-shadow: 0 0 0 3px white, 0 0 0 5px var(--primary-color), 0 12px 35px var(--primary-glow);
}

.ai-info h1 {
    font-size: 1rem;
    font-weight: 700;
    letter-spacing: -0.01em;
    color: var(--text-main);
}

/* Online status badge */
.status-indicator {
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 0.4rem;
    margin-top: 2px;
}

.dot {
    width: 7px;
    height: 7px;
    background: #10b981;
    border-radius: 50%;
    display: inline-block;
    box-shadow: 0 0 0 2px rgba(16,185,129,0.2);
    animation: pulse-green 2s infinite;
}

@keyframes pulse-green {
    0%, 100% { box-shadow: 0 0 0 2px rgba(16,185,129,0.2); }
    50%       { box-shadow: 0 0 0 5px rgba(16,185,129,0.08); }
}

/* Header Progress */
.chat-progress {
    text-align: right;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 5px;
}

#header-progress-text {
    font-size: 0.68rem;
    font-weight: 700;
    color: var(--text-muted);
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.progress-track-small {
    width: 90px;
    height: 6px;
    background: var(--border-color);
    border-radius: var(--radius-full);
    overflow: hidden;
}

.progress-fill-small {
    height: 100%;
    background: linear-gradient(90deg, var(--primary-color), color-mix(in srgb, var(--primary-color) 70%, #a78bfa));
    border-radius: var(--radius-full);
    transition: width 0.5s cubic-bezier(0.16, 1, 0.3, 1);
    box-shadow: 2px 0 8px var(--primary-glow);
}

/* ── SCROLL AREA ── */
.chat-container {
    flex: 1;
    overflow-y: auto;
    padding: 1.75rem 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
    scroll-behavior: smooth;
    overscroll-behavior: contain;
    background: transparent;
}

.chat-container::-webkit-scrollbar { width: 4px; }
.chat-container::-webkit-scrollbar-track { background: transparent; }
.chat-container::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: var(--radius-full);
}
.chat-container::-webkit-scrollbar-thumb:hover {
    background: color-mix(in srgb, var(--primary-color) 40%, #cbd5e1);
}

/* ── MESSAGES ── */
.message {
    display: flex;
    gap: 0.75rem;
    max-width: 88%;
    opacity: 0;
    transform: translateY(12px);
    animation: msgEnter 0.45s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.ai-message  { align-self: flex-start; }
.user-message {
    align-self: flex-end;
    flex-direction: row-reverse;
    max-width: 78%;
}

/* Small avatar beside messages */
.avatar-sm {
    width: 34px;
    height: 34px;
    min-width: 34px;
    border-radius: var(--radius-full);
    background: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 900;
    font-size: 0.65rem;
    color: var(--primary-color);
    margin-top: auto;
    border: 1.5px solid var(--border-color);
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
    overflow: hidden;
    transition: box-shadow var(--transition);
}

/* AI bubble: white card with brand left-accent */
.msg-bubble {
    padding: 0.9rem 1.2rem;
    border-radius: var(--radius-lg);
    font-size: 0.97rem;
    line-height: 1.6;
    box-shadow: var(--shadow-card);
}

.ai-message .msg-bubble {
    background: var(--ai-bubble);
    color: var(--text-main);
    border-bottom-left-radius: 3px;
    border: 1px solid var(--border-color);
    border-left: 3px solid var(--primary-color);
    box-shadow: 0 2px 12px rgba(0,0,0,0.06), 4px 0 0 -3px var(--primary-soft);
}

/* User bubble: solid brand color + glow */
.user-message .msg-bubble {
    background: linear-gradient(135deg, var(--primary-color), color-mix(in srgb, var(--primary-color) 80%, #7c3aed));
    color: white;
    border-bottom-right-radius: 3px;
    box-shadow: 0 4px 20px var(--primary-glow);
}

@keyframes msgEnter {
    to { opacity: 1; transform: translateY(0); }
}

/* ── TYPING INDICATOR ── */
.typing-bubble {
    display: flex;
    gap: 5px;
    padding: 0.85rem 1.2rem !important;
    align-items: center;
    justify-content: flex-start;
    background: var(--ai-bubble);
    border: 1px solid var(--border-color);
    border-left: 3px solid var(--primary-color);
    width: fit-content;
}

.typing-dot {
    width: 7px;
    height: 7px;
    background: var(--primary-color);
    border-radius: 50%;
    opacity: 0.4;
    animation: typing 1.4s infinite cubic-bezier(0.2, 0.8, 0.2, 1);
}
.typing-dot:nth-child(2) { animation-delay: 0.18s; }
.typing-dot:nth-child(3) { animation-delay: 0.36s; }

@keyframes typing {
    0%, 100% { transform: translateY(0);  opacity: 0.4; }
    50%       { transform: translateY(-5px); opacity: 1; }
}

/* ── INPUT FOOTER ── */
.chat-input-area {
    padding: 1rem 1.25rem 1.5rem;
    background: linear-gradient(to top, rgba(255,255,255,1) 75%, rgba(255,255,255,0));
    z-index: 10;
    border-top: 1px solid rgba(226,232,240,0.6);
}

/* ── BUTTONS ── */
.hidden { display: none !important; }
.w-full { width: 100%; }
.mt-2   { margin-top: 0.5rem; }

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 1rem 1.5rem;
    font-size: 1.05rem;
    font-weight: 700;
    border-radius: var(--radius-lg);
    border: none;
    cursor: pointer;
    transition: all var(--transition);
    text-decoration: none;
    letter-spacing: 0.01em;
    position: relative;
    overflow: hidden;
}

/* Shimmer sweep on hover */
.btn::after {
    content: '';
    position: absolute;
    top: -50%; left: -75%;
    width: 50%; height: 200%;
    background: rgba(255,255,255,0.15);
    transform: skewX(-20deg);
    transition: left 0.6s ease;
}
.btn:hover::after { left: 125%; }

/* START CTA: brand gradient + pulse glow */
.btn-primary {
    background: linear-gradient(135deg, var(--primary-color), color-mix(in srgb, var(--primary-color) 75%, #7c3aed));
    color: white;
    box-shadow: 0 6px 24px var(--primary-glow), 0 1px 0 rgba(255,255,255,0.15) inset;
}
.btn-primary:hover {
    transform: translateY(-3px);
    box-shadow: 0 12px 36px var(--primary-glow), 0 1px 0 rgba(255,255,255,0.15) inset;
}
.btn-primary:active { transform: scale(0.97); }

/* Pulsing ring animation for the Start button */
.btn-pulse {
    animation: buttonPulse 2.8s ease-in-out infinite;
}
@keyframes buttonPulse {
    0%, 100% { box-shadow: 0 6px 24px var(--primary-glow); }
    50%       { box-shadow: 0 6px 24px var(--primary-glow), 0 0 0 8px var(--primary-soft); }
}

/* WhatsApp CTA */
.btn-whatsapp {
    background: linear-gradient(135deg, #25D366, #128C7E);
    color: white;
    font-weight: 700;
    box-shadow: 0 6px 24px rgba(37, 211, 102, 0.3);
}
.btn-whatsapp:hover {
    transform: translateY(-3px);
    box-shadow: 0 12px 32px rgba(37, 211, 102, 0.4);
}

/* ── OPTION CHIPS (chat mode) ── */
#input-options {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.chip-btn {
    position: relative;
    background: var(--bg-surface);
    border: 1.5px solid var(--border-color);
    color: var(--text-main);
    padding: 0.9rem 1.2rem;
    border-radius: var(--radius-lg);
    font-size: 0.95rem;
    font-weight: 600;
    text-align: left;
    cursor: pointer;
    transition: all 0.22s cubic-bezier(0.16, 1, 0.3, 1);
    opacity: 0;
    transform: translateY(8px);
    animation: slideUpFade 0.3s forwards;
    overflow: hidden;
}

/* Staggered entrance */
.chip-btn:nth-child(1) { animation-delay: 0.00s; }
.chip-btn:nth-child(2) { animation-delay: 0.06s; }
.chip-btn:nth-child(3) { animation-delay: 0.12s; }
.chip-btn:nth-child(4) { animation-delay: 0.18s; }
.chip-btn:nth-child(5) { animation-delay: 0.24s; }

/* Brand color fill sweeps in from left on hover */
.chip-btn::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, var(--primary-color), color-mix(in srgb, var(--primary-color) 75%, #7c3aed));
    transform: scaleX(0);
    transform-origin: left;
    transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1);
    z-index: 0;
}
.chip-btn span, .chip-btn > * { position: relative; z-index: 1; }

.chip-btn:hover {
    border-color: var(--primary-color);
    color: white;
    transform: translateY(-2px);
    box-shadow: 0 8px 24px var(--primary-glow);
}
.chip-btn:hover::before { transform: scaleX(1); }

.chip-btn:active {
    transform: scale(0.97) !important;
}

/* Fix chip-btn text that's directly inside (not wrapped in span) */
.chip-btn:hover { color: white !important; }

/* ── LEAD FORM INPUTS ── */
.lead-input {
    width: 100%;
    padding: 1rem 1.2rem;
    border-radius: var(--radius-lg);
    background: #f8fafc;
    border: 1.5px solid var(--border-color);
    color: var(--text-main);
    font-size: 0.95rem;
    font-weight: 600;
    outline: none;
    transition: all 0.22s ease;
}
.lead-input:focus {
    border-color: var(--primary-color);
    background: white;
    box-shadow: 0 0 0 4px var(--primary-soft);
}
.lead-input::placeholder { color: #94a3b8; font-weight: 400; }

/* ── ANIMATIONS ── */
@keyframes slideUpFade {
    to { opacity: 1; transform: translateY(0); }
}

.animate-quiz-enter {
    animation: slideInUp 0.55s cubic-bezier(0.23, 1, 0.32, 1) forwards;
}

@keyframes slideInUp {
    from { opacity: 0; transform: translateY(28px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ======================================================
   QUIZ MODULE — Traditional Card Layout
   ====================================================== */

.mode-quiz .chat-header    { border-bottom: none; padding-bottom: 0; }
.mode-quiz .chat-input-area { display: none; }
.mode-quiz.quiz-active .chat-input-area { display: flex; }

.mode-quiz .chat-container,
.mode-quiz .chat-wrapper,
.mode-quiz { background: white !important; }

.mode-quiz .chat-header { background: transparent; }

#quiz-module-container {
    max-width: 600px;
    margin: 0 auto;
    width: 100%;
}

.mode-quiz .chat-container {
    padding: 2rem 2.5rem;
    overflow-x: hidden;
}

/* Quiz question title */
.quiz-question-title {
    font-size: 1.7rem;
    font-weight: 800;
    color: var(--text-main);
    line-height: 1.25;
    letter-spacing: -0.02em;
    margin-bottom: 1.75rem;
}

/* Premium quiz option cards */
.quiz-option-card {
    background: white;
    border: 2px solid #f1f5f9;
    padding: 1.15rem 1.6rem;
    border-radius: var(--radius-xl);
    cursor: pointer;
    transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-weight: 600;
    font-size: 0.95rem;
    color: var(--text-main);
    position: relative;
    overflow: hidden;
}

.quiz-option-card::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, var(--primary-soft), transparent);
    opacity: 0;
    transition: opacity 0.25s ease;
}

.quiz-option-card:hover {
    border-color: var(--primary-color);
    transform: translateY(-2px) scale(1.005);
    box-shadow: 0 12px 28px -8px var(--primary-glow);
}
.quiz-option-card:hover::before { opacity: 1; }

.quiz-option-card.selected {
    border-color: var(--primary-color);
    background: linear-gradient(135deg, var(--primary-soft), rgba(255,255,255,0.8));
    color: var(--primary-color);
    box-shadow: 0 0 0 3px var(--primary-soft), 0 8px 24px var(--primary-glow);
}
.quiz-option-card.selected::before { opacity: 1; }

/* Radio dot */
.quiz-option-dot {
    width: 18px;
    height: 18px;
    border: 2px solid #cbd5e1;
    border-radius: 50%;
    transition: all 0.22s ease;
    flex-shrink: 0;
    position: relative;
    z-index: 1;
}
.quiz-option-dot::after {
    content: '';
    position: absolute;
    inset: 3px;
    border-radius: 50%;
    background: var(--primary-color);
    transform: scale(0);
    transition: transform 0.22s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.quiz-option-card.selected .quiz-option-dot {
    border-color: var(--primary-color);
}
.quiz-option-card.selected .quiz-option-dot::after {
    transform: scale(1);
}

/* ── STRUCTURED QUESTION CARD ── */
.quiz-question-card {
    display: flex;
    flex-direction: column;
    gap: 0;
}

.quiz-q-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1.25rem;
    flex-wrap: wrap;
}

/* "Step X of Y" badge */
.quiz-step-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.7rem;
    font-weight: 900;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--primary-color);
    background: var(--primary-soft);
    border: 1.5px solid color-mix(in srgb, var(--primary-color) 25%, transparent);
    border-radius: var(--radius-full);
    padding: 0.35rem 0.9rem;
}

.quiz-step-badge::before {
    content: '';
    display: inline-block;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--primary-color);
    animation: pulse-green 1.8s infinite;
}

/* Options list with stagger */
.quiz-options-list {
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
}

/* Each option animates in with stagger via inline style */
.quiz-options-list .quiz-option-card {
    opacity: 0;
    animation: optionEnter 0.4s cubic-bezier(0.23, 1, 0.32, 1) forwards;
}

@keyframes optionEnter {
    from { opacity: 0; transform: translateX(-10px); }
    to   { opacity: 1; transform: translateX(0); }
}

/* Alphabetical badge before each option */
.quiz-opt-num {
    width: 28px;
    height: 28px;
    min-width: 28px;
    border-radius: 0.6rem;
    background: var(--primary-soft);
    color: var(--primary-color);
    font-size: 0.72rem;
    font-weight: 900;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-right: 0.85rem;
    transition: all 0.22s ease;
    position: relative;
    z-index: 1;
}

.quiz-option-card:hover .quiz-opt-num,
.quiz-option-card.selected .quiz-opt-num {
    background: white;
    color: var(--primary-color);
}

/* ── QUIZ PROGRESS BAR ── */
#quiz-track-header .h-1\.5 {
    height: 8px !important;
    border-radius: var(--radius-full);
}

/* Engagement nudge bar */
@keyframes nudgeEnter {
    0%   { opacity: 0; transform: translateY(-12px) scale(0.94); }
    65%  { opacity: 1; transform: translateY(2px) scale(1.02); }
    100% { transform: translateY(0) scale(1); }
}
@keyframes nudgeGlow {
    0%, 100% { box-shadow: 0 0 0 0 var(--primary-soft); }
    50%       { box-shadow: 0 0 0 6px var(--primary-soft); }
}

.quiz-nudge-bar {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    background: linear-gradient(135deg, var(--primary-soft), rgba(167,139,250,0.07));
    border: 1.5px solid color-mix(in srgb, var(--primary-color) 30%, transparent);
    border-radius: var(--radius-full);
    padding: 0.5rem 1rem;
    margin-bottom: 1.25rem;
    animation:
        nudgeEnter 0.5s cubic-bezier(0.23, 1, 0.32, 1) forwards,
        nudgeGlow 2s ease-in-out 0.5s infinite;
}
.quiz-nudge-icon { font-size: 1rem; line-height: 1; }
.quiz-nudge-text {
    font-size: 0.78rem;
    font-weight: 800;
    color: var(--primary-color);
    letter-spacing: 0.01em;
}

/* Quiz launchpad */
.quiz-launchpad {
    display: flex;
    flex-direction: column;
    min-height: calc(100vh - 120px);
    padding: 1rem 0 4rem;
}

/* ── OFFER CARD / LEAD FORM ── */
#input-lead-form,
#input-thankyou {
    width: 100%;
}

/* Brand gradient line at top of offer card */
.offer-card-accent {
    height: 4px;
    background: linear-gradient(90deg, var(--primary-color), color-mix(in srgb, var(--primary-color) 60%, #a78bfa));
    border-radius: var(--radius-full) var(--radius-full) 0 0;
    margin-bottom: 1.5rem;
}

/* ── MOBILE: safe-area + responsive tweaks ── */
@supports (padding-bottom: env(safe-area-inset-bottom)) {
    .chat-input-area {
        padding-bottom: calc(1.5rem + env(safe-area-inset-bottom));
    }
}

@media (max-width: 480px) {
    .chat-container { padding: 1.25rem 1rem; }
    .mode-quiz .chat-container { padding: 1.5rem 1.25rem; }
    .quiz-question-title { font-size: 1.4rem; }
    .msg-bubble { font-size: 0.93rem; }
}

/* ── ACCESSIBILITY ── */
.chip-btn:focus-visible,
.btn:focus-visible {
    outline: 3px solid var(--primary-color);
    outline-offset: 3px;
}

#btn-submit-lead:disabled {
    opacity: 0.65;
    cursor: not-allowed;
    transform: none !important;
    animation: none !important;
}

/* ── COMPACT FORM (legacy) ── */
.compact-form { display: flex; flex-direction: column; gap: 0.75rem; }
.compact-form input {
    width: 100%;
    padding: 1rem 1.2rem;
    border-radius: var(--radius-lg);
    background: #f8fafc;
    border: 1.5px solid var(--border-color);
    color: var(--text-main);
    font-size: 0.95rem;
    outline: none;
    transition: all 0.2s;
}
.compact-form input:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 4px var(--primary-soft);
    background: white;
}
.privacy-note {
    font-size: 0.72rem;
    text-align: center;
    color: var(--text-muted);
    margin-top: 0.5rem;
}
