:root {
    --bg-dark: #09090c;
    --card-bg: rgba(22, 22, 28, 0.7);
    --card-border: rgba(255, 255, 255, 0.05);
    --text-main: #f3f4f6;
    --text-muted: #9ca3af;
    --accent: #8e9aaf;
    --accent-glow: rgba(142, 154, 175, 0.3);
    --border-radius: 16px;
    --transition-speed: 0.4s;
    --font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

/* ==========================================================================
   THEME PALETTES (Dynamically mapped based on Moon phase Column)
   ========================================================================== */

/* 1. RESET & DESINTOXICACIÓN (Gris / Plata / Azul Acero) */
body.theme-reset {
    --bg-dark: #0b0c10;
    --card-bg: rgba(20, 22, 30, 0.85);
    --card-border: rgba(142, 154, 175, 0.1);
    --accent: #c5c6c7;
    --accent-glow: rgba(197, 198, 199, 0.25);
    --text-main: #f1f3f5;
    --text-muted: #9ba4b4;
}

/* 2. HIPERTROFIA & CONSTRUCCIÓN (Naranja de Alta Energía / Oro Anabólico) */
body.theme-construccion {
    --bg-dark: #060606;
    --card-bg: rgba(18, 18, 18, 0.9);
    --card-border: rgba(255, 159, 28, 0.15);
    --accent: #ff9f1c;
    --accent-glow: rgba(255, 159, 28, 0.3);
    --text-main: #ffffff;
    --text-muted: #a8a8a8;
}

/* 3. ESTABILIDAD & POTENCIA (Negro Puro y Rojo Láser Científico) */
body.theme-potencia {
    --bg-dark: #000000;
    --card-bg: rgba(13, 13, 13, 0.95);
    --card-border: rgba(255, 51, 102, 0.2);
    --accent: #ff3366;
    --accent-glow: rgba(255, 51, 102, 0.45);
    --text-main: #fafafa;
    --text-muted: #8e8e93;
}

/* 4. DESCARGA & REPARACIÓN (Naranja Atardecer / Modulación Nerviosa / Magnesio) */
body.theme-reparacion {
    --bg-dark: #090401;
    --card-bg: rgba(20, 11, 4, 0.9);
    --card-border: rgba(247, 127, 0, 0.15);
    --accent: #f77f00;
    --accent-glow: rgba(247, 127, 0, 0.35);
    --text-main: #fffcf9;
    --text-muted: #fca5a5;
}

/* ==========================================================================
   GENERAL & APP LAYOUT
   ========================================================================== */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    background-color: var(--bg-dark);
    color: var(--text-main);
    font-family: var(--font-family);
    line-height: 1.6;
    transition: background-color var(--transition-speed) ease, color var(--transition-speed) ease;
    padding-bottom: 24px;
    display: flex;
    justify-content: center;
    align-items: flex-start;
}

.app-shell {
    width: 100%;
    max-width: 480px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    background: transparent;
    padding: 0 12px;
    position: relative;
}

/* --- NAV BAR --- */
.app-navbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 8px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.03);
}

.brand-logo {
    display: flex;
    align-items: center;
    gap: 10px;
}

.logo-emoji {
    font-size: 1.5rem;
    transition: transform var(--transition-speed) ease;
}

.brand-name {
    font-size: 0.95rem;
    font-weight: 800;
    letter-spacing: 1.5px;
    color: var(--text-main);
}

.sync-status {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-muted);
}

.pulse-dot {
    width: 6px;
    height: 6px;
    background-color: var(--accent);
    border-radius: 50%;
    box-shadow: 0 0 8px var(--accent);
    animation: pulse 1.8s infinite alternate;
}

@keyframes pulse {
    0% { transform: scale(0.9); opacity: 0.5; }
    100% { transform: scale(1.3); opacity: 1; box-shadow: 0 0 12px var(--accent); }
}

/* ==========================================================================
   MOON HERO HEADER (Astronomy display)
   ========================================================================== */
.moon-tracker-hero {
    background: radial-gradient(circle at top, rgba(255, 255, 255, 0.02) 0%, transparent 70%);
    padding: 24px 8px 16px 8px;
    text-align: center;
}

.moon-display-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.moon-sphere-container {
    position: relative;
    width: 160px;
    height: 160px;
    margin-bottom: 16px;
}

#hero-moon-canvas {
    border-radius: 50%;
    display: block;
}

.moon-glow-overlay {
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    border-radius: 50%;
    background: radial-gradient(circle at center, transparent 60%, rgba(0,0,0,0.4) 100%);
    pointer-events: none;
}

.moon-meta-info {
    margin-top: 4px;
}

.fase-badge {
    display: inline-block;
    font-size: 0.65rem;
    font-weight: 800;
    letter-spacing: 2px;
    padding: 4px 10px;
    background-color: rgba(255,255,255,0.03);
    border: 1px solid var(--card-border);
    border-radius: 50px;
    color: var(--accent);
    margin-bottom: 8px;
}

#luna-nombre-texto {
    font-size: 1.6rem;
    font-weight: 800;
    letter-spacing: -0.5px;
    margin-bottom: 4px;
}

.moon-astronomy-data {
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* --- COSMIC SYNC SYSTEM CONTROLLER --- */
.cosmic-sync-controller {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--card-border);
    border-radius: var(--border-radius);
    padding: 12px;
    margin-top: 16px;
}

.toggle-control {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.toggle-label {
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--text-main);
    display: flex;
    align-items: center;
    gap: 8px;
}

.toggle-label i {
    color: var(--accent);
}

/* IOS SWITCH SLIDER */
.switch {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
}

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

.slider {
    position: absolute;
    cursor: pointer;
    top: 0; left: 0; right: 0; bottom: 0;
    background-color: rgba(255,255,255,0.1);
    transition: .4s;
    border: 1px solid rgba(255,255,255,0.05);
}

.slider:before {
    position: absolute;
    content: "";
    height: 16px;
    width: 16px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: .4s;
}

input:checked + .slider {
    background-color: var(--accent);
}

input:checked + .slider:before {
    transform: translateX(20px);
}

.slider.round {
    border-radius: 34px;
}

.slider.round:before {
    border-radius: 50%;
}

/* MANUAL NAVIGATION ROW */
.manual-day-selector-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px dashed rgba(255,255,255,0.05);
}

.selector-label {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.day-navigation {
    display: flex;
    align-items: center;
    gap: 16px;
}

.nav-day-btn {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255,255,255,0.05);
    color: var(--text-main);
    width: 28px;
    height: 28px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 0.8rem;
    transition: .2s;
}

.nav-day-btn:hover {
    background: var(--accent);
    color: #000;
}

#manual-day-indicator {
    font-size: 0.9rem;
    font-weight: 800;
    color: var(--accent);
    min-width: 60px;
    text-align: center;
}

/* ==========================================================================
   CARD DESIGN STANDARDS
   ========================================================================== */
.card {
    background-color: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: var(--border-radius);
    padding: 20px;
    margin-bottom: 16px;
    position: relative;
    overflow: hidden;
    backdrop-filter: blur(10px);
}

/* --- TEXT STYLES --- */
.card h3 {
    font-size: 1.1rem;
    font-weight: 800;
    letter-spacing: -0.2px;
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.text-accent {
    color: var(--accent);
}

/* --- HERO ENFOQUE CARD --- */
.day-enfoque-card {
    padding: 16px;
}

.enfoque-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 8px;
}

.dia-label-badge {
    font-size: 0.7rem;
    font-weight: 800;
    color: #000;
    background-color: var(--accent);
    padding: 3px 8px;
    border-radius: 4px;
}

.enfoque-text {
    font-size: 0.9rem;
    color: var(--text-main);
    font-weight: 500;
}

/* ==========================================================================
   VERTICAL TIMELINE DESIGN (Cronograma)
   ========================================================================== */
.vertical-timeline {
    position: relative;
    padding-left: 16px;
    margin-top: 16px;
}

.vertical-timeline::before {
    content: "";
    position: absolute;
    left: 4px;
    top: 5px;
    bottom: 5px;
    width: 2px;
    background-color: rgba(255, 255, 255, 0.05);
}

.timeline-item {
    position: relative;
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding-bottom: 16px;
}

.timeline-item:last-child {
    padding-bottom: 0;
}

.timeline-bullet {
    position: absolute;
    left: -15px;
    top: 6px;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: var(--accent);
    border: 2px solid var(--bg-dark);
}

.timeline-time-box {
    font-size: 0.75rem;
    font-weight: 800;
    color: var(--accent);
    background-color: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--card-border);
    padding: 2px 6px;
    border-radius: 4px;
    white-space: nowrap;
}

.timeline-activity-desc {
    font-size: 0.85rem;
    color: var(--text-main);
    margin-top: 1px;
}

/* ==========================================================================
   DIET & NUTRITION TABS
   ========================================================================== */
.card-header-with-icon {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
}

.header-icon-circle {
    width: 36px;
    height: 36px;
    background-color: rgba(255,255,255,0.02);
    border: 1px solid var(--card-border);
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    color: var(--accent);
}

.header-texts h3 {
    margin-bottom: 2px;
}

.sub-header-desc {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.diet-tabs, .skincare-tabs {
    display: flex;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--card-border);
    padding: 4px;
    border-radius: 8px;
    margin-bottom: 16px;
    gap: 4px;
}

.diet-tab-btn, .skin-tab-btn {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 0.8rem;
    font-weight: 700;
    padding: 8px;
    border-radius: 6px;
    cursor: pointer;
    transition: .2s;
}

.diet-tab-btn.active, .skin-tab-btn.active {
    background-color: rgba(255,255,255,0.05);
    color: var(--accent);
}

.diet-detail-box {
    font-size: 0.85rem;
    color: var(--text-main);
    background-color: rgba(0, 0, 0, 0.1);
    border: 1px solid rgba(255,255,255,0.02);
    padding: 14px;
    border-radius: 8px;
    line-height: 1.5;
}

/* ==========================================================================
   SKINCARE CARDS & TIMELINE STEPS
   ========================================================================== */
.skincare-steps-wrapper {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.skin-step {
    background-color: rgba(255, 255, 255, 0.01);
    border: 1px solid rgba(255,255,255,0.03);
    border-left: 3px solid var(--accent);
    border-radius: 0 8px 8px 0;
    padding: 10px 14px;
    transition: var(--transition-speed);
}

.skin-step-num {
    font-size: 0.7rem;
    font-weight: 800;
    color: var(--accent);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 2px;
}

.skin-step-text {
    font-size: 0.85rem;
    color: var(--text-main);
}

/* ==========================================================================
   INTERACTIVE GAMIFIED WORKOUT TRACKING
   ========================================================================== */
.exercise-log-card {
    background-color: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--card-border);
    border-radius: 8px;
    padding: 12px 14px;
    margin-bottom: 10px;
}

.exercise-name {
    font-size: 0.85rem;
    font-weight: 800;
    color: var(--text-main);
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 10px;
}

.exercise-name i {
    color: var(--accent);
}

.exercise-inputs-row {
    display: flex;
    gap: 10px;
}

.input-col {
    flex: 1;
}

.input-col label {
    font-size: 0.7rem;
    color: var(--text-muted);
    display: block;
    margin-bottom: 4px;
    font-weight: 600;
}

/* STEPPER CONTROLS (+ / -) */
.stepper-input {
    display: flex;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--card-border);
    border-radius: 6px;
    overflow: hidden;
}

.stepper-btn {
    background: transparent;
    border: none;
    color: var(--text-main);
    width: 24px;
    cursor: pointer;
    font-weight: 800;
    font-size: 0.9rem;
    transition: .1s;
}

.stepper-btn:hover {
    background-color: rgba(255,255,255,0.05);
    color: var(--accent);
}

.stepper-input input {
    flex: 1;
    width: 100%;
    background: transparent;
    border: none;
    color: #fff;
    text-align: center;
    font-size: 0.8rem;
    font-weight: 700;
    padding: 6px 0;
    outline: none;
}

/* ==========================================================================
   CARD MEDIA & GIF PLAYERS (Añadido v8)
   ========================================================================== */
.card-sub-media {
    background-color: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--card-border);
    border-radius: 12px;
    padding: 12px;
    margin-bottom: 16px;
}

.gif-header {
    display: flex;
    justify-content: flex-start;
    align-items: center;
    margin-bottom: 8px;
}

.gif-tag-badge {
    font-size: 0.65rem;
    font-weight: 800;
    color: #000;
    background-color: var(--accent);
    padding: 2px 6px;
    border-radius: 4px;
    letter-spacing: 0.5px;
}

.gif-wrapper {
    width: 100%;
    height: 180px;
    border-radius: 8px;
    overflow: hidden;
    background-color: #000;
    display: flex;
    justify-content: center;
    align-items: center;
}

.gif-wrapper img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

/* ==========================================================================
   SUPPLEMENTATION CHECKLIST
   ========================================================================== */
.supp-checklist {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 12px;
}

.checklist-item {
    display: flex;
    align-items: center;
    gap: 12px;
    background-color: rgba(255, 255, 255, 0.01);
    border: 1px solid rgba(255,255,255,0.02);
    padding: 10px 14px;
    border-radius: 8px;
    cursor: pointer;
    transition: .2s;
}

.checklist-item:hover {
    background-color: rgba(255,255,255,0.03);
    border-color: var(--accent-glow);
}

.checklist-item input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: var(--accent);
    cursor: pointer;
}

.checklist-item label {
    font-size: 0.85rem;
    color: var(--text-main);
    cursor: pointer;
}

/* ==========================================================================
   DYNAMIC INPUTS & BIOMETRICS (IOS STYLE SWITCH & RANGES)
   ========================================================================== */
.dynamic-inputs-header {
    margin: 20px 0 10px 0;
    border-top: 1px dashed rgba(255,255,255,0.05);
    padding-top: 16px;
}

.dynamic-inputs-header h4 {
    font-size: 0.9rem;
    font-weight: 800;
    letter-spacing: -0.2px;
}

.dynamic-inputs-header h4 i {
    color: var(--accent);
}

.biometric-input-card {
    background-color: rgba(255,255,255,0.01);
    border: 1px solid var(--card-border);
    padding: 12px 14px;
    border-radius: 8px;
    margin-bottom: 8px;
}

.biometric-input-card label {
    display: block;
    font-size: 0.75rem;
    color: var(--text-muted);
    font-weight: 700;
    margin-bottom: 8px;
}

.number-input-wrap input {
    width: 100%;
    background-color: rgba(0,0,0,0.3);
    border: 1px solid var(--card-border);
    border-radius: 6px;
    color: #fff;
    padding: 8px 12px;
    font-size: 0.85rem;
    font-weight: 700;
    outline: none;
    transition: .2s;
}

.number-input-wrap input:focus {
    border-color: var(--accent);
}

/* GLOWING SLIDER 1-10 */
.slider-container-glowing {
    display: flex;
    align-items: center;
    gap: 12px;
}

.slider-container-glowing input[type="range"] {
    flex: 1;
    accent-color: var(--accent);
    cursor: pointer;
}

.slider-value-bubble {
    font-size: 0.75rem;
    font-weight: 800;
    color: #000;
    background-color: var(--accent);
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
}

/* EMOJI RATINGS */
.emoji-ratings-wrapper {
    display: flex;
    justify-content: space-around;
    padding: 6px 0;
}

.emoji-ratings-wrapper input[type="radio"] {
    display: none;
}

.emoji-ratings-wrapper label {
    font-size: 1.6rem;
    cursor: pointer;
    filter: grayscale(1);
    transition: transform .2s, filter .2s;
    margin-bottom: 0;
}

.emoji-ratings-wrapper input[type="radio"]:checked + label {
    filter: grayscale(0);
    transform: scale(1.35);
}

/* ==========================================================================
   AMAZON & CLICKBANK FEEDS
   ========================================================================== */
.products-vertical-feed {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 12px;
}

.product-item {
    border-left: 3px solid var(--accent);
    background-color: rgba(255,255,255,0.01);
    border: 1px solid var(--card-border);
    border-left: 3px solid var(--accent);
    padding: 12px 14px;
    border-radius: 0 8px 8px 0;
}

.product-item h4 {
    font-size: 0.85rem;
    font-weight: 800;
    margin-bottom: 4px;
}

.product-desc {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-bottom: 8px;
    line-height: 1.4;
}

.btn-buy {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    text-decoration: none;
    background: #ff9900;
    color: #000;
    font-size: 0.7rem;
    font-weight: bold;
    padding: 6px 12px;
    border-radius: 4px;
    transition: .2s;
}

.btn-buy.clickbank {
    background: #00b159 !important;
    color: #fff !important;
}

.btn-buy:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

/* ==========================================================================
   BUTTON ACTION GLOW (SUBMIT METRICS)
   ========================================================================== */
.btn-action-glow {
    width: 100%;
    padding: 12px;
    border: none;
    border-radius: var(--border-radius);
    background-color: var(--accent);
    color: #000;
    font-weight: bold;
    font-size: 0.85rem;
    cursor: pointer;
    transition: .3s;
    margin-top: 14px;
    box-shadow: 0 0 10px var(--accent-glow);
}

.btn-action-glow:hover {
    box-shadow: 0 0 20px var(--accent);
}

/* ==========================================================================
   INTERACTIVE NATIVE TAB SYSTEM (BOTTOM BAR)
   ========================================================================== */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 100%;
    max-width: 480px;
    height: 68px;
    background-color: var(--card-bg);
    border-top: 1px solid var(--card-border);
    display: flex;
    justify-content: space-around;
    align-items: center;
    z-index: 9999;
    backdrop-filter: blur(20px);
    padding-bottom: env(safe-area-inset-bottom);
}

.nav-item {
    background: transparent;
    border: none;
    color: var(--text-muted);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    flex: 1;
    height: 100%;
    padding: 6px 0;
}

.nav-item i {
    font-size: 1.25rem;
    transition: transform 0.2s ease;
}

.nav-item span {
    font-size: 0.65rem;
    font-weight: 700;
    letter-spacing: 0.5px;
}

.nav-item.active {
    color: var(--accent);
    text-shadow: 0 0 15px var(--accent-glow);
}

.nav-item.active i {
    transform: translateY(-2px);
}

/* TAB SCREEN TRANSITIONS */
.tab-screen {
    display: none;
    animation: tabSlideIn 0.3s ease-out;
}

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

@keyframes tabSlideIn {
    from {
        opacity: 0;
        transform: translateY(12px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Padding de seguridad para evitar solapamientos con la barra de navegación */
.app-main-container {
    padding-bottom: 90px;
}

/* --- FOOTER --- */
.app-footer {
    text-align: center;
    padding: 32px 16px 96px 16px; /* Aumentamos el padding para librar la bottom-nav */
    font-size: 0.7rem;
    color: var(--text-muted);
    border-top: 1px solid rgba(255, 255, 255, 0.03);
}

.footer-logo {
    font-size: 0.8rem;
    font-weight: 800;
    letter-spacing: 1px;
    color: var(--text-main);
    margin-bottom: 6px;
}

.app-footer .copyright {
    margin-top: 8px;
    font-size: 0.65rem;
}
