/* Reset y estilos base */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #e3f2fd 0%, #f1f8e9 100%);
    color: #2e7d32;
    line-height: 1.6;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
}

/* Header */
header {
    text-align: center;
    margin-bottom: 30px;
    background: rgba(255, 255, 255, 0.9);
    padding: 30px;
    border-radius: 15px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

header h1 {
    font-size: 2.5rem;
    color: #1b5e20;
    margin-bottom: 10px;
}

header p {
    font-size: 1.1rem;
    color: #388e3c;
}

/* Panel de Filtros */
.filters-panel {
    background: rgba(255, 255, 255, 0.95);
    padding: 25px;
    border-radius: 12px;
    margin-bottom: 30px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.08);
}

/* Panel de Insights AI */
.insights-panel {
    background: rgba(255, 255, 255, 0.95);
    padding: 25px;
    border-radius: 12px;
    margin-bottom: 30px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.08);
    border-left: 4px solid #2196f3;
}

.privacy-notice {
    background: #fff3cd;
    border: 1px solid #ffeaa7;
    border-radius: 8px;
    padding: 15px;
    margin-bottom: 20px;
    border-left: 4px solid #f39c12;
}

.privacy-notice p {
    margin: 0;
    color: #856404;
    font-size: 14px;
    line-height: 1.4;
}

.privacy-notice strong {
    color: #856404;
}

.insights-panel h3 {
    color: #1976d2;
    margin-bottom: 20px;
    font-size: 1.4rem;
    display: flex;
    align-items: center;
    gap: 10px;
}

.insights-controls {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.insights-main-controls {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.insights-options {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    align-items: center;
}

.checkbox-container {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-weight: 500;
    color: #2e7d32;
}

.checkbox-container input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: #4caf50;
}

.model-selector {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.model-selector label {
    font-weight: 600;
    color: #2e7d32;
    font-size: 0.9rem;
}

.model-selector select {
    padding: 8px 12px;
    border: 2px solid #a5d6a7;
    border-radius: 6px;
    font-size: 14px;
    background: white;
    color: #2e7d32;
    min-width: 200px;
}

.model-selector select:focus {
    outline: none;
    border-color: #4caf50;
    box-shadow: 0 0 0 3px rgba(76, 175, 80, 0.1);
}

.insights-output {
    background: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 8px;
    padding: 20px;
}

.insights-output h4 {
    color: #1976d2;
    margin-bottom: 15px;
    font-size: 1.1rem;
}

.insights-output pre,
.ai-output-content {
    background: white;
    border: 1px solid #dee2e6;
    border-radius: 6px;
    padding: 15px;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    font-size: 14px;
    line-height: 1.5;
    color: #495057;
    max-height: 300px;
    overflow-y: auto;
}

.insights-output pre {
    white-space: pre-wrap;
    word-wrap: break-word;
}

.ai-output-content {
    white-space: normal;
}

.ai-output-content:empty::before {
    content: "Haz clic en 'Explicar lo que veo' después de cargar tus datos CSV para obtener un análisis inteligente de tus gráficos.";
    color: #6c757d;
    font-style: italic;
}

/* Markdown-like styling for AI output */
.ai-output-content h1,
.ai-output-content h2,
.ai-output-content h3,
.ai-output-content h4,
.ai-output-content h5,
.ai-output-content h6 {
    color: #1976d2;
    margin: 15px 0 10px 0;
    font-weight: 600;
}

.ai-output-content h1 { font-size: 18px; }
.ai-output-content h2 { font-size: 16px; }
.ai-output-content h3 { font-size: 15px; }

.ai-output-content strong {
    font-weight: 600;
    color: #2e7d32;
}

.ai-output-content em {
    font-style: italic;
    color: #666;
}

.ai-output-content ul,
.ai-output-content ol {
    margin: 10px 0;
    padding-left: 20px;
}

.ai-output-content li {
    margin: 5px 0;
}

.ai-output-content p {
    margin: 10px 0;
}

.filters-panel h3 {
    color: #1b5e20;
    margin-bottom: 20px;
    font-size: 1.4rem;
}

.filters-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    align-items: end;
}

.filter-group {
    display: flex;
    flex-direction: column;
}

.filter-group label {
    font-weight: 600;
    margin-bottom: 8px;
    color: #2e7d32;
}

.filter-group select {
    padding: 10px;
    border: 2px solid #a5d6a7;
    border-radius: 8px;
    font-size: 14px;
    background: white;
    color: #2e7d32;
    transition: border-color 0.3s ease;
}

.filter-group select:focus {
    outline: none;
    border-color: #4caf50;
    box-shadow: 0 0 0 3px rgba(76, 175, 80, 0.1);
}

.reset-btn {
    background: #ff7043;
    color: white;
    border: none;
    padding: 12px 20px;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    transition: background-color 0.3s ease;
    height: fit-content;
}

.reset-btn:hover {
    background: #f4511e;
}

/* Tablero Resumen */
.summary-dashboard {
    background: rgba(255, 255, 255, 0.95);
    padding: 25px;
    border-radius: 12px;
    margin-bottom: 30px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.08);
}

.summary-dashboard h2 {
    color: #1b5e20;
    margin-bottom: 20px;
    text-align: center;
}

.kpi-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
}

.kpi-card {
    background: linear-gradient(135deg, #66bb6a, #4caf50);
    color: white;
    padding: 25px;
    border-radius: 12px;
    text-align: center;
    box-shadow: 0 4px 15px rgba(76, 175, 80, 0.3);
    transition: transform 0.3s ease;
}

.kpi-card:hover {
    transform: translateY(-5px);
}

.kpi-card h3 {
    font-size: 1rem;
    margin-bottom: 10px;
    opacity: 0.9;
}

.kpi-value {
    font-size: 2.2rem;
    font-weight: bold;
    margin-bottom: 5px;
}

.kpi-unit {
    font-size: 0.9rem;
    opacity: 0.8;
}

/* Descripción de gráficos */
.chart-description {
    margin: 0 0 15px 0;
    font-size: 0.9rem;
    color: #666;
    font-style: italic;
}

/* Contenedor de Gráficos */
.charts-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
    gap: 30px;
}

.chart-section {
    background: rgba(255, 255, 255, 0.95);
    padding: 25px;
    border-radius: 12px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.08);
}

.chart-section h2 {
    color: #1b5e20;
    margin-bottom: 20px;
    text-align: center;
    font-size: 1.3rem;
}

.chart-container {
    position: relative;
    height: 400px;
    margin-top: 15px;
}

.chart-container canvas {
    max-height: 100%;
}

/* Footer */
footer {
    text-align: center;
    margin-top: 40px;
    padding: 20px;
    color: #388e3c;
    font-size: 0.9rem;
}

/* Loading */
.loading {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.9);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.loading.hidden {
    display: none;
}

.loading-spinner {
    width: 50px;
    height: 50px;
    border: 4px solid #e8f5e8;
    border-top: 4px solid #4caf50;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 20px;
}

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

.loading p {
    color: #2e7d32;
    font-size: 1.1rem;
    font-weight: 600;
}

/* Responsive Design */
@media (max-width: 600px) {
    .container {
        padding: 15px;
    }
    
    header h1 {
        font-size: 2rem;
    }
    
    .filters-grid {
        grid-template-columns: 1fr;
        gap: 15px;
    }
    
    .kpi-cards {
        grid-template-columns: 1fr;
        gap: 15px;
    }
    
    .charts-container {
        grid-template-columns: 1fr;
        gap: 20px;
    }
    
    .chart-container {
        height: 300px;
    }
    
    .kpi-value {
        font-size: 1.8rem;
    }
    
    .chart-section {
        padding: 20px;
    }
}

@media (max-width: 768px) {
    .charts-container {
        grid-template-columns: 1fr;
    }
    
    .kpi-cards {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* Estilos para select múltiple */
select[multiple] {
    min-height: 80px;
}

select[multiple] option {
    padding: 5px;
}

select[multiple] option:checked {
    background: #4caf50;
    color: white;
}

/* Tooltips personalizados para gráficos */
.chartjs-tooltip {
    opacity: 1;
    position: absolute;
    background: rgba(0, 0, 0, 0.8);
    color: white;
    border-radius: 3px;
    pointer-events: none;
    transform: translate(-50%, 0);
    transition: all .1s ease;
}

.chartjs-tooltip-key {
    display: inline-block;
    width: 10px;
    height: 10px;
    margin-right: 10px;
}

/* === NUEVOS ESTILOS PARA CARGA Y MAPEO DE DATOS === */

/* Panel de Carga de Datos */
.upload-panel {
    background: rgba(255, 255, 255, 0.95);
    padding: 25px;
    border-radius: 12px;
    margin-bottom: 30px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.08);
}

.upload-panel h3 {
    color: #1b5e20;
    margin-bottom: 20px;
    font-size: 1.3rem;
}

.upload-area {
    text-align: center;
}

.upload-zone {
    border: 2px dashed #4caf50;
    border-radius: 12px;
    padding: 40px 20px;
    background: linear-gradient(135deg, #f1f8e9 0%, #e8f5e8 100%);
    cursor: pointer;
    transition: all 0.3s ease;
    margin-bottom: 20px;
}

.upload-zone:hover {
    border-color: #2e7d32;
    background: linear-gradient(135deg, #e8f5e8 0%, #c8e6c9 100%);
    transform: translateY(-2px);
}

.upload-zone.dragover {
    border-color: #1b5e20;
    background: linear-gradient(135deg, #c8e6c9 0%, #a5d6a7 100%);
}

.upload-icon {
    font-size: 3rem;
    margin-bottom: 15px;
    color: #4caf50;
}

.upload-zone p {
    margin: 5px 0;
    color: #2e7d32;
}

.upload-hint {
    font-size: 0.9rem;
    color: #388e3c !important;
    font-style: italic;
}

.upload-actions {
    display: flex;
    gap: 15px;
    justify-content: center;
    margin-top: 20px;
}

/* Panel de Mapeo de Variables */
.mapping-panel {
    background: rgba(255, 255, 255, 0.95);
    padding: 25px;
    border-radius: 12px;
    margin-bottom: 30px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.08);
}

.mapping-panel h3 {
    color: #1b5e20;
    margin-bottom: 15px;
    font-size: 1.3rem;
}

.mapping-instructions {
    background: #e3f2fd;
    padding: 15px;
    border-radius: 8px;
    margin-bottom: 20px;
    border-left: 4px solid #2196f3;
}

.mapping-instructions p {
    margin: 0;
    color: #1565c0;
}

.mapping-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 20px;
    margin-bottom: 25px;
}

.mapping-item {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.mapping-item label {
    font-weight: 600;
    color: #2e7d32;
    display: flex;
    align-items: center;
    gap: 8px;
}

.mapping-item .required {
    color: #d32f2f;
    font-size: 0.8rem;
}

.mapping-item select {
    padding: 10px;
    border: 2px solid #e0e0e0;
    border-radius: 6px;
    background: white;
    font-size: 14px;
    color: #333;
    transition: border-color 0.3s ease;
}

.mapping-item select:focus {
    outline: none;
    border-color: #4caf50;
    box-shadow: 0 0 0 3px rgba(76, 175, 80, 0.1);
}

.mapping-item .field-description {
    font-size: 0.85rem;
    color: #666;
    font-style: italic;
}

.mapping-actions {
    display: flex;
    gap: 15px;
    justify-content: center;
    flex-wrap: wrap;
}

/* Panel de Vista Previa */
.preview-panel {
    background: rgba(255, 255, 255, 0.95);
    padding: 25px;
    border-radius: 12px;
    margin-bottom: 30px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.08);
}

.preview-panel h3 {
    color: #1b5e20;
    margin-bottom: 20px;
    font-size: 1.3rem;
}

.preview-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 15px;
    margin-bottom: 20px;
    padding: 15px;
    background: #f1f8e9;
    border-radius: 8px;
}

.preview-stat {
    text-align: center;
}

.preview-stat-value {
    font-size: 1.5rem;
    font-weight: 600;
    color: #2e7d32;
}

.preview-stat-label {
    font-size: 0.9rem;
    color: #388e3c;
}

.preview-table-container {
    max-height: 400px;
    overflow: auto;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    background: white;
}

.preview-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

.preview-table th,
.preview-table td {
    padding: 8px 12px;
    text-align: left;
    border-bottom: 1px solid #e0e0e0;
}

.preview-table th {
    background: #f5f5f5;
    font-weight: 600;
    color: #2e7d32;
    position: sticky;
    top: 0;
    z-index: 1;
}

.preview-table tr:hover {
    background: #f9f9f9;
}

/* Botones */
.btn-primary, .btn-secondary, .btn-success, .btn-upload {
    padding: 12px 24px;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    text-decoration: none;
    display: inline-block;
}

.btn-primary {
    background: #2196f3;
    color: white;
}

.btn-primary:hover {
    background: #1976d2;
    transform: translateY(-2px);
}

.btn-secondary {
    background: #757575;
    color: white;
}

.btn-secondary:hover {
    background: #616161;
    transform: translateY(-2px);
}

.btn-success {
    background: #4caf50;
    color: white;
}

.btn-success:hover {
    background: #388e3c;
    transform: translateY(-2px);
}

.btn-upload {
    background: #ff9800;
    color: white;
    font-size: 12px;
    padding: 8px 16px;
}

.btn-upload:hover {
    background: #f57c00;
    transform: translateY(-2px);
}

/* Estados de carga */
.processing {
    opacity: 0.6;
    pointer-events: none;
}

.success-message {
    background: #c8e6c9;
    color: #2e7d32;
    padding: 12px;
    border-radius: 6px;
    margin: 10px 0;
    border-left: 4px solid #4caf50;
}

.error-message {
    background: #ffcdd2;
    color: #c62828;
    padding: 12px;
    border-radius: 6px;
    margin: 10px 0;
    border-left: 4px solid #f44336;
}

/* Responsive Design para nuevos componentes */
@media (max-width: 768px) {
    .mapping-grid {
        grid-template-columns: 1fr;
    }
    
    .upload-actions,
    .mapping-actions {
        flex-direction: column;
        align-items: stretch;
    }
    
    .btn-primary, .btn-secondary, .btn-success, .btn-upload {
        width: 100%;
        margin-bottom: 10px;
    }
    
    .preview-stats {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .upload-zone {
        padding: 30px 15px;
    }
    
    .upload-icon {
        font-size: 2rem;
    }
}
