:root {
    --bg-color: #121212;
    --text-color: #ffffff;
    --card-bg: #1f1f1f;
    --input-bg: #2c2c2c;
    --border-color: #333333;
}
[data-theme="light"] {
    --bg-color: #f0f2f5;
    --text-color: #1c1e21;
    --card-bg: #ffffff;
    --input-bg: #e4e6eb;
    --border-color: #cccccc;
}

* { 
    box-sizing: border-box; 
    margin: 0; 
    padding: 0; 
    -webkit-tap-highlight-color: transparent; /* Adiós al parpadeo gris al tocar */
    outline: none;
}

/* Evitar que se seleccione el texto al mantener pulsado (Efecto App Nativa) */
button, a, .nav-btn, .tab-btn, h1, h2, h3, .profile-tabs, #user-greeting {
    -webkit-user-select: none;
    user-select: none;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background-color: var(--bg-color); color: var(--text-color);
    transition: background-color 0.3s, color 0.3s;
}

.header-top { background-color: var(--card-bg); position: sticky; top: 0; z-index: 100; border-bottom: 1px solid var(--border-color); display: flex; flex-direction: column; }
.header-main { display: flex; justify-content: space-between; align-items: center; padding: 15px; }
#theme-toggle { background: none; border: none; font-size: 24px; cursor: pointer; }

/* ESTILOS DEL MENÚ PRINCIPAL (Escritorio por defecto) */
.main-nav {
    flex-direction: row; 
    background: var(--card-bg);
    border-bottom: 1px solid var(--border-color);
    width: 100%;
    justify-content: center;
}
.nav-links {
    display: flex;
    flex-direction: row;
    gap: 15px;
    padding: 10px 15px;
    overflow-x: auto;
    width: 100%;
    justify-content: center;
    scrollbar-width: none;
}
.nav-links::-webkit-scrollbar { display: none; }

.nav-btn { 
    flex: 0 0 auto; 
    background: none; border: none; color: #888; 
    font-size: 14px; padding: 10px 5px; cursor: pointer; text-align: center; 
}
.nav-btn.active { color: #e50914; font-weight: bold; }

.view { display: none; } .view.active { display: block; }

.search-bar { display: flex; padding: 15px; gap: 10px; }
.search-bar input, .auth-box input { flex: 1; padding: 12px; border-radius: 8px; border: 1px solid var(--border-color); background: var(--input-bg); color: var(--text-color); font-size: 16px; outline: none; }
.search-bar button { padding: 12px 20px; border-radius: 8px; border: none; background: #e50914; color: white; font-weight: bold; font-size: 16px; cursor: pointer; }

.grid-container { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 15px; padding: 15px; }

.card { background: var(--card-bg); border-radius: 8px; overflow: hidden; display: flex; flex-direction: column; text-align: center; border: 1px solid var(--border-color); box-shadow: 0 2px 5px rgba(0,0,0,0.1); position: relative; }
.card img { width: 100%; height: auto; aspect-ratio: 2/3; object-fit: cover; cursor: pointer; }
.card h3 { font-size: 14px; padding: 10px; flex: 1; cursor: pointer; }
.card button { background: #e50914; color: white; border: none; padding: 10px; width: 100%; font-weight: bold; cursor: pointer; }

.auth-box { padding: 30px; display: flex; flex-direction: column; gap: 15px; margin-top: 50px; }
.auth-box button { padding: 15px; border-radius: 8px; border: none; background: #e50914; color: white; font-weight: bold; cursor: pointer; }
.auth-box .btn-secondary { background: #444; }

.btn-group { display: flex; width: 100%; gap: 5px; padding: 5px; }
.btn-group button { font-size: 12px; padding: 8px; border-radius: 4px; cursor: pointer; }
/* Botón para hacer la acción (Azul) */
.btn-visto { background: #007bff !important; color: white; } 

/* Botón de confirmación cuando ya está vista (Verde y desactivado) */
.btn-ya-visto { 
    background: #28a745 !important; 
    color: white; 
    opacity: 0.8; 
    cursor: default !important; 
    pointer-events: none; /* Evita que se pueda hacer clic de nuevo */
}
.btn-borrar { background: #dc3545 !important; }
.status-badge { position: absolute; top: 5px; right: 5px; background: rgba(40,167,69,0.9); color:white; padding: 5px 10px; border-radius: 5px; font-size: 12px; font-weight: bold; z-index: 10; }
.media-badge { position: absolute; top: 5px; left: 5px; background: rgba(0, 0, 0, 0.8); color: white; padding: 4px 8px; border-radius: 5px; font-size: 12px; font-weight: bold; z-index: 10; border: 1px solid rgba(255,255,255,0.2); backdrop-filter: blur(2px); }

/* SISTEMA DE ESTRELLAS */
.rating-container { display: flex; justify-content: center; gap: 1px; padding: 5px 0; margin-top: auto; }
.star { color: #555555; font-size: 14px; cursor: pointer; transition: transform 0.1s, color 0.2s; }
.star.active { color: #f5c518; }
.star:active { transform: scale(1.3); }

/* PESTAÑAS DEL PERFIL */
.profile-header { padding: 20px; text-align: center; background: var(--card-bg); border-bottom: 1px solid var(--border-color); }
#profile-username { margin-bottom: 15px; font-size: 22px; color: #e50914; }
.profile-tabs { display: flex; justify-content: center; gap: 10px; }
.tab-btn { padding: 10px 15px; border-radius: 20px; border: 1px solid var(--border-color); background: var(--input-bg); color: var(--text-color); cursor: pointer; font-weight: bold; font-size: 13px;}
.tab-btn.active { background: #e50914; color: white; border-color: #e50914; }

/* Detalles y Responsive */
.btn-volver { margin: 15px; padding: 10px 15px; background: var(--card-bg); color: var(--text-color); border: 1px solid var(--border-color); border-radius: 8px; font-weight: bold; cursor: pointer; }

.details-header { 
    display: flex; 
    gap: 15px; 
    margin-bottom: 20px; 
}

.details-header img { 
    width: 120px; 
    border-radius: 8px; 
    box-shadow: 0 4px 8px rgba(0,0,0,0.3); 
    align-self: flex-start; /* Evita que la imagen se estire verticalmente */
    object-fit: cover; 
    aspect-ratio: 2/3; 
    flex-shrink: 0; /* Evita que el móvil aplaste la imagen si falta espacio */
}

.details-info { 
    flex: 1; 
    min-width: 0; /* ¡LA CLAVE MÁGICA! Evita que el texto empuje la pantalla hacia los lados */
}

.details-info h2 { 
    margin-bottom: 10px; 
    font-size: 20px; 
    word-wrap: break-word; /* Si un título es excesivamente largo, lo corta en lugar de salirse */
}

.tag { 
    display: inline-block; 
    background: #e50914; 
    color: white; 
    padding: 4px 8px; 
    border-radius: 12px; 
    font-size: 12px; 
    font-weight: bold; 
    margin-bottom: 5px; 
}

.overview { 
    line-height: 1.6; 
    opacity: 0.9; 
    word-wrap: break-word; 
}

/* Hacemos que los botones de acción se adapten si no caben en una fila */
.details-info > div[style*="display:flex"] {
    flex-wrap: wrap !important;
}

/* ESTILOS PARA USUARIOS Y AMIGOS */
.user-card {
    background: var(--card-bg); border: 1px solid var(--border-color);
    padding: 15px; border-radius: 8px; margin-bottom: 10px;
    display: flex; justify-content: space-between; align-items: center;
}
.user-card-info { display: flex; align-items: center; gap: 10px; font-weight: bold; font-size: 16px; }
.user-card-actions { display: flex; gap: 5px; }
.btn-small { padding: 8px 12px; border-radius: 5px; font-weight: bold; border: none; cursor: pointer; color: white; }
.btn-add { background: #e50914; }
.btn-accept { background: #28a745; }
.btn-reject { background: #dc3545; }

/* ==================================================== */
/* COMPONENTES VISUALES Y EFECTOS                       */
/* ==================================================== */

/* EFECTO SPOILER PARA COMENTARIOS */
.spoiler {
    background-color: rgba(255, 255, 255, 0.1);
    color: transparent;
    text-shadow: 0 0 10px rgba(255, 255, 255, 0.5);
    cursor: pointer;
    border-radius: 4px;
    padding: 0 5px;
    transition: all 0.3s ease;
}
.spoiler.revealed {
    background-color: rgba(229, 9, 20, 0.2);
    color: inherit;
    text-shadow: none;
}

/* SPINNER DE CARGA ANIMADO */
.spinner {
    width: 40px; height: 40px;
    border: 4px solid rgba(255, 255, 255, 0.1);
    border-left-color: #e50914;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto;
}
@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}
.loader-container {
    grid-column: 1 / -1;
    text-align: center;
    padding: 40px 20px;
}

/* BOTÓN FLOTANTE PARA VOLVER ARRIBA */
#btn-scroll-top {
    display: none; position: fixed; bottom: 30px; right: 30px; z-index: 999;
    font-size: 20px; border: none; outline: none; background-color: #e50914; color: white;
    cursor: pointer; width: 50px; height: 50px; border-radius: 50%;
    box-shadow: 0 4px 10px rgba(0,0,0,0.5); transition: background-color 0.3s, transform 0.2s;
    display: flex; align-items: center; justify-content: center; opacity: 0; pointer-events: none;
}
#btn-scroll-top.visible { opacity: 1; pointer-events: auto; }
#btn-scroll-top:hover { background-color: #b2070f; transform: scale(1.1); }

/* ==================================================== */
/* DISEÑO MÓVIL (BURBUJA FLOTANTE LIQUID GLASS)        */
/* ==================================================== */
@media (max-width: 768px) {
    /* 1. Ocultar el viejo botón de menú hamburguesa */
    .menu-toggle { display: none !important; }
    
    /* 2. Burbuja flotante estilo Telegram con efecto Liquid Glass */
    #main-nav {
        position: fixed !important;
        bottom: 25px; /* Flota a 25px del fondo */
        left: 50%;
        transform: translateX(-50%); /* Centrado horizontal perfecto */
        width: auto !important; /* Se ajusta al contenido */
        max-width: 92% !important; /* Evita que toque los bordes */
        z-index: 1000;
        
        /* Aumentamos transparencia y desenfoque para el efecto Liquid Glass */
        background: rgba(10, 10, 10, 0.45) !important; /* Más transparente */
        backdrop-filter: blur(25px); /* Mucho más desenfoque */
        -webkit-backdrop-filter: blur(25px);
        
        /* Borde muy sutil y forma de píldora */
        border: 1px solid rgba(255, 255, 255, 0.08) !important; 
        border-radius: 35px; /* Burbuja/píldora */
        
        /* Sombra pronunciada para el efecto flotante */
        box-shadow: 0 10px 40px 0 rgba(0, 0, 0, 0.5); 
        
        flex-direction: row !important; /* Forzamos horizontal */
        transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        padding: 6px 10px; /* Padding interno de la burbuja */
    }

    /* Clase para ocultar la burbuja al hacer scroll (la esconde por debajo) */
    #main-nav.nav-hidden {
        transform: translate(-50%, 150%);
    }

    /* 3. Contenedor de botones horizontal y deslizable */
    #nav-links {
        display: flex !important;
        flex-direction: row !important;
        padding: 6px 0; /* Quitamos padding lateral para el scroll */
        gap: 10px; /* Espacio reducido entre botones */
        overflow-x: auto;
        scrollbar-width: none; 
        -ms-overflow-style: none; 
        width: 100%;
        justify-content: flex-start; /* Permitimos el scroll lateral */
    }
    #nav-links::-webkit-scrollbar { display: none; }

    /* 4. Estilo de los botones "píldora" dentro de la burbuja */
    .nav-btn, .nav-links button {
        flex: 0 0 auto !important;
        white-space: nowrap !important;
        padding: 8px 16px !important;
        border: none !important;
        background: rgba(255,255,255,0.06) !important; /* Fondo sutil */
        border-radius: 20px !important; 
        font-size: 14px !important;
        color: var(--text-color) !important;
        opacity: 0.9;
    }
    .nav-btn.active, .nav-links button.active {
        background: #e50914 !important; /* Rojo PopcornWatch al activo */
        color: white !important;
        opacity: 1;
    }

    /* 5. Ajustes extra para el contenido de la web */
    body { padding-bottom: 110px; } /* Espacio para la burbuja flotante */
    #btn-scroll-top { bottom: 105px; } /* Sube el botón de volver arriba */

    /* Ocultar el footer en móviles para que parezca una App Nativa */
    footer { display: none !important; }
}

/* ==================================================== */
/* RULETA DE CARGA PARA BOTONES (UX Premium)            */
/* ==================================================== */
.btn-spinner {
    display: inline-block;
    width: 14px;
    height: 14px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: #fff;
    animation: spin-btn 0.8s linear infinite;
    vertical-align: middle;
    margin-right: 6px;
}

@keyframes spin-btn {
    100% { transform: rotate(360deg); }
}