:root {
    /* Colores principales */
    --primary: #4361ee;
    --primary-dark: #3a56d4;
    --primary-light: rgba(67, 97, 238, 0.1);
    --secondary: #7209b7;
    --secondary-light: rgba(114, 9, 183, 0.1);
    
    /* Escala de grises */
    --dark: #1d3557;
    --gray-dark: #495057;
    --gray: #6c757d;
    --gray-light: #e9ecef;
    --light: #f8f9fa;
    --white: #ffffff;

    /* Dark mode colors */
    --dark-bg: #121212;
    --dark-card: #1e1e1e;
    --dark-text: #e0e0e0;
    --dark-border: #333;

    /* Tamaños responsive */
    --max-width: 1400px;
    --mobile-breakpoint: 1200px;
    --tablet-breakpoint: 768px;

    /* Espaciados */
    --space-xs: 4px;
    --space-sm: 8px;
    --space-md: 16px;
    --space-lg: 24px;
    --space-xl: 32px;
    
    /* Feedback colors */
    --success: #4cc9f0;
    --warning: #ffd166;
    --danger: #ef476f;
    
    /* Componentes */
    --card-bg: var(--white);
    --input-bg: #f5f7ff;
    --border-color: #eee;
    
    /* Efectos */
    --bg-gradient: linear-gradient(135deg, #f5f7fa 0%, #e4edf5 100%);
    --shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.05);
    --transition: all 0.3s ease;
    
    /* Tipografía */
    --font-base: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    --font-mono: 'Courier New', monospace;
}

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-gradient);
    color: var(--dark);
    line-height: 1.6;
    min-height: 100vh;
    padding: 20px;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    display: grid;
    grid-template-areas:
        "header header"
        "content content";
    grid-template-columns: 1fr;
    gap: 24px;
}

/* Header Styles */
.header {
    grid-area: header;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 0;
    margin-bottom: 20px;
}

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

.logo i {
    font-size: 28px;
    color: var(--primary);
    background: rgba(67, 97, 238, 0.1);
    width: 50px;
    height: 50px;
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.logo h1 {
    font-size: 28px;
    font-weight: 700;
    background: linear-gradient(90deg, var(--primary), var(--secondary));
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}

.tagline {
    font-size: 14px;
    color: var(--gray);
    margin-left: 5px;
}

.controls {
    display: flex;
    gap: 10px;
}

.control-btn {
    padding: 8px 15px;
    border-radius: 8px;
    border: none;
    background: var(--primary);
    color: white;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    gap: 5px;
}

.control-btn:hover {
    background: var(--primary-dark);
}

/* Main Content - Dos columnas */
.main-content {
    grid-area: content;
    display: grid;
    grid-template-columns: 1fr 1fr; /* Dos columnas iguales */
    gap: 24px;
    height: calc(100vh - 180px);
}

.chat-column {
    grid-column: 1;
}

.analytics-column {
    grid-column: 2;
}

/* Chat Styles */
.chat-container {
    display: flex;
    flex-direction: column;
    height: calc(100vh - 180px);
    background: var(--card-bg);
    border-radius: 20px;
    overflow: hidden;
    box-shadow: var(--shadow);
}

.chat-messages {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 16px;
    background: #fafcff;
}

.message {
    display: flex;
    gap: 12px;
    max-width: 85%;
}

.avatar {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    background: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.avatar i {
    color: white;
    font-size: 18px;
}

.message-content {
    background: white;
    padding: 14px 18px;
    border-radius: 18px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
    position: relative;
}

.message-content:after {
    content: '';
    position: absolute;
    width: 12px;
    height: 12px;
    background: white;
    transform: rotate(45deg);
    z-index: -1;
}

.user .message-content:after {
    right: -6px;
    top: 14px;
    box-shadow: -2px -2px 5px rgba(0, 0, 0, 0.03);
}

.bot .message-content:after {
    left: -6px;
    top: 14px;
    box-shadow: 2px -2px 5px rgba(0, 0, 0, 0.03);
}

.user {
    margin-left: auto;
    flex-direction: row-reverse;
}

.user .avatar {
    background: var(--secondary);
}

.user .message-content {
    background: var(--primary);
    color: white;
}

.typing-indicator {
    display: flex;
    gap: 5px;
    padding: 5px 0;
}

.typing-indicator span {
    width: 8px;
    height: 8px;
    background: var(--gray);
    border-radius: 50%;
    animation: typing 1.4s infinite ease-in-out;
}

.typing-indicator span:nth-child(2) {
    animation-delay: 0.2s;
}

.typing-indicator span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typing {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.5; }
    30% { transform: translateY(-5px); opacity: 1; }
}

.chat-input {
    display: flex;
    padding: 15px;
    background: white;
    border-top: 1px solid #eee;
    gap: 10px;
}

#user-input {
    flex: 1;
    padding: 14px 20px;
    border: none;
    background: #f5f7ff;
    border-radius: 16px;
    font-size: 16px;
    outline: none;
    transition: var(--transition);
}

#user-input:focus {
    box-shadow: 0 0 0 3px rgba(67, 97, 238, 0.2);
}

#send-btn {
    width: 50px;
    height: 50px;
    border-radius: 16px;
    background: var(--primary);
    border: none;
    color: white;
    font-size: 18px;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
}

#send-btn:hover {
    background: var(--primary-dark);
    transform: scale(1.05);
}

/* Analytics Panel */
.panel-header {
    padding: 20px;
    border-bottom: 1px solid #eee;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.panel-header h2 {
    font-size: 20px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--dark);
}

.tabs {
    display: flex;
    gap: 5px;
    background: #f5f7ff;
    border-radius: 10px;
    padding: 4px;
}

.tab {
    border: none;
    background: transparent;
    padding: 8px 16px;
    border-radius: 8px;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    color: var(--gray);
}

.tab.active {
    background: white;
    color: var(--primary);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.panel-content {
    flex: 1;
    padding: 20px;
    overflow: hidden;
    display: flex;
}

.tab-content {
    width: 100%;
    height: 100%;
    display: none;
}

.tab-content.active {
    display: block;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.chart-container {
    width: 100%;
    height: 400px; /* Altura fija para evitar que se extienda sin límite */
    min-height: 300px;
    max-height: 600px;
    position: relative;
    background: white;
    border-radius: 12px;
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}

.chart-controls {
    position: absolute;
    top: 10px;
    right: 10px;
    z-index: 100;
    display: flex;
    gap: 8px;
}

.reset-zoom-btn {
    background: var(--primary);
    color: white;
    border: none;
    border-radius: 6px;
    padding: 6px 12px;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
}

.reset-zoom-btn:hover {
    background: var(--primary-dark);
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
}

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

/* Estados del cursor para el zoom */
.chart-container.grabbing {
    cursor: grabbing !important;
}

.chart-container.grab {
    cursor: grab !important;
}

.chart-container.zoom {
    cursor: zoom-in !important;
}

.table-container {
    width: 100%;
    height: 100%;
    overflow: auto;
    border-radius: 12px;
    border: 1px solid #eee;
}

#results-table {
    width: 100%;
    border-collapse: collapse;
}

#results-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
}

#results-table th {
    background: var(--primary);
    color: white;
    padding: 12px 15px;
    text-align: left;
    font-weight: 600;
    position: sticky;
    top: 0;
    z-index: 10;
}

#results-table th:first-child {
    border-top-left-radius: 8px;
}

#results-table th:last-child {
    border-top-right-radius: 8px;
}

#results-table td {
    padding: 12px 15px;
    border-bottom: 1px solid var(--border-color);
}

#results-table tr:nth-child(even) {
    background-color: var(--light);
}

#results-table tr:hover {
    background-color: var(--primary-light);
}

#results-table tr:last-child td {
    border-bottom: none;
}

#results-table tr:last-child td:first-child {
    border-bottom-left-radius: 8px;
}

#results-table tr:last-child td:last-child {
    border-bottom-right-radius: 8px;
}

.sql-editor {
    background: #1e1e1e;
    color: #d4d4d4;
    padding: 20px;
    border-radius: 12px;
    font-family: var(--font-mono);
    font-size: 14px;
    line-height: 1.5;
    overflow-x: auto;
    height: 100%;
    margin: 0;
    tab-size: 4;
}

.sql-editor .keyword {
    color: #569cd6;
}

.sql-editor .string {
    color: #ce9178;
}

.sql-editor .number {
    color: #b5cea8;
}

.sql-editor .function {
    color: #dcdcaa;
}

/* Loading Indicator */
.loading-indicator {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 1000;
    display: none;
}

.loading-spinner {
    border: 6px solid #f3f3f3;
    border-top: 6px solid #4a90e2;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Footer Styles */
.footer {
    position: relative;
    text-align: center;
    padding: 15px 20px 10px;
    margin-top: auto;
}

.powered-by {
    font-size: 14px;
    font-weight: 500;
    color: var(--gray);
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(10px);
    padding: 8px 16px;
    border-radius: 20px;
    display: inline-block;
    box-shadow: var(--shadow-sm);
    transition: var(--transition);
}

.powered-by:hover {
    color: var(--primary);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(67, 97, 238, 0.15);
}

.powered-by strong {
    font-weight: 600;
    background: linear-gradient(90deg, var(--primary), var(--secondary));
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}

/* Responsive Design - En pantallas pequeñas, el chat y los gráficos se apilan */
@media (max-width: 1200px) {
    .main-content {
        grid-template-columns: 1fr;
    }
    
    .chat-column, .analytics-column {
        grid-column: auto;
    }
}
