/* ==========================================================================
   Variables y Tokens
   ========================================================================== */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;600;800&display=swap');

:root {
    /* Neutrales */
    --bg-0: #0f0f10;
    /* fondo oscuro principal */
    --bg-1: #0b0b0c;
    /* fondo secundario */
    --surface: rgba(255, 255, 255, 0.03);
    /* glass card */
    --fg: #f5f5f5;
    /* texto principal */
    --muted: #9aa0a6;
    /* texto secundario */

    /* Acentos vivos (neon/metálico) */
    --accent-cyan: #00f0ff;
    /* cian eléctrico */
    --accent-magenta: #ff4db8;
    /* magenta vibrante */
    --accent-gold: #ffd166;
    /* dorado metálico */

    /* Estados */
    --success: #6EE7B7;
    --warning: #FFC857;
    --danger: #FF5C5C;

    /* Espaciamiento y tipografía */
    --space-xs: 4px;
    --space-sm: 8px;
    --space-md: 16px;
    --space-lg: 24px;
    --space-xl: 40px;
    --radius: 12px;
    --glass-blur: 8px;

    /* Tipografía */
    --font-sans: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    --type-scale-base: 16px;
}

/* ==========================================================================
   Base
   ========================================================================== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    /* Transición global para theme change */
    transition: background-color .45s ease, color .35s ease, border-color .35s ease, box-shadow .35s ease;
}

html,
body {
    height: 100%;
    background-color: #0f0f10;
    /* Force dark background */
}

body {
    background: linear-gradient(180deg, #0f0f10 0%, #0b0b0c 100%) fixed;
    color: var(--fg);
    font-family: var(--font-sans);
    font-size: var(--type-scale-base);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
}

h1,
h2,
h3 {
    font-weight: 800;
    line-height: 1.2;
}

p {
    line-height: 1.6;
}

.text-muted {
    color: var(--muted);
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* ==========================================================================
   Animaciones
   ========================================================================== */
@keyframes colorBloom {
    0% {
        opacity: 0;
        transform: scale(.98);
    }

    60% {
        opacity: .8;
        transform: scale(1.02);
    }

    100% {
        opacity: 1;
        transform: scale(1);
    }
}

@keyframes slideUpFade {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

/* Reducción de movimiento */
@media (prefers-reduced-motion: reduce) {
    * {
        transition: none !important;
        animation: none !important;
    }
}

/* ==========================================================================
   Accesibilidad (Focus)
   ========================================================================== */
*:focus-visible {
    outline: 3px solid rgba(0, 240, 255, 0.18);
    outline-offset: 3px;
    box-shadow: 0 0 0 4px rgba(0, 240, 255, 0.06);
}

/* ==========================================================================
   Componentes BEM
   ========================================================================== */

/* Secciones generales */
.app-container {
    width: 100%;
    max-width: 800px;
    margin: 0 auto;
    padding: var(--space-md);
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    background: transparent;
}

.section {
    display: none;
    opacity: 0;
    transform: translateY(20px);
    background: transparent;
}

.section.state--active {
    display: flex;
    flex-direction: column;
    animation: slideUpFade 0.5s ease forwards;
}

/* 1. Hero / Landing */
.hero {
    position: relative;
    padding: var(--space-xl) var(--space-md);
    border-radius: calc(var(--radius) * 1.2);
    overflow: hidden;
    text-align: center;
}

.hero::after {
    content: '';
    position: absolute;
    inset: 0;
    background: radial-gradient(circle at 20% 30%, rgba(0, 240, 255, 0.08), transparent 20%),
        radial-gradient(circle at 80% 70%, rgba(255, 77, 184, 0.06), transparent 18%);
    opacity: 0;
    pointer-events: none;
    transition: opacity .8s ease;
}

.theme--accented .hero::after {
    opacity: 1;
    filter: blur(20px);
}

.theme--accented .hero {
    animation: colorBloom .9s cubic-bezier(.2, .9, .3, 1) both;
}

.hero__title {
    font-size: clamp(2.2rem, 8vw, 3.5rem);
    letter-spacing: -0.02em;
    margin-bottom: var(--space-md);
    position: relative;
    z-index: 1;
}

.hero__subtitle {
    font-size: 1.125rem;
    color: var(--muted);
    max-width: 600px;
    margin: 0 auto var(--space-xl) auto;
    position: relative;
    z-index: 1;
}

.cta-group {
    display: flex;
    gap: var(--space-md);
    justify-content: center;
    flex-wrap: wrap;
    position: relative;
    z-index: 1;
}

/* 2. Cards & Glass Panels */
.card {
    background: rgba(255, 255, 255, 0.05);
    /* Increased contrast for mono theme */
    border-radius: var(--radius);
    padding: var(--space-lg);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(var(--glass-blur));
    -webkit-backdrop-filter: blur(var(--glass-blur));
    border: 1px solid rgba(255, 255, 255, 0.08);
}

.theme--accented .card {
    background: var(--surface);
    /* Original glass for accented theme */
    border-color: rgba(255, 255, 255, 0.04);
    animation: colorBloom .9s cubic-bezier(.2, .9, .3, 1) both;
}

.card--accent {
    position: relative;
}

.card--accent::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--accent-cyan), var(--accent-magenta));
    border-top-left-radius: var(--radius);
    border-top-right-radius: var(--radius);
}

/* 3. CTAs (Botones) */
.cta {
    display: inline-block;
    font-family: var(--font-sans);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    text-align: center;
    border: none;
    position: relative;
    z-index: 1;
}

.cta--primary {
    background: linear-gradient(90deg, var(--accent-cyan), var(--accent-magenta));
    color: #071017;
    padding: .9rem 2rem;
    border-radius: 999px;
    box-shadow: 0 8px 30px rgba(0, 240, 255, 0.12);
    transform: translateZ(0);
    transition: transform .18s cubic-bezier(.2, .9, .3, 1), box-shadow .18s;
}

.cta--primary:hover {
    box-shadow: 0 12px 40px rgba(0, 240, 255, 0.25);
    transform: translateY(-1px);
}

.cta--primary:active {
    transform: translateY(1px) scale(.98);
}

.cta--ghost {
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 999px;
    padding: .8rem 1.6rem;
    color: var(--fg);
    transition: background .18s;
}

.cta--ghost:hover {
    background: rgba(255, 255, 255, 0.05);
}

/* 4. Onboarding Form (Cuestionario) */
.onboard-form {
    max-width: 600px;
    margin: 0 auto;
    width: 100%;
}

.onboard-form__progress {
    width: 100%;
    height: 4px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 2px;
    margin-bottom: var(--space-xl);
    overflow: hidden;
}

.onboard-form__fill {
    height: 100%;
    background: linear-gradient(90deg, var(--muted), #fff);
    width: 0%;
    transition: width 0.3s ease;
    border-radius: 2px;
}

.question-card {
    display: flex;
    flex-direction: column;
}

.question-card__title {
    font-size: clamp(1.3rem, 5vw, 1.8rem);
    margin-bottom: var(--space-xl);
}

.radio--pill {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    padding: 1.1rem 1.4rem;
    cursor: pointer;
    transition: all .2s ease;
    color: var(--fg);
    font-size: 1.05rem;
    text-align: left;
    font-family: var(--font-sans);
    margin-bottom: var(--space-sm);
}

.radio--pill:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.2);
    transform: translateX(4px);
}

/* Active state triggered briefly before moving to next question */
.radio--pill.is-active {
    background: linear-gradient(90deg, rgba(0, 240, 240, 0.2), rgba(255, 77, 184, 0.15));
    border-color: var(--accent-cyan);
}


/* 5. Profile Result */
.profile-result {
    display: grid;
    grid-template-columns: 1fr;
    gap: var(--space-lg);
    align-items: center;
    text-align: center;
}

.profile-result__title {
    font-size: 2.5rem;
    background: linear-gradient(90deg, var(--accent-cyan), var(--accent-magenta));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: var(--space-sm);
}

.profile-result__desc {
    margin-bottom: var(--space-lg);
}

.colorbar {
    height: 12px;
    border-radius: 8px;
    background: linear-gradient(90deg, var(--accent-cyan), var(--accent-magenta), var(--accent-gold));
    box-shadow: inset 0 -4px 12px rgba(0, 0, 0, 0.6);
    margin-top: var(--space-md);
    margin-bottom: var(--space-xl);
}

/* 6. Chat (Coach IA) - WhatsApp-like Redesign */
#chat.state--active {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100svh;
    height: 100dvh;
    z-index: 1000;
    background-color: var(--bg-0);
    padding: 0;
    margin: 0;
    display: flex;
    animation: slideInUp 0.5s cubic-bezier(0.4, 0, 0.2, 1) forwards !important;
}

@keyframes slideInUp {
    from {
        transform: translateY(100%);
        opacity: 0;
    }

    to {
        transform: translateY(0);
        opacity: 1;
    }
}

#chat .chat {
    width: 100%;
    height: 100%;
    max-width: none;
    border-radius: 0;
    display: flex;
    flex-direction: column;
    background: var(--bg-0);
    border: none;
    box-shadow: none;
    padding: 0 !important;
}

.chat__header {
    height: 70px;
    padding: 0 var(--space-lg);
    background: rgba(20, 20, 22, 0.95);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
}

.chat__title {
    font-size: 1.2rem;
    font-weight: 700;
    background: linear-gradient(90deg, var(--accent-cyan), #fff);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.chat__messages {
    flex: 1;
    overflow-y: auto;
    padding: var(--space-lg) var(--space-md);
    background: radial-gradient(circle at top right, rgba(0, 240, 255, 0.03), transparent 40%),
        radial-gradient(circle at bottom left, rgba(255, 77, 184, 0.03), transparent 40%);
    display: flex;
    flex-direction: column;
    gap: 1.2rem;
}

.msg {
    max-width: 90%;
    padding: 0.85rem 1.15rem;
    font-size: 1rem;
    line-height: 1.4;
    position: relative;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    word-wrap: break-word;
    white-space: pre-wrap;
    /* Preserve intended spacing but wrap long lines */
}

.msg--user {
    align-self: flex-end;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.12), rgba(255, 255, 255, 0.08));
    color: var(--fg);
    border-radius: 18px 18px 4px 18px;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.msg--agent {
    align-self: flex-start;
    background: linear-gradient(135deg, rgba(0, 240, 255, 0.1), rgba(255, 77, 184, 0.05));
    color: #fff;
    border-radius: 18px 18px 18px 4px;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

/* Options within AI messages */
.msg__options {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    margin-top: 1rem;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    padding-top: 0.8rem;
}

.option-pill {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(0, 240, 255, 0.3);
    border-radius: 12px;
    padding: 0.7rem 1rem;
    color: var(--accent-cyan);
    font-size: 0.9rem;
    cursor: pointer;
    text-align: left;
    transition: all 0.2s ease;
    font-family: var(--font-sans);
    line-height: 1.3;
}

.option-pill:hover {
    background: rgba(0, 240, 255, 0.1);
    border-color: var(--accent-cyan);
    transform: translateX(3px);
}

.msg__options.is-disabled {
    pointer-events: none;
    opacity: 0.6;
}

.msg__options.is-disabled .option-pill {
    border-color: rgba(255, 255, 255, 0.1);
    color: var(--muted);
}

.chat__input-area {
    padding: var(--space-md) var(--space-lg);
    background: rgba(15, 15, 17, 0.98);
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    flex-shrink: 0;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    /* Safe area + robust buffer for browser toolbars */
    padding-bottom: calc(var(--space-lg) + env(safe-area-inset-bottom, 16px));
}

.chat__input {
    flex: 1;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 24px;
    padding: 0.8rem 1.4rem;
    color: #fff;
    font-size: 1rem;
    transition: all 0.2s ease;
}

.chat__input:focus {
    outline: none;
    border-color: var(--accent-cyan);
    background: rgba(255, 255, 255, 0.1);
}

#btn-send-message {
    height: 48px;
    border-radius: 24px;
    padding: 0 1.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    background: linear-gradient(90deg, var(--accent-cyan), var(--accent-magenta));
    color: #000;
    border: none;
    font-weight: 800;
    font-size: 0.95rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    cursor: pointer;
}

#btn-close-chat {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: var(--muted);
    transition: all 0.2s ease;
}

#btn-close-chat:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
    transform: scale(1.05);
}

/* ==========================================================================
   Media Queries
   ========================================================================== */
@media (min-width: 768px) {
    #chat.state--active {
        position: static;
        width: 100%;
        height: auto;
        display: flex;
        animation: slideUpFade 0.5s ease forwards;
    }

    #chat .chat {
        height: 80vh;
        max-width: 720px;
        margin: 2rem auto;
        border-radius: 20px;
        border: 1px solid rgba(255, 255, 255, 0.1);
        box-shadow: 0 20px 50px rgba(0, 0, 0, 0.6);
        overflow: hidden;
    }

    .msg {
        max-width: 70%;
    }
}

/* Force background color for mobile */
html,
body {
    background: #0f0f10 !important;
    background-color: #0f0f10 !important;
}