@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600&display=swap');

:root {
    --bg-color: #0b051a;
    --primary-color: #7b2cbf;
    --secondary-color: #3c096c;
    --text-color: #ffffff;
    --text-muted: #a99bb8;
    --card-bg: #1a0f2e;
    --user-msg-bg: #7b2cbf;
    --bot-msg-bg: #1a0f2e;
}

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

body {
    background-color: var(--bg-color);
    color: var(--text-color);
    height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
    /* Fondo con ondas/gradiente suave */
    background: radial-gradient(circle at center, #240b36 0%, #0b051a 100%);
}

.screen {
    width: 100%;
    max-width: 400px;
    height: 100vh;
    max-height: 800px;
    position: relative;
    display: flex;
    flex-direction: column;
    transition: opacity 0.5s ease-in-out;
}

.screen.hidden {
    display: none;
    opacity: 0;
}

.screen.active {
    display: flex;
    opacity: 1;
}

/* --- PANTALLA 1: Animación de Carta --- */
#screen-1 {
    justify-content: center;
    align-items: center;
}

.envelope-container {
    width: 150px;
    height: 100px;
    position: relative;
    cursor: pointer;
}

.envelope {
    width: 100%;
    height: 100%;
    background-color: var(--primary-color);
    border-radius: 5px;
    position: relative;
    box-shadow: 0 0 20px rgba(123, 44, 191, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
}

.envelope-flap {
    position: absolute;
    top: 0;
    left: 0;
    width: 0;
    height: 0;
    border-left: 75px solid transparent;
    border-right: 75px solid transparent;
    border-top: 50px solid var(--secondary-color);
    transform-origin: top;
    transition: transform 1s ease;
    z-index: 3;
}

.envelope.open .envelope-flap {
    transform: rotateX(180deg);
    z-index: 1;
}

.envelope-body {
    position: absolute;
    width: 100%;
    height: 100%;
    background: var(--primary-color);
    z-index: 2;
    border-radius: 5px;
    clip-path: polygon(0 0, 50% 50%, 100% 0, 100% 100%, 0 100%);
}

.envelope-letter {
    position: absolute;
    bottom: 0;
    width: 90%;
    height: 80%;
    background: white;
    color: var(--bg-color);
    left: 5%;
    border-radius: 5px;
    display: flex;
    justify-content: center;
    align-items: center;
    text-align: center;
    padding: 10px;
    z-index: 1;
    transition: transform 1s ease, bottom 1s ease;
}

.envelope-letter p {
    font-size: 14px;
    font-weight: 600;
    margin: 0;
}

.envelope.open .envelope-letter {
    transform: translateY(-80px);
    z-index: 4;
}

/* --- PANTALLA 2: Validación --- */
#screen-2 {
    justify-content: center;
    align-items: center;
    padding: 20px;
    text-align: center;
}

.validation-container {
    width: 100%;
}

.star-icon {
    font-size: 30px;
    color: #b57df3;
    margin-bottom: 20px;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.2); }
    100% { transform: scale(1); }
}

#screen-2 h1 {
    font-size: 24px;
    font-weight: 600;
    margin-bottom: 30px;
}

.input-wrapper {
    position: relative;
    width: 100%;
    max-width: 300px;
    margin: 0 auto;
}

.input-wrapper input {
    width: 100%;
    padding: 15px 50px 15px 20px;
    border-radius: 25px;
    border: 1px solid rgba(255,255,255,0.1);
    background-color: var(--card-bg);
    color: white;
    font-size: 16px;
    outline: none;
    transition: border 0.3s;
}

.input-wrapper input:focus {
    border-color: var(--primary-color);
}

.input-wrapper button {
    position: absolute;
    right: 5px;
    top: 5px;
    bottom: 5px;
    width: 40px;
    border-radius: 50%;
    border: none;
    background-color: transparent;
    color: var(--primary-color);
    font-size: 18px;
    cursor: pointer;
    transition: color 0.3s;
}

.input-wrapper button:hover {
    color: #9d4edd;
}

.error-msg {
    color: #ff4d4d;
    font-size: 14px;
    margin-top: 10px;
}

.error-msg.hidden {
    display: none;
}

/* --- PANTALLA 3: Chat IA --- */
.chat-container {
    display: flex;
    flex-direction: column;
    height: 100%;
    background-color: var(--bg-color);
}

.chat-header {
    display: flex;
    align-items: center;
    padding: 20px;
    background-color: var(--card-bg);
    border-bottom-left-radius: 20px;
    border-bottom-right-radius: 20px;
}

.chat-avatar {
    width: 45px;
    height: 45px;
    border-radius: 50%;
    background: linear-gradient(135deg, #9d4edd, #5a189a);
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 20px;
    margin-right: 15px;
}

.chat-info {
    flex-grow: 1;
}

.chat-info h2 {
    font-size: 16px;
    font-weight: 600;
}

.status {
    font-size: 12px;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    margin-top: 3px;
}

.dot {
    width: 8px;
    height: 8px;
    background-color: #00e676;
    border-radius: 50%;
    display: inline-block;
    margin-right: 5px;
}

.chat-options {
    color: var(--text-muted);
    cursor: pointer;
    padding: 10px;
}

.chat-messages {
    flex-grow: 1;
    padding: 20px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.message {
    max-width: 80%;
    padding: 12px 16px;
    border-radius: 18px;
    font-size: 14px;
    line-height: 1.4;
    word-wrap: break-word;
    position: relative;
}

.message.bot {
    align-self: flex-start;
    background-color: var(--bot-msg-bg);
    border-bottom-left-radius: 5px;
}

.message.user {
    align-self: flex-end;
    background-color: var(--user-msg-bg);
    border-bottom-right-radius: 5px;
}

.message .time {
    font-size: 10px;
    color: rgba(255,255,255,0.5);
    display: block;
    text-align: right;
    margin-top: 5px;
}

.chat-input-area {
    padding: 15px 20px;
    display: flex;
    align-items: center;
    gap: 10px;
    background-color: transparent;
}

.add-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: none;
    background-color: var(--card-bg);
    color: white;
    font-size: 16px;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
}

.input-box {
    flex-grow: 1;
    position: relative;
    display: flex;
    align-items: center;
}

.input-box input {
    width: 100%;
    padding: 12px 45px 12px 20px;
    border-radius: 20px;
    border: none;
    background-color: var(--card-bg);
    color: white;
    font-size: 14px;
    outline: none;
}

.input-box button {
    position: absolute;
    right: 5px;
    width: 35px;
    height: 35px;
    border-radius: 50%;
    border: none;
    background-color: var(--primary-color);
    color: white;
    font-size: 14px;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: background-color 0.3s;
}

.input-box button:hover {
    background-color: #9d4edd;
}

/* Loading indicator for bot */
.typing-indicator {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 10px 15px;
    background-color: var(--bot-msg-bg);
    border-radius: 18px;
    align-self: flex-start;
    border-bottom-left-radius: 5px;
    width: fit-content;
}

.typing-indicator span {
    width: 6px;
    height: 6px;
    background-color: var(--text-muted);
    border-radius: 50%;
    animation: typing 1.4s infinite ease-in-out both;
}

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

@keyframes typing {
    0%, 80%, 100% { transform: scale(0); }
    40% { transform: scale(1); }
}
