/* ==========================================================================
   ESTILOS GENERALES Y VARIABLES (TEMÁTICA ROMÁNTICA ELEGANTE)
   ========================================================================== */
:root {
    --bg-main: #0c0b0e;
    --bg-card: #151419;
    --bg-card-secondary: #1f1d24;
    --primary-pink: #f7a8b8;
    --primary-pink-dark: #e58296;
    --primary-pink-glow: rgba(247, 168, 184, 0.35);
    --text-white: #ffffff;
    --text-muted: #a7a2ad;
    --text-pink-light: #ffdce3;
    --bubble-user: #e58296;
    --bubble-user-text: #ffffff;
    --bubble-ai: #1e1d23;
    --bubble-ai-text: #f0edf4;
    --border-subtle: rgba(247, 168, 184, 0.15);
    --font-heading: 'Caveat', cursive;
    --font-body: 'Outfit', sans-serif;
    --font-serif: 'Playfair Display', serif;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

body {
    background-color: var(--bg-main);
    color: var(--text-white);
    font-family: var(--font-body);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow-x: hidden;
    position: relative;
}

/* Partículas y destellos de fondo */
.stars-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    background: radial-gradient(ellipse at bottom, #2b1324 0%, #0c0b0e 70%);
    z-index: 0;
}

.floating-hearts-bg {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1;
    overflow: hidden;
}

.floating-heart {
    position: absolute;
    color: rgba(247, 168, 184, 0.25);
    user-select: none;
    animation: floatUp 8s linear infinite;
}

@keyframes floatUp {
    0% {
        transform: translateY(105vh) scale(0.6) rotate(0deg);
        opacity: 0;
    }
    20% { opacity: 0.6; }
    80% { opacity: 0.4; }
    100% {
        transform: translateY(-10vh) scale(1.1) rotate(25deg);
        opacity: 0;
    }
}

/* ==========================================================================
   MAQUETA MÓVIL (FRAME IPHONE / SMARTPHONE)
   ========================================================================== */
.phone-wrapper {
    position: relative;
    z-index: 10;
    padding: 15px;
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
    max-width: 440px;
    height: 100vh;
    max-height: 890px;
}

.phone-frame {
    width: 100%;
    height: 100%;
    background: #111015;
    border-radius: 46px;
    box-shadow: 0 25px 65px rgba(0, 0, 0, 0.85),
                0 0 0 4px #26242e,
                0 0 35px var(--primary-pink-glow);
    position: relative;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    border: 1px solid rgba(255, 255, 255, 0.08);
}

/* Dynamic Island */
.dynamic-island {
    position: absolute;
    top: 10px;
    left: 50%;
    transform: translateX(-50%);
    width: 110px;
    height: 26px;
    background: #000;
    border-radius: 20px;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    padding-right: 12px;
}

.island-camera {
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: #121927;
    border: 1px solid #1a233a;
}

/* Estructura común de las Pantallas */
.screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.6s cubic-bezier(0.4, 0, 0.2, 1), 
                transform 0.6s cubic-bezier(0.4, 0, 0.2, 1);
    transform: scale(0.96);
    pointer-events: none;
}

.screen.active {
    opacity: 1;
    visibility: visible;
    transform: scale(1);
    pointer-events: auto;
}

/* ==========================================================================
   PANTALLA 1: CARGA E INTRODUCCIÓN CON SOBRE ANIMADO
   ========================================================================== */
#screen-intro {
    background: linear-gradient(180deg, #1b0f19 0%, #110e14 55%, #180914 100%);
    justify-content: space-between;
    align-items: center;
    padding: 70px 25px 40px;
    text-align: center;
}

.intro-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    height: 100%;
}

.romantic-quote {
    font-family: var(--font-heading);
    font-size: 2.2rem;
    line-height: 1.25;
    color: var(--text-pink-light);
    text-shadow: 0 0 15px rgba(247, 168, 184, 0.4);
    margin-top: 15px;
    animation: fadeInDown 1.2s ease forwards;
}

.heart-symbol {
    color: var(--primary-pink);
    display: inline-block;
    animation: pulseHeart 1.8s infinite;
}

/* --- SOBRE DE CARTA 3D ELEGANTE --- */
.envelope-wrapper {
    position: relative;
    width: 220px;
    height: 150px;
    margin: 25px auto 15px;
    perspective: 1000px;
    cursor: pointer;
}

.envelope {
    position: relative;
    width: 100%;
    height: 100%;
    background: #1c1822;
    border-radius: 10px;
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.75), 0 0 25px var(--primary-pink-glow);
}

/* Solapa superior abatible (cierra el sobre) */
.envelope-flap-top {
    position: absolute;
    top: 0;
    left: 0;
    width: 0;
    height: 0;
    border-style: solid;
    border-width: 80px 110px 0 110px;
    border-color: #352b3d transparent transparent transparent;
    transform-origin: top center;
    transition: transform 0.8s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 5;
    border-top-left-radius: 10px;
    border-top-right-radius: 10px;
    filter: drop-shadow(0 3px 5px rgba(0, 0, 0, 0.3));
}

/* Sello de lacre con corazón */
.envelope-seal {
    position: absolute;
    top: 56px;
    left: 50%;
    transform: translateX(-50%);
    width: 36px;
    height: 36px;
    background: radial-gradient(circle, #f7a8b8 0%, #d15674 70%, #99314c 100%);
    border-radius: 50%;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.6), 0 0 10px rgba(247, 168, 184, 0.5);
    z-index: 6;
    transition: opacity 0.4s ease, transform 0.4s ease;
}

/* Bolsillo frontal inferior */
.envelope-pocket {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 0;
    height: 0;
    border-style: solid;
    border-width: 0 110px 85px 110px;
    border-color: transparent transparent #251e2c transparent;
    z-index: 4;
    border-bottom-left-radius: 10px;
    border-bottom-right-radius: 10px;
}

/* Carta interior: TOTALMENTE OCULTA cuando el sobre está cerrado */
.envelope-letter {
    position: absolute;
    top: 10px;
    left: 15px;
    width: 190px;
    height: 130px;
    background: #fffbf7;
    border-radius: 8px;
    padding: 14px 12px;
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.35);
    z-index: 2;
    text-align: center;
    color: #3b2c34;
    display: flex;
    flex-direction: column;
    justify-content: center;

    /* REGLA CRÍTICA: Totalmente invisible antes de abrirse */
    opacity: 0;
    visibility: hidden;
    transform: translateY(25px) scale(0.92);
    pointer-events: none;
    transition: transform 1s cubic-bezier(0.2, 0.8, 0.2, 1), 
                opacity 0.4s ease, 
                visibility 0.4s ease;
}

.letter-inner {
    opacity: 0;
    transform: translateY(8px);
    transition: opacity 0.4s ease, transform 0.4s ease;
}

.letter-inner h4 {
    font-family: var(--font-heading);
    font-size: 1.45rem;
    color: #d15674;
    margin-bottom: 5px;
}

.letter-inner p {
    font-size: 0.85rem;
    font-weight: 500;
    line-height: 1.25;
    color: #4a3c44;
}

.letter-heart {
    display: block;
    margin-top: 5px;
    font-size: 14px;
    color: #e58296;
}

/* ESTADO ABIERTO: El sobre se abre y la carta se revela */
.envelope-wrapper.open .envelope-flap-top {
    transform: rotateX(180deg);
    z-index: 1;
}

.envelope-wrapper.open .envelope-seal {
    opacity: 0;
    transform: translateX(-50%) scale(0.6);
    pointer-events: none;
}

.envelope-wrapper.open .envelope-letter {
    opacity: 1;
    visibility: visible;
    transform: translateY(-80px) scale(1.05);
    z-index: 7;
    pointer-events: auto;
    transition: transform 1.1s cubic-bezier(0.2, 0.8, 0.2, 1) 0.35s, 
                opacity 0.4s ease 0.35s, 
                visibility 0.4s ease 0.35s;
}

.envelope-wrapper.open .letter-inner {
    opacity: 1;
    transform: translateY(0);
    transition: opacity 0.5s ease 0.65s, transform 0.5s ease 0.65s;
}

/* Barra de Carga */
.loading-box {
    width: 85%;
    margin-bottom: 25px;
}

.progress-bar-container {
    width: 100%;
    height: 7px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    overflow: hidden;
    position: relative;
    border: 1px solid rgba(247, 168, 184, 0.2);
}

.progress-bar-fill {
    width: 0%;
    height: 100%;
    background: linear-gradient(90deg, #e58296, #ffb8c7);
    border-radius: 10px;
    box-shadow: 0 0 10px var(--primary-pink);
    transition: width 0.1s linear;
}

.loading-status {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-top: 8px;
    display: inline-block;
    letter-spacing: 0.5px;
}

/* Silueta inferior de ciudad/pareja */
.city-silhouettes {
    width: 100%;
    height: 85px;
    background-image: radial-gradient(circle at 50% 100%, rgba(229, 130, 150, 0.25) 0%, transparent 70%);
    pointer-events: none;
}

/* ==========================================================================
   PANTALLA 2: SEGURIDAD Y PREGUNTA SECRETA
   ========================================================================== */
#screen-security {
    background: linear-gradient(180deg, #16141a 0%, #0d0c0f 100%);
    justify-content: center;
    align-items: center;
    padding: 30px 24px;
}

.security-card {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
}

.lock-icon-container {
    position: relative;
    margin-bottom: 24px;
}

.lock-circle {
    width: 74px;
    height: 74px;
    border-radius: 50%;
    border: 1.5px solid var(--primary-pink);
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(247, 168, 184, 0.06);
    box-shadow: 0 0 25px var(--primary-pink-glow);
    position: relative;
    animation: floatGently 3s ease-in-out infinite;
}

.lock-svg {
    width: 32px;
    height: 32px;
    color: var(--primary-pink);
}

.heart-badge {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -20%);
    font-size: 13px;
    color: var(--primary-pink);
}

.security-title {
    font-family: var(--font-heading);
    font-size: 2.3rem;
    color: var(--text-white);
    margin-bottom: 8px;
    font-weight: 600;
}

.security-question {
    font-size: 0.95rem;
    color: var(--text-muted);
    margin-bottom: 30px;
    line-height: 1.4;
    padding: 0 10px;
}

.security-form {
    width: 100%;
}

.input-group {
    position: relative;
    width: 100%;
    display: flex;
    align-items: center;
    background: var(--bg-card-secondary);
    border: 1.5px solid var(--border-subtle);
    border-radius: 28px;
    padding: 4px 16px;
    transition: all 0.3s ease;
}

.input-group:focus-within {
    border-color: var(--primary-pink);
    box-shadow: 0 0 15px var(--primary-pink-glow);
}

.input-icon {
    color: var(--text-muted);
    display: flex;
    align-items: center;
    margin-right: 10px;
}

.input-group input {
    width: 100%;
    background: transparent;
    border: none;
    outline: none;
    color: #fff;
    font-size: 0.95rem;
    font-family: var(--font-body);
    padding: 12px 0;
}

.input-group input::placeholder {
    color: #6d6775;
}

.toggle-password-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    padding: 6px;
    transition: color 0.2s;
}

.toggle-password-btn:hover {
    color: var(--primary-pink);
}

.error-msg {
    color: #ff708a;
    font-size: 0.85rem;
    margin-top: 10px;
    min-height: 20px;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.error-msg.visible {
    opacity: 1;
}

/* Animación de temblor en caso de error */
.shake {
    animation: shakeAnim 0.5s ease;
}

@keyframes shakeAnim {
    0%, 100% { transform: translateX(0); }
    20%, 60% { transform: translateX(-8px); }
    40%, 80% { transform: translateX(8px); }
}

.btn-enter {
    width: 100%;
    background: linear-gradient(135deg, #e58296 0%, #f7a8b8 100%);
    color: #2b131e;
    font-weight: 600;
    font-size: 1.05rem;
    border: none;
    border-radius: 28px;
    padding: 14px 20px;
    margin-top: 20px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    box-shadow: 0 6px 20px var(--primary-pink-glow);
    transition: all 0.3s ease;
}

.btn-enter:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(247, 168, 184, 0.5);
}

.btn-enter:active {
    transform: translateY(0);
}

.security-footer {
    margin-top: 35px;
    font-family: var(--font-heading);
    font-size: 1.4rem;
    color: rgba(247, 168, 184, 0.7);
}

/* ==========================================================================
   PANTALLA 3: CHAT PERSONAL
   ========================================================================== */
#screen-chat {
    background: #111015;
    justify-content: space-between;
}

/* Cabecera del Chat */
.chat-header {
    height: 75px;
    padding-top: 22px;
    padding-left: 12px;
    padding-right: 14px;
    background: rgba(21, 20, 25, 0.95);
    backdrop-filter: blur(10px);
    display: flex;
    align-items: center;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    z-index: 20;
}

.back-btn, .action-btn {
    background: transparent;
    border: none;
    color: var(--text-white);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 6px;
    border-radius: 50%;
    transition: background 0.2s;
}

.back-btn:hover, .action-btn:hover {
    background: rgba(255, 255, 255, 0.1);
}

.avatar-container {
    position: relative;
    width: 42px;
    height: 42px;
    margin: 0 10px 0 6px;
}

.avatar-img {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
    border: 1.5px solid var(--primary-pink);
    background: #25222e;
}

.online-indicator {
    position: absolute;
    bottom: 1px;
    right: 1px;
    width: 10px;
    height: 10px;
    background: #25d366;
    border-radius: 50%;
    border: 2px solid #111015;
}

.contact-info {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.contact-name {
    font-size: 0.98rem;
    font-weight: 600;
    color: #fff;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.contact-status {
    font-size: 0.76rem;
    color: #25d366;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 4px;
}

/* Área de Mensajes */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px 14px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    scroll-behavior: smooth;
}

.chat-date-badge {
    text-align: center;
    margin: 6px 0 12px;
}

.chat-date-badge span {
    font-size: 0.72rem;
    font-weight: 500;
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-muted);
    padding: 3px 12px;
    border-radius: 12px;
    letter-spacing: 0.5px;
}

/* Burbujas de Chat */
.message-row {
    display: flex;
    width: 100%;
    animation: bubbleSlideIn 0.3s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.message-row.user {
    justify-content: flex-end;
}

.message-row.ai {
    justify-content: flex-start;
}

.message-bubble {
    max-width: 82%;
    padding: 10px 14px 7px;
    border-radius: 18px;
    position: relative;
    font-size: 0.92rem;
    line-height: 1.4;
    word-break: break-word;
}

.message-row.user .message-bubble {
    background: linear-gradient(135deg, var(--bubble-user) 0%, var(--primary-pink) 100%);
    color: var(--bubble-user-text);
    border-bottom-right-radius: 4px;
    box-shadow: 0 4px 15px rgba(229, 130, 150, 0.35);
}

.message-row.ai .message-bubble {
    background: var(--bubble-ai);
    color: var(--bubble-ai-text);
    border-bottom-left-radius: 4px;
    border: 1px solid rgba(255, 255, 255, 0.06);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.35);
}

.message-meta {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 4px;
    margin-top: 4px;
    font-size: 0.7rem;
    color: rgba(255, 255, 255, 0.75);
}

.message-row.ai .message-meta {
    color: var(--text-muted);
}

.checkmarks {
    color: #fff;
    font-size: 11px;
    font-weight: bold;
}

/* Indicador de escritura animado (tres puntos) */
.typing-bubble {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 12px 16px;
    background: var(--bubble-ai);
    border-radius: 18px;
    border-bottom-left-radius: 4px;
    width: fit-content;
}

.typing-dot {
    width: 6px;
    height: 6px;
    background: var(--primary-pink);
    border-radius: 50%;
    animation: typingBounce 1.4s infinite ease-in-out;
}

.typing-dot:nth-child(1) { animation-delay: 0s; }
.typing-dot:nth-child(2) { animation-delay: 0.2s; }
.typing-dot:nth-child(3) { animation-delay: 0.4s; }

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

/* Notificación de memoria guardada */
.memory-notification {
    background: rgba(247, 168, 184, 0.18);
    border: 1px solid var(--primary-pink);
    border-radius: 14px;
    padding: 6px 14px;
    margin: 4px 15px;
    text-align: center;
    font-size: 0.8rem;
    color: var(--text-pink-light);
    opacity: 0;
    transform: translateY(10px);
    transition: all 0.4s ease;
    pointer-events: none;
}

.memory-notification.show {
    opacity: 1;
    transform: translateY(0);
}

/* Barra inferior de entrada */
.chat-input-bar {
    padding: 10px 12px 14px;
    background: rgba(21, 20, 25, 0.95);
    backdrop-filter: blur(10px);
    display: flex;
    align-items: center;
    gap: 8px;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
}

.tool-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 1.15rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 6px;
    transition: color 0.2s;
}

.tool-btn:hover {
    color: var(--primary-pink);
}

.input-field-wrapper {
    flex: 1;
    background: var(--bg-card-secondary);
    border-radius: 22px;
    padding: 8px 14px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    display: flex;
    align-items: center;
}

.input-field-wrapper textarea {
    width: 100%;
    background: transparent;
    border: none;
    outline: none;
    color: #fff;
    font-family: var(--font-body);
    font-size: 0.92rem;
    resize: none;
    max-height: 90px;
    line-height: 1.35;
}

.input-field-wrapper textarea::placeholder {
    color: #6a6473;
}

.btn-send {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: linear-gradient(135deg, #e58296 0%, #f7a8b8 100%);
    border: none;
    color: #26101a;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 4px 15px var(--primary-pink-glow);
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.btn-send:hover {
    transform: scale(1.06);
}

.btn-send:active {
    transform: scale(0.96);
}

/* ==========================================================================
   ANIMACIONES
   ========================================================================== */
@keyframes fadeInDown {
    from { opacity: 0; transform: translateY(-20px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes pulseHeart {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.22); }
}

@keyframes floatGently {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-6px); }
}

@keyframes bubbleSlideIn {
    from { opacity: 0; transform: translateY(12px) scale(0.95); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

/* ==========================================================================
   RESPONSIVIDAD (MÓVIL PANTALLA COMPLETA)
   ========================================================================== */
@media (max-width: 480px) {
    body {
        background-color: #111015;
    }
    
    .phone-wrapper {
        padding: 0;
        max-width: 100%;
        height: 100vh;
        max-height: 100vh;
    }
    
    .phone-frame {
        border-radius: 0;
        border: none;
        box-shadow: none;
    }

    .dynamic-island {
        top: 6px;
        width: 95px;
        height: 22px;
    }

    #screen-intro {
        padding-top: 55px;
    }
}
