:root {
    /* --- TEMA DARK (Por defecto) --- */
    --bg-main: radial-gradient(circle at top center, #1a2332 0%, #0d1013 80%);
    --text-main: #e0e6ed;
    --text-title: #ffffff;
    --text-muted: #abb5c2;
    --text-subtitle: rgba(255, 255, 255, 0.55);

    /* Tarjetas */
    --card-bg: rgba(22, 28, 36, 0.85);
    --card-border: rgba(255, 255, 255, 0.08);
    --card-shadow: rgba(0, 0, 0, 0.4);

    /* Colores del Termo / BMS */
    --cold-primary: #00d2ff;
    --cold-glow: rgba(0, 210, 255, 0.4);
    --cold-bg: rgba(0, 210, 255, 0.12);

    --optimal-primary: #2ecc71;
    --optimal-glow: rgba(46, 204, 113, 0.4);
    --optimal-bg: rgba(46, 204, 113, 0.12);

    --warning-primary: #ff9f43;
    --warning-glow: rgba(255, 159, 67, 0.4);
    --warning-bg: rgba(255, 159, 67, 0.12);

    --danger-primary: #ff6b6b;
    --danger-glow: rgba(255, 107, 107, 0.4);
    --danger-bg: rgba(255, 107, 107, 0.12);

    --cyan-primary: #00d2ff;
    --cyan-glow: rgba(0, 210, 255, 0.4);
    --cyan-border: rgba(0, 210, 255, 0.3);
    --cyan-bg: rgba(0, 210, 255, 0.1);

    --separator-color: rgba(255, 255, 255, 0.15);
    --shadow-color: rgba(0, 0, 0, 0.4);
}

[data-theme='light'] {
    /* --- TEMA LIGHT --- */
    --bg-main: linear-gradient(135deg, #f3f6f9 0%, #e5ebf1 100%);
    --text-main: #2c3e50;
    --text-title: #1a252f;
    --text-muted: #5a6b7c;
    --text-subtitle: #7f8c8d;

    /* Tarjetas */
    --card-bg: #ffffff;
    --card-border: rgba(0, 0, 0, 0.12);
    --card-shadow: rgba(0, 0, 0, 0.12);

    /* Colores adaptados a luz */
    --cold-primary: #008ba3;
    --cold-glow: rgba(0, 139, 163, 0.25);
    --cold-bg: rgba(0, 139, 163, 0.08);

    --optimal-primary: #27ae60;
    --optimal-glow: rgba(39, 174, 96, 0.25);
    --optimal-bg: rgba(39, 174, 96, 0.08);

    --warning-primary: #d35400;
    --warning-glow: rgba(211, 84, 0, 0.25);
    --warning-bg: rgba(211, 84, 0, 0.08);

    --danger-primary: #c0392b;
    --danger-glow: rgba(192, 57, 43, 0.25);
    --danger-bg: rgba(192, 57, 43, 0.08);

    --cyan-primary: #0d84a3;
    --cyan-glow: rgba(13, 132, 163, 0.25);
    --cyan-border: rgba(13, 132, 163, 0.35);
    --cyan-bg: rgba(13, 132, 163, 0.08);

    --separator-color: rgba(0, 0, 0, 0.12);
    --shadow-color: rgba(0, 0, 0, 0.12);
}

/* ========== GENERAL ========== */
body {
    background: var(--bg-main) !important;
    color: var(--text-main);
    font-family: 'Outfit', 'Inter', sans-serif;
}

.content-wrapper {
    max-width: 1400px;
    margin: 0 auto;
}

/* ========== THEME TOGGLE (Alineación requerida) ========== */
.theme-toggle {
    position: fixed;
    top: 80px;
    right: 20px;
    width: 45px;
    height: 45px;
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 1000;
    box-shadow: 0 4px 15px var(--shadow-color);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.theme-toggle:hover {
    transform: scale(1.1);
}

.theme-toggle i {
    font-size: 1.25rem;
    color: var(--warning-primary);
}

/* ========== TEXTOS Y LEGIBILIDAD ========== */
.text-white-custom {
    color: var(--text-title) !important;
}

.text-light-custom {
    color: var(--text-main) !important;
}

.text-white-50-custom {
    color: var(--text-subtitle) !important;
}

/* Blindaje de pequeños y mutados */
.text-muted, .small-muted, .small, .form-text {
    color: var(--text-muted) !important;
}

.main-title {
    color: var(--cyan-primary);
    text-shadow: 0 0 20px var(--cyan-glow);
    font-weight: 800;
    letter-spacing: -0.5px;
}

.main-subtitle {
    color: var(--text-subtitle);
}

/* ========== TARJETAS ========== */
.card-clean {
    border: 1px solid var(--card-border);
    border-radius: 1.25rem;
    box-shadow: 0 8px 24px var(--card-shadow);
    background-color: var(--card-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    height: 100%;
    color: var(--text-main);
    transition: transform 0.25s ease, box-shadow 0.25s ease;
}

/* ========== PESTAÑAS (NAVS) ========== */
.nav-tabs-custom {
    border-bottom: 2px solid var(--separator-color);
    margin-bottom: 2rem;
}

.nav-tabs-custom .nav-link {
    color: var(--text-subtitle);
    border: none;
    background: transparent;
    padding: 0.9rem 1.8rem;
    font-weight: 700;
    transition: all 0.2s ease;
    border-bottom: 3px solid transparent;
}

.nav-tabs-custom .nav-link:hover {
    color: var(--text-title);
    border-bottom: 3px solid var(--separator-color);
}

.nav-tabs-custom .nav-link.active {
    color: var(--cyan-primary);
    background: transparent;
    border: none;
    border-bottom: 3px solid var(--cyan-primary);
    text-shadow: 0 0 12px var(--cyan-glow);
}

/* ========== SLIDERS ELEGANTES ========== */
.range-slider-container {
    position: relative;
    padding-bottom: 12px;
}

.custom-range {
    -webkit-appearance: none;
    width: 100%;
    height: 6px;
    border-radius: 3px;
    background: var(--separator-color);
    outline: none;
}

.custom-range::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: var(--cyan-primary);
    cursor: pointer;
    box-shadow: 0 0 12px var(--cyan-glow);
    transition: transform 0.1s ease;
}

.custom-range::-webkit-slider-thumb:hover {
    transform: scale(1.25);
}

.custom-range::-moz-range-thumb {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: var(--cyan-primary);
    cursor: pointer;
    border: none;
    box-shadow: 0 0 12px var(--cyan-glow);
    transition: transform 0.1s ease;
}

.custom-range::-moz-range-thumb:hover {
    transform: scale(1.25);
}

.slider-value-badge {
    background: var(--cyan-bg);
    border: 1px solid var(--cyan-border);
    color: var(--cyan-primary);
    padding: 0.25rem 0.75rem;
    border-radius: 0.5rem;
    font-size: 0.95rem;
    font-weight: 700;
}

/* ========== SWITCH DE PRECALENTAMIENTO ========== */
.custom-switch-container {
    background: rgba(0, 0, 0, 0.25);
    border: 1px solid var(--card-border);
    padding: 1rem;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.custom-switch-label {
    font-weight: 700;
    font-size: 0.95rem;
}

.switch-toggle {
    position: relative;
    display: inline-block;
    width: 52px;
    height: 28px;
}

.switch-toggle input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider-switch {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: var(--separator-color);
    transition: .3s;
    border-radius: 34px;
}

.slider-switch:before {
    position: absolute;
    content: "";
    height: 20px;
    width: 20px;
    left: 4px;
    bottom: 4px;
    background-color: white;
    transition: .3s;
    border-radius: 50%;
}

input:checked + .slider-switch {
    background-color: var(--cyan-primary);
    box-shadow: 0 0 8px var(--cyan-glow);
}

input:checked + .slider-switch:before {
    transform: translateX(24px);
}

/* ========== TERMÓMETRO VISUAL ========== */
.thermometer-container {
    display: flex;
    align-items: center;
    gap: 20px;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 16px;
    padding: 1.5rem;
    border: 1px solid rgba(255, 255, 255, 0.05);
    margin-bottom: 1.5rem;
}

.thermo-gauge-wrapper {
    width: 24px;
    height: 180px;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 12px;
    position: relative;
    border: 1px solid var(--card-border);
    overflow: hidden;
}

.thermo-fill {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 50%; /* Dinámico */
    background: linear-gradient(to top, var(--cold-primary), var(--optimal-primary));
    transition: height 0.6s cubic-bezier(0.4, 0, 0.2, 1), background 0.6s ease;
    border-radius: 0 0 12px 12px;
}

.thermo-labels {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    height: 180px;
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--text-subtitle);
}

.thermo-label-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px dashed rgba(255, 255, 255, 0.05);
    padding-bottom: 2px;
}

/* ========== DISPLAYS ========== */
.display-result-wrapper {
    text-align: center;
    padding: 1.25rem;
    background: rgba(0,0,0,0.18);
    border-radius: 12px;
    border: 1px solid var(--card-border);
    transition: all 0.3s ease;
}

.display-result {
    font-size: 2.4rem;
    font-weight: 800;
    margin-bottom: 2px;
    line-height: 1.2;
    transition: color 0.3s ease, text-shadow 0.3s ease;
}

.display-label {
    font-size: 0.8rem;
    color: var(--text-subtitle);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1.2px;
}

/* ========== DIAGNÓSTICOS BMS ========== */
.diagnostic-alert {
    border-radius: 14px;
    padding: 1.25rem 1.5rem;
    margin-bottom: 1.5rem;
    border-left: 5px solid transparent;
    display: flex;
    align-items: flex-start;
    animation: fadeIn 0.4s ease-out;
}

.diagnostic-alert i {
    font-size: 1.7rem;
    margin-right: 15px;
    margin-top: 3px;
}

.diagnostic-alert h5 {
    font-weight: 800;
    margin-bottom: 6px;
    font-size: 1.1rem;
}

.diagnostic-alert p {
    margin-bottom: 0;
    font-size: 0.92rem;
    line-height: 1.55;
}

/* Clases de estado BMS */
.status-cold {
    background: var(--cold-bg);
    border: 1px solid rgba(0, 210, 255, 0.25);
    border-left: 5px solid var(--cold-primary);
    color: var(--text-main);
}
.status-cold i, .status-cold h5 { color: var(--cold-primary); }

.status-optimal {
    background: var(--optimal-bg);
    border: 1px solid rgba(46, 204, 113, 0.25);
    border-left: 5px solid var(--optimal-primary);
    color: var(--text-main);
}
.status-optimal i, .status-optimal h5 { color: var(--optimal-primary); }

.status-warning {
    background: var(--warning-bg);
    border: 1px solid rgba(255, 159, 67, 0.25);
    border-left: 5px solid var(--warning-primary);
    color: var(--text-main);
}
.status-warning i, .status-warning h5 { color: var(--warning-primary); }

.status-danger {
    background: var(--danger-bg);
    border: 1px solid rgba(255, 107, 107, 0.25);
    border-left: 5px solid var(--danger-primary);
    color: var(--text-main);
}
.status-danger i, .status-danger h5 { color: var(--danger-primary); }

/* ========== GRÁFICAS ========== */
.chart-container {
    position: relative;
    width: 100%;
    height: 320px;
}

/* ========== SECCIÓN DE FÍSICA ========== */
.physics-intro-card {
    border-bottom: 3px solid var(--cyan-primary);
    margin-bottom: 2rem;
}

.theory-block {
    padding: 1.5rem;
    border-radius: 14px;
    height: 100%;
    border: 1px solid var(--card-border);
    background: rgba(0, 0, 0, 0.15);
    transition: transform 0.25s ease;
}

.theory-block:hover {
    transform: translateY(-4px);
}

.theory-block i {
    font-size: 2rem;
    margin-bottom: 12px;
}

.theory-block h5 {
    font-weight: 800;
    margin-bottom: 10px;
    font-size: 1.15rem;
}

.theory-block p {
    font-size: 0.9rem;
    line-height: 1.6;
    margin-bottom: 0;
}

.block-blue i, .block-blue h5 { color: var(--cold-primary); }
.block-red i, .block-red h5 { color: var(--danger-primary); }
.block-green i, .block-green h5 { color: var(--optimal-primary); }
.block-purple i, .block-purple h5 { color: #a55eea; }

/* ========== ANIMACIONES ========== */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(12px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ========== RESPONSIVE ========== */
@media (max-width: 991px) {
    .theme-toggle {
        top: auto;
        bottom: 20px;
        right: 20px;
    }
    .thermometer-container {
        padding: 1rem;
    }
    .display-result {
        font-size: 2rem;
    }
}
