/* ============================================================
   GAME SPOTLIGHT — identidad visual
   Concepto: cada juego se ilumina con el color de su propio género
   (generos.color_gradient ya viene en tu BD) — como un foco de
   escenario cayendo sobre la carátula. Fondo casi negro para que
   funcione igual de bien en un monitor de escritorio y en una TV.
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Anton&family=Manrope:wght@400;500;700;800&family=JetBrains+Mono:wght@400;600&display=swap');

:root {
    --bg: #0A0B10;
    --surface: #14161F;
    --surface-hover: #1B1E2A;
    --line: #262A38;
    --text: #ECEDF2;
    --muted: #8A8FA3;
    --gold: #E8B94A;
    --gold-dim: #E8B94A33;
    --radius: 14px;
    --font-display: 'Anton', sans-serif;
    --font-body: 'Manrope', sans-serif;
    --font-mono: 'JetBrains Mono', monospace;
}

* { box-sizing: border-box; }

/* El atributo hidden debe ganar siempre, incluso sobre elementos con
   display:flex o display:grid definido por su propia clase (modal,
   .app, .auth-gate, etc.) — sin esto, "hidden" queda sin efecto. */
[hidden] { display: none !important; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: var(--font-body);
    -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }

/* ---------- Layout ---------- */

.app {
    display: grid;
    grid-template-columns: 240px 1fr;
    min-height: 100vh;
}

.sidebar {
    background: var(--surface);
    border-right: 1px solid var(--line);
    padding: 28px 20px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.brand {
    font-family: var(--font-display);
    font-size: 22px;
    letter-spacing: 0.5px;
    margin-bottom: 32px;
    display: flex;
    align-items: baseline;
    gap: 6px;
}

.brand span { color: var(--gold); }

.nav-item {
    padding: 11px 14px;
    border-radius: 10px;
    color: var(--muted);
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease;
}

.nav-item:hover,
.nav-item:focus-visible {
    background: var(--surface-hover);
    color: var(--text);
    outline: 2px solid var(--gold-dim);
}

.nav-item.active {
    background: var(--gold-dim);
    color: var(--gold);
}

.main {
    padding: 32px 40px;
    max-width: 1400px;
}

.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 28px;
}

.topbar h1 {
    font-family: var(--font-display);
    font-weight: 400;
    font-size: 28px;
    margin: 0;
    letter-spacing: 0.3px;
}

.topbar .subtitle {
    color: var(--muted);
    font-size: 14px;
    margin-top: 4px;
}

/* ---------- Filtros ---------- */

.filtros {
    display: flex;
    gap: 10px;
    margin-bottom: 24px;
    flex-wrap: wrap;
}

.filtros select,
.filtros input {
    background: var(--surface);
    border: 1px solid var(--line);
    color: var(--text);
    border-radius: 9px;
    padding: 9px 14px;
    font-family: var(--font-body);
    font-size: 13px;
}

.filtros select:focus-visible,
.filtros input:focus-visible {
    outline: 2px solid var(--gold);
}

/* ---------- Grid de juegos (elemento firma: el "spotlight") ---------- */

.grid-juegos {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 20px;
}

.card-juego {
    position: relative;
    background: var(--surface);
    border-radius: var(--radius);
    overflow: hidden;
    border: 1px solid var(--line);
    transition: transform 0.18s ease, border-color 0.18s ease;
    cursor: pointer;
}

.card-juego:hover,
.card-juego:focus-visible {
    transform: translateY(-4px);
    border-color: var(--card-glow, var(--gold));
    outline: none;
}

/* El "foco de luz": un gradiente radial cayendo desde arriba con el color
   propio del género de cada juego (--card-glow se inyecta desde JS) */
.card-juego::before {
    content: '';
    position: absolute;
    inset: 0;
    background: radial-gradient(ellipse 140% 60% at 50% -10%, var(--card-glow, transparent), transparent 70%);
    opacity: 0.35;
    pointer-events: none;
}

.card-juego img {
    width: 100%;
    aspect-ratio: 3 / 4;
    object-fit: cover;
    display: block;
    background: var(--bg);
}

.card-juego .info {
    padding: 14px 14px 16px;
}

.card-juego .genero-tag {
    display: inline-block;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    padding: 3px 9px;
    border-radius: 999px;
    background: var(--card-glow, var(--gold-dim));
    color: #0A0B10;
    margin-bottom: 8px;
}

.card-juego h3 {
    margin: 0 0 4px;
    font-size: 15px;
    line-height: 1.3;
}

.card-juego .fecha {
    font-family: var(--font-mono);
    font-size: 12px;
    color: var(--muted);
}

/* ---------- Estados ---------- */

.estado-vacio,
.estado-cargando {
    color: var(--muted);
    font-family: var(--font-mono);
    font-size: 13px;
    padding: 40px 0;
    text-align: center;
}

/* ---------- Barra de sesión / login ---------- */

.barra-sesion {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 10px;
    font-size: 13px;
    color: var(--muted);
    margin-bottom: 18px;
    min-height: 20px;
}

.form-login {
    display: flex;
    gap: 8px;
    align-items: center;
}

.form-login input {
    background: var(--surface);
    border: 1px solid var(--line);
    color: var(--text);
    border-radius: 8px;
    padding: 7px 12px;
    font-size: 13px;
}

.form-login button {
    background: var(--gold);
    border: none;
    color: #0A0B10;
    font-weight: 700;
    border-radius: 8px;
    padding: 7px 16px;
    cursor: pointer;
    font-size: 13px;
}

.form-login .error {
    color: #E86A6A;
    font-size: 12px;
}

.link-boton {
    background: none;
    border: none;
    color: var(--gold);
    cursor: pointer;
    font-size: 13px;
    text-decoration: underline;
}

.boton-secundario {
    background: var(--surface);
    border: 1px solid var(--line);
    color: var(--text);
    border-radius: 9px;
    padding: 9px 16px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
}

.boton-secundario:hover { border-color: var(--gold); color: var(--gold); }

/* ---------- Vista Archivos ---------- */

.subtitulo-seccion {
    font-family: var(--font-display);
    font-weight: 400;
    font-size: 18px;
    margin: 32px 0 14px;
    color: var(--muted);
}

.dropzone {
    border: 2px dashed var(--line);
    border-radius: var(--radius);
    padding: 40px 20px;
    text-align: center;
    color: var(--muted);
    cursor: pointer;
    transition: border-color 0.15s ease, background 0.15s ease;
    margin-bottom: 20px;
}

.dropzone p { margin: 0; font-size: 14px; }
.dropzone strong { color: var(--text); }

.dropzone:hover,
.dropzone-activo {
    border-color: var(--gold);
    background: var(--gold-dim);
}

.form-vinculo {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
    margin-bottom: 20px;
}

.form-vinculo label {
    display: flex;
    flex-direction: column;
    gap: 6px;
    font-size: 12px;
    color: var(--muted);
    font-weight: 600;
}

.form-vinculo select {
    background: var(--surface);
    border: 1px solid var(--line);
    color: var(--text);
    border-radius: 8px;
    padding: 8px 12px;
    font-size: 13px;
    min-width: 180px;
}

.progreso {
    margin-bottom: 20px;
}

.progreso .barra {
    height: 8px;
    background: var(--surface);
    border-radius: 999px;
    overflow: hidden;
    border: 1px solid var(--line);
}

.progreso .barra span {
    display: block;
    height: 100%;
    background: var(--gold);
    width: 0%;
    transition: width 0.2s ease;
}

.progreso .texto-progreso {
    font-family: var(--font-mono);
    font-size: 12px;
    color: var(--muted);
}

.tabla-archivos {
    width: 100%;
    border-collapse: collapse;
    background: var(--surface);
    border-radius: var(--radius);
    overflow: hidden;
}

.tabla-archivos th,
.tabla-archivos td {
    text-align: left;
    padding: 12px 16px;
    border-bottom: 1px solid var(--line);
    font-size: 13px;
}

.tabla-archivos th {
    color: var(--muted);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 700;
}

.celda-mono { font-family: var(--font-mono); color: var(--muted); font-size: 12px; }

.acciones-tabla { display: flex; gap: 8px; }

.acciones-tabla button {
    background: var(--surface-hover);
    border: 1px solid var(--line);
    color: var(--text);
    border-radius: 7px;
    padding: 6px 12px;
    font-size: 12px;
    cursor: pointer;
}

.acciones-tabla button:hover { border-color: var(--gold); }
.acciones-tabla .boton-peligro:hover { border-color: #E86A6A; color: #E86A6A; }

/* ---------- Pantalla de acceso (auth gate) ---------- */

.auth-gate {
    position: fixed;
    inset: 0;
    background: var(--bg);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    padding: 20px;
}

.auth-box {
    width: 100%;
    max-width: 380px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 32px;
}

.brand-center { justify-content: center; margin-bottom: 24px; }

.auth-tabs {
    display: flex;
    gap: 4px;
    background: var(--bg);
    border-radius: 10px;
    padding: 4px;
    margin-bottom: 22px;
}

.auth-tab {
    flex: 1;
    background: none;
    border: none;
    color: var(--muted);
    padding: 9px;
    border-radius: 7px;
    cursor: pointer;
    font-weight: 700;
    font-size: 13px;
}

.auth-tab.active { background: var(--gold-dim); color: var(--gold); }

.form-auth {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.form-auth label {
    display: flex;
    flex-direction: column;
    gap: 6px;
    font-size: 12px;
    color: var(--muted);
    font-weight: 600;
}

.form-auth input {
    background: var(--bg);
    border: 1px solid var(--line);
    color: var(--text);
    border-radius: 8px;
    padding: 10px 12px;
    font-size: 14px;
}

.form-auth button {
    background: var(--gold);
    border: none;
    color: #0A0B10;
    font-weight: 700;
    border-radius: 9px;
    padding: 11px;
    cursor: pointer;
    font-size: 14px;
    margin-top: 4px;
}

.error { color: #E86A6A; font-size: 12px; }

/* ---------- Botón primario / acciones de tarjeta ---------- */

.boton-primario {
    background: var(--gold);
    border: none;
    color: #0A0B10;
    font-weight: 700;
    border-radius: 9px;
    padding: 9px 16px;
    cursor: pointer;
    font-size: 13px;
}

.acciones-card {
    display: flex;
    gap: 8px;
    margin-top: 10px;
}

.acciones-card button {
    flex: 1;
    background: var(--surface-hover);
    border: 1px solid var(--line);
    color: var(--text);
    border-radius: 7px;
    padding: 6px 0;
    font-size: 12px;
    cursor: pointer;
}

.acciones-card button:hover { border-color: var(--gold); }
.acciones-card .boton-peligro:hover { border-color: #E86A6A; color: #E86A6A; }

/* ---------- Modal genérico ---------- */

.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 200;
    padding: 20px;
}

.modal-box {
    width: 100%;
    max-width: 480px;
    max-height: 85vh;
    overflow-y: auto;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 24px;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 18px;
}

.modal-header h3 { margin: 0; font-family: var(--font-display); font-weight: 400; font-size: 20px; }

.modal-cerrar {
    background: none;
    border: none;
    color: var(--muted);
    font-size: 22px;
    cursor: pointer;
    line-height: 1;
}

.modal-form {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.modal-form label {
    display: flex;
    flex-direction: column;
    gap: 6px;
    font-size: 12px;
    color: var(--muted);
    font-weight: 600;
}

.modal-form input,
.modal-form select,
.modal-form textarea {
    background: var(--bg);
    border: 1px solid var(--line);
    color: var(--text);
    border-radius: 8px;
    padding: 9px 12px;
    font-size: 14px;
    font-family: var(--font-body);
}

.modal-form fieldset {
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 12px;
}

.modal-form legend {
    font-size: 12px;
    color: var(--muted);
    font-weight: 600;
    padding: 0 6px;
}

.check-inline {
    flex-direction: row !important;
    align-items: center;
    gap: 8px !important;
    font-size: 13px !important;
    color: var(--text) !important;
    display: inline-flex;
    margin: 4px 10px 4px 0;
}

.modal-form button[type="submit"] {
    background: var(--gold);
    border: none;
    color: #0A0B10;
    font-weight: 700;
    border-radius: 9px;
    padding: 11px;
    cursor: pointer;
    font-size: 14px;
}

.swatch {
    display: inline-block;
    width: 14px;
    height: 14px;
    border-radius: 4px;
    vertical-align: middle;
    margin-right: 4px;
}

/* ---------- Listas de administración (noticias/trailers/géneros/plataformas) ---------- */

.lista-admin table { width: 100%; }

/* ---------- Responsive ---------- */

@media (max-width: 860px) {
    .app { grid-template-columns: 1fr; }
    .sidebar {
        border-right: none;
        border-bottom: 1px solid var(--line);
        flex-direction: row;
        overflow-x: auto;
        padding: 16px 20px;
    }
    .brand { display: none; }
    .main { padding: 20px; }
}

/* ---------- Modo TV (10-foot UI) ---------- */
/* Activado agregando la clase .modo-tv al <body> — ver assets/js/app.js */

body.modo-tv {
    font-size: 18px;
}

body.modo-tv .grid-juegos {
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 32px;
}

body.modo-tv .card-juego h3 { font-size: 20px; }
body.modo-tv .card-juego .fecha { font-size: 15px; }

body.modo-tv .card-juego:focus-visible {
    transform: scale(1.06);
    border-color: var(--gold);
    box-shadow: 0 0 0 4px var(--gold-dim);
}

@media (prefers-reduced-motion: reduce) {
    .card-juego { transition: none; }
}
