/* Neural Vault Design System - traspasofacil.es */

:root {
    /* Tonal Foundation */
    --background: #0d112a;
    --surface-lowest: #080c25;
    --surface-low: #161a33;
    --surface-high: #242842;
    --surface-highest: #2f334e;
    
    /* Accent & Signal */
    --primary: #ffb874;
    --primary-container: #f7931a;
    --on-primary: #4b2800; /* Deep Brown for contrast */
    --secondary: #ffb3b0;
    
    /* Text */
    --on-surface: #dee0ff;
    --on-surface-variant: #dbc2ae;
    
    /* Spacing & Radii */
    --radius-xl: 0.75rem;
    --radius-full: 9999px;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    background-color: var(--background);
    color: var(--on-surface);
    font-family: 'Manrope', sans-serif;
    line-height: 1.6;
    min-height: 100vh;
}


.fixed-layout {
    height: 100vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

/* Custom Scrollbar Global */
::-webkit-scrollbar {
    width: 6px;
}
::-webkit-scrollbar-track {
    background: var(--background);
}
::-webkit-scrollbar-thumb {
    background: var(--surface-high);
    border-radius: 10px;
}
::-webkit-scrollbar-thumb:hover {
    background: var(--surface-highest);
}

/* Typography */
h1, h2, h3, .headline {
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 700;
}

.label {
    font-family: 'Inter', sans-serif;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* Technical Grid Background */
.technical-grid {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-image: radial-gradient(circle at 2px 2px, rgba(247, 147, 26, 0.05) 1px, transparent 0);
    background-size: 40px 40px;
    z-index: -1;
}

/* Glassmorphism */
.glass-panel {
    background: rgba(47, 51, 78, 0.6);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
}

/* Layout Core */
.app-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    height: 100dvh; /* Dynamic Viewport Height for mobile */
    width: 100%;
    position: relative;
    overflow: hidden;
}

header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem 3rem;
    background: rgba(13, 17, 42, 0.8);
    backdrop-filter: blur(10px);
    z-index: 30;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.logo-container {
    display: flex;
    flex-direction: column;
}

.logo-text {
    font-size: 1.5rem;
    color: var(--primary-container);
    text-transform: uppercase;
    letter-spacing: -0.02em;
}

.status-badge {
    background: rgba(255, 184, 116, 0.1);
    color: var(--primary);
    padding: 0.125rem 0.5rem;
    border-radius: var(--radius-full);
    border: 1px solid rgba(255, 184, 116, 0.2);
    font-weight: 800;
    font-size: 0.625rem;
    margin-left: 0.75rem;
}

@keyframes pulseRed {
    0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(255, 95, 86, 0.7); }
    70% { transform: scale(1); box-shadow: 0 0 0 10px rgba(255, 95, 86, 0); }
    100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(255, 95, 86, 0); }
}

.pulse-red {
    animation: pulseRed 2s infinite;
}

/* Chat Area */
.chat-window {
    flex: 1;
    overflow-y: auto;
    padding: 2.5rem 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 3.5rem; /* Increased from 2.5rem */
    scroll-behavior: smooth;
    max-width: 1000px;
    margin: 0 auto;
    width: 100%;
}

/* Custom Scrollbar removed from here as it's now global */

/* Messages */
.message {
    display: flex;
    gap: 1rem;
    max-width: 90%;
    animation: slideIn 0.5s ease-out;
}

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

.message.ai {
    align-self: flex-start;
}

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

.avatar {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-full);
    overflow: hidden;
    flex-shrink: 0;
    border: 1px solid rgba(255, 184, 116, 0.2);
}

.avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.message-bubble {
    padding: 1.5rem;
    border-radius: 1.25rem;
    font-size: 0.875rem;
    position: relative;
}

.ai .message-bubble {
    background: rgba(47, 51, 78, 0.6);
    backdrop-filter: blur(20px);
    border-top: 1px solid rgba(255, 184, 116, 0.15);
    border-radius: 0 1.25rem 1.25rem 1.25rem;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
}

.user .message-bubble {
    background: var(--surface-low);
    color: var(--on-surface-variant);
    border-radius: 1.25rem 0 1.25rem 1.25rem;
}

/* Input Area */
.input-container {
    padding: 2rem 3rem;
    width: 100%;
    max-width: 1000px;
    margin: 0 auto;
    position: relative;
    z-index: 50;
}

.input-bar {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.625rem 1.5rem;
    border-radius: var(--radius-full);
    background: rgba(47, 51, 78, 0.4);
    backdrop-filter: blur(20px);
    border-top: 1px solid rgba(255, 184, 116, 0.2);
    box-shadow: 0 -20px 50px rgba(13, 17, 42, 0.8);
    transition: all 0.3s ease;
}

.input-bar:focus-within {
    box-shadow: 0 0 20px rgba(247, 147, 26, 0.2), 0 -20px 50px rgba(13, 17, 42, 0.8);
    border-top: 1px solid rgba(255, 184, 116, 0.4);
    background: rgba(47, 51, 78, 0.5);
}


.input-bar input {
    flex: 1;
    background: transparent;
    border: none;
    outline: none;
    color: var(--on-surface);
    font-size: 1rem;
    padding: 0.75rem 0;
}

.input-bar input::placeholder {
    color: rgba(219, 194, 174, 0.4);
}

.action-btn {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-full);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.btn-send {
    background: var(--primary-container);
    color: var(--on-primary);
    box-shadow: 0 4px 15px rgba(247, 147, 26, 0.3);
}

.btn-send:hover {
    filter: brightness(1.1);
    transform: scale(1.05);
}

.btn-icon {
    background: transparent;
    color: var(--on-surface-variant);
}

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

/* Animations */
.glow-line {
    width: 100%;
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--primary), transparent);
    margin-top: 0.5rem;
    opacity: 0.5;
    animation: pulse 2s infinite ease-in-out;
}

@keyframes pulse {
    0%, 100% { opacity: 0.2; transform: scaleX(0.8); }
    50% { opacity: 0.6; transform: scaleX(1); }
}

/* Background Gradients */
.bg-blob {
    position: fixed;
    width: 50vw;
    height: 50vw;
    border-radius: var(--radius-full);
    filter: blur(120px);
    z-index: -2;
    opacity: 0.2;
    pointer-events: none;
}

.blob-1 {
    top: -10%;
    right: -10%;
    background: var(--primary);
}

.blob-2 {
    bottom: -10%;
    left: -10%;
    background: var(--surface-highest);
}

/* Markdown styling for chat */
.message-bubble h1, .message-bubble h2, .message-bubble h3 {
    margin-bottom: 0.5rem;
    color: var(--primary);
}

.message-bubble p {
    margin-bottom: 1rem;
}

.message-bubble p:last-child {
    margin-bottom: 0;
}

/* System Log */
.system-log {
    background: var(--surface-lowest);
    border: 1px solid rgba(85, 67, 53, 0.15);
    padding: 0.75rem;
    border-radius: 0.75rem;
    font-family: monospace;
    font-size: 0.625rem;
    color: rgba(255, 184, 116, 0.6);
    margin-bottom: 2rem;
}

/* ============================================================
   MOBILE OPTIMIZATIONS (Media Queries at the EOF)
   ============================================================ */
@media screen and (max-width: 768px) {
    body {
        height: 100dvh;
        overflow: hidden;
    }

    .app-container {
        height: 100dvh;
    }

    header {
        padding: 0.5rem 1rem;
        height: 60px;
        flex-shrink: 0;
    }

    .logo-text { 
        font-size: 0.9rem !important; 
        font-weight: 800;
    }

    .status-badge { 
        display: none !important; 
    }

    .logo-container .label { 
        display: none !important; 
    }

    .chat-window {
        padding: 1rem 0.75rem;
        gap: 2rem;
    }

    .system-log {
        font-size: 0.5rem;
        max-height: 60px; 
        margin-bottom: 0.5rem;
        padding: 0.4rem;
        flex-shrink: 0;
    }

    .message {
        max-width: 100%;
        gap: 0.5rem;
    }

    .avatar {
        width: 28px !important;
        height: 28px !important;
    }

    .message-bubble {
        padding: 0.75rem 1rem;
        font-size: 0.85rem;
    }

    .input-container {
        padding: 0.5rem 0.75rem 1.75rem; /* Safer bottom margin for iOS home bar */
        background: var(--background);
        border-top: 1px solid rgba(255, 255, 255, 0.05);
    }

    .input-bar {
        padding: 0.35rem 0.75rem;
        gap: 0.35rem;
        border-radius: 1.25rem;
    }

    .input-bar input {
        font-size: 0.9rem; 
        padding: 0.5rem 0;
    }

    .action-btn {
        width: 34px;
        height: 34px;
    }

    .action-btn .material-symbols-outlined {
        font-size: 1.1rem;
    }

    .glow-line {
        display: none;
    }
}
/* --- Typing Indicator --- */
.typing-indicator {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    font-size: 0.75rem;
    color: var(--primary);
    opacity: 0.7;
    font-family: 'Space Grotesk', sans-serif;
    margin-bottom: 2rem;
    animation: fadeIn 0.3s ease;
}

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

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

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

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(5px); }
    to { opacity: 0.7; transform: translateY(0); }
}

@keyframes fadeOut {
    from { opacity: 0.7; transform: translateY(0); }
    to { opacity: 0; transform: translateY(-5px); }
}

.fade-out {
    animation: fadeOut 0.3s forwards;
}
