/* ======================================= */
/* 1. RESET Y ESTILOS BASE                 */
/* ======================================= */

:root {
    --primary-color: #3498db; /* Azul */
    --secondary-color: #2c3e50; /* Azul oscuro para botones PDF/secundarios */
    --accent-color: #e74c3c; /* Rojo para alertas */
    --bg-light: #ecf0f1; /* Fondo muy claro */
    --bg-dark: #f0f3f5; /* Fondo del panel lateral */
    --border-color: #bdc3c7;
    --shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

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

body {
    font-family: 'Roboto', sans-serif;
    background-color: var(--bg-light);
    color: var(--secondary-color);
    line-height: 1.6;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* ======================================= */
/* 2. LAYOUT PRINCIPAL Y BARRA SUPERIOR    */
/* ======================================= */

.top-bar {
    background-color: var(--primary-color);
    color: white;
    padding: 15px 20px;
    box-shadow: var(--shadow);
    z-index: 10;
}

.top-bar h1 {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 1.5rem;
    font-weight: 500;
}

.container {
    display: flex;
    flex: 1;
    max-width: 1400px;
    width: 100%;
    margin: 0 auto;
    padding-top: 15px; /* Espacio para separar de la barra superior */
}

.controls {
    width: 300px;
    padding: 15px;
    background-color: var(--bg-dark);
    border-radius: 8px;
    box-shadow: var(--shadow);
    height: fit-content;
    margin-right: 15px;
    position: sticky;
    top: 15px;
}

.main-content {
    flex: 1;
    padding: 0 15px 15px 0;
    min-height: 800px; /* Altura mínima para el área de gráficos */
}

/* ======================================= */
/* 3. PANELES DE CONTROL (INPUTS)          */
/* ======================================= */

.control-group {
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 1px solid var(--border-color);
}

.control-group h3 {
    font-size: 1.1rem;
    color: var(--secondary-color);
    margin-bottom: 10px;
    font-weight: 500;
}

label {
    display: block;
    margin-bottom: 5px;
    font-size: 0.9rem;
    font-weight: 500;
    color: #555;
}

input[type="number"], select {
    width: 100%;
    padding: 8px;
    margin-bottom: 10px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-size: 0.9rem;
}

/* Inputs en una sola fila */
.row-inputs {
    display: flex;
    gap: 10px;
    margin-bottom: 10px;
}
.row-inputs > div {
    flex: 1;
}
.row-inputs input {
    margin-bottom: 0;
}

/* Fila para rango y color */
.range-row {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 8px;
}
.range-row label {
    flex: 1;
    margin-bottom: 0;
}
.range-row input[type="number"] {
    width: 60px;
    flex-grow: 0;
    margin-bottom: 0;
    text-align: right;
}
.range-row input[type="color"] {
    width: 30px;
    height: 30px;
    padding: 0;
    border: none;
    border-radius: 4px;
    cursor: pointer;
}
.range-row span {
    font-size: 0.9rem;
}

/* Control deslizante de rango */
input[type="range"] {
    -webkit-appearance: none;
    appearance: none;
    height: 6px;
    background: var(--border-color);
    border-radius: 3px;
    cursor: pointer;
    margin-bottom: 0;
    flex-grow: 1;
}
input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--primary-color);
    cursor: pointer;
}
.range-row:last-child {
    margin-bottom: 15px;
}


/* Carga de archivos */
.file-upload {
    background-color: #f7f9fb;
    border: 1px dashed var(--border-color);
    padding: 10px;
    text-align: center;
    cursor: pointer;
    border-radius: 4px;
    margin-bottom: 15px;
    transition: background-color 0.2s;
}
.file-upload:hover {
    background-color: #e9eff3;
}
.file-upload input[type="file"] {
    display: none;
}

/* Mensaje de estado */
.status-message {
    margin-top: 15px;
    padding: 8px;
    background-color: #f1c40f33;
    color: #e67e22;
    border: 1px solid #f1c40f;
    border-radius: 4px;
    font-size: 0.85rem;
    text-align: center;
}

.highlight-group {
    border: 1px solid var(--primary-color);
    padding: 15px;
    border-radius: 8px;
    background-color: #fcfdff;
}
.highlight-group h3 {
    color: var(--primary-color);
}

/* ======================================= */
/* 4. BOTONES                              */
/* ======================================= */

.btn-primary, .btn-secondary {
    padding: 10px;
    width: 100%;
    font-size: 0.9rem;
    font-weight: bold;
    border-radius: 4px;
    cursor: pointer;
    transition: 0.2s;
    border: none;
    
    /* Para centrar iconos de FontAwesome */
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
}

.btn-primary {
    background: #27ae60; /* Verde principal */
    color: white;
    margin-top: 15px;
    box-shadow: 0 3px 6px rgba(0,0,0,0.15);
}

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

.btn-secondary {
    background: var(--secondary-color);
    color: white;
    margin-top: 10px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.btn-secondary:hover {
    background: #34495e;
    transform: translateY(-1px);
}

.btn-primary:disabled, .btn-secondary:disabled {
    background: #bdc3c7;
    cursor: not-allowed;
    box-shadow: none;
}

/* ======================================= */
/* 5. ÁREA PRINCIPAL Y PESTAÑAS (TABS)     */
/* ======================================= */

.tabs {
    display: flex;
    border-bottom: 2px solid var(--border-color);
    margin-bottom: 15px;
}

.tab-button {
    background-color: #f5f5f5;
    border: 1px solid var(--border-color);
    border-bottom: none;
    padding: 10px 15px;
    cursor: pointer;
    font-weight: bold;
    font-size: 1rem;
    border-radius: 8px 8px 0 0;
    transition: background-color 0.2s;
    color: #7f8c8d;
    
    /* Para centrar iconos de FontAwesome */
    display: flex;
    align-items: center;
    gap: 8px;
}

.tab-button:hover:not(.active) {
    background-color: #ecf0f1;
    color: var(--secondary-color);
}

.tab-button.active {
    background-color: white;
    border-color: var(--border-color);
    border-bottom: 2px solid white; /* Simula que la pestaña está sobre el borde */
    color: var(--primary-color);
}

.tab-content {
    background-color: white;
    border: 1px solid var(--border-color);
    border-radius: 0 8px 8px 8px;
    padding: 10px;
    display: none;
    min-height: 700px;
}

.tab-content.active {
    display: block;
}

/* Área de Plotly */
.plot-area {
    min-height: 750px;
}

/* Gráficos auxiliares */
.grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
    min-height: 350px;
    /* Al usar display: grid, la función showTab debe configurarlo */
}
.card {
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 6px;
    min-height: 350px;
}

/* ======================================= */
/* 6. RESULTADOS Y TABLA                   */
/* ======================================= */

#results {
    display: flex;
    flex-direction: column;
}

.results-layout {
    display: flex;
    gap: 20px;
    flex: 1;
}

.results-chart-container {
    flex: 2; /* Ocupa 2/3 del espacio */
    padding: 10px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    min-height: 650px;
}
.results-chart-container h3 {
    text-align: center;
    margin-bottom: 10px;
    color: var(--secondary-color);
}

.results-table-container {
    flex: 1; /* Ocupa 1/3 del espacio */
    padding: 10px;
}
.results-table-container h3 {
    margin-bottom: 10px;
    color: var(--secondary-color);
}

#volumeResultsTable {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

#volumeResultsTable th, #volumeResultsTable td {
    border: 1px solid #ddd;
    padding: 10px 8px;
    text-align: left;
}

#volumeResultsTable th {
    background-color: var(--primary-color);
    color: white;
    font-weight: 500;
    text-transform: uppercase;
    font-size: 0.8rem;
}

#volumeResultsTable tbody tr:nth-child(even) {
    background-color: #f9f9f9;
}

/* Columna de color */
#volumeResultsTable td:nth-child(2) {
    width: 15px;
    border: 1px solid #ddd !important; 
}

.summary-row td {
    background-color: #f0f0f0 !important;
    font-weight: bold;
    text-align: center !important;
}

/* ======================================= */
/* 7. AJUSTES DE ICONOS (FontAwesome)      */
/* ======================================= */

.fa, .fas {
    margin-right: 5px; 
}

/* Asegurar que los iconos en los botones no se corten */
.btn-primary .fa, .btn-secondary .fa {
    margin-right: 8px;
}

.tab-button .fa {
    margin-right: 0px; 
}