/* ==========================================================================
   Variables de Diseño (Estilo Netflix)
   ========================================================================== */
:root {
    --bg-color: #141414;
    /* Fondo principal oscuro */
    --bg-color-hover: #262626;
    --text-color: #e5e5e5;
    /* Blanco hueso para mejor legibilidad */
    --text-muted: #808080;
    --primary-color: #E50914;
    /* Rojo Netflix */
    --primary-color-hover: #b81d24;
    --navbar-bg: rgba(20, 20, 20, 0);
    /* Transparente inicialmente */
    --navbar-bg-scrolled: rgb(20, 20, 20);
    /* Sólido en scroll */
    --match-green: #46d369;
    /* Verde de "98% Match" */

    --font-family: 'Inter', system-ui, -apple-system, sans-serif;

    --transition-fast: 0.2s ease;
    --transition-smooth: 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94);

    --z-index-nav: 1000;
    --z-index-hero-content: 10;
}

/* ==========================================================================
   Reset y Base
   ========================================================================== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    background-color: var(--bg-color);
    color: var(--text-color);
    font-family: var(--font-family);
    font-size: 16px;
    line-height: 1.5;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

a {
    color: inherit;
    text-decoration: none;
    transition: color var(--transition-fast);
}

button {
    font-family: inherit;
    cursor: pointer;
    border: none;
    background: none;
}

/* ==========================================================================
   Navegación (Navbar)
   ========================================================================== */
.navbar {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    padding: 20px 4%;
    background-color: var(--navbar-bg);
    background-image: linear-gradient(to bottom, rgba(0, 0, 0, 0.7) 10%, rgba(0, 0, 0, 0));
    z-index: var(--z-index-nav);
    transition: background-color var(--transition-smooth);
}

.navbar.scrolled {
    background-color: var(--navbar-bg-scrolled);
    background-image: none;
}

.nav-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    max-width: 1800px;
    margin: 0 auto;
}

.logo {
    color: var(--primary-color);
    font-size: 1.8rem;
    font-weight: 800;
    letter-spacing: -1px;
    text-transform: uppercase;
}

.logo span {
    color: white;
    font-weight: 300;
    text-transform: none;
}

.nav-links {
    display: none;
    /* Oculto en móviles, mostrado en desktop */
    margin-left: 2rem;
    flex-grow: 1;
}

.nav-links a {
    margin-right: 20px;
    font-size: 0.9rem;
    font-weight: 500;
    color: #e5e5e5;
    opacity: 0.8;
}

.nav-links a:hover,
.nav-links a.active {
    opacity: 1;
    font-weight: 600;
}

.nav-actions {
    display: flex;
    align-items: center;
    gap: 15px; /* Increased to accommodate balance */
}

.tivon-balance {
    display: flex; /* JS controla visibilidad via style.display */
    align-items: center;
    gap: 6px;
    background: rgba(255, 215, 0, 0.1);
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 700;
    color: #ffd700;
    border: 1px solid rgba(255, 215, 0, 0.3);
    cursor: pointer;
    transition: transform 0.2s ease;
}

.tivon-balance:hover {
    transform: scale(1.05);
    background: rgba(255, 215, 0, 0.2);
}

.tivon-balance.premium {
    background: linear-gradient(90deg, #ffd700, #ffcc00);
    color: #000;
    border: none;
}

/* Marco dorado brillante para foto premium */
@keyframes gold-glow-spin {
    0%   { box-shadow: 0 0 0 3px #ffd700, 0 0 12px 4px #ffd70088, 0 0 24px 8px #d4af3744; }
    50%  { box-shadow: 0 0 0 3px #f5c400, 0 0 18px 6px #ffd700bb, 0 0 36px 12px #d4af3766; }
    100% { box-shadow: 0 0 0 3px #ffd700, 0 0 12px 4px #ffd70088, 0 0 24px 8px #d4af3744; }
}

.premium-avatar-frame {
    border: 3px solid #ffd700 !important;
    animation: gold-glow-spin 2s ease-in-out infinite;
    overflow: visible !important;
}

.premium-avatar-frame img,
.premium-avatar-frame #account-avatar-placeholder {
    border-radius: 50%;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Badge "PRO" sobre el avatar */
.premium-avatar-badge {
    position: absolute;
    bottom: -4px;
    right: -4px;
    background: linear-gradient(135deg, #d4af37, #ffd700);
    color: #000;
    font-size: 9px;
    font-weight: 900;
    padding: 2px 6px;
    border-radius: 8px;
    letter-spacing: 0.5px;
    z-index: 10;
    box-shadow: 0 2px 6px rgba(0,0,0,0.5);
}

.btn-icon {
    color: white;
    opacity: 0.8;
}

.btn-icon:hover {
    opacity: 1;
}

.user-profile {
    width: 32px;
    height: 32px;
    background-color: #333;
    border-radius: 4px;
    /* Cuadrado con bordes muy ligeros, típico Netflix */
    background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="white"><path d="M12 12c2.21 0 4-1.79 4-4s-1.79-4-4-4-4 1.79-4 4 1.79 4 4 4zm0 2c-2.67 0-8 1.34-8 4v2h16v-2c0-2.66-5.33-4-8-4z"/></svg>');
    background-size: cover;
    cursor: pointer;
}

/* ==========================================================================
   Hero Section
   ========================================================================== */
.hero {
    position: relative;
    height: 55vh;
    min-height: 400px;
    display: flex;
    align-items: center;
    padding: 0 4%;
    color: white;
    background-color: #000;
    /* Efecto parallax ultra sutil en el futuro */
}

/* El fondo falso para representar la viñeta y gradientes */
.hero-bg-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background:
        radial-gradient(circle at center, rgba(0, 0, 0, 0) 0%, #141414 100%),
        /* Gradiente para leer el texto en móvil */
        linear-gradient(to right, rgba(0, 0, 0, 0.8) 0%, rgba(0, 0, 0, 0) 60%);
    z-index: 1;
}

/* Patrón de puntos o imagen decorativa de fondo */
.hero::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: radial-gradient(circle, #333 1px, transparent 1px);
    background-size: 20px 20px;
    opacity: 0.1;
}

.hero-content {
    position: relative;
    z-index: var(--z-index-hero-content);
    max-width: 600px;
    margin-top: 50px;
}

.hero-title {
    font-size: clamp(2.5rem, 5vw, 4rem);
    font-weight: 800;
    line-height: 1.1;
    margin-bottom: 20px;
    letter-spacing: -1px;
}

.hero-subtitle {
    font-size: 1.2rem;
    font-weight: 400;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.45);
    margin-bottom: 30px;
    color: #fff;
    line-height: 1.6;
}

.hero-buttons {
    display: flex;
    gap: 15px;
    flex-wrap: wrap;
}

.btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 10px 24px;
    font-size: 1.2rem;
    font-weight: 600;
    border-radius: 4px;
    transition: var(--transition-fast);
}

.btn-primary {
    background-color: white;
    color: black;
}

.btn-primary:hover {
    background-color: rgba(255, 255, 255, 0.75);
}

.btn-secondary {
    background-color: rgba(109, 109, 110, 0.7);
    color: white;
}

.btn-secondary:hover {
    background-color: rgba(109, 109, 110, 0.4);
}

.hero-fade-bottom {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 150px;
    background-image: linear-gradient(to bottom, rgba(20, 20, 20, 0) 0%, #141414 100%);
    z-index: 5;
}

/* ==========================================================================
   Catálogo / Grid Principal
   ========================================================================== */
.main-content {
    padding: 2vw 4%;
    position: relative;
    z-index: 10;
    margin-top: -100px;
    /* Para superponerse sutilmente al hero */
}

.catalog-section {
    margin-bottom: 3vw;
}

.section-title {
    font-size: 1.4vw;
    font-weight: 600;
    margin-bottom: 15px;
    display: inline-block;
}

@media (max-width: 800px) {
    .section-title {
        font-size: 18px;
    }
}

.grid-container {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 20px;
    /* Grid estilo Netflix: no es flex wrap, sino grillas uniformes */
}

/* ==========================================================================
   Tarjetas de Herramientas (Cards)
   ========================================================================== */
.tool-card {
    position: relative;
    border-radius: 4px;
    overflow: hidden;
    cursor: pointer;
    transition: transform var(--transition-smooth), box-shadow var(--transition-smooth);
    background-color: var(--bg-color-hover);
}

.card-image-wrapper {
    position: relative;
    width: 100%;
    aspect-ratio: 16 / 9;
    /* Formato clásico de miniatura */
    background-color: #222;
    overflow: hidden;
}

.placeholder-skeleton {
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, #222 25%, #333 50%, #222 75%);
    background-size: 200% 100%;
    animation: skeleton-loading 1.5s infinite linear;
}

@keyframes skeleton-loading {
    0% {
        background-position: 200% 0;
    }

    100% {
        background-position: -200% 0;
    }
}

/* Overlay en hover */
.card-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity var(--transition-fast);
}

.tool-card:hover {
    transform: scale(1.05);
    z-index: 50;
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.6);
}

.tool-card:hover .card-overlay {
    opacity: 1;
}

.btn-play-mini {
    background: rgba(255, 255, 255, 0.2);
    border: 2px solid white;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition-fast);
}

.btn-play-mini:hover {
    background: white;
    color: black;
}

.card-info {
    padding: 15px;
    background: var(--bg-color-hover);
}

.card-title {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 8px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.card-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.8rem;
    font-weight: 500;
}

.match-score {
    color: var(--match-green);
}

.badge {
    border: 1px solid rgba(255, 255, 255, 0.4);
    padding: 1px 4px;
    border-radius: 2px;
    color: #fff;
    text-transform: uppercase;
    font-size: 0.7rem;
}

.quality {
    border: 1px solid rgba(255, 255, 255, 0.4);
    padding: 1px 4px;
    border-radius: 3px;
    font-size: 0.6rem;
}

/* ==========================================================================
   Footer
   ========================================================================== */
.site-footer {
    padding: 40px 4%;
    margin-top: 50px;
    color: var(--text-muted);
    font-size: 0.9rem;
    text-align: center;
}

/* ==========================================================================
   Responsive Ajustes
   ========================================================================== */
@media (min-width: 768px) {
    .nav-links {
        display: flex;
    }
}

/* ==========================================================================
   Modales de Autenticación (Login / Registro)
   ========================================================================== */
.auth-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.85);
    /* Fondo oscuro semitransparente pesado */
    backdrop-filter: blur(8px);
    z-index: 9999;
    display: flex;
    justify-content: center;
    align-items: center;
    opacity: 1;
    transition: opacity 0.3s ease;
}

.auth-overlay.hidden {
    opacity: 0;
    pointer-events: none;
    display: none;
}

.auth-modal {
    background-color: #181818;
    /* Casi negro profundo */
    border: 1px solid #333;
    border-radius: 12px;
    width: 90%;
    max-width: 440px;
    padding: 40px;
    position: relative;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.8);
    transform: translateY(0);
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.auth-overlay.hidden .auth-modal {
    transform: translateY(20px);
}

.auth-close-btn {
    position: absolute;
    top: 15px;
    right: 20px;
    font-size: 28px;
    color: #808080;
    transition: color 0.2s ease;
}

.auth-close-btn:hover {
    color: #fff;
}

.auth-header {
    text-align: center;
    margin-bottom: 25px;
}

.auth-header h2 {
    font-size: 2rem;
    color: var(--primary-color);
    font-weight: 800;
    margin-bottom: 5px;
}

.auth-header h2 span {
    color: white;
}

.auth-header p {
    color: #a3a3a3;
    font-size: 0.95rem;
}

.auth-tabs {
    display: flex;
    border-bottom: 1px solid #333;
    margin-bottom: 25px;
}

.auth-tab {
    flex: 1;
    padding: 12px 10px;
    color: #808080;
    font-weight: 600;
    font-size: 1rem;
    transition: all 0.2s ease;
    border-bottom: 3px solid transparent;
}

.auth-tab.active {
    color: #fff;
    border-bottom: 3px solid var(--primary-color);
}

.auth-tab:hover:not(.active) {
    color: #bbb;
}

.auth-form {
    display: none;
    flex-direction: column;
    gap: 15px;
}

.auth-form.active {
    display: flex;
}

.form-group label {
    display: block;
    margin-bottom: 6px;
    font-size: 0.85rem;
    color: #a3a3a3;
    font-weight: 500;
}

.form-group input {
    width: 100%;
    background-color: #333;
    border: 1px solid #444;
    color: #fff;
    padding: 12px 15px;
    border-radius: 6px;
    font-size: 1rem;
    font-family: inherit;
    transition: border-color 0.2s ease, background-color 0.2s ease;
}

.form-group input:focus {
    outline: none;
    border-color: var(--primary-color);
    background-color: #404040;
}

.auth-submit {
    margin-top: 10px;
    padding: 14px;
    font-size: 1.1rem;
    font-weight: 600;
    border-radius: 6px;
}

.auth-error {
    color: var(--primary-color);
    font-size: 0.85rem;
    text-align: center;
    min-height: 20px;
    margin-top: 5px;
}

/* Estado de perfil cuando está logueado */
.user-profile.logged-in {
    background-color: var(--primary-color);
    color: white;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
}