/* ========================================================================
   1. ESTILOS BASE Y RESETEO (BLINDADO)
   ======================================================================== */
body {
    background-color: #000;
    color: #fff;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    margin-top: 0px;
    margin-right: 0px;
    margin-bottom: 0px;
    margin-left: 0px;
    padding-top: 0px;
    padding-right: 0px;
    padding-bottom: 0px;
    padding-left: 0px;
    overflow-x: hidden;
}

/* ######################################################################## */
/* [ZONA BLINDADA] PANTALLA DE ACCESO (LOGIN)                               */
/* ######################################################################## */
.login-overlay {
    position: fixed;
    top: 0px;
    left: 0px;
    width: 100%;
    height: 100%;
    background-color: #000;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
}

.login-box {
    background-color: #111;
    padding-top: 40px;
    padding-right: 40px;
    padding-bottom: 40px;
    padding-left: 40px;
    border-radius: 15px;
    border-top-width: 1px;
    border-top-style: solid;
    border-top-color: #333;
    border-right-width: 1px;
    border-right-style: solid;
    border-right-color: #333;
    border-bottom-width: 1px;
    border-bottom-style: solid;
    border-bottom-color: #333;
    border-left-width: 1px;
    border-left-style: solid;
    border-left-color: #333;
    width: 320px;
    text-align: center;
    box-shadow: 0px 10px 30px rgba(0, 0, 0, 0.5);
    box-sizing: border-box;
}

.login-logo {
    width: 200px;
    max-width: 100%;
    height: auto;
    display: block;
    margin-top: 0px;
    margin-right: auto;
    margin-bottom: 20px;
    margin-left: auto;
    object-fit: contain;
}

.login-box h2 {
    color: #fff;
    font-size: 1.2rem;
    margin-top: 0px;
    margin-right: 0px;
    margin-bottom: 25px;
    margin-left: 0px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.login-box input {
    width: 100%;
    padding-top: 12px;
    padding-right: 12px;
    padding-bottom: 12px;
    padding-left: 12px;
    margin-top: 0px;
    margin-right: 0px;
    margin-bottom: 15px;
    margin-left: 0px;
    background-color: #222;
    border-top-width: 1px;
    border-top-style: solid;
    border-top-color: #444;
    border-right-width: 1px;
    border-right-style: solid;
    border-right-color: #444;
    border-bottom-width: 1px;
    border-bottom-style: solid;
    border-bottom-color: #444;
    border-left-width: 1px;
    border-left-style: solid;
    border-left-color: #444;
    color: white;
    border-radius: 5px;
    box-sizing: border-box;
    outline: none;
}

.login-box input:focus {
    border-top-color: #ffb500;
    border-right-color: #ffb500;
    border-bottom-color: #ffb500;
    border-left-color: #ffb500;
}

.btn-naranja-login {
    width: 100%;
    padding-top: 12px;
    padding-right: 12px;
    padding-bottom: 12px;
    padding-left: 12px;
    background-color: #ffb500;
    border-top-style: none;
    border-right-style: none;
    border-bottom-style: none;
    border-left-style: none;
    color: #000;
    font-weight: bold;
    cursor: pointer;
    border-radius: 5px;
    font-size: 1rem;
    transition-property: background-color;
    transition-duration: 0.3s;
    transition-timing-function: ease;
}

.btn-naranja-login:hover {
    background-color: #e6a400;
}

/* ========================================================================
   2. HEADER: LOGO 30PX Y BUSCADOR
   ======================================================================== */
.main-header {
    background-color: #000;
    position: sticky;
    top: 0px;
    z-index: 1000;
    border-bottom-width: 1px;
    border-bottom-style: solid;
    border-bottom-color: #222;
}

.header-top {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    padding-top: 10px;
    padding-right: 4%;
    padding-bottom: 10px;
    padding-left: 4%;
}

.main-logo {
    height: 30px;
    width: auto;
    cursor: pointer;
    display: block;
}

.h-center {
    width: 100%;
    display: flex;
    justify-content: center;
}

.search-container {
    position: relative;
    width: 100%;
    max-width: 500px;
    display: flex;
    align-items: center;
}

#searchInput {
    width: 100%;
    padding-top: 6px;
    padding-right: 40px;
    padding-bottom: 6px;
    padding-left: 15px;
    border-radius: 20px;
    border-top-width: 1px;
    border-top-style: solid;
    border-top-color: #333;
    border-right-width: 1px;
    border-right-style: solid;
    border-right-color: #333;
    border-bottom-width: 1px;
    border-bottom-style: solid;
    border-bottom-color: #333;
    border-left-width: 1px;
    border-left-style: solid;
    border-left-color: #333;
    background-color: #1a1a1a;
    color: #fff;
    font-size: 16px;
    box-sizing: border-box;
}

#searchInput:focus {
    border-top-color: #ffb500;
    border-right-color: #ffb500;
    border-bottom-color: #ffb500;
    border-left-color: #ffb500;
    outline: none;
}

.btn-clear-search {
    position: absolute;
    right: 10px;
    background-color: transparent;
    border-top-style: none;
    border-right-style: none;
    border-bottom-style: none;
    border-left-style: none;
    color: #666;
    font-size: 20px;
    cursor: pointer;
    line-height: 1;
}

.h-right {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 15px;
}

.user-badge {
    height: 30px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    position: relative;
    padding: 5px 10px;
}

.user-avatar-circle {
    width: 40px !important;
    height: 40px !important;
    border: 2px solid #ffb500 !important;
    border-radius: 50% !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    color: #ffb500 !important;
    transition: all 0.3s ease;
}

.user-avatar-circle svg {
    width: 24px !important;
    height: 24px !important;
}

#userNameDisplay {
    font-size: 7px;
    color: #888;
    font-weight: bold;
    text-transform: uppercase;
    line-height: 1;
}

.user-badge:hover .user-avatar-circle {
    background-color: #ffb500 !important;
    color: #000 !important;
}

.user-menu {
    display: none;
    position: absolute;
    top: 55px;
    right: 0;
    background: #111;
    border: 1px solid #ffb500;
    border-radius: 8px;
    width: 150px;
    z-index: 10000;
    box-shadow: 0 4px 15px rgba(0,0,0,0.8);
}

.menu-item {
    padding: 12px;
    color: white;
    text-align: center;
    transition: 0.2s;
}

.menu-item:hover {
    background: #ffb500;
    color: #000;
}

/* ========================================================================
   3. NAVEGACIÓN PRINCIPAL
   ======================================================================== */
.main-nav {
    display: flex;
    justify-content: center;
    gap: 30px;
    padding-top: 15px;
    padding-right: 0px;
    padding-bottom: 15px;
    padding-left: 0px;
    background-color: #050505;
}

.nav-item {
    cursor: pointer;
    color: #888;
    font-weight: bold;
    text-transform: none;
    transition-property: color;
    transition-duration: 0.3s;
    transition-timing-function: ease;
}

.nav-item:hover, .nav-item.active {
    color: #ffb500;
}

/* ========================================================================
   4. SECCIÓN DE GÉNEROS Y GRID
   ======================================================================== */
.section-title {
    padding-top: 20px;
    padding-right: 4%;
    padding-bottom: 0px;
    padding-left: 4%;
    color: #ffb500;
    font-size: 0.8rem;
    font-weight: bold;
    text-transform: uppercase;
    letter-spacing: 1px;
}

#grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 20px;
    padding-top: 25px;
    padding-right: 4%;
    padding-bottom: 25px;
    padding-left: 4%;
}

.grid-item {
    cursor: pointer;
    transition-property: transform;
    transition-duration: 0.3s;
    transition-timing-function: ease;
    border-radius: 8px;
    overflow: hidden;
    border-top-width: 1px;
    border-top-style: solid;
    border-top-color: #ffb500;
    border-right-width: 1px;
    border-right-style: solid;
    border-right-color: #ffb500;
    border-bottom-width: 1px;
    border-bottom-style: solid;
    border-bottom-color: #ffb500;
    border-left-width: 1px;
    border-left-style: solid;
    border-left-color: #ffb500;
    position: relative;
}

.grid-item:hover {
    transform: scale(1.05);
    border-top-color: #fff;
    border-right-color: #fff;
    border-bottom-color: #fff;
    border-left-color: #fff;
    box-shadow: 0px 0px 20px rgba(255, 181, 0, 0.5);
}

.grid-item img {
    width: 100%;
    aspect-ratio: 2 / 3;
    object-fit: cover;
    display: block;
}

.genero-card {
    background-color: #1a1a1a;
    border-radius: 10px;
    height: 90px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition-property: all;
    transition-duration: 0.3s;
    text-align: center;
    padding: 10px 15px;
    box-sizing: border-box;
    border: 1px solid #333;
}

.genero-card:hover {
    border-color: #ffb500;
    transform: translateY(-5px);
    background-color: #222;
}

.genero-card span {
    color: #ffb500;
    font-weight: bold;
    font-size: 0.6rem;
    letter-spacing: 1px;
    text-transform: uppercase;
}

/* ========================================================================
   5. MODAL DE DETALLES
   ======================================================================== */
.modal-overlay {
    position: fixed;
    top: 0px;
    right: 0px;
    bottom: 0px;
    left: 0px;
    background-color: rgba(0, 0, 0, 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 5000;
}

.modal-content {
    background-color: #111;
    border: 1px solid #333;
    border-radius: 15px;
    width: 90%;
    max-width: 850px;
    padding: 30px;
    position: relative;
    box-sizing: border-box;
}

.modal-body {
    display: flex;
    flex-direction: row;
    gap: 30px;
}

#modalPoster {
    width: 280px;
    height: auto;
    border-radius: 10px;
    border: 1px solid #ffb500;
    object-fit: cover;
}

.modal-info {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
}

.modal-info h2 {
    margin-top: 0px;
    margin-bottom: 10px;
    color: #fff;
    font-size: 1.8rem;
}

#modalMeta {
    color: #888;
    font-size: 0.9rem;
    margin-bottom: 15px;
}

.estrellas {
    margin-bottom: 20px;
    display: flex;
    flex-direction: row;
    gap: 5px;
}

.star {
    color: #444;
    font-size: 25px;
    cursor: pointer;
    transition-property: color;
    transition-duration: 0.2s;
}

.star.active {
    color: #ffb500;
}

.modal-actions {
    margin-top: auto;
    display: flex;
    align-items: center;
    gap: 15px;
}

.btn-play {
    background-color: #ffb500;
    color: #000;
    border: none;
    padding: 12px 30px;
    font-weight: bold;
    border-radius: 5px;
    cursor: pointer;
    font-size: 1rem;
    transition: background-color 0.3s;
}

.btn-fav-icon {
    background-color: transparent;
    border: 1px solid #333;
    color: #555;
    padding: 10px;
    font-size: 20px;
    border-radius: 5px;
    cursor: pointer;
    transition: all 0.3s;
}

.btn-fav-icon.active {
    color: #ff0000;
    border-color: #ff0000;
}

.close-modal {
    position: absolute;
    right: 20px;
    top: 15px;
    font-size: 40px;           
    color: #ffb500;           
    cursor: pointer;
    font-weight: bold;
    z-index: 1000;            
    transition: all 0.2s ease; 
    display: flex;
    align-items: center;
    justify-content: center;
    width: 45px;
    height: 45px;
}

.close-modal:active {
    color: #FFFFFF !important;
    transform: scale(0.85);    
}

.close-modal:hover {
    color: #FFFFFF;
}

/* ========================================================================
   6. REPRODUCTOR DE VIDEO (CONFIGURACIÓN ESTABLE)
   ======================================================================== */
.video-wrapper {
    width: 100% !important;
    height: 100% !important;
    position: relative;
    overflow: hidden;
    background-color: #000; 
    display: flex;
    align-items: center;
    justify-content: center;
}

.video-js {
    width: 100% !important;
    height: 100% !important;
}

.video-js .vjs-tech {
    object-fit: contain !important;
    width: 100% !important;
    height: 100% !important;
}

/* Forzar que los controles siempre sean visibles y táctiles */
.video-js .vjs-control-bar {
    display: flex !important;
    opacity: 1 !important;
    visibility: visible !important;
    z-index: 2147483647 !important;
    pointer-events: auto !important;
}

/* ========================================================================
   7. INFORMACIÓN DE POSTERS Y EFECTOS
   ======================================================================== */
.peli-info {
    padding: 10px;
    text-align: left;
    background-color: #111; 
}

.peli-titulo {
    color: #cccccc;
    font-size: 0.75rem;
    font-weight: bold;
    line-height: 1.3;
    display: -webkit-box;
    -webkit-line-clamp: 2; 
    -webkit-box-orient: vertical;
    overflow: hidden;
    white-space: normal !important; 
    height: 2rem; 
    margin: 0;
}

.peli-anio {
    display: none !important;
}

.play-overlay {
    position: absolute;
    top: 40%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 60px;
    height: 60px;
    background-color: rgba(255, 181, 0, 0.85);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.3s ease, transform 0.3s ease;
    pointer-events: none;
    z-index: 10;
}

.play-icon {
    color: #000;
    font-size: 24px;
    margin-left: 4px;
}

.grid-item:hover .play-overlay {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1.1);
}

.poster-container {
    position: relative; 
}

.orden-badge {
    position: absolute;
    top: 10px;
    left: 10px;
    background: rgba(0, 0, 0, 0.7); 
    color: #ffb500; 
    border: 1px solid #ffb500;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 14px;
    font-weight: bold;
    z-index: 10;
    pointer-events: none; 
    box-shadow: 0 2px 5px rgba(0,0,0,0.5);
}

/* ========================================================================
   [ZONA BLINDADA] OPTIMIZACIÓN MÓVIL (Max 768px)
   ======================================================================== */
.hamburger-btn {
    display: none;
    cursor: pointer;
    margin-right: 15px;
}

.mobile-nav {
    display: none;
    flex-direction: column;
    background-color: #111;
    width: 100%;
    border-top: 1px solid #333;
    border-bottom: 2px solid #ffb500; 
}

@media (max-width: 768px) {
    /* 1. HEADER Y BUSCADOR REORGANIZADOS PARA QUE NO CHOQUEN */
    .header-top {
        display: flex !important;
        flex-wrap: wrap !important; /* Permite que los elementos pasen a otra línea */
        justify-content: space-between !important;
        padding: 15px 10px !important;
    }
    .h-left { order: 1; }
    .h-right { order: 2; width: auto; }
    
    /* El buscador se va a la línea 2, ocupando todo el ancho */
    .h-center {
        order: 3;
        width: 100% !important;
        margin-top: 15px !important;
    }
    .search-container {
        max-width: 100% !important; 
    }

    /* Ocultar nav desktop y mostrar hamburguesa */
    .main-nav { display: none !important; }
    .hamburger-btn { display: block !important; }

    .mobile-nav.active {
        display: flex !important;
    }
    .mobile-nav .nav-item {
        padding: 15px;
        text-align: center;
        border-bottom: 1px solid #222;
        width: 100%;
        color: #888;
        font-weight: bold;
    }
    .mobile-nav .nav-item.active {
        color: #ffb500;
    }

    /* 2. CUADRÍCULA 2x2 */
    #grid {
        display: grid !important;
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 10px !important;
        padding: 10px !important;
    }

    .peli-info { padding: 8px !important; }
    .peli-titulo { font-size: 0.8rem !important; height: 2.2rem !important; }

    /* 3. AJUSTE DE MODAL DETALLES */
    .modal-content {
        width: 92% !important;
        max-height: 85vh !important;
        overflow-y: auto !important;
        padding: 20px 15px !important;
        border-radius: 12px !important;
    }
    .modal-body {
        flex-direction: column !important;
        align-items: center !important;
        gap: 10px !important;
    }
    #modalPoster {
        width: 45% !important;
        max-width: 140px !important;
        margin: 0 auto 5px auto !important;
    }
    .modal-info { width: 100% !important; text-align: center !important; }
    .modal-info h2 { font-size: 1.3rem !important; margin-bottom: 5px !important; }
    .modal-info p { font-size: 0.85rem !important; margin-bottom: 8px !important; }
    .estrellas { justify-content: center !important; margin-bottom: 15px !important; }
    .modal-actions { flex-direction: column !important; gap: 8px !important; }
    .btn-play, .btn-fav-icon { width: 100% !important; margin: 0 !important; box-sizing: border-box; }

    /* 4. BLINDAJE DEL REPRODUCTOR MÓVIL (BLOQUEA EL SCROLL) */
    #playerModal {
        position: fixed !important;
        top: 0 !important;
        left: 0 !important;
        width: 100vw !important;
        height: 100vh !important;
        z-index: 99999 !important; /* Por encima de todo */
        background: #000 !important;
    }
    /* X de cierre del reproductor anclada a la pantalla (MUDANZA ACTIVA A ABSOLUTE) */
    #playerModal .close-modal {
        position: absolute !important; 
        top: 15px !important;
        right: 15px !important;
        z-index: 100000 !important;
        background: rgba(0, 0, 0, 0.6) !important; /* Fondo sutil para que no se pierda */
        border-radius: 50% !important;
    }
    /* Forzar controles sobre el video en dispositivos táctiles */
    .video-js .vjs-control-bar {
        display: flex !important;
        opacity: 1 !important;
        visibility: visible !important;
        pointer-events: auto !important;
        z-index: 2147483647 !important; /* Z-index máximo posible */
    }

    /* Evitar que el contenedor del modal bloquee clics en tablets */
    #playerModal {
        pointer-events: auto !important;
    }
}