/* ==========================================================================
   ESTILOS GENERALES Y VARIABLES
   ========================================================================== */
:root {
    --bg-dark: #070913;
    --bg-card: rgba(18, 24, 43, 0.75);
    --bg-card-border: rgba(255, 255, 255, 0.12);
    
    --primary-gradient: linear-gradient(135deg, #6366f1 0%, #a855f7 50%, #ec4899 100%);
    --accent-blue: #00d2ff;
    --accent-purple: #7c3aed;
    --accent-glow: rgba(124, 58, 237, 0.35);

    --text-main: #ffffff;
    --text-muted: #94a3b8;
    --text-dim: #64748b;

    --bot-msg-bg: rgba(25, 33, 56, 0.85);
    --user-msg-bg: linear-gradient(135deg, #5b21b6 0%, #0284c7 100%);

    --font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    --radius-lg: 24px;
    --radius-md: 16px;
    --radius-sm: 10px;
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: var(--font-family);
    -webkit-tap-highlight-color: transparent;
}

body {
    background-color: #030509;
    background-image: 
        radial-gradient(at 0% 0%, rgba(99, 102, 241, 0.15) 0px, transparent 50%),
        radial-gradient(at 100% 100%, rgba(168, 85, 247, 0.15) 0px, transparent 50%);
    color: var(--text-main);
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    overflow: hidden;
}

/* ==========================================================================
   CONTENEDOR PRINCIPAL / VIEWPORT MOBILE MOCKUP
   ========================================================================== */
.app-viewport {
    width: 100%;
    max-width: 440px;
    height: 100vh;
    max-height: 900px;
    background: var(--bg-dark);
    position: relative;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.8), 
                0 0 40px rgba(99, 102, 241, 0.2);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

@media (min-width: 480px) {
    .app-viewport {
        height: 92vh;
        border-radius: 36px;
        border: 1px solid rgba(255, 255, 255, 0.1);
    }
}

/* Manejo de Pantallas (Screens) */
.screen {
    width: 100%;
    height: 100%;
    position: absolute;
    top: 0;
    left: 0;
    display: flex;
    flex-direction: column;
    opacity: 0;
    visibility: hidden;
    transform: scale(0.96);
    transition: opacity 0.4s ease, transform 0.4s ease, visibility 0.4s;
    z-index: 1;
}

.screen.active {
    opacity: 1;
    visibility: visible;
    transform: scale(1);
    z-index: 10;
}

.screen.hidden {
    display: none;
}

/* Fondo Resplandeciente Decorativo */
.glow-bg {
    position: absolute;
    width: 300px;
    height: 300px;
    background: radial-gradient(circle, rgba(124, 58, 237, 0.35) 0%, rgba(0, 210, 255, 0.15) 50%, transparent 70%);
    top: 15%;
    left: 50%;
    transform: translateX(-50%);
    filter: blur(50px);
    pointer-events: none;
    z-index: 0;
}

/* ==========================================================================
   PANTALLA 1: INICIO (INTRO)
   ========================================================================== */
#screen-intro {
    justify-content: space-between;
    align-items: center;
    padding: 40px 24px;
    text-align: center;
}

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

.intro-avatar-wrapper {
    position: relative;
    margin-top: 30px;
    width: 220px;
    height: 220px;
    display: flex;
    justify-content: center;
    align-items: center;
}

.avatar-glow {
    position: absolute;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(0, 212, 255, 0.4) 0%, rgba(124, 58, 237, 0.2) 60%, transparent 80%);
    filter: blur(20px);
    animation: pulseGlow 4s infinite alternate;
}

.intro-avatar-img {
    width: 190px;
    height: 190px;
    border-radius: 50%;
    object-fit: cover;
    position: relative;
    z-index: 2;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    border: 2px solid rgba(255, 255, 255, 0.2);
}

.intro-brand {
    margin: 20px 0;
}

.logo-badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: var(--accent-blue);
    font-size: 0.95rem;
    font-weight: 600;
    margin-bottom: 12px;
}

.intro-title {
    font-size: 1.75rem;
    font-weight: 700;
    color: #ffffff;
    letter-spacing: -0.5px;
    margin-bottom: 8px;
    text-shadow: 0 2px 10px rgba(0, 0, 0, 0.5);
}

.intro-subtitle {
    color: var(--text-muted);
    font-size: 0.95rem;
    font-weight: 400;
    max-width: 280px;
    margin: 0 auto;
}

.intro-footer {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 24px;
}

.pagination-dots {
    display: flex;
    gap: 8px;
}

.dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    transition: var(--transition);
}

.dot.active {
    width: 24px;
    border-radius: 12px;
    background: var(--accent-blue);
}

.btn-primary {
    width: 100%;
    max-width: 320px;
    padding: 16px;
    border: none;
    border-radius: 30px;
    background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
    color: #ffffff;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 8px 25px rgba(99, 102, 241, 0.4);
    transition: var(--transition);
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 30px rgba(99, 102, 241, 0.6);
}

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

/* ==========================================================================
   PANTALLA 2: ACCESO PRIVADO (SEGURIDAD)
   ========================================================================== */
#screen-security {
    justify-content: center;
    align-items: center;
    padding: 24px;
}

.security-card {
    position: relative;
    z-index: 2;
    width: 100%;
    background: var(--bg-card);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--bg-card-border);
    border-radius: var(--radius-lg);
    padding: 32px 24px 24px 24px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.6);
}

.shield-badge {
    width: 60px;
    height: 60px;
    margin: 0 auto 16px auto;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(0, 212, 255, 0.2) 0%, rgba(124, 58, 237, 0.3) 100%);
    border: 1px solid rgba(0, 212, 255, 0.4);
    display: flex;
    justify-content: center;
    align-items: center;
    color: var(--accent-blue);
    font-size: 1.5rem;
    box-shadow: 0 0 20px rgba(0, 212, 255, 0.3);
}

.security-header {
    text-align: center;
    margin-bottom: 24px;
}

.security-header h2 {
    font-size: 1.4rem;
    font-weight: 700;
    color: #ffffff;
    margin-bottom: 6px;
}

.security-header p {
    font-size: 0.88rem;
    color: var(--text-muted);
}

.input-group {
    margin-bottom: 18px;
    text-align: left;
}

.input-group label {
    display: block;
    font-size: 0.82rem;
    color: var(--text-muted);
    margin-bottom: 8px;
    font-weight: 500;
}

.input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.input-wrapper input {
    width: 100%;
    padding: 14px 16px;
    background: rgba(10, 14, 28, 0.8);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: var(--radius-md);
    color: #ffffff;
    font-size: 0.95rem;
    outline: none;
    transition: var(--transition);
}

.input-wrapper input:focus {
    border-color: var(--accent-blue);
    box-shadow: 0 0 12px rgba(0, 212, 255, 0.25);
}

.icon-btn-inline {
    position: absolute;
    right: 14px;
    background: none;
    border: none;
    color: var(--text-dim);
    cursor: pointer;
    font-size: 1rem;
    transition: var(--transition);
}

.icon-btn-inline:hover {
    color: #ffffff;
}

.security-question-box {
    background: rgba(0, 212, 255, 0.06);
    border: 1px solid rgba(0, 212, 255, 0.3);
    border-radius: var(--radius-md);
    padding: 12px 14px;
    color: #e0f2fe;
    font-size: 0.9rem;
    font-weight: 500;
}

.margin-top-sm {
    margin-top: 10px;
}

.error-box {
    background: rgba(239, 68, 68, 0.15);
    border: 1px solid rgba(239, 68, 68, 0.4);
    border-radius: var(--radius-sm);
    padding: 10px;
    color: #fca5a5;
    font-size: 0.82rem;
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 16px;
}

.verify-btn {
    margin-top: 8px;
    background: linear-gradient(135deg, #7c3aed 0%, #4f46e5 100%);
}

.security-footer {
    margin-top: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    color: var(--text-dim);
    font-size: 0.75rem;
}

/* ==========================================================================
   PANTALLA 3: CHAT PRINCIPAL Y GENERAL
   ========================================================================== */
#screen-chat {
    background: #070a14;
    display: flex;
    flex-direction: column;
}

/* Header del Chat */
.chat-header {
    height: 70px;
    padding: 12px 20px;
    background: rgba(13, 18, 35, 0.9);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    display: flex;
    align-items: center;
    justify-content: space-between;
    z-index: 5;
}

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

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

.header-avatar-img {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
    border: 1.5px solid rgba(255, 255, 255, 0.2);
}

.online-indicator {
    position: absolute;
    bottom: 0;
    right: 0;
    width: 11px;
    height: 11px;
    border-radius: 50%;
    background-color: #10b981;
    border: 2px solid #0d1223;
}

.header-info h3 {
    font-size: 1rem;
    font-weight: 600;
    color: #ffffff;
}

.status-text {
    font-size: 0.75rem;
    color: #10b981;
}

.header-icon-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.1rem;
    cursor: pointer;
    padding: 8px;
    transition: var(--transition);
}

.header-icon-btn:hover {
    color: #ffffff;
}

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

/* Personalización del Scrollbar */
.chat-messages::-webkit-scrollbar {
    width: 5px;
}
.chat-messages::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 10px;
}

/* Burbujas de Chat */
.msg-wrapper {
    display: flex;
    align-items: flex-end;
    gap: 10px;
    max-width: 88%;
    animation: fadeInMsg 0.3s ease;
}

.msg-wrapper.bot {
    align-self: flex-start;
}

.msg-wrapper.user {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.msg-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
}

.msg-bubble {
    padding: 14px 18px;
    border-radius: 20px;
    font-size: 0.93rem;
    line-height: 1.5;
    word-break: break-word;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
}

.msg-wrapper.bot .msg-bubble {
    background: var(--bot-msg-bg);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-bottom-left-radius: 4px;
    color: #e2e8f0;
}

.msg-wrapper.user .msg-bubble {
    background: var(--user-msg-bg);
    border-bottom-right-radius: 4px;
    color: #ffffff;
}

/* Formato de listas en bot responses */
.msg-bubble ul, .msg-bubble ol {
    margin-top: 8px;
    margin-bottom: 8px;
    padding-left: 20px;
}

.msg-bubble li {
    margin-bottom: 4px;
}

/* Typing Indicator */
.typing-container {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0 20px 12px 20px;
}

.bot-avatar-tiny img {
    width: 28px;
    height: 28px;
    border-radius: 50%;
}

.typing-bubble {
    background: var(--bot-msg-bg);
    border: 1px solid rgba(255, 255, 255, 0.08);
    padding: 10px 16px;
    border-radius: 18px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.typing-dots {
    display: flex;
    gap: 4px;
}

.typing-dots span {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--accent-blue);
    animation: typingPulse 1.4s infinite ease-in-out both;
}

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

.typing-text {
    font-size: 0.78rem;
    color: var(--text-dim);
    font-weight: 500;
}

/* Footer & Input Bar */
.chat-footer {
    padding: 12px 16px;
    background: rgba(10, 14, 28, 0.95);
    backdrop-filter: blur(12px);
    border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.suggestions-chips {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding-bottom: 10px;
    scrollbar-width: none;
}

.suggestions-chips::-webkit-scrollbar {
    display: none;
}

.chip-btn {
    background: rgba(30, 41, 69, 0.7);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 20px;
    padding: 6px 14px;
    color: #cbd5e1;
    font-size: 0.82rem;
    white-space: nowrap;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    gap: 6px;
}

.chip-btn:hover {
    background: rgba(124, 58, 237, 0.3);
    border-color: var(--accent-purple);
    color: #ffffff;
}

.chat-input-bar {
    display: flex;
    align-items: center;
    gap: 10px;
    background: rgba(21, 28, 50, 0.8);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 30px;
    padding: 6px 10px 6px 16px;
    transition: var(--transition);
}

.chat-input-bar:focus-within {
    border-color: var(--accent-purple);
    box-shadow: 0 0 15px rgba(124, 58, 237, 0.3);
}

.input-action-btn {
    background: none;
    border: none;
    color: var(--text-dim);
    font-size: 1.1rem;
    cursor: pointer;
    padding: 6px;
    transition: var(--transition);
}

.input-action-btn:hover {
    color: var(--accent-blue);
}

#chat-input {
    flex: 1;
    background: none;
    border: none;
    color: #ffffff;
    font-size: 0.93rem;
    outline: none;
    resize: none;
    max-height: 80px;
}

#chat-input::placeholder {
    color: var(--text-dim);
}

.btn-send {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    border: none;
    background: linear-gradient(135deg, #7c3aed 0%, #3b82f6 100%);
    color: #ffffff;
    font-size: 0.95rem;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    box-shadow: 0 4px 12px rgba(124, 58, 237, 0.4);
    transition: var(--transition);
    flex-shrink: 0;
}

.btn-send:hover {
    transform: scale(1.06);
    box-shadow: 0 6px 16px rgba(124, 58, 237, 0.6);
}

/* ANIMACIONES */
@keyframes pulseGlow {
    0% { transform: scale(0.95); opacity: 0.6; }
    100% { transform: scale(1.1); opacity: 1; }
}

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

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