:root { 
    --bg-color: #f4f7f6; 
    --text-color: #333; 
    --card-bg: white; 
    --border-color: #ddd; 
    --hover-bg: #f1f8ff; 
    --th-bg: #f8f9fa; 
}

body.dark-mode { 
    --bg-color: #121212; 
    --text-color: #e0e0e0; 
    --card-bg: #1e1e1e; 
    --border-color: #333; 
    --hover-bg: #2a2a2a; 
    --th-bg: #252525; 
}

body { 
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; 
    margin: 0; 
    padding: 15px; 
    background: var(--bg-color); 
    color: var(--text-color); 
    transition: 0.3s; 
}

.container { 
    max-width: 1100px; 
    margin: auto; 
    background: var(--card-bg); 
    padding: 20px; 
    border-radius: 8px; 
    box-shadow: 0 4px 6px rgba(0,0,0,0.1); 
}

/* Spinner */
#spinner { 
    position: fixed; 
    top:0; left:0; width:100%; height:100%; 
    background: rgba(0,0,0,0.7); 
    z-index: 9999; 
    display: none; 
    justify-content: center; 
    align-items: center; 
    flex-direction: column; 
    color: white; 
}
.loader { 
    border: 6px solid #f3f3f3; 
    border-top: 6px solid #3498db; 
    border-radius: 50%; 
    width: 50px; height: 50px; 
    animation: spin 1s linear infinite; 
    margin-bottom: 15px; 
}
@keyframes spin { 100% { transform: rotate(360deg); } }

/* Componentes Básicos */
.header { 
    display: flex; justify-content: space-between; align-items: center; 
    margin-bottom: 15px; flex-wrap: wrap; gap: 10px;
}
.header h2 { margin: 0; }
.controls { 
    display: flex; gap: 10px; margin-bottom: 15px; 
    flex-wrap: wrap; align-items: center; 
}
input, select, button { 
    padding: 10px; border: 1px solid var(--border-color); 
    border-radius: 4px; background: var(--card-bg); 
    color: var(--text-color); font-size: 0.9rem;
}
button { 
    background: #3498db; color: white; cursor: pointer; 
    border: none; font-weight: bold; transition: 0.2s;
}
button:hover { background: #2980b9; }

/* Botones de Colores */
.btn-success { background: #27ae60; } .btn-success:hover { background: #2ecc71; }
.btn-danger { background: #dc3545; } .btn-danger:hover { background: #c82333; }
.btn-warning { background: #f39c12; color: #fff; } .btn-warning:hover { background: #e67e22; }

.btn-group button { border-radius: 0; margin-right: -1px; }
.btn-group button:first-child { border-radius: 4px 0 0 4px; }
.btn-group button:last-child { border-radius: 0 4px 4px 0; }
.btn-group button.active { background: #2c3e50; }

/* Tabs */
.tabs { display: flex; border-bottom: 2px solid var(--border-color); margin-bottom: 15px; flex-wrap: wrap; }
.tab-btn { 
    padding: 10px 15px; cursor: pointer; background: transparent; 
    border: 1px solid transparent; border-bottom: none; 
    border-radius: 5px 5px 0 0; color: var(--text-color); 
    font-weight: bold; opacity: 0.7; 
}
.tab-btn.active { 
    background: var(--card-bg); border-bottom: 2px solid var(--card-bg); 
    margin-bottom: -2px; opacity: 1; color: #3498db; 
}
.tab-content { display: none; }
.tab-content.active { display: block; }

/* Tablas Responsive */
.table-container { overflow-x: auto; width: 100%; border: 1px solid var(--border-color); border-radius: 4px; margin-bottom: 20px;}
table { width: 100%; border-collapse: collapse; font-size: 0.85rem; min-width: 600px; }
th, td { padding: 8px; text-align: center; border-bottom: 1px solid var(--border-color); }
th { background: var(--th-bg); color: var(--text-color); position: sticky; top: 0; z-index: 10; }
th.sortable { cursor: pointer; } th.sortable:hover { background: var(--hover-bg); }
tr:hover { background: var(--hover-bg); }
.clickable-row { cursor: pointer; }

/* Colores Resultados */
.res-win { color: #27ae60; font-weight: bold; }
.res-draw { color: #f39c12; font-weight: bold; }
.res-loss { color: #e74c3c; font-weight: bold; }
.bg-win-light { background-color: rgba(39, 174, 96, 0.1) !important; }
.bg-draw-light { background-color: rgba(243, 156, 18, 0.1) !important; }
.bg-lose-light { background-color: rgba(231, 76, 60, 0.1) !important; }

/* Guía de Forma (Form Guide) */
.form-guide { display: inline-flex; gap: 3px; align-items: center;}
.form-badge {
    display: inline-flex; justify-content: center; align-items: center;
    width: 20px; height: 20px; border-radius: 3px;
    font-size: 0.7rem; font-weight: bold; color: white;
}
.form-w { background-color: #27ae60; } /* Verde: Victoria */
.form-d { background-color: #f1c40f; color: #333; } /* Amarillo: Empate */
.form-l { background-color: #e74c3c; } /* Rojo: Derrota */

/* Simulador UI */
.pred-controls { display: inline-flex; align-items: center; justify-content: center; gap: 5px; }
.pred-controls button { padding: 2px 10px; font-size: 1.1rem; background: #7f8c8d; border-radius: 3px; }
.pred-score { font-weight:bold; margin:0 10px; font-size:1.1rem; min-width: 45px; display: inline-block; text-align: center;}
.pred-badge { display: inline-block; padding: 3px 6px; border-radius: 3px; color: white; font-size: 0.75rem; font-weight: bold; }

/* Gráficos */
.charts-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-top: 15px; }
.chart-box { background: var(--bg-color); padding: 15px; border-radius: 8px; border: 1px solid var(--border-color); }
.chart-full-width { grid-column: 1 / -1; }
canvas { max-width: 100%; }

@media (max-width: 768px) {
    .controls { flex-direction: column; align-items: stretch; }
    .tabs { flex-direction: column; border-bottom: none; }
    .tab-btn { margin-bottom: 5px; border: 1px solid var(--border-color); border-radius: 4px; }
    .tab-btn.active { margin-bottom: 5px; border-color: #3498db; }
    .charts-grid { grid-template-columns: 1fr; }
    .chart-full-width { grid-column: 1; }
    .btn-group { display: flex; width: 100%; }
    .btn-group button { flex: 1; }
}

/* Columna de Probabilidades 1X2 */
/* Columna de Probabilidades 1X2 */
.prob-box { 
    flex: 1; /* Asegura que las tres cajas midan exactamente lo mismo */
    padding: 4px 0; 
    border-radius: 4px; 
    font-size: 0.8rem; 
    font-weight: bold; 
    border: 2px solid transparent; 
    text-align: center; 
    color: #333;
    white-space: nowrap; /* Evita que el % se rompa en dos líneas */
}
.prob-1 { background-color: rgba(39, 174, 96, 0.6); }  /* Verde */
.prob-x { background-color: rgba(241, 196, 15, 0.6); } /* Amarillo */
.prob-2 { background-color: rgba(231, 76, 60, 0.6); }  /* Rojo */

.prob-highest { border-color: #000; } /* Borde negro por defecto (modo claro) */
body.dark-mode .prob-highest { border-color: #fff; } /* Borde blanco (modo oscuro) */
body.dark-mode .prob-box { color: #fff; }

/* Resaltar rival en la tabla de jornadas al hacer hover */
tr.highlight-rival {
    background-color: rgba(52, 152, 219, 0.3) !important; 
    outline: 2px solid #3498db;
}
body.dark-mode tr.highlight-rival {
    background-color: rgba(52, 152, 219, 0.5) !important;
}