/* CSS Reset and Variables */
:root {
    --bg-main: #0B0F19; /* Deep Dark Blue */
    --bg-sidebar: #111827; /* Dark Grey Blue */
    --bg-chat: #182235; /* Dark Glass Slate */
    --border-color: rgba(255, 255, 255, 0.08);
    --border-glow: rgba(20, 184, 166, 0.2);
    
    --primary: #14b8a6; /* Vibrant Teal */
    --primary-hover: #0d9488;
    --primary-glow: rgba(20, 184, 166, 0.4);
    
    --text-primary: #F3F4F6;
    --text-secondary: #9CA3AF;
    --text-muted: #6B7280;
    
    --font-heading: 'Outfit', sans-serif;
    --font-body: 'Inter', sans-serif;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    scrollbar-width: thin;
    scrollbar-color: var(--border-color) transparent;
}

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

/* App Container Layout */
.app-container {
    display: flex;
    width: 100vw;
    height: 100vh;
    height: 100dvh;
    background-color: var(--bg-main);
}

/* Sidebar Styling */
.sidebar {
    width: 320px;
    background-color: var(--bg-sidebar);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    padding: 24px;
    flex-shrink: 0;
}

.sidebar-header {
    margin-bottom: 32px;
}

.logo-container {
    display: flex;
    align-items: center;
    gap: 12px;
}

.logo-icon {
    width: 32px;
    height: 32px;
    color: var(--primary);
    filter: drop-shadow(0 0 8px var(--primary-glow));
}

.logo-text {
    font-family: var(--font-heading);
    font-size: 20px;
    font-weight: 700;
    letter-spacing: 0.5px;
    background: linear-gradient(135deg, #FFF, var(--primary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.sidebar-content {
    flex-grow: 1;
}

.sidebar-content h3 {
    font-family: var(--font-heading);
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 12px;
}

.sidebar-desc {
    color: var(--text-secondary);
    font-size: 14px;
    line-height: 1.6;
    margin-bottom: 24px;
}

.suggested-topics h4 {
    color: var(--text-muted);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 12px;
    font-weight: 600;
}

.topic-btn {
    width: 100%;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 12px 16px;
    color: var(--text-primary);
    font-family: var(--font-body);
    font-size: 14px;
    text-align: left;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 10px;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.topic-btn:hover {
    background: rgba(20, 184, 166, 0.08);
    border-color: var(--primary);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(20, 184, 166, 0.1);
}

.sidebar-footer {
    display: flex;
    flex-direction: column;
    gap: 16px;
    border-top: 1px solid var(--border-color);
    padding-top: 24px;
}

.session-badge {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    color: var(--text-secondary);
}

.badge-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: var(--primary);
    box-shadow: 0 0 8px var(--primary);
    animation: pulse 2s infinite;
}

.reset-btn {
    background: transparent;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 12px;
    color: var(--text-secondary);
    font-family: var(--font-body);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all 0.2s ease;
}

.reset-btn svg {
    width: 16px;
    height: 16px;
    transition: transform 0.3s ease;
}

.reset-btn:hover {
    border-color: rgba(239, 68, 68, 0.4);
    color: #EF4444;
    background: rgba(239, 68, 68, 0.05);
}

.reset-btn:hover svg {
    transform: rotate(-180deg);
}

/* Chat Area Layout */
.chat-area {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    background-color: var(--bg-chat);
    position: relative;
}

.chat-header {
    height: 80px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 32px;
    background: rgba(17, 24, 39, 0.3);
    backdrop-filter: blur(10px);
}

.header-user-info {
    display: flex;
    align-items: center;
    gap: 16px;
}

.avatar {
    width: 46px;
    height: 46px;
    border-radius: 14px;
    background: transparent;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 12px rgba(20, 184, 166, 0.2);
    overflow: hidden;
}

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

/* Estilos para el Avatar de la Barra Lateral */
.sidebar-avatar-container {
    width: 100%;
    display: flex;
    justify-content: center;
    margin-bottom: 24px;
}

.sidebar-avatar {
    width: 110px;
    height: 110px;
    border-radius: 50%;
    box-shadow: 0 8px 24px rgba(20, 184, 166, 0.25);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.sidebar-avatar:hover {
    transform: scale(1.05) rotate(3deg);
    box-shadow: 0 12px 28px rgba(20, 184, 166, 0.4);
}

.chat-header h2 {
    font-family: var(--font-heading);
    font-size: 18px;
    font-weight: 600;
}

.status-text {
    color: var(--primary);
    font-size: 12px;
    font-weight: 500;
}

/* Message Container */
.messages-container {
    flex-grow: 1;
    padding: 32px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.message {
    display: flex;
    width: 100%;
}

.message.bot {
    justify-content: flex-start;
}

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

.message-content {
    max-width: 75%;
    padding: 16px 20px;
    border-radius: 20px;
    font-size: 15px;
    line-height: 1.6;
}

.message.bot .message-content {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    border-bottom-left-radius: 4px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
}

.message.user .message-content {
    background: linear-gradient(135deg, var(--primary-hover), var(--primary));
    color: white;
    border-bottom-right-radius: 4px;
    box-shadow: 0 4px 15px rgba(20, 184, 166, 0.15);
}

/* Formateo de contenidos internos */
.message-content p {
    margin-bottom: 10px;
}

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

.message-content ul, .message-content ol {
    margin-left: 20px;
    margin-bottom: 10px;
}

.message-content li {
    margin-bottom: 4px;
}

.message-content strong {
    font-weight: 600;
    color: white;
}

.message.user .message-content strong {
    color: #FFF;
}

/* Typing Indicator */
.typing-indicator {
    display: none;
    align-self: flex-start;
    margin-left: 32px;
    margin-bottom: 16px;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--border-color);
    padding: 12px 20px;
    border-radius: 20px;
    border-bottom-left-radius: 4px;
    gap: 6px;
}

.typing-indicator span {
    width: 8px;
    height: 8px;
    background-color: var(--primary);
    border-radius: 50%;
    display: inline-block;
    animation: bounce 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; }

/* Chat Footer Input */
.chat-footer {
    padding: 24px 32px;
    border-top: 1px solid var(--border-color);
    background: rgba(17, 24, 39, 0.2);
}

.input-form {
    display: flex;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 6px;
    gap: 8px;
    transition: all 0.3s ease;
}

.input-form:focus-within {
    border-color: var(--primary);
    box-shadow: 0 0 14px var(--border-glow);
    background: rgba(255, 255, 255, 0.05);
}

.input-form input {
    flex-grow: 1;
    background: transparent;
    border: none;
    outline: none;
    color: var(--text-primary);
    font-family: var(--font-body);
    font-size: 16px;
    padding: 12px 16px;
}

.input-form input::placeholder {
    color: var(--text-muted);
}

.input-form button {
    background-color: var(--primary);
    border: none;
    border-radius: 12px;
    width: 44px;
    height: 44px;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.input-form button:hover {
    background-color: var(--primary-hover);
    transform: scale(1.05);
    box-shadow: 0 0 10px var(--primary-glow);
}

.input-form button svg {
    width: 18px;
    height: 18px;
}

/* Animations */
@keyframes pulse {
    0% { transform: scale(0.9); opacity: 0.7; }
    50% { transform: scale(1.1); opacity: 1; }
    100% { transform: scale(0.9); opacity: 0.7; }
}

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

/* Custom Scrollbar for messages */
.messages-container::-webkit-scrollbar {
    width: 6px;
}

.messages-container::-webkit-scrollbar-track {
    background: transparent;
}

.messages-container::-webkit-scrollbar-thumb {
    background-color: rgba(255, 255, 255, 0.05);
    border-radius: 3px;
}

.messages-container::-webkit-scrollbar-thumb:hover {
    background-color: rgba(20, 184, 166, 0.3);
}

/* Responsive Design */
@media (max-width: 768px) {
    .sidebar {
        display: none; /* Ocultar sidebar en móviles */
    }
    .message-content {
        max-width: 85%;
    }
    .chat-header {
        padding: 0 20px;
    }
    .messages-container {
        padding: 20px;
    }
    .chat-footer {
        padding: 16px 20px;
    }
}

/* Expandir burbuja de chat a un ancho máximo de 700px cuando el visor de trámites está abierto */
.message.bot.expanded .message-content {
    max-width: 700px;
    width: 100%;
    transition: max-width 0.3s cubic-bezier(0.4, 0, 0.2, 1), width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Visor Integrado de Trámites */
.integrated-viewer-container {
    margin-top: 15px;
    width: 100%;
}

.btn-toggle-viewer {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: rgba(20, 184, 166, 0.15);
    border: 1px solid rgba(20, 184, 166, 0.3);
    color: var(--primary);
    padding: 10px 18px;
    border-radius: 12px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 4px 12px rgba(20, 184, 166, 0.1);
}

.btn-toggle-viewer:hover {
    background: rgba(20, 184, 166, 0.25);
    border-color: var(--primary);
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(20, 184, 166, 0.2);
}

.btn-toggle-viewer span {
    font-size: 14px;
}

.iframe-wrapper {
    display: flex;
    flex-direction: column;
    width: 100%;
    height: 480px;
    border-radius: 14px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    background: #0f172a;
    overflow: hidden;
    box-shadow: 0 12px 36px rgba(0, 0, 0, 0.45);
    animation: slideDown 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

.iframe-header {
    background: rgba(30, 41, 59, 0.9);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    padding: 10px 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
}

.btn-close-iframe {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 20px;
    cursor: pointer;
    line-height: 1;
    padding: 0 4px;
    transition: all 0.2s ease;
}

.btn-close-iframe:hover {
    color: #ef4444;
    transform: scale(1.1);
}

.iframe-wrapper iframe {
    width: 100%;
    height: 100%;
    border: none;
    background: white;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-12px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Botón de control de voz */
.voice-toggle-btn {
    background: rgba(20, 184, 166, 0.12);
    border: 1px solid rgba(20, 184, 166, 0.3);
    border-radius: 12px;
    width: 44px;
    height: 44px;
    color: var(--primary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    flex-shrink: 0;
}

.voice-toggle-btn svg {
    width: 20px;
    height: 20px;
}

.voice-toggle-btn:hover {
    background: rgba(20, 184, 166, 0.25);
    border-color: var(--primary);
    box-shadow: 0 0 12px var(--primary-glow);
    transform: scale(1.05);
}

.voice-toggle-btn.muted {
    background: rgba(239, 68, 68, 0.1);
    border-color: rgba(239, 68, 68, 0.35);
    color: #ef4444;
}

.voice-toggle-btn.muted:hover {
    background: rgba(239, 68, 68, 0.2);
    border-color: #ef4444;
    box-shadow: 0 0 12px rgba(239, 68, 68, 0.3);
}

/* Card de autenticación segura (Fase 2) */
.secure-login-box {
    background: rgba(17, 24, 39, 0.4);
    border: 1px solid rgba(20, 184, 166, 0.2);
    border-radius: 16px;
    padding: 20px;
    margin-top: 10px;
    width: 100%;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    animation: slideDown 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

.login-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px;
}

.login-header h3 {
    font-family: var(--font-heading);
    font-size: 16px;
    font-weight: 600;
    color: var(--primary);
}

.login-desc {
    color: var(--text-secondary);
    font-size: 13.5px;
    line-height: 1.5;
    margin-bottom: 16px;
}

.secure-login-form {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.form-group label {
    font-size: 12px;
    font-weight: 500;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.form-group input {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 10px 12px;
    color: var(--text-primary);
    font-family: var(--font-body);
    font-size: 14px;
    outline: none;
    transition: all 0.2s ease;
}

.form-group input:focus {
    border-color: var(--primary);
    background: rgba(255, 255, 255, 0.06);
    box-shadow: 0 0 8px var(--border-glow);
}

.login-submit-btn {
    background-color: var(--primary);
    color: white;
    border: none;
    border-radius: 8px;
    padding: 12px;
    font-family: var(--font-body);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    margin-top: 6px;
}

.login-submit-btn:hover {
    background-color: var(--primary-hover);
    box-shadow: 0 0 10px var(--primary-glow);
}

.login-submit-btn:disabled {
    background-color: var(--text-muted);
    cursor: not-allowed;
    box-shadow: none;
}

