/* --- Global Styles --- */
:root {
    --background-color: #121212;
    --sidebar-bg: #1E1E1E;
    --surface-color: #2C2C2C;
    --primary-text-color: #E0E0E0;
    --secondary-text-color: #A0A0A0;
    --accent-color: #C09553;
    --border-color: #444;
    --scrollbar-gap: 15px;
    --chat-bottom-padding: 150px;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background-color: var(--background-color);
    color: var(--primary-text-color);
    height: 100vh;
    overflow: hidden; 
}

.app-container { display: flex; width: 100%; height: 100%; }

/* --- SIDEBAR --- */
.sidebar {
    width: 260px;
    background-color: var(--sidebar-bg);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    padding: 1.5rem;
    flex-shrink: 0;
}
.sidebar-header { margin-bottom: 2rem; }
.logo { height: 40px; content: url('logo.png'); }
.nav-label { font-size: 0.75rem; color: var(--secondary-text-color); margin-bottom: 0.75rem; font-weight: 600; }
.nav-item {
    background: none; border: none; width: 100%; text-align: left; padding: 0.85rem 1rem;
    color: var(--secondary-text-color); font-size: 0.95rem; cursor: pointer;
    border-radius: 12px; margin-bottom: 0.5rem; display: flex; align-items: center; gap: 12px;
    transition: all 0.2s ease;
}
.nav-item:hover { background-color: rgba(255, 255, 255, 0.05); color: var(--primary-text-color); }
.nav-item.active { background-color: rgba(192, 149, 83, 0.15); color: var(--accent-color); font-weight: 500; }

/* --- MAIN CONTENT --- */
.main-content {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    background-color: var(--background-color);
    height: 100vh;
    position: relative;
    overflow: hidden;
}

/* Header */
.chat-header {
    height: 70px;
    border-bottom: 1px solid var(--border-color);
    display: flex; justify-content: space-between; align-items: center; padding: 0 2rem;
    background-color: var(--background-color);
    flex-shrink: 0;
    z-index: 10;
}
.header-controls { display: flex; align-items: center; gap: 20px; }
.status-badge { font-size: 0.8rem; color: #4CAF50; display: flex; align-items: center; gap: 6px; }
.dot { width: 8px; height: 8px; background: #4CAF50; border-radius: 50%; }

/* --- CHAT HISTORY --- */
#chat-history {
    flex: 1 1 0; 
    height: 100%;
    min-height: 0;
    overflow-y: auto;
    padding: 2rem 2rem 0 2rem; 
    padding-bottom: var(--chat-bottom-padding); 
    padding-right: calc(2rem + var(--scrollbar-gap));
    display: flex;
    flex-direction: column;
    scroll-behavior: smooth;
    width: 100%;
}
    
/* Initial View */
.initial-view { margin: auto; text-align: center; max-width: 600px; padding-bottom: 2rem; }
.ai-avatar-large img { width: 64px; height: 64px; margin-bottom: 1rem; opacity: 0.8; }
.title {
    font-size: 2.5rem; font-weight: bold; margin-bottom: 0.5rem; line-height: 1.1;
    background: linear-gradient(90deg, #ffffff 0%, #d7d7d7 50%, #ffffff 100%);
    -webkit-background-clip: text; background-clip: text; color: transparent;
}
.subtitle { color: var(--secondary-text-color); font-size: 1.1rem; }

/* --- SUGGESTION BUBBLES --- */
.suggestions-container {
    position: absolute;
    bottom: 120px;
    left: 0;
    right: 0;
    display: flex;
    justify-content: center;
    gap: 10px;
    padding: 0 1.5rem;
    pointer-events: none; 
    flex-wrap: wrap;
    z-index: 20;
}

.suggestion-chip {
    background-color: var(--surface-color);
    border: 1px solid var(--border-color);
    color: var(--primary-text-color);
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 0.85rem;
    cursor: pointer;
    pointer-events: auto;
    transition: transform 0.2s, border-color 0.2s;
    box-shadow: 0 4px 10px rgba(0,0,0,0.2);
    white-space: nowrap;
}

.suggestion-chip:hover {
    transform: translateY(-3px);
    border-color: var(--accent-color);
    background-color: #333;
}

/* --- INPUT AREA --- */
.input-area {
    position: absolute;
    bottom: 0;
    left: 0;
    right: var(--scrollbar-gap);
    padding: 1.5rem 2rem;

    background: linear-gradient(to top, var(--background-color) 70%, rgba(18,18,18,0)); 
    z-index: 30;
}

.prompt-input-wrapper {
    background-color: var(--surface-color);
    border: 1px solid var(--border-color);
    border-radius: 30px;
    display: flex; align-items: center; padding: 0.5rem 1rem;
    max-width: 900px; margin: 0 auto;
    box-shadow: 0 5px 20px rgba(0,0,0,0.3);
}
.prompt-input-wrapper:focus-within { border-color: var(--accent-color); }

#prompt-input {
    flex-grow: 1; background: none; border: none; color: var(--primary-text-color);
    font-size: 1rem; padding: 0.75rem; outline: none;
}

#ask-button {
    background-color: var(--accent-color); border: none; border-radius: 50%;
    width: 40px; height: 40px; color: #121212; cursor: pointer;
    display: flex; justify-content: center; align-items: center; font-size: 1.1rem;
}

/* --- MESSAGES --- */
.chat-message { max-width: 85%; margin-bottom: 1.5rem; padding: 1rem; border-radius: 12px; line-height: 1.6; }
.user-message { align-self: flex-end; background-color: var(--surface-color); border-top-right-radius: 2px; }
.ai-message { align-self: flex-start; display: flex; gap: 1rem; width: 100%; /* Ocupa ancho disponible */ }
.ai-icon img { width: 36px; height: 36px; border-radius: 6px; }


.message-content { 
    flex-grow: 1; 
    min-width: 0;
}

.message-content h4 {
    color: var(--secondary-text-color); font-size: 0.75rem; margin-top: 1rem;
    margin-bottom: 0.5rem; letter-spacing: 1px; text-transform: uppercase;
}

.sql-query {
    background: #0d0d0d;
    padding: 15px;
    border-radius: 8px;
    border: 1px solid #333;
    font-family: 'Consolas', monospace;
    font-size: 0.9rem;
    color: #a5d6ff;
    white-space: pre-wrap; 
    word-wrap: break-word; 
    overflow-x: hidden;
    max-width: 100%;
    display: block;
}

.sql-container, .results-container {
    max-width: 100%;
}

.natural-answer { white-space: pre-wrap; color: var(--primary-text-color); }
.hidden { display: none; }

/* LOADING DOTS */
.loading-dots span {
    display: inline-block; width: 8px; height: 8px; border-radius: 50%;
    background-color: var(--secondary-text-color); margin: 0 2px;
    animation: bounce 2s infinite ease-in-out both;
}
.loading-dots span:nth-child(1) { animation-delay: -0.32s; }
.loading-dots span:nth-child(2) { animation-delay: -0.16s; }
@keyframes bounce { 0%, 80%, 100% { transform: scale(0); } 40% { transform: scale(1.0); } }

/* THEME SWITCHER */
.theme-switcher-wrapper { display: flex; align-items: center; gap: 10px; color: var(--secondary-text-color); font-size: 0.9rem; }
.theme-toggle-checkbox { display: none; }
.theme-toggle-label {
    display: block; width: 44px; height: 24px; background-color: var(--surface-color);
    border-radius: 12px; cursor: pointer; position: relative; border: 1px solid var(--border-color);
}
.theme-toggle-label::after {
    content: ''; position: absolute; width: 18px; height: 18px; border-radius: 50%;
    background-color: #fff; top: 2px; left: 2px; transition: transform 0.3s ease;
}
.theme-toggle-checkbox:checked + .theme-toggle-label::after { transform: translateX(20px); }

/* LIGHT MODE */
body.light-mode { --background-color: #F7F7F8; --sidebar-bg: #FFFFFF; --surface-color: #FFFFFF; --primary-text-color: #333; --border-color: #E0E0E0; }
body.light-mode .user-message { background-color: var(--accent-color); color: white; }
body.light-mode .sql-query { background-color: #f4f4f4; color: #333; border-color: #ddd; }