:root {
    --primary: #6366f1;
    --primary-glow: rgba(99, 102, 241, 0.4);
    --bg: #0f172a;
    --surface: #1e293b;
    --text: #f8fafc;
    --text-dim: #94a3b8;
    --accent: #10b981;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Outfit', sans-serif;
    background-color: var(--bg);
    color: var(--text);
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow-x: hidden;
}

.app-container {
    width: 100%;
    max-width: 500px;
    height: 90vh;
    background: var(--surface);
    border-radius: 24px;
    display: flex;
    flex-direction: column;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    border: 1px solid rgba(255, 255, 255, 0.1);
    position: relative;
    margin: 20px;
}

header {
    padding: 24px;
    text-align: center;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

header h1 {
    font-size: 1.5rem;
    font-weight: 600;
    background: linear-gradient(135deg, #fff 0%, #94a3b8 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

header p {
    font-size: 0.875rem;
    color: var(--text-dim);
}

.chat-window {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    scrollbar-width: thin;
    scrollbar-color: var(--primary) transparent;
}

.message {
    max-width: 85%;
    padding: 12px 16px;
    border-radius: 16px;
    line-height: 1.5;
    font-size: 0.95rem;
    animation: fadeIn 0.3s ease-out;
}

.message.user {
    align-self: flex-end;
    background: var(--primary);
    color: white;
    border-bottom-right-radius: 4px;
}

.chat-link {
    color: #fcd34d;
    /* Dorado/Amarillo para que resalte */
    text-decoration: underline;
    font-weight: 600;
}

.message.ai {
    align-self: flex-start;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-bottom-left-radius: 4px;
}

.message.system {
    align-self: center;
    background: transparent;
    color: var(--text-dim);
    font-size: 0.8rem;
    text-align: center;
}

.controls {
    padding: 24px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    background: rgba(15, 23, 42, 0.8);
    backdrop-filter: blur(10px);
    border-bottom-left-radius: 24px;
    border-bottom-right-radius: 24px;
}

.mic-button {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: var(--primary);
    border: none;
    color: white;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    box-shadow: 0 0 20px var(--primary-glow);
}

.mic-button:hover {
    transform: scale(1.1);
}

.mic-button.listening {
    background: #ef4444;
    animation: pulse 1.5s infinite;
    box-shadow: 0 0 30px rgba(239, 68, 68, 0.6);
}

.mic-button svg {
    width: 28px;
    height: 28px;
}

.status-indicator {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-dim);
}

.input-fallback {
    width: 100%;
    display: flex;
    gap: 8px;
}

.input-fallback input {
    flex: 1;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    padding: 10px 16px;
    color: white;
    outline: none;
}

.input-fallback button {
    background: transparent;
    border: 1px solid var(--primary);
    color: var(--primary);
    padding: 8px 16px;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s;
}

.input-fallback button:hover {
    background: var(--primary);
    color: white;
}

/* Modal Styling */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(5px);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 100;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: var(--surface);
    padding: 32px;
    border-radius: 24px;
    width: 90%;
    max-width: 400px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    text-align: center;
}

.modal-content input {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: white;
    padding: 12px;
    border-radius: 12px;
    outline: none;
}

.modal-content button {
    background: var(--primary);
    color: white;
    border: none;
    padding: 12px;
    border-radius: 12px;
    font-weight: 600;
    cursor: pointer;
}

.note {
    font-size: 0.7rem;
    color: var(--text-dim);
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes pulse {
    0% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.1);
    }

    100% {
        transform: scale(1);
    }
}

/* Mobile adjustments */
@media (max-width: 600px) {
    body {
        align-items: flex-start;
        /* Permitir scroll si es necesario (ej: teclado abierto) */
        overflow-y: auto; 
    }

    .app-container {
        /* Usar d極h para mejor soporte en móviles */
        height: 100vh;
        height: 100dvh;
        max-height: 100dvh;
        margin: 0;
        border-radius: 0;
        display: flex;
        flex-direction: column;
    }

    header {
        padding: 12px;
        flex-shrink: 0;
    }

    header h1 {
        font-size: 1.2rem;
    }

    .chat-window {
        flex: 1;
        overflow-y: auto;
        padding: 15px;
    }

    .controls {
        border-radius: 0;
        /* Padding inferior extra para evitar superposición con barras del sistema */
        padding: 16px 16px 24px 16px; 
        background: var(--surface);
        box-shadow: 0 -10px 20px rgba(0, 0, 0, 0.3);
        flex-shrink: 0;
    }
}