@import url('https://fonts.googleapis.com/css2?family=Orbitron:wght@400;700;900&family=Plus+Jakarta+Sans:wght@300;400;600;800&display=swap');

/* TEMAS DE COLOR DINÁMICOS */
:root {
    --primary: #ff4500; 
    --primary-glow: rgba(255, 69, 0, 0.3);
    --bg: #080808;
    --card-bg: #111;
    --glass-border: rgba(255, 255, 255, 0.1);
    --text-main: #ffffff;
    --text-dim: #888;
}

/* Variaciones de temas */
[data-theme="violeta-cyberpunk"] { --primary: #9d00ff; --primary-glow: rgba(157, 0, 255, 0.3); --bg: #0a0011; --card-bg: #150022; }
[data-theme="matrix"] { --primary: #00ff00; --primary-glow: rgba(0, 255, 0, 0.3); }
[data-theme="neon"] { --primary: #00ffff; --primary-glow: rgba(0, 255, 255, 0.3); --bg: #001a1a; --card-bg: #003333; }
body { font-family: 'Plus Jakarta Sans', sans-serif; background: radial-gradient(circle at top right, #1a1a1a, var(--bg)); color: var(--text-main); margin: 0; height: 100dvh; display: flex; overflow: hidden; transition: background 0.8s ease; }
* { transition: border-color 0.3s ease, box-shadow 0.3s ease, color 0.3s ease, background-color 0.3s ease; }

@keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
.fade-in { animation: fadeIn 0.4s ease forwards; }

/* NAVEGACIÓN (ESCRITORIO) */
aside { width: 260px; background: rgba(0,0,0,0.6); border-right: 1px solid var(--glass-border); display: flex; flex-direction: column; padding: 40px 20px; z-index: 10; backdrop-filter: blur(10px); }

.user-profile-mini { display: flex; align-items: center; gap: 15px; margin-bottom: 40px; padding: 15px; background: rgba(255,255,255,0.02); border-radius: 15px; border: 1px solid var(--glass-border); }
.user-profile-mini img { width: 55px; height: 55px; border-radius: 50%; object-fit: cover; border: 2px solid var(--primary); }

.nav-item { padding: 18px 15px; margin-bottom: 12px; border-radius: 12px; color: var(--text-dim); cursor: pointer; border: none; background: transparent; display: flex; align-items: center; gap: 12px; font-weight: 600; width: 100%; text-align: left; font-size: 1rem;}
.nav-item:hover { color: var(--primary); background: rgba(255,255,255,0.05); }
.nav-item.active { color: #fff; background: var(--primary-glow); border-left: 4px solid var(--primary); }

main { flex: 1; padding: 60px; overflow-y: auto; scroll-behavior: smooth; -webkit-overflow-scrolling: touch; }

.scroll-x-hidden::-webkit-scrollbar { display: none; }

/* TARJETAS Y GRID */
.dashboard-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 25px; margin-top: 20px; }
.stat-card { background: var(--card-bg); border: 1px solid var(--glass-border); border-radius: 30px; padding: 40px 20px; text-align: center; cursor: pointer; display: flex; flex-direction: column; align-items: center; justify-content: center; height: 100%; box-sizing: border-box; }
.stat-card:hover { transform: translateY(-10px); border-color: var(--primary); box-shadow: 0 15px 40px var(--primary-glow); }
.stat-card h3 { font-family: 'Orbitron'; font-size: 1.2rem; text-transform: uppercase; margin: 15px 0 5px 0; }
.pr-number { font-family: 'Orbitron'; font-size: 2.2rem; color: #fff; display: block; margin-top: 5px; }

.add-pr-card { border: 2px dashed var(--glass-border); background: transparent; }
.add-pr-card:hover { border-color: var(--primary); background: rgba(255,255,255,0.02); }
.add-pr-card i { font-size: 3rem; color: var(--text-dim); margin-bottom: 15px; transition: 0.3s; }
.add-pr-card:hover i { color: var(--primary); transform: scale(1.2) rotate(90deg); }

.pr-card-wrapper { position: relative; height: 100%; }
.btn-remove-pr { position: absolute; top: 15px; right: 15px; background: rgba(255,0,0,0.1); border: 1px solid rgba(255,0,0,0.3); color: #ff4444; border-radius: 50%; width: 40px; height: 40px; cursor: pointer; display: flex; align-items: center; justify-content: center; z-index: 5; transition: 0.2s; font-size: 1.2rem;}
.btn-remove-pr:hover { background: #ff4444; color: white; border-color: #ff4444; transform: scale(1.1); }

.routine-card { background: #050505; border: 3px solid var(--primary); border-radius: 16px; padding: 10px; text-align: center; cursor: pointer; box-shadow: 0 0 25px var(--primary-glow); display: flex; flex-direction: column; }
.routine-card:hover { transform: translateY(-5px); box-shadow: 0 0 40px var(--primary-glow); }
.routine-card img { width: 100%; height: 350px; object-fit: cover; border-radius: 8px; filter: grayscale(20%); transition: 0.3s; }
.routine-card:hover img { filter: grayscale(0%); }
.routine-card h3 { font-family: 'Orbitron'; font-size: 1.2rem; text-transform: uppercase; margin: 20px 0 10px 0; color: #ffffff; }

/* SISTEMA XP / MEDALLAS / OBJETIVO */
.header-panel { display: flex; gap: 25px; flex-wrap: wrap; margin-bottom: 30px; }
.panel-box { background: var(--card-bg); padding: 25px; border-radius: 24px; border: 1px solid var(--glass-border); flex: 1; min-width: 250px; }
.xp-bar-bg { width: 100%; height: 12px; background: #222; border-radius: 6px; margin-top: 10px; overflow: hidden; }
.xp-bar-fill { height: 100%; background: var(--primary); width: 0%; box-shadow: 0 0 10px var(--primary); transition: width 0.8s cubic-bezier(0.4, 0, 0.2, 1); }

.badges-container { display: flex; gap: 15px; margin-top: 20px; flex-wrap: wrap; }
.badge { background: #1a1a1a; border: 1px solid #333; border-radius: 15px; padding: 15px; text-align: center; flex: 1; min-width: 100px; opacity: 0.4; filter: grayscale(100%); transition: 0.5s; cursor: pointer; }
.badge.unlocked { opacity: 1; filter: grayscale(0%); border-color: var(--primary); box-shadow: 0 0 15px var(--primary-glow); }
.badge i { font-size: 2rem; color: var(--primary); margin-bottom: 10px; }
.badge span { display: block; font-family: 'Orbitron'; font-size: 0.75rem; font-weight: bold; text-transform: uppercase; }
.badge-desc { display: none; font-family: 'Plus Jakarta Sans', sans-serif; font-size: 0.8rem; color: #aaa; margin-top: 15px; line-height: 1.4; }
.badge.show-info .badge-desc { display: block; animation: fadeIn 0.3s ease; }

/* CALENDARIO MENSUAL */
.calendar-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; margin-top: 15px; }
.cal-day-header { text-align: center; font-size: 0.7rem; color: var(--text-dim); font-weight: bold; font-family: 'Orbitron'; margin-bottom: 5px; }
.cal-box { aspect-ratio: 1; border-radius: 8px; background: rgba(255,255,255,0.03); border: 1px solid rgba(255,255,255,0.05); display: flex; align-items: center; justify-content: center; font-size: 0.9rem; color: #666; cursor: pointer; transition: 0.2s; font-weight: 600; }
.cal-box:hover:not(.cal-empty) { transform: scale(1.1); z-index: 10; border-color: var(--primary); color: #fff; }
.cal-empty { background: transparent; border: none; cursor: default; }
.cal-1 { background: var(--primary); opacity: 0.4; color: #fff; border: none; }
.cal-2 { background: var(--primary); opacity: 0.7; color: #fff; border: none; }
.cal-3 { background: var(--primary); opacity: 1; color: #fff; font-weight: 800; box-shadow: 0 0 10px var(--primary); border: none; }

/* Modificamos cal-box añadiendo box-sizing para que los bordes no rompan el grid */
.cal-box { 
    aspect-ratio: 1; 
    border-radius: 8px; 
    background: rgba(255,255,255,0.03); 
    border: 1px solid rgba(255,255,255,0.05); 
    display: flex; 
    align-items: center; 
    justify-content: center; 
    font-size: 0.9rem; 
    color: #666; 
    cursor: pointer; 
    transition: 0.2s; 
    font-weight: 600; 
    box-sizing: border-box; /* MAGIA: El borde crece hacia adentro */
}

.cal-box:hover:not(.cal-empty) { transform: scale(1.1); z-index: 10; border-color: var(--primary); color: #fff; }
.cal-empty { background: transparent; border: none; cursor: default; }
.cal-1 { background: var(--primary); opacity: 0.4; color: #fff; border: none; }
.cal-2 { background: var(--primary); opacity: 0.7; color: #fff; border: none; }
.cal-3 { background: var(--primary); opacity: 1; color: #fff; font-weight: 800; box-shadow: 0 0 10px var(--primary); border: none; }


/* FORMULARIOS Y BOTONES */
.input-group { display: flex; flex-direction: column; gap: 8px; transition: 0.3s; width: 100%; box-sizing: border-box;}
.input-group label { font-family: 'Orbitron'; font-size: 0.75rem; color: var(--primary); font-weight: 900; letter-spacing: 1px; white-space: nowrap; }
.input-group input, .input-group select { background: #1a1a1a; border: 1px solid var(--glass-border); color: #fff; padding: 18px; border-radius: 12px; text-align: center; font-family: 'Orbitron'; width: 100%; box-sizing: border-box; font-size: 1.1rem;}
.input-group input[type="text"] { text-align: left; font-family: 'Plus Jakarta Sans'; }

.btn-save { background: var(--primary); color: white; border: none; padding: 18px 30px; border-radius: 12px; font-weight: 900; font-family: 'Orbitron'; cursor: pointer; text-transform: uppercase; transition: 0.2s; font-size: 1.1rem;}
.btn-save:active { transform: scale(0.95); }
.btn-save:hover { box-shadow: 0 0 20px var(--primary-glow); }
.file-upload-btn { background: #1a1a1a; border: 2px dashed var(--primary); color: var(--primary); padding: 18px; border-radius: 12px; text-align: center; cursor: pointer; font-family: 'Orbitron'; font-weight: 700; transition: 0.3s; display: block; font-size: 1.1rem;}
.file-upload-btn:hover { background: var(--primary-glow); color: white; border-style: solid; }

/* ENTRENAMIENTO Y LOGS */
.training-window { max-width: 900px; margin: 0 auto; position: relative; }
.info-box { background: var(--card-bg); padding: 40px; border-radius: 30px; border: 1px solid var(--glass-border); margin-bottom: 25px; }

.log-container {
    background: var(--primary-glow);
    padding: 30px;
    border-radius: 24px;
    border: 1px solid var(--primary);
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 15px;
    align-items: end;
}
.col-span-1 { grid-column: span 1; }
.col-span-2 { grid-column: span 2; }
.col-span-4 { grid-column: span 4; }

.btn-fullscreen { position: absolute; top: 0; right: 0; background: none; border: 1px solid var(--primary); color: var(--primary); padding: 12px 18px; border-radius: 8px; cursor: pointer; font-family: 'Orbitron'; font-size: 0.9rem;}
.btn-fullscreen:hover { background: var(--primary); color: white; }

/* TEMPORIZADOR Y CÍRCULO SVG */
.timer-box { background: #1a1a1a; border: 1px solid var(--glass-border); padding: 25px 15px; border-radius: 15px; text-align: center; margin-top: 20px; }
.timer-btn { background: #333; color: white; border: none; padding: 12px 18px; border-radius: 8px; cursor: pointer; margin: 0 5px; font-size:1rem; font-weight:bold;}
.timer-btn:hover { background: var(--primary); }

.circular-timer-container { position: relative; width: 140px; height: 140px; margin: 0 auto; }
.circular-timer-svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.timer-circle-bg { fill: none; stroke: #222; stroke-width: 6; }
.timer-circle-progress { 
    fill: none; 
    stroke: var(--primary); 
    stroke-width: 6; 
    stroke-linecap: round; 
    stroke-dasharray: 283; 
    stroke-dashoffset: 0; 
    transition: stroke-dashoffset 1s linear, stroke 0.3s ease; 
}
.timer-display-overlay { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); font-family: 'Orbitron'; font-size: 2.2rem; color: var(--primary); text-shadow: 0 0 10px var(--primary-glow); font-weight: 700; transition: 0.3s; }

/* TABLA HISTORIAL MODO SESIÓN */
.session-card { background: rgba(255,255,255,0.02); border: 1px solid var(--glass-border); border-radius: 20px; margin-bottom: 25px; overflow: hidden; box-shadow: 0 10px 30px rgba(0,0,0,0.3); }
.session-header { background: var(--primary-glow); padding: 15px 25px; border-bottom: 1px solid var(--primary); display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 10px;}
.session-title { margin: 0; font-family: 'Orbitron'; color: #fff; font-size: 1.2rem; text-transform: uppercase; }
.session-badge { background: var(--primary); color: #fff; padding: 5px 12px; border-radius: 8px; font-weight: 800; font-size: 0.8rem; font-family: 'Orbitron'; }
.session-body { padding: 20px 25px; }

.ex-group-title { color: var(--primary); font-family: 'Orbitron'; margin: 15px 0 10px 0; font-size: 1.2rem; border-bottom: 1px solid #333; padding-bottom: 5px;}
.set-row { display: flex; justify-content: space-between; align-items: center; padding: 15px 0; border-bottom: 1px dashed rgba(255,255,255,0.1); flex-wrap: wrap; gap: 10px;}
.set-info { display: flex; gap: 15px; align-items: center; flex-wrap: wrap; font-size: 1rem; }

.action-btn { background: none; border: none; cursor: pointer; padding: 10px; border-radius: 5px; margin-right: 5px; transition: 0.2s; font-size: 1.2rem;}
.edit-btn { color: #4CAF50; } .edit-btn:hover { background: rgba(76, 175, 80, 0.2); }
.del-btn { color: #f44336; } .del-btn:hover { background: rgba(244, 67, 54, 0.2); }

/* NOTIFICACIONES */
#toast-container { position: fixed; bottom: 30px; right: 30px; z-index: 9999; display: flex; flex-direction: column; gap: 10px; }
.toast { background: rgba(17,17,17,0.95); border-left: 5px solid var(--primary); padding: 15px 25px; border-radius: 12px; color: white; font-family: 'Orbitron'; font-size: 1rem; box-shadow: 0 5px 15px rgba(0,0,0,0.5); animation: fadeIn 0.3s ease; }

/* MODALES Y LOGIN */
#auth-screen, .modal-overlay { position: fixed; inset: 0; z-index: 2000; display: flex; align-items: center; justify-content: center; background: rgba(0,0,0,0.85); backdrop-filter: blur(5px); }
.auth-card { 
    background: var(--card-bg); 
    padding: 40px; 
    border-radius: 30px; 
    border: 1px solid var(--glass-border); 
    width: 380px; 
    text-align: center; 
    box-shadow: 0 20px 50px rgba(0,0,0,0.5); 
    max-height: 85dvh; /* Le damos un límite de altura para móviles */
    overflow-y: auto;  /* Habilitamos la barra de scroll interna */
}

.auth-card input, .auth-card select { 
    width: 100%; 
    box-sizing: border-box; 
    margin-bottom: 15px; 
    background: #1a1a1a; 
    border: 1px solid var(--glass-border); 
    color: #fff; 
    padding: 18px; 
    border-radius: 12px; 
    font-size: 1.1rem; 
}#app-layout { display: none; width: 100%; height: 100dvh; }

/* HISTORIAL DE PESO CORPORAL */
.weight-history-container { border-top: 1px solid var(--glass-border); padding-top: 20px; margin-top: 10px; }
.weight-history-container label { display: block; font-family: 'Orbitron'; font-size: 0.8rem; color: var(--primary); font-weight: 900; letter-spacing: 1px; margin-bottom: 10px; }
.weight-list { list-style: none; padding: 0; margin: 0; }
.weight-list li { display: flex; justify-content: space-between; padding: 12px 0; border-bottom: 1px dashed rgba(255,255,255,0.1); font-size: 0.95rem; color: var(--text-dim); }
.weight-list li .weight-val { font-weight: bold; color: #fff; }

/* SKELETON LOADER ANIMADO */
.skeleton-card {
    background: rgba(255,255,255,0.02);
    border: 1px solid var(--glass-border);
    border-radius: 20px;
    margin-bottom: 25px;
    padding: 15px 25px;
    animation: skeleton-pulse 1.5s infinite ease-in-out;
}
.skeleton-header {
    height: 20px;
    width: 30%;
    background: rgba(255,255,255,0.05);
    border-radius: 8px;
    margin-bottom: 20px;
}
.skeleton-row {
    height: 40px;
    width: 100%;
    background: rgba(255,255,255,0.05);
    border-radius: 8px;
    margin-bottom: 10px;
}
@keyframes skeleton-pulse {
    0% { opacity: 0.4; }
    50% { opacity: 1; }
    100% { opacity: 0.4; }
}

/* =========================================
   HISTORIAL DESPLEGABLE POR FECHAS
   ========================================= */
details.history-day {
    background: var(--card-bg);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    margin-bottom: 12px;
    overflow: hidden;
    transition: all 0.3s ease;
}

details.history-day summary {
    padding: 15px;
    font-family: 'Orbitron', sans-serif;
    font-size: 1rem;
    font-weight: bold;
    color: var(--primary);
    cursor: pointer;
    list-style: none; 
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(255, 255, 255, 0.02);
}

details.history-day summary::-webkit-details-marker {
    display: none;
}

details.history-day summary:after {
    content: '\f078';
    font-family: 'Font Awesome 6 Free';
    font-weight: 900;
    color: var(--text-dim);
    transition: transform 0.3s ease;
}

details[open].history-day summary:after {
    transform: rotate(180deg);
    color: var(--primary);
}

.history-day-content {
    padding: 10px 15px;
    border-top: 1px solid var(--glass-border);
    display: flex;
    flex-direction: column;
    gap: 10px;
    background: rgba(0, 0, 0, 0.2);
}

.history-day-content .history-card {
    background: transparent;
    border: none;
    border-bottom: 1px dashed rgba(255,255,255,0.1);
    border-radius: 0;
    padding: 10px 0;
    margin: 0;
}

.history-day-content .history-card:last-child {
    border-bottom: none;
}

/* =========================================================
   📱 MÓVIL: BARRA INFERIOR (NAVEGACIÓN) + BARRA SUPERIOR DESLIZABLE (FIJA A 60PX)
   ========================================================= */
/* =========================================================
   📱 MÓVIL: LA SOLUCIÓN DEFINITIVA (BARRA ARRIBA Y ABAJO)
   ========================================================= */
/* =========================================================
   📱 MÓVIL: BARRA INFERIOR (4 items) + MENÚ LATERAL
   ========================================================= */

/* Ocultar la barra inferior si estás en ordenador */
.mobile-bottom-nav {
    display: none;
}

/* =========================================
   📱 MENÚ LATERAL (SIDEBAR) Y OVERLAY
   ========================================= */
#sidebar {
    position: fixed;
    top: 0;
    left: -300px; /* Escondido */
    width: 260px;
    height: 100vh;
    background-color: #0a0a0a;
    border-right: 1px solid var(--primary);
    z-index: 10000; /* <-- MUY ALTO para estar por encima de todo */
    transition: left 0.3s ease-in-out;
    padding: 20px;
    box-sizing: border-box;
    display: block !important; /* Aseguramos que sea visible al deslizar */
}

#sidebar.active {
    left: 0; /* Se desliza hacia adentro */
}

#sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(3px);
    z-index: 9999; /* <-- JUSTO DEBAJO del sidebar (10000 - 1) */
}

#sidebar-overlay.active {
    display: block; /* Ahora coincide con el .toggle('active') de tu JS */
}

/* Estilo para los textos dentro del menú */
.nav-items {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 20px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 12px 15px;
    color: #ffffff; /* Forzamos color blanco para que se vea */
    text-decoration: none;
    border-radius: 8px;
}

#sidebar {
    z-index: 10000 !important; /* El valor más alto para que esté arriba */
    background-color: #0a0a0a;
    /* ... resto de tus estilos ... */
}

#sidebar-overlay {
    z-index: 9999 !important; /* Un nivel por debajo del sidebar */
}

/* Estilo para los textos blancos del menú */
.nav-item span {
    color: #ffffff;
}

/* =========================================
   📱 BARRA DE NAVEGACIÓN INFERIOR (MÓVIL)
   ========================================= */
.mobile-bottom-nav {
    display: none;
}

/* =========================================================
   📱 MÓVIL: LA SOLUCIÓN DEFINITIVA (MAESTRO)
   ========================================================= */
/* =========================================================
   📱 MÓVIL: LA SOLUCIÓN DEFINITIVA (MAESTRO FINAL)
   ========================================================= */
@media (max-width: 768px) {

    /* 1. BARRA INFERIOR */
    .mobile-bottom-nav {
        display: flex;
        flex-direction: row;
        justify-content: space-around;
        align-items: center;
        position: fixed;
        bottom: 0;
        left: 0;
        width: 100%;
        height: 70px;
        background-color: var(--card-bg);
        border-top: 1px solid var(--glass-border);
        z-index: 5000;
        padding-bottom: env(safe-area-inset-bottom);
    }

    .mobile-bottom-nav .nav-item {
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        color: var(--text-dim);
        font-size: 0.75rem;
        font-family: 'Plus Jakarta Sans', sans-serif;
        font-weight: 600;
        flex: 1;
        height: 100%;
        transition: all 0.3s ease;
        cursor: pointer;
        background: transparent;
        border: none;
        padding: 0; margin: 0; width: auto; border-radius: 0; gap: 0; 
    }

    .mobile-bottom-nav .nav-item i { font-size: 1.3rem; margin-bottom: 4px; }

    .mobile-bottom-nav .nav-item.active,
    .mobile-bottom-nav .nav-item.active i {
        color: var(--primary);
        background: transparent;
        border: none;
    }

    /* 2. CABECERA SUPERIOR (Header) */
    .mobile-header.desktop-hide {
        display: flex !important;
        justify-content: space-between;
        align-items: center;
        padding: 10px 20px;
        background: rgba(17, 17, 17, 0.75);
        backdrop-filter: blur(12px);
        border-bottom: 1px solid var(--glass-border);
        position: sticky;
        top: 0;
        z-index: 1000;
        margin: 0 -20px 20px -20px;
    }

    .menu-btn {
        background: rgba(255, 255, 255, 0.05);
        border: 1px solid var(--glass-border);
        color: var(--text-main);
        width: 45px; height: 45px; border-radius: 12px;
        display: flex; align-items: center; justify-content: center;
    }

    .mobile-header-title {
        font-family: 'Orbitron', sans-serif;
        font-size: 1.1rem;
        color: var(--primary);
        letter-spacing: 2px;
    }

    /* 3. MENÚ LATERAL (Sidebar Mobile) */
    #sidebar {
        position: fixed; top: 0; left: -280px; width: 260px; height: 100vh;
        background-color: #0a0a0a; border-right: 2px solid var(--primary);
        z-index: 9999; transition: all 0.3s ease; visibility: hidden;
    }
    #sidebar.active { left: 0; visibility: visible; }
    #sidebar-overlay {
        position: fixed; top: 0; left: 0; width: 100%; height: 100%;
        background: rgba(0, 0, 0, 0.8); backdrop-filter: blur(4px);
        z-index: 9998; display: none;
    }
    #sidebar-overlay.active { display: block; }

    /* 4. AJUSTES DE ESPACIO Y SCROLL (Precisión al milímetro) */
    main { 
        padding: 20px 20px 0 20px !important; 
    }
    
    .section {
        /* Exactamente los 70px de tu barra + 20px de respiro. Cero huecos gigantes. */
        padding-bottom: 90px !important; 
    }

    /* 5. ARREGLO PLAYLIST DE RUTINA (Playlist Fix) */
    .log-container {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 10px !important; padding: 15px !important;
    }
    .col-span-1 { grid-column: span 1 !important; }
    .col-span-4 { grid-column: span 2 !important; }

    .input-group label {
        font-size: 0.65rem !important;
        white-space: normal !important;
    }
    .input-group input {
        padding: 12px !important;
        font-size: 1rem !important;
        height: 50px !important;
    }
    .log-container .btn-save {
        margin-top: 5px !important;
        padding: 15px !important;
        font-size: 0.9rem !important;
    }

    /* 6. AVATARES: FORZAR 3 POR LÍNEA EN MÓVIL */
    .avatar-grid {
        display: grid !important;
        grid-template-columns: repeat(3, 1fr) !important; 
        gap: 12px !important; 
        justify-items: center !important;
    }
    
    .avatar-option, .avatar-item {
        width: 70px !important; 
        height: 70px !important;
    }
}

/* =========================================
   📱 MENÚ LATERAL (SIDEBAR) Y OVERLAY
   ========================================= */
#sidebar {
    position: fixed;
    top: 0;
    left: -280px;
    width: 260px;
    height: 100vh;
    background-color: #0a0a0a;
    border-right: 2px solid var(--primary);
    z-index: 9999;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    padding: 20px;
    box-sizing: border-box;
    visibility: hidden;
}

#sidebar.active {
    left: 0;
    visibility: visible;
    box-shadow: 10px 0 30px rgba(0,0,0,0.5);
}

#sidebar-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(4px);
    z-index: 9998;
    display: none;
}

#sidebar-overlay.active {
    display: block;
}

/* =========================================
   📱 CABECERA MÓVIL PROFESIONAL (TOP BAR)
   ========================================= */
.mobile-header {
    display: none; /* Oculto por defecto en escritorio */
}

/* Ocultar elementos en escritorio explícitamente */
@media (min-width: 769px) {
    .desktop-hide {
        display: none !important;
    }
}

@media (max-width: 768px) {
    /* Mostrar cabecera en móvil */
    .mobile-header.desktop-hide {
        display: flex !important;
        justify-content: space-between;
        align-items: center;
        padding: 10px 20px;
        background: rgba(17, 17, 17, 0.75); /* Transparente oscuro */
        backdrop-filter: blur(12px); /* Efecto cristal (Glassmorphism) */
        border-bottom: 1px solid var(--glass-border);
        position: sticky;
        top: 0;
        z-index: 1000;
        margin-bottom: 20px;
        margin-left: -20px; /* Para contrarrestar el padding del main si lo tiene */
        margin-right: -20px;
    }

    /* Diseño del botón del menú */
    .menu-btn {
        background: rgba(255, 255, 255, 0.05);
        border: 1px solid var(--glass-border);
        color: var(--text-main);
        font-size: 1.3rem;
        cursor: pointer;
        width: 45px;
        height: 45px;
        border-radius: 12px;
        display: flex;
        align-items: center;
        justify-content: center;
        transition: all 0.2s ease-in-out;
        box-shadow: 0 4px 6px rgba(0,0,0,0.3);
    }

    .menu-btn:hover, .menu-btn:active {
        background: var(--primary-glow);
        color: var(--primary);
        border-color: var(--primary);
        transform: scale(0.92);
    }

    /* Título centrado en la barra superior */
    .mobile-header-title {
        font-family: 'Orbitron', sans-serif;
        font-size: 1.1rem;
        color: var(--primary);
        margin: 0;
        text-shadow: 0 0 10px var(--primary-glow);
        letter-spacing: 2px;
    }

    /* Ajustamos el padding del main en móvil para que respire mejor */
    main {
        padding: 0 20px 70px 20px !important; 
    }
    /* Forzamos el espacio vacío al final de cada pantalla para que la barra no tape nada */
    .section {
        padding-bottom: 70px !important; 
    }
}

/* =========================================
   🖥️ ESCRITORIO: FORZAR SIDEBAR FIJO A LA IZQUIERDA
   ========================================= */
@media (min-width: 769px) {
    #sidebar {
        position: relative !important;
        left: 0 !important;
        visibility: visible !important;
        z-index: 10 !important;
        border-right: 1px solid var(--glass-border) !important;
        box-shadow: none !important;
        display: flex !important;
        background: rgba(0,0,0,0.6) !important;
        backdrop-filter: blur(10px) !important;
    }
    
    #sidebar-overlay {
        display: none !important;
    }
}

.avatar-grid {
    display: flex;
    gap: 15px;
    flex-wrap: wrap;
    justify-content: center;
    margin-bottom: 20px;
}

.avatar-option {
    width: 65px;
    height: 65px;
    border-radius: 50%;
    cursor: pointer;
    border: 3px solid transparent;
    transition: all 0.3s ease;
    background-color: rgba(255, 255, 255, 0.05);
}

.avatar-option:hover {
    transform: scale(1.1);
}

.avatar-option.selected {
    border-color: var(--primary); /* Usará tu color verde/naranja */
    transform: scale(1.15);
    box-shadow: 0 0 15px var(--primary-glow, rgba(0, 255, 0, 0.5));
}

/* Contenedor de los avatares */
.avatar-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    justify-content: center;
    margin-top: 15px;
}

/* Cada avatar individual */
.avatar-item {
    width: 80px;      /* Tamaño perfecto para un botón de avatar */
    height: 80px;
    border-radius: 50%; /* Los hace redondos */
    cursor: pointer;
    border: 2px solid transparent; /* Borde invisible por defecto */
    transition: transform 0.2s, border-color 0.2s;
}

/* Efecto al pasar el ratón por encima */
.avatar-item:hover {
    transform: scale(1.1); /* Se hace un pelín más grande */
    border-color: #ff4500; /* Borde naranja Elite Coach */
}

/* Si la imagen principal de tu perfil también se ve gigante, usa esto: */
.foto-perfil-display {
    max-width: 150px;
    max-height: 150px;
    border-radius: 50%;
    object-fit: cover;
}

@media (min-width: 768px) {
    /* ... (lo del body y main lo dejamos igual, que centra la app perfecto) ... */

    /* ELIMINAMOS LA BARRA DEL MÓVIL EN PC (Porque ya tienes el Sidebar) */
    .mobile-bottom-nav, #bottom-nav {
        display: none !important;
    }

    /* ... (lo de los inputs déjalo igual) ... */
}

/* Día actual destacado (CORREGIDO) */
.cal-today {
    background: var(--primary-glow) !important;
    box-shadow: inset 0 0 0 2px var(--primary), 0 0 15px var(--primary-glow) !important;
    border: none !important;
    color: #fff !important;
    font-weight: 900 !important;
    transform: none !important; /* Anulamos el efecto gigante */
    z-index: 10 !important;
}

/* ==========================================
   📸 PLANTILLA DE HISTORIA PREMIUM (INSTAGRAM)
   ========================================== */
#story-share-template {
    width: 1080px; height: 1920px;
    position: fixed; top: 0; left: -2000px; /* Escondida fuera de la pantalla */
    display: none; flex-direction: column; align-items: center; justify-content: space-between;
    padding: 80px 50px; box-sizing: border-box;
    font-family: 'Orbitron', 'Inter', sans-serif !important; /* Fuente técnica/deportiva */
    
    /* Fondo con degradado profundo y textura sutil */
    background: radial-gradient(circle at center, #1a1a1a 0%, #080808 100%);
    overflow: hidden;
    border: 5px solid rgba(255,255,255,0.03); /* Borde sutil */
}

/* Efecto de líneas de escaneo de fondo (Muy sutil) */
#story-share-template::before {
    content: ""; position: absolute; top: 0; left: 0; width: 100%; height: 100%;
    background: linear-gradient(rgba(18, 18, 18, 0) 50%, rgba(0, 0, 0, 0.25) 50%);
    background-size: 100% 8px; z-index: 1; pointer-events: none; opacity: 0.3;
}

/* --- SECCIÓN SUPERIOR: PERFIL --- */
#story-share-template .story-header {
    display: flex; flex-direction: column; align-items: center; gap: 25px;
    z-index: 2; width: 100%;
}
#story-share-template .story-avatar {
    width: 220px; height: 220px;
    border-radius: 50%;
    border: 8px solid var(--primary);
    box-shadow: 0 0 40px var(--primary-glow);
    object-fit: cover;
}
#story-share-template #story-template-alias {
    font-size: 5rem; font-weight: 900; color: #fff;
    text-transform: uppercase; letter-spacing: 5px;
    text-shadow: 0 0 20px rgba(255,255,255,0.5);
    margin: 0;
}

/* --- SECCIÓN CENTRAL: LAS GRANDES CARTAS DE STATS --- */
#story-share-template .story-stats-grid {
    display: grid; grid-template-columns: 1fr 1fr;
    gap: 40px; width: 100%;
    z-index: 2;
}
#story-share-template .story-stat-card {
    background: rgba(255, 255, 255, 0.03);
    border: 2px solid rgba(255, 255, 255, 0.05);
    border-radius: 25px;
    padding: 40px;
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    position: relative;
    transition: 0.3s;
}
#story-share-template .story-stat-card.active {
    border-color: var(--primary);
    box-shadow: 0 0 30px var(--primary-glow);
}
#story-share-template .story-stat-card i {
    font-size: 4rem; color: #555; margin-bottom: 20px;
}
#story-share-template .story-stat-card.active i {
    color: var(--primary); text-shadow: 0 0 15px var(--primary-glow);
}
#story-share-template .story-stat-value {
    font-size: 8rem; font-weight: 900; color: #fff; line-height: 1; margin: 10px 0;
}
#story-share-template .story-stat-label {
    font-size: 1.8rem; text-transform: uppercase; color: #aaa; letter-spacing: 2px;
}

/* --- SECCIÓN INFERIOR: BARRA DE XP Y FOOTER --- */
#story-share-template .story-footer {
    width: 100%; display: flex; flex-direction: column; align-items: center; gap: 30px;
    z-index: 2;
}
#story-share-template .story-xp-section {
    width: 100%; background: rgba(0,0,0,0.3); padding: 30px; border-radius: 20px;
    border: 1px solid rgba(255,255,255,0.03);
}
#story-share-template .story-xp-header {
    display: flex; justify-content: space-between; align-items: center; margin-bottom: 15px;
}
#story-share-template .story-xp-label {
    font-size: 1.8rem; color: #fff; font-weight: bold; text-transform: uppercase;
}
#story-share-template .story-xp-values {
    font-size: 1.6rem; color: #aaa;
}
#story-share-template .story-xp-bar-bg {
    width: 100%; height: 25px;
    background: rgba(255,255,255,0.05); border-radius: 50px; overflow: hidden;
    position: relative;
}
#story-share-template #story-template-xp-fill {
    height: 100%; background: var(--primary);
    border-radius: 50px;
    box-shadow: 0 0 20px var(--primary-glow);
    width: 0%; /* Se llena por JS */
}

#story-share-template .story-watermark {
    font-size: 2.5rem; font-weight: 900; color: rgba(255,255,255,0.1);
    text-transform: uppercase; letter-spacing: 8px;
    margin-top: 20px;
}

/* 📱 Eliminar márgenes fantasma en la parte inferior del móvil */
@media (max-width: 768px) {
    /* Quita el margen del último elemento para que no empuje el fondo */
    .dashboard-section > :last-child,
    .panel-contenedor > :last-child {
        margin-bottom: 0 !important;
    }

    /* Si tienes un contenedor principal, asegúrate de que no tenga un padding inferior gigante */
    #main-container { 
        padding-bottom: 20px !important; /* Ajusta este valor si necesitas un poco de respiro, pero no un hueco enorme */
    }
}

/* ========================================== */
/* APLICAR LA ALTURA EXACTA CALCULADA POR JS  */
/* ========================================== */
html, body {
    margin: 0 !important;
    padding: 0 !important;
    background-color: var(--bg) !important;
    /* Usamos la variable exacta que calculó JavaScript */
    height: 100vh; /* Fallback por si acaso */
    height: calc(var(--vh, 1vh) * 100) !important; 
    overflow-x: hidden;
}

/* Aplicamos lo mismo al contenedor que envuelve tu app */
/* Ajusta el nombre de la clase/ID si el tuyo es distinto */
#main-container, .app-wrapper {
    height: calc(var(--vh, 1vh) * 100) !important;
    overflow-y: auto; /* Permite scroll interno si hay mucho contenido */
    padding-bottom: 0 !important;
}

/* ==========================================
   📅 ICONO DEL CALENDARIO EN BLANCO
   ========================================== */
input[type="date"]::-webkit-calendar-picker-indicator {
    filter: invert(1);
    cursor: pointer;
    opacity: 0.8;
    transition: 0.2s;
}

input[type="date"]::-webkit-calendar-picker-indicator:hover {
    opacity: 1;
    transform: scale(1.1);
}

/* ==========================================
   📅 RESET TOTAL DE FLATPICKR (ESTILO ELITE)
   ========================================== */
/* Forzamos el estilo negro en el input que crea Flatpickr */
.flatpickr-input.form-control.input {
    background-color: #000 !important;
    color: #fff !important;
    border: 1px solid var(--glass-border) !important;
    border-radius: 10px !important;
    padding: 18px !important;
    padding-right: 45px !important; /* Espacio para el icono */
    font-family: 'Plus Jakarta Sans', sans-serif !important;
    font-size: 1rem !important;
    box-sizing: border-box !important;
    width: 100% !important;
}

/* Evitamos que Flatpickr apile los inputs */
.flatpickr-calendar.hasWeeks {
    width: auto !important;
}

/* 👇 OCULTAR LA BARRA DE SCROLL FEA EN TODA LA APP 👇 */

/* Para Chrome, Safari y Opera (Ordenador y Móvil) */
::-webkit-scrollbar {
    display: none;
}

/* Para Firefox y Edge (Ordenador) */
html, body, * {
    -ms-overflow-style: none;  /* IE y Edge */
    scrollbar-width: none;     /* Firefox */
}
/* ☝️ FIN OCULTAR SCROLL ☝️ */


.leaderboard-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding-bottom: 100px;
}

.rank-card {
    display: flex;
    align-items: center;
    background: rgba(255, 255, 255, 0.05);
    padding: 15px;
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.rank-pos {
    font-size: 1.8rem;
    font-weight: 900;
    width: 50px;
    text-align: center;
    margin-right: 15px;
}

.rank-pos.gold { color: #ffd700; text-shadow: 0 0 15px rgba(255, 215, 0, 0.6); }
.rank-pos.silver { color: #c0c0c0; text-shadow: 0 0 10px rgba(192, 192, 192, 0.5); }
.rank-pos.bronze { color: #cd7f32; text-shadow: 0 0 10px rgba(205, 127, 50, 0.5); }
.rank-pos.normal { color: #555; font-size: 1.2rem; }

.rank-info { flex-grow: 1; }
.rank-name { font-weight: bold; color: #fff; font-size: 1.1rem; }
.rank-title { font-size: 0.8rem; color: #aaa; text-transform: uppercase; }
.rank-score { color: var(--primary); font-weight: 900; font-size: 1.2rem; }


/* ==========================================
   🏟️ ESTILOS DEL COLISEO (LEADERBOARD)
========================================== */
.leaderboard-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding-bottom: 100px; /* Para que el menú de abajo no lo tape */
}

.rank-card {
    display: flex;
    align-items: center;
    background: rgba(255, 255, 255, 0.05); /* Fondo semitransparente */
    padding: 15px;
    border-radius: 16px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    transition: transform 0.2s ease;
}

.rank-card:active {
    transform: scale(0.98); /* Pequeño efecto al tocar */
}

.rank-pos {
    font-size: 1.8rem;
    font-weight: 900;
    width: 50px;
    text-align: center;
    margin-right: 15px;
    font-family: 'Orbitron', sans-serif;
}

/* 🏅 Las medallas de los Dioses */
.rank-pos.gold { color: #ffd700; text-shadow: 0 0 15px rgba(255, 215, 0, 0.6); }
.rank-pos.silver { color: #c0c0c0; text-shadow: 0 0 10px rgba(192, 192, 192, 0.5); }
.rank-pos.bronze { color: #cd7f32; text-shadow: 0 0 10px rgba(205, 127, 50, 0.5); }
.rank-pos.normal { color: #555; font-size: 1.2rem; }

.rank-info {
    flex-grow: 1;
}

.rank-name {
    font-weight: bold;
    color: #fff;
    font-size: 1.1rem;
    margin-bottom: 4px;
    text-transform: uppercase;
}

.rank-title {
    font-size: 0.8rem;
    color: #aaa;
    letter-spacing: 1px;
}

.rank-score {
    color: var(--primary);
    font-weight: 900;
    font-size: 1.2rem;
    text-shadow: 0 0 10px var(--primary-glow);
    font-family: 'Orbitron', sans-serif;
}


/* ==========================================
   ☀️ MAGIA DEL MODO CLARO (OUTDOOR PREMIUM)
   ========================================== */
[data-theme="light"] {
    --primary: #ff4500;
    --primary-glow: rgba(255, 69, 0, 0.15);
    --bg: #f2f2f7; /* Fondo gris súper claro (Estilo iOS) */
    --card-bg: #ffffff; /* Tarjetas totalmente blancas */
    --glass-border: rgba(0, 0, 0, 0.08); /* Bordes casi invisibles */
    --text-main: #1c1c1e; /* Texto casi negro para no cansar la vista */
    --text-dim: #8e8e93; /* Texto secundario gris */
    --shadow-soft: 0 8px 24px rgba(149, 157, 165, 0.2); /* Sombra 3D profesional */
    --panel-bg: rgba(0, 0, 0, 0.03); /* Fondo interno para inputs */
}

/* Fondo principal */
[data-theme="light"] body {
    background: var(--bg) !important;
    color: var(--text-main) !important;
}

/* 1. MENÚ LATERAL Y BARRA MÓVIL */
[data-theme="light"] aside, 
[data-theme="light"] #sidebar,
[data-theme="light"] .mobile-header,
[data-theme="light"] .mobile-bottom-nav {
    background: rgba(255, 255, 255, 0.9) !important;
    backdrop-filter: blur(15px) !important;
    border-color: var(--glass-border) !important;
}
[data-theme="light"] .nav-item span, 
[data-theme="light"] #sidebar-name,
[data-theme="light"] .mobile-header-title {
    color: var(--text-main) !important;
}
[data-theme="light"] .nav-item i:not(.active i) {
    color: var(--text-dim) !important;
}
[data-theme="light"] .nav-item:hover {
    background: var(--panel-bg) !important;
}

/* 2. TARJETAS Y PANELES (Darles profundidad 3D) */
[data-theme="light"] .stat-card, 
[data-theme="light"] .panel-box, 
[data-theme="light"] .auth-card,
[data-theme="light"] .info-box,
[data-theme="light"] .timer-box,
[data-theme="light"] .routine-card,
[data-theme="light"] .history-day,
[data-theme="light"] #goal-card {
    background: var(--card-bg) !important;
    border: 1px solid var(--glass-border) !important;
    box-shadow: var(--shadow-soft) !important;
}

/* 3. ARREGLAR LOS TEXTOS BLANCOS INVISIBLES */
[data-theme="light"] [style*="color:#fff"], 
[data-theme="light"] [style*="color: #fff"], 
[data-theme="light"] [style*="color:white"],
[data-theme="light"] [style*="color: white"],
[data-theme="light"] h1, 
[data-theme="light"] h2, 
[data-theme="light"] h3,
[data-theme="light"] .routine-card h3 {
    color: var(--text-main) !important;
}

/* Excepciones donde SÍ queremos texto blanco (Botones) */
[data-theme="light"] .btn-save, 
[data-theme="light"] .btn-save *,
[data-theme="light"] .cal-today,
[data-theme="light"] .rank-pos,
[data-theme="light"] .story-stat-value {
    color: #ffffff !important;
}

/* 4. INPUTS Y FORMULARIOS */
[data-theme="light"] input, 
[data-theme="light"] select,
[data-theme="light"] .flatpickr-input {
    background: var(--panel-bg) !important;
    color: var(--text-main) !important;
    border: 1px solid var(--glass-border) !important;
}

/* 5. CÍRCULO DEL CRONÓMETRO */
[data-theme="light"] .timer-circle-bg {
    stroke: #e5e5ea !important;
}

/* 6. PLAYLISTS SUPERIORES */
[data-theme="light"] .scroll-x-hidden > div {
    background: var(--card-bg) !important;
    box-shadow: 0 4px 12px rgba(0,0,0,0.05) !important;
}

/* ==========================================
   ✨ TOQUES PREMIUM MODO CLARO (LOGROS Y BARRAS)
   ========================================== */

/* Insignias Bloqueadas (Gris suave) */
[data-theme="light"] .badge {
    background: #f2f2f7 !important;
    border: 1px solid #e5e5ea !important;
    box-shadow: none !important;
}
[data-theme="light"] .badge i {
    color: #aeaeb2 !important; 
}

/* Insignias Desbloqueadas (Blancas con sombra neón) */
[data-theme="light"] .badge.unlocked {
    background: #ffffff !important;
    border: 2px solid var(--primary) !important;
    box-shadow: 0 8px 20px var(--primary-glow) !important; 
    transform: translateY(-2px); 
}
[data-theme="light"] .badge.unlocked i {
    color: var(--primary) !important; 
}
[data-theme="light"] .badge.unlocked span {
    color: var(--text-main) !important; 
    font-weight: 800;
}

/* Fondo de las barras de progreso */
[data-theme="light"] .progress-bg {
    background: #e5e5ea !important;
}

/* Separador del menú lateral */
[data-theme="light"] #sidebar {
    border-right: 1px solid rgba(0,0,0,0.05) !important;
    box-shadow: 4px 0 24px rgba(0,0,0,0.03) !important;
}

/* Tarjetas de PRs principales */
[data-theme="light"] .pr-card {
    background: #ffffff !important;
    border: 1px solid #e5e5ea !important;
    box-shadow: var(--shadow-soft) !important;
}
[data-theme="light"] .pr-card .pr-value {
    color: var(--primary) !important;
}


/* ==========================================
   🌟 MODO CLARO DEFINITIVO (COLISEO Y FORMULARIOS)
   ========================================== */

/* ----- 1. PANELES, TARJETAS Y CAJAS ----- */

/* Tarjetas de Ranking y Paneles Grandes (Fondo blanco y sombra limpia) */
[data-theme="light"] #coliseo .rank-card,
[data-theme="light"] .panel-box,
[data-theme="light"] div[style*="background: var(--primary-glow)"],
[data-theme="light"] div[style*="background:var(--primary-glow)"] {
    background: #ffffff !important;
    border: 1px solid #e5e5ea !important;
    box-shadow: 0 4px 12px rgba(0,0,0,0.05) !important;
}

/* Caja del cronómetro (Fondo blanco limpio) */
[data-theme="light"] div[style*="border: 1px solid #00ff00"],
[data-theme="light"] div[style*="border: 1px solid var(--primary)"] {
    background: #fafafa !important;
    border-color: #e5e5ea !important;
}


/* ----- 2. TEXTOS Y TIPOGRAFÍA ----- */

/* Forzar todos los textos base de la tarjeta a ser oscuros */
[data-theme="light"] #coliseo .rank-card,
[data-theme="light"] #coliseo .rank-card div,
[data-theme="light"] #coliseo .rank-card span,
[data-theme="light"] #coliseo .rank-card h3,
[data-theme="light"] #coliseo .rank-card p,
[data-theme="light"] #coliseo .rank-card b {
    color: #1c1c1e !important;
}

/* Excepciones: Textos destacados (XP, Nombres, Labels y Títulos pequeños) */
[data-theme="light"] label,
[data-theme="light"] .text-xs,
[data-theme="light"] div[style*="color: var(--primary)"],
[data-theme="light"] span[style*="color: var(--primary)"] {
    color: var(--primary) !important;
    font-weight: 800 !important;
}


/* ----- 3. FORMULARIOS (ESTILO iOS) ----- */

/* Cajas de texto e inputs */
[data-theme="light"] input,
[data-theme="light"] select,
[data-theme="light"] textarea {
    background: #f2f2f7 !important; 
    border: 1px solid #d1d1d6 !important;
    color: #1c1c1e !important;
    font-weight: 700 !important;
    border-radius: 8px !important;
    transition: all 0.2s ease;
}

/* Efecto Premium al tocar/escribir en un input */
[data-theme="light"] input:focus,
[data-theme="light"] select:focus,
[data-theme="light"] textarea:focus {
    background: #ffffff !important;
    border-color: var(--primary) !important;
    box-shadow: 0 0 0 3px var(--primary-glow) !important;
    outline: none !important;
}


/* ----- 4. BOTONES DEL COLISEO ----- */

/* Botones de Filtro inactivos (Grises claros) */
[data-theme="light"] #coliseo button {
    background: #f2f2f7 !important;
    color: #1c1c1e !important;
    border: 1px solid #d1d1d6 !important;
    box-shadow: none !important;
}

/* Botones activos (Naranjas/Primarios) */
[data-theme="light"] #coliseo button[style*="background: var(--primary)"],
[data-theme="light"] #coliseo button[style*="background:var(--primary)"] {
    background: var(--primary) !important;
    color: #ffffff !important;
    border-color: var(--primary) !important;
}

/* Botón transparente de "Explorar Arena" */
[data-theme="light"] #coliseo button[style*="border: 1px dashed"] {
    background: transparent !important;
    color: var(--primary) !important;
    border: 1px dashed var(--primary) !important;
}

/* ==========================================
   💎 LIMPIEZA PREMIUM MODO OSCURO (DARK MODE)
   ========================================== */

/* 1. Quitar el "manchón" de color de los paneles (Fondo oscuro elegante) */
:root:not([data-theme="light"]) .panel-box,
:root:not([data-theme="light"]) div[style*="background: var(--primary-glow)"],
:root:not([data-theme="light"]) div[style*="background:rgba(255, 69, 0, 0.2)"] {
    background: #1c1c1e !important; /* Gris muy oscuro, estilo Apple/Spotify */
    border: 1px solid rgba(255, 255, 255, 0.05) !important; /* Borde súper sutil */
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5) !important; /* Sombra profunda */
}

/* 2. Inputs limpios y modernos */
:root:not([data-theme="light"]) input,
:root:not([data-theme="light"]) select,
:root:not([data-theme="light"]) textarea {
    background: #2c2c2e !important; /* Gris ligeramente más claro que el fondo */
    border: 1px solid transparent !important;
    color: #ffffff !important;
    border-radius: 8px !important;
    transition: all 0.3s ease;
}

/* 3. Efecto Neón al tocar/escribir en un input */
:root:not([data-theme="light"]) input:focus,
:root:not([data-theme="light"]) select:focus,
:root:not([data-theme="light"]) textarea:focus {
    background: #1c1c1e !important;
    border-color: var(--primary) !important;
    box-shadow: 0 0 15px var(--primary-glow) !important;
    outline: none !important;
}

/* 4. Textos pequeños más elegantes (Menos saturación) */
:root:not([data-theme="light"]) label,
:root:not([data-theme="light"]) .text-xs {
    color: #8e8e93 !important; /* Gris claro en lugar de naranja chillón */
    font-weight: 700 !important;
    letter-spacing: 1px;
}

/* 5. Asegurar que el botón principal y el crono destaquen */
:root:not([data-theme="light"]) div[style*="border: 1px solid #00ff00"],
:root:not([data-theme="light"]) div[style*="border: 1px solid var(--primary)"] {
    background: #121212 !important; /* Negro profundo para el cronómetro */
    border-color: rgba(255,255,255,0.1) !important;
}

/* ==========================================
   🖋️ CORRECCIÓN: TEXTOS LEGIBLES EN MODO CLARO
   ========================================== */

/* Obligar a que todos los textos dentro de los paneles y tarjetas sean oscuros */
[data-theme="light"] .panel-box,
[data-theme="light"] .panel-box p,
[data-theme="light"] .panel-box h2,
[data-theme="light"] .panel-box h3,
[data-theme="light"] .panel-box span,
[data-theme="light"] .panel-box div,
[data-theme="light"] .auth-card,
[data-theme="light"] .auth-card p,
[data-theme="light"] .auth-card h2,
[data-theme="light"] .auth-card h3,
[data-theme="light"] .auth-card span,
[data-theme="light"] .auth-card div {
    color: #1c1c1e !important;
}

/* Excepción: Respetar los textos que tengan el color principal (naranja) */
[data-theme="light"] .panel-box [style*="color: var(--primary)"],
[data-theme="light"] .auth-card [style*="color: var(--primary)"] {
    color: var(--primary) !important;
}

/* ==========================================
   🎓 ACADEMIA Y GUÍAS (RESCATE MODO CLARO)
   ========================================== */

/* 1. Contenido de los Tutoriales (Academia) */
[data-theme="light"] #tut-content,
[data-theme="light"] #tut-content p,
[data-theme="light"] #tut-content li,
[data-theme="light"] #tut-content b,
[data-theme="light"] #tut-content strong {
    color: #1c1c1e !important; /* Negro Apple */
}

/* 2. Guía Técnica de Ejercicios (Training View) */
[data-theme="light"] #ex-guide,
[data-theme="light"] #ex-guide p,
[data-theme="light"] #ex-guide li,
[data-theme="light"] #ex-guide span:not([style*="color: var(--primary)"]) {
    color: #1c1c1e !important;
}

/* 3. Arreglar el bloque de "Anatomía y Técnica" (El cuadro gris de la foto) */
[data-theme="light"] #ex-guide div[style*="background: #222"],
[data-theme="light"] #ex-guide div[style*="background:#222"],
[data-theme="light"] #ex-guide div[style*="background: rgba(255,255,255,0.05)"] {
    background: #f2f2f7 !important; /* Gris iOS muy suave */
    border: 1px solid #e5e5ea !important;
    border-left: 4px solid var(--primary) !important; /* Mantenemos el acento lateral */
}

/* 4. Títulos de sección dentro de las guías (Tips, Progresión, etc.) */
[data-theme="light"] #tut-content h3,
[data-theme="light"] #tut-content h4,
[data-theme="light"] #ex-guide h3,
[data-theme="light"] #ex-guide h4,
[data-theme="light"] #ex-guide div[style*="color: var(--primary)"] {
    color: var(--primary) !important;
    font-weight: 900 !important;
    text-transform: uppercase;
}

/* 5. Asegurar que los puntos de las listas (bullets) sean visibles */
[data-theme="light"] #tut-content li::marker,
[data-theme="light"] #ex-guide li::marker {
    color: var(--primary) !important;
}

/* ==========================================
   🖋️ MODO CLARO: BOTONES SECUNDARIOS Y DE CIERRE
   ========================================== */

/* Ataca solo a los botones que tengan fondo transparente o sirvan para cerrar/cancelar */
[data-theme="light"] button.btn-save[style*="transparent"],
[data-theme="light"] button[onclick*="closeModal"],
[data-theme="light"] button[onclick*="cerrarEntrenamientoActivo"] {
    color: #1c1c1e !important; /* Texto gris muy oscuro/casi negro */
    border-color: #d1d1d6 !important; /* Borde gris suave para que se vea la forma */
    background-color: #f5f5f7 !important; /* Fondo gris súper clarito para que destaque del blanco */
    font-weight: bold !important;
}

/* Efecto al pulsar o pasar el ratón por los botones de cerrar en modo claro */
[data-theme="light"] button.btn-save[style*="transparent"]:hover,
[data-theme="light"] button[onclick*="closeModal"]:hover,
[data-theme="light"] button[onclick*="cerrarEntrenamientoActivo"]:hover {
    background-color: #e5e5ea !important;
}


/* ==========================================
   🌟 ARREGLOS FINALES MODO CLARO (HISTORIAL, PRs Y CALENDARIO)
   ========================================== */

/* 1. PRs Principales legibles */
[data-theme="light"] .pr-number {
    color: #1c1c1e !important;
}

/* 2. Historial Lista (El ID correcto es #history-container) */
[data-theme="light"] #history-container [style*="color:#fff"],
[data-theme="light"] #history-container [style*="color: #fff"],
[data-theme="light"] .history-day-content h4 {
    color: #1c1c1e !important;
}

/* Líneas de separación más limpias en las tarjetas de historial */
[data-theme="light"] .set-row,
[data-theme="light"] .history-day-content .history-card {
    border-bottom: 1px dashed #d1d1d6 !important;
}

/* Fondo de las sub-tarjetas del historial */
[data-theme="light"] .history-day-content {
    background: #f9f9f9 !important;
    border-top: 1px solid #d1d1d6 !important;
}

/* 3. Calendario Dinámico */

/* Estado: Día entrenado (Aplica en oscuro y claro) */
.cal-trained {
    background: var(--primary) !important;
    opacity: 0.4;
    color: #fff !important;
    border: none !important;
}

/* Modo Claro: Días normales (grises) */
[data-theme="light"] .cal-box:not(.cal-empty):not(.cal-trained):not(.cal-today) {
    background: #f2f2f7 !important;
    border-color: #d1d1d6 !important;
    color: #1c1c1e !important;
}

/* Modo Claro: Días entrenados (Solid, sin opacidad) */
[data-theme="light"] .cal-trained {
    opacity: 1 !important;
}

/* Modo Claro: Día de HOY sin entrenar */
[data-theme="light"] .cal-today {
    background: #ffffff !important;
    color: var(--primary) !important;
    border: 2px solid var(--primary) !important;
    box-shadow: 0 4px 10px var(--primary-glow) !important;
}

/* Modo Claro: Día de HOY entrenado */
[data-theme="light"] .cal-trained.cal-today {
    background: var(--primary) !important;
    color: #ffffff !important;
    border: 2px solid #1c1c1e !important; /* Borde oscuro para resaltar sobre el fondo naranja */
}

/* ==========================================
   🔥 RESCATE DEL DÍA ACTUAL (BRILLO MÁXIMO)
   ========================================== */

/* 1. Día de HOY en Modo Oscuro (Sin entrenar aún) */
.cal-today {
    border: 2px solid var(--primary) !important;
    box-shadow: 0 0 15px var(--primary-glow) !important;
    opacity: 1 !important; /* Forzamos que nunca sea transparente */
    font-weight: 900 !important;
}

/* 2. Día de HOY en Modo Oscuro (Ya entrenado = ¡Fuego!) */
.cal-trained.cal-today {
    background: var(--primary) !important;
    color: #ffffff !important;
    opacity: 1 !important; /* Brillo al 100% */
    border: 2px solid #ffffff !important; /* Borde blanco para que resalte brutal */
    box-shadow: 0 0 20px var(--primary) !important;
}

/* 3. Asegurar que el Modo Claro también mantenga la opacidad al 100% hoy */
[data-theme="light"] .cal-today,
[data-theme="light"] .cal-trained.cal-today {
    opacity: 1 !important;
}

/* ==========================================
   📅 CALENDARIO MODO CLARO: DÍAS ANTERIORES SUAVES
   ========================================== */
[data-theme="light"] .cal-trained:not(.cal-today) {
    background: var(--primary-glow) !important; /* Fondo translúcido muy suave */
    color: var(--primary) !important; /* El número mantiene tu color principal */
    border: none !important;
    opacity: 1 !important; /* Quitamos la opacidad general para que el número se lea perfecto */
    font-weight: 800 !important;
}

/* ==========================================
   🖋️ CONTRASTE TOTAL: TEXTOS NEGROS EN MODO CLARO
   ========================================== */

/* Forzar negro en los párrafos de descripción de todas las secciones */
[data-theme="light"] body .section p,
[data-theme="light"] body .panel-box p,
[data-theme="light"] body .auth-card p,
[data-theme="light"] body #badges-section p {
    color: #000000 !important; /* Negro Puro */
    opacity: 1 !important;
    font-weight: 500 !important;
}

/* Forzar negro en las etiquetas de los formularios (Peso, Alias, etc.) */
[data-theme="light"] body .input-group label,
[data-theme="light"] body .avatar-selection-container p {
    color: #000000 !important;
    font-weight: 800 !important;
    opacity: 1 !important;
}

/* Forzar negro en los textos descriptivos del historial */
[data-theme="light"] body .history-day summary span,
[data-theme="light"] body .set-info span:last-child {
    color: #444446 !important; /* Gris muy oscuro casi negro */
}

/* ==========================================
   🛠️ PARCHE DE EMERGENCIA: TEXTOS INVISIBLES MODO CLARO
   ========================================== */

/* 1. Rescatar los textos blancos de la Meta Láser y el Reto Semanal */
[data-theme="light"] #goal-card h3,
[data-theme="light"] #goal-current-val,
[data-theme="light"] #goal-target-val,
[data-theme="light"] #challenge-current,
[data-theme="light"] #weekly-challenge-card b {
    color: #1c1c1e !important; /* Negro oscuro puro */
}

/* 2. Rescatar la etiqueta "EN PROGRESO" del reto */
[data-theme="light"] #challenge-status {
    background: rgba(0, 0, 0, 0.1) !important; /* Fondo gris oscurito */
    color: #1c1c1e !important; /* Texto negro */
    border: 1px solid rgba(0,0,0,0.2) !important;
}

/* 3. Rescatar los iconos fantasmas en botones transparentes (Ej: La Campana) */
[data-theme="light"] button[style*="transparent"] i,
[data-theme="light"] button[style*="transparent"] * {
    color: inherit !important; /* Hereda el color morado o naranja del botón */
}

/* ==========================================
   📸 PLANTILLA HD PARA INSTAGRAM STORIES (9:16)
   ========================================== */
#story-share-template {
    /* Forzamos un tamaño exacto con proporción 9:16 (vertical) */
    width: 450px !important; 
    height: 800px !important; 
    
    /* Centramos el contenido dentro de la tarjeta */
    box-sizing: border-box !important;
    display: flex;
    flex-direction: column;
    justify-content: center;
    
    /* Margen interno para que no pegue a los bordes */
    padding: 40px !important; 
    
    /* Fondo oscuro puro para que destaque */
    background: #080808 !important; 
    overflow: hidden !important;
}

/* Forzar que los elementos de dentro no se desborden */
#story-share-template * {
    max-width: 100% !important;
}

/* ==========================================
   📸 ESTILOS DE HISTORIA HD (V2. TACTICAL DARK)
   ========================================== */

/* Lienzo principal rígidamente delimitado */
#story-share-template {
    width: 450px; height: 800px;
    background-color: #09090b; /* Negro mate profundo */
    font-family: 'Plus Jakarta Sans', sans-serif;
    color: #ffffff;
    position: relative; overflow: hidden;
    box-sizing: border-box;
    z-index: -10;
}

/* Brillo táctico asimétrico de fondo */
.story-pro-bg { position: absolute; top: 0; left: 0; width: 100%; height: 100%; z-index: 0; }
.story-pro-glow {
    position: absolute; top: -150px; right: -150px;
    width: 400px; height: 400px;
    background: #ff4500; filter: blur(120px);
    opacity: 0.25; border-radius: 50%;
}

/* Contenedor Flex para distribución perfecta */
.story-pro-content {
    position: relative; z-index: 1;
    width: 100%; height: 100%;
    display: flex; flex-direction: column;
    padding: 50px 35px; box-sizing: border-box;
}

/* HEADER: Avatar y Alias Irrompible */
.story-pro-header {
    display: flex; flex-direction: column; align-items: center; gap: 15px;
    margin-bottom: 40px; text-align: center;
}
.story-pro-avatar-wrap {
    position: relative; width: 110px; height: 110px;
}
#story-template-avatar-img {
    width: 100%; height: 100%; border-radius: 50%; object-fit: cover;
    position: relative; z-index: 2; border: 3px solid #09090b;
}
.story-pro-avatar-ring {
    position: absolute; top: -4px; left: -4px; right: -4px; bottom: -4px;
    border-radius: 50%;
    background: linear-gradient(135deg, #ff4500, transparent, #ff4500);
    z-index: 1; opacity: 0.8;
}
.story-pro-alias-container {
    width: 100%; padding: 0 10px; box-sizing: border-box;
}
.story-pro-alias {
    font-family: 'Orbitron', sans-serif; font-size: 26px; font-weight: 800;
    margin: 0; text-transform: uppercase; letter-spacing: 1px;
    /* La magia antimutilación de texto: */
    word-wrap: break-word; overflow-wrap: break-word; white-space: normal;
    line-height: 1.2;
}

/* ETIQUETAS Y TEXTOS PEQUEÑOS */
.story-pro-label {
    font-size: 11px; font-weight: 800; color: #ff4500;
    letter-spacing: 2px; text-transform: uppercase; margin-bottom: 8px;
    display: block; opacity: 0.9;
}

/* CAJA DE MISIÓN (Líneas afiladas, diseño hardcore) */
.story-pro-mission {
    background: rgba(20, 20, 23, 0.95);
    border-left: 4px solid #ff4500;
    padding: 25px 20px; border-radius: 4px 12px 12px 4px;
    margin-bottom: 30px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.5);
}
.story-pro-goal {
    font-size: 32px; font-weight: 900; margin: 0; line-height: 1.1;
    text-transform: uppercase; color: #fff;
    word-wrap: break-word; overflow-wrap: break-word;
}

/* TARJETAS DE ESTADÍSTICAS */
.story-pro-stats {
    display: flex; gap: 15px; width: 100%; margin-bottom: 40px;
}
.story-pro-card {
    flex: 1; background: rgba(20, 20, 23, 0.6);
    border: 1px solid rgba(255,255,255,0.05);
    padding: 20px; border-radius: 12px; text-align: center;
}
.story-pro-val {
    font-family: 'Orbitron', sans-serif; font-size: 36px; font-weight: 900;
    display: flex; align-items: center; justify-content: center; gap: 8px;
    text-shadow: 0 2px 10px rgba(0,0,0,0.8);
}

/* BARRA DE EXPERIENCIA (Diseño plano de alta tecnología) */
.story-pro-xp {
    background: rgba(20, 20, 23, 0.6); padding: 20px;
    border-radius: 12px; border: 1px solid rgba(255,255,255,0.05);
    margin-bottom: auto; /* Esto empuja el footer hacia abajo */
}
.story-pro-xp-header {
    display: flex; justify-content: space-between; align-items: flex-end; margin-bottom: 12px;
}
.story-pro-xp-numbers {
    font-family: 'Orbitron', sans-serif; font-size: 14px; font-weight: 700; color: #aaa;
}
.story-pro-xp-bar {
    width: 100%; height: 10px; background: #000; border-radius: 5px; overflow: hidden;
}
.story-pro-xp-fill {
    height: 100%; background: linear-gradient(90deg, #ff4500, #ff8c00);
    border-radius: 5px; width: 0%;
}

/* FOOTER / BRANDING */
.story-pro-footer {
    text-align: center; border-top: 1px solid rgba(255,255,255,0.05); padding-top: 20px;
}
.story-pro-logo {
    font-family: 'Orbitron', sans-serif; font-size: 24px; font-weight: 900;
    letter-spacing: 1px; color: #fff;
}
.story-pro-logo span { color: #ff4500; }
.story-pro-tag {
    font-size: 10px; font-weight: 700; color: #555; letter-spacing: 4px; margin-top: 6px;
}

/* =========================================
   🔥 MEJORAS UX MÓVIL (RUTINAS)
   ========================================= */

/* Hace que las tarjetas midan 150px, cabiendo 2 y asomando la 3ra */
.rutina-card {
    flex: 0 0 150px !important; 
    scroll-snap-align: start !important; 
}

/* Añade un espacio vacío al final para que la última tarjeta no se pegue al borde derecho */
.espacio-final-scroll {
    padding-right: 25px !important;
}

/* Botón Smart Coach Adaptable */
.btn-smart-coach {
    position: relative;
    /* Usamos var(--card-bg) para que sea blanco en light y negro en dark */
    background: var(--card-bg); 
    border: 2px solid var(--primary);
    color: var(--text-main);
    padding: 15px 5px;
    border-radius: 12px;
    cursor: pointer;
    font-family: 'Orbitron';
    font-weight: bold;
    font-size: 0.85rem;
    width: 100%;
    /* Un resplandor suave que usa el color principal */
    box-shadow: 0 4px 15px var(--primary-glow);
    text-transform: uppercase;
    letter-spacing: 1px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all 0.3s ease;
}

.btn-smart-coach:active {
    transform: scale(0.95);
}

/* Ajuste específico para que en modo claro tenga un toque sutil de color de fondo */
[data-theme="light"] .btn-smart-coach {
    background: linear-gradient(145deg, #ffffff, #f0f0f0);
}