/* ---------------------------------- */
/*      Variables de Color (Temas)    */
/* ---------------------------------- */
:root {
    --color-bg: #0B0F19; 
    --color-surface: #151C2C; 
    --color-header-default: #1E293B; 
    --color-text-primary: #FFFFFF;
    --color-text-secondary: #94A3B8;
    --color-border: #334155;
    --shadow-color: rgba(0, 0, 0, 0.8);
    --color-nuevo: #FF0055; 
    --color-brand: #FFD700; 
    --ball-bg: radial-gradient(circle at 30% 30%, #ffffff, #e2e8f0 60%, #94a3b8 100%);
    --ball-text: #0F172A;
    --font-principal: 'Poppins', sans-serif;
    --font-numeros: 'Montserrat', sans-serif;
}

html.theme-light {
    --color-bg: #F0F4F8;
    --color-surface: #FFFFFF;
    --color-header-default: #E2E8F0;
    --color-text-primary: #0F172A;
    --color-text-secondary: #475569;
    --color-border: #CBD5E1;
    --shadow-color: rgba(0, 0, 0, 0.15);
    --color-brand: #D4AF37; 
    --ball-bg: radial-gradient(circle at 30% 30%, #ffffff, #f1f5f9 60%, #cbd5e1 100%);
}

/* ---------------------------------- */
/*          Estilos Base              */
/* ---------------------------------- */
body.tv-mode {
    background-color: var(--color-bg);
    color: var(--color-text-primary);
    font-family: var(--font-principal);
    margin: 0;
    padding: 0 0 60px 0; 
    overflow-x: hidden;
    min-height: 100vh;
}

/* ---------------------------------- */
/*      Encabezado de TV VIP          */
/* ---------------------------------- */
.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 2rem;
    background: linear-gradient(180deg, rgba(0,0,0,0.6) 0%, transparent 100%);
    border-bottom: 2px solid var(--color-brand);
    box-shadow: 0 4px 20px rgba(0,0,0,0.5);
    margin-bottom: 1.5rem;
}

.brand-container { display: flex; align-items: center; gap: 15px; }
.logo { max-height: 70px; filter: drop-shadow(0 0 10px rgba(255, 215, 0, 0.4)); }
.brand-title {
    margin: 0; font-size: 3.5rem; font-weight: 900; color: var(--color-brand);
    text-transform: uppercase; text-shadow: 0 0 20px rgba(255, 215, 0, 0.5), 2px 2px 0px #000;
}

.reloj-tv {
    background: rgba(0, 0, 0, 0.6); color: var(--color-brand);
    padding: 0.8rem 1.5rem; border-radius: 50px; border: 2px solid var(--color-brand);
    font-size: 1.8rem; font-weight: 700; font-family: var(--font-numeros);
    display: inline-flex; align-items: center; gap: 10px;
}

/* Controles ocultos hasta pasar el ratón */
.tv-controls {
    display: flex; gap: 10px; opacity: 0.2; transition: opacity 0.3s ease; align-items: center;
}
.header:hover .tv-controls { opacity: 1; }

.theme-select {
    background: var(--color-surface); border: 2px solid var(--color-border);
    color: var(--color-text-primary); height: 55px; border-radius: 15px;
    padding: 0 15px; font-size: 1.2rem; font-weight: bold; cursor: pointer; outline: none;
}
.theme-button {
    background: var(--color-surface); border: 2px solid var(--color-border);
    color: var(--color-text-primary); width: 55px; height: 55px;
    border-radius: 15px; cursor: pointer; font-size: 1.5rem; transition: all 0.3s;
}
.theme-button:hover, .theme-select:hover { border-color: var(--color-brand); color: var(--color-brand); }
.theme-select option { background: var(--color-surface); color: var(--color-text-primary); }

/* ---------------------------------- */
/*      Pizarra y Tarjetas            */
/* ---------------------------------- */
.pizarra {
    display: grid;
    /* Por defecto, fluido. Esto cambiará con el JS si el usuario usa el selector */
    grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
    gap: 1.5rem;
    padding: 0 2rem;
    transition: all 0.5s ease;
}

.tarjeta-loteria {
    position: relative; background-color: var(--color-surface);
    border: 2px solid var(--color-border); border-radius: 20px;
    box-shadow: 0 15px 35px var(--shadow-color); overflow: hidden;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    animation: slideUp 0.6s ease-out forwards;
}

.tarjeta-loteria:hover {
    transform: translateY(-10px) scale(1.02); z-index: 10;
    box-shadow: 0 25px 50px var(--shadow-color), 0 0 30px rgba(255, 215, 0, 0.2);
    border-color: var(--color-brand);
}

.tarjeta-header {
    display: flex; flex-direction: column; align-items: center; padding: 1rem;
    font-size: 1.6rem; font-weight: 800; text-transform: uppercase; text-align: center;
    background-color: var(--color-header-default); color: var(--color-text-primary);
    border-bottom: 4px solid rgba(0,0,0,0.2);
}

.tarjeta-header i { color: var(--color-brand); margin-bottom: 5px; font-size: 1.8rem; }

.tarjeta-body {
    padding: 1.5rem; display: flex; justify-content: center; align-items: center; gap: 15px; flex-wrap: wrap; min-height: 120px;
}

/* Bolos 3D */
.numero-ganador {
    font-family: var(--font-numeros); font-size: 2.5rem; font-weight: 900;
    width: 80px; height: 80px; display: flex; justify-content: center; align-items: center;
    border-radius: 50%; background: var(--ball-bg); color: var(--ball-text);
    box-shadow: inset -8px -8px 15px rgba(0,0,0,0.3), inset 5px 5px 10px rgba(255,255,255,0.8), 0 10px 15px rgba(0,0,0,0.6);
    animation: popIn 0.5s backwards;
}

/* Alturas */
.pizarra.height-auto .tarjeta-loteria { min-height: 250px; }
.pizarra.height-short .tarjeta-loteria { min-height: 200px; }
.pizarra.height-normal .tarjeta-loteria { min-height: 300px; }
.pizarra.height-tall .tarjeta-loteria { min-height: 400px; }

/* ---------------------------------- */
/*      Indicadores NUEVO             */
/* ---------------------------------- */
.resultado-tag {
    padding: 0.4rem 1.2rem; border-radius: 30px; font-size: 1rem; font-weight: 900; margin-top: 8px;
}
.tag-nuevo { background-color: var(--color-nuevo); color: white; border: 2px solid #FF4D85; animation: neonPulse 1.5s infinite; }
.tag-actualizado { background-color: rgba(0,0,0,0.5); color: var(--color-brand); border: 1px solid var(--color-brand); }

/* ---------------------------------- */
/*      Cinta Animada (TICKER)        */
/* ---------------------------------- */
.tv-ticker {
    position: fixed; bottom: 0; left: 0; width: 100%; height: 60px;
    background: #000; border-top: 3px solid var(--color-brand); display: flex; align-items: center; z-index: 9000;
}
.ticker-label {
    background: var(--color-brand); color: #000; font-weight: 900; font-size: 1.5rem; padding: 0 2rem;
    height: 100%; display: flex; align-items: center; z-index: 2; box-shadow: 5px 0 15px rgba(0,0,0,0.5); text-transform: uppercase;
}
.ticker-content { flex: 1; overflow: hidden; white-space: nowrap; position: relative; height: 100%; display: flex; align-items: center; }
.ticker-text { display: inline-block; font-size: 1.8rem; font-weight: 700; color: #FFF; padding-left: 100%; animation: marquee 25s linear infinite; }
.ticker-text span { margin-right: 50px; }
.ticker-text i { color: var(--color-brand); margin-right: 10px; }

/* ---------------------------------- */
/*      Modal de Edición (Fijo)       */
/* ---------------------------------- */
.modal-overlay {
    position: fixed; top: 0; left: 0; width: 100vw; height: 100vh;
    background: rgba(0, 0, 0, 0.85); backdrop-filter: blur(5px);
    display: flex; justify-content: center; align-items: center; z-index: 10000;
}
.modal-content {
    background: var(--color-surface); padding: 2.5rem; border-radius: 20px;
    width: 90%; max-width: 500px; border: 2px solid var(--color-brand); box-shadow: 0 0 50px rgba(0,0,0,1);
}
.modal-content h2 { margin-top: 0; text-align: center; color: var(--color-brand); font-size: 2.2rem; margin-bottom: 1.5rem; }
.form-group { margin-bottom: 1.5rem; }
.form-group label { display: block; margin-bottom: 0.5rem; font-size: 1.2rem; font-weight: bold; color: var(--color-text-primary); }
.color-input { width: 100%; height: 60px; border: 2px solid var(--color-border); border-radius: 10px; padding: 0; cursor: pointer; background-color: transparent; }
.modal-actions { display: flex; justify-content: space-between; gap: 15px; margin-top: 2rem; }
.btn { flex: 1; padding: 1rem 0; border: none; border-radius: 10px; cursor: pointer; font-weight: 900; font-size: 1.1rem; text-transform: uppercase; transition: all 0.2s; }
.btn:hover { opacity: 0.8; transform: scale(1.05); }
.btn-save { background-color: #28A745; color: white; }
.btn-delete { background-color: var(--color-nuevo); color: white; }
.btn-close { background-color: var(--color-border); color: var(--color-text-primary); }

/* Varios */
.settings-btn { position: absolute; top: 10px; right: 10px; background: rgba(0,0,0,0.5); border: none; color: white; width: 40px; height: 40px; border-radius: 50%; cursor: pointer; z-index: 10; opacity: 0; transition: all 0.3s; }
.tarjeta-loteria:hover .settings-btn { opacity: 1; }
.settings-btn:hover { background: var(--color-brand); color: #000; transform: rotate(90deg); }

.loader-tv { text-align: center; color: var(--color-brand); font-size: 2rem; font-weight: bold; padding: 50px; grid-column: 1/-1;}
.lotto-ball-loader { width: 100px; height: 100px; border-radius: 50%; background: var(--ball-bg); margin: 0 auto 20px auto; animation: bounceLoader 1s infinite alternate; }

/* Animaciones */
@keyframes marquee { 0% { transform: translateX(0); } 100% { transform: translateX(-100%); } }
@keyframes neonPulse { 0% { box-shadow: 0 0 5px var(--color-nuevo); transform: scale(1); } 50% { box-shadow: 0 0 20px var(--color-nuevo); transform: scale(1.05); } 100% { box-shadow: 0 0 5px var(--color-nuevo); transform: scale(1); } }
@keyframes popIn { 0% { transform: scale(0); opacity: 0; } 80% { transform: scale(1.2); opacity: 1; } 100% { transform: scale(1); opacity: 1; } }
@keyframes slideUp { from { opacity: 0; transform: translateY(50px); } to { opacity: 1; transform: translateY(0); } }
@keyframes bounceLoader { from { transform: translateY(0); } to { transform: translateY(-50px); } }