/* ===================================
   LAYOUT FIXES - Correcciones de superposicion
   Este archivo debe cargarse AL FINAL para sobrescribir conflictos
   =================================== */

/* ===== RESET UNIFICADO ===== */
*, *::before, *::after {
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
    -webkit-text-size-adjust: 100%;
}

body {
    margin: 0;
    padding: 0;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: #0a0a0a;
    color: #ffffff;
    min-height: 100vh;
    overflow-x: hidden;
    line-height: 1.6;
}

/* ===== HEADER PRINCIPAL - FIX DEFINITIVO ===== */
header {
    position: sticky;
    top: 0;
    left: 0;
    right: 0;
    z-index: 9000;
    background: rgba(10, 10, 10, 0.95);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    padding: 0.75rem 0;
}

.header-container {
    max-width: 1600px;
    margin: 0 auto;
    padding: 0 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: nowrap;
    min-height: 50px;
}

/* Logo */
.logo {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    text-decoration: none;
    flex-shrink: 0;
}

.logo-icon {
    display: flex;
    align-items: center;
    justify-content: center;
}

.logo-icon img {
    width: auto;
    height: 28px;
    max-width: 120px;
    object-fit: contain;
}

/* ===== NAVEGACION PRINCIPAL ===== */
#vararriba {
    flex: 1;
    display: flex;
    justify-content: center;
    overflow: hidden;
    min-width: 0;
}

#vararriba ul {
    list-style: none;
    margin: 0;
    padding: 0.4rem;
    display: flex;
    align-items: center;
    gap: 0.25rem;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 50px;
    overflow-x: auto;
    overflow-y: hidden;
    scrollbar-width: none;
    -ms-overflow-style: none;
    max-width: 100%;
}

#vararriba ul::-webkit-scrollbar {
    display: none;
}

#vararriba ul li {
    flex-shrink: 0;
}

#vararriba ul li a {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.5rem 1rem;
    color: rgba(255, 255, 255, 0.75);
    text-decoration: none;
    font-size: 0.85rem;
    font-weight: 500;
    border-radius: 25px;
    transition: all 0.2s ease;
    white-space: nowrap;
    border: 1px solid transparent;
}

#vararriba ul li a:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #ffffff;
}

#vararriba ul li a.active {
    background: linear-gradient(135deg, #6366f1 0%, #4f46e5 100%);
    color: #ffffff;
    box-shadow: 0 4px 15px rgba(99, 102, 241, 0.3);
}

.nav-icon {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
}

.nav-text {
    display: inline;
}

/* ===== MENU DE USUARIO ===== */
.user-menu-container {
    position: relative;
    flex-shrink: 0;
    z-index: 9999;
}

.user-avatar-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, #6366f1 0%, #4f46e5 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    border: 2px solid rgba(255, 255, 255, 0.2);
    transition: all 0.2s ease;
}

.user-avatar-btn:hover {
    border-color: rgba(255, 255, 255, 0.4);
    transform: scale(1.05);
    box-shadow: 0 0 20px rgba(99, 102, 241, 0.4);
}

.user-avatar-btn svg {
    width: 20px;
    height: 20px;
    color: white;
}

/* Dropdown del usuario */
.user-menu-dropdown {
    position: absolute;
    top: calc(100% + 10px);
    right: 0;
    width: 240px;
    background: #1a1a1a;
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 12px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.6);
    display: none;
    overflow: hidden;
    z-index: 10000;
}

.user-menu-dropdown.show {
    display: block;
    animation: dropdownFadeIn 0.2s ease;
}

@keyframes dropdownFadeIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.user-menu-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px;
    background: rgba(255, 255, 255, 0.03);
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.user-menu-avatar {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: linear-gradient(135deg, #6366f1 0%, #4f46e5 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.user-menu-avatar svg {
    width: 22px;
    height: 22px;
    color: white;
}

.user-menu-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
    flex: 1;
}

.user-menu-name {
    font-size: 0.95rem;
    font-weight: 600;
    color: #fff;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-menu-role {
    font-size: 0.7rem;
    color: #888;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.user-menu-divider {
    height: 1px;
    background: rgba(255, 255, 255, 0.08);
}

.user-menu-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    color: #ccc;
    text-decoration: none;
    font-size: 0.9rem;
    transition: all 0.15s ease;
}

.user-menu-item:hover {
    background: rgba(255, 255, 255, 0.08);
    color: #fff;
}

.user-menu-item svg {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
}

.user-menu-logout {
    color: #f87171;
}

.user-menu-logout:hover {
    background: rgba(248, 113, 113, 0.12);
    color: #f87171;
}

/* Boton de login */
.header-login-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 0.6rem 1.25rem;
    background: linear-gradient(135deg, #6366f1 0%, #4f46e5 100%);
    color: white;
    text-decoration: none;
    border-radius: 25px;
    font-weight: 500;
    font-size: 0.85rem;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.header-login-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(99, 102, 241, 0.35);
}

.header-login-btn svg {
    width: 18px;
    height: 18px;
}

/* ===== CONTENIDO PRINCIPAL ===== */
main, .main-content {
    position: relative;
    z-index: 1;
}

/* Hero banner fix */
.hero-banner {
    position: relative;
    z-index: 1;
    margin-top: 0;
}

/* Secciones de peliculas */
.movie-section {
    position: relative;
    z-index: 1;
}

/* ===== RESPONSIVE - TABLET ===== */
@media (max-width: 1024px) {
    .header-container {
        padding: 0 1rem;
    }

    #vararriba ul li a {
        padding: 0.45rem 0.8rem;
        font-size: 0.8rem;
    }

    .nav-text {
        display: none;
    }

    .nav-icon {
        width: 20px;
        height: 20px;
    }
}

/* ===== RESPONSIVE - MOBILE ===== */
@media (max-width: 768px) {
    header {
        padding: 0.5rem 0;
    }

    .header-container {
        padding: 0 0.75rem;
        gap: 0.5rem;
    }

    .logo-icon img {
        height: 24px;
        max-width: 100px;
    }

    /* Navegacion horizontal con scroll */
    #vararriba {
        order: 3;
        flex: none;
        width: 100%;
        justify-content: flex-start;
        margin-top: 0.5rem;
    }

    #vararriba ul {
        width: 100%;
        padding: 0.35rem;
        gap: 0.2rem;
        justify-content: flex-start;
        border-radius: 25px;
    }

    #vararriba ul li a {
        padding: 0.5rem 0.75rem;
        font-size: 0.75rem;
        border-radius: 20px;
    }

    .nav-icon {
        width: 16px;
        height: 16px;
    }

    .nav-text {
        display: inline;
    }

    /* Usuario a la derecha del logo */
    .user-menu-container {
        order: 2;
        margin-left: auto;
    }

    .user-avatar-btn {
        width: 36px;
        height: 36px;
    }

    .user-avatar-btn svg {
        width: 18px;
        height: 18px;
    }

    .user-menu-dropdown {
        right: -5px;
        width: 220px;
    }

    /* Boton login en mobile */
    .header-login-btn {
        padding: 0.5rem 1rem;
        font-size: 0.8rem;
    }

    .header-login-btn span {
        display: none;
    }

    .header-login-btn {
        padding: 0.5rem;
        border-radius: 50%;
    }
}

/* ===== RESPONSIVE - MOBILE SMALL ===== */
@media (max-width: 480px) {
    .header-container {
        flex-wrap: wrap;
    }

    #vararriba ul li a {
        padding: 0.4rem 0.6rem;
        font-size: 0.7rem;
    }

    .nav-icon {
        display: none;
    }

    .user-menu-dropdown {
        width: 200px;
        right: 0;
    }

    .user-menu-header {
        padding: 12px;
    }

    .user-menu-avatar {
        width: 38px;
        height: 38px;
    }

    .user-menu-name {
        font-size: 0.85rem;
    }

    .user-menu-item {
        padding: 12px;
        font-size: 0.85rem;
    }
}

/* ===== FIX PARA ELEMENTOS QUE SE SUPERPONEN ===== */

/* Asegurar que el hero no se superponga al header */
.hero-banner {
    margin-top: 0 !important;
}

/* Footer siempre al fondo */
footer, .main-footer {
    position: relative;
    z-index: 1;
    margin-top: auto;
}

/* Fix para modals y dropdowns */
.modal, .dropdown-menu, [class*="popup"] {
    z-index: 10001;
}

/* ===== DARK THEME CONSISTENTE ===== */
:root {
    --bg-primary: #0a0a0a;
    --bg-secondary: #141414;
    --bg-card: #1a1a1a;
    --text-primary: #ffffff;
    --text-secondary: #a0a0a0;
    --border-color: rgba(255, 255, 255, 0.1);
    --accent-color: #6366f1;
    --accent-hover: #4f46e5;
}

/* ===== ESTILOS PARA PAGINAS DE CATEGORIAS ===== */
.page-header {
    padding: 2rem 0;
    margin-bottom: 1.5rem;
}

.page-title {
    font-size: 2rem;
    font-weight: 600;
    color: #fff;
    margin: 0 0 0.5rem 0;
}

.page-subtitle {
    font-size: 1rem;
    color: rgba(255, 255, 255, 0.6);
    margin: 0;
}

/* Grid de peliculas */
.peliculas-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 1.5rem;
    padding: 0 0 3rem 0;
}

.pelicula-card {
    position: relative;
    transition: transform 0.3s ease;
}

.pelicula-card:hover {
    transform: scale(1.05);
}

.pelicula-card a {
    text-decoration: none;
    color: inherit;
    display: block;
}

.pelicula-poster {
    position: relative;
    width: 100%;
    padding-bottom: 150%;
    border-radius: 0.5rem;
    overflow: hidden;
    background: #1a1a1a;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}

.pelicula-poster img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease;
}

.pelicula-card:hover .pelicula-poster img {
    transform: scale(1.1);
}

.pelicula-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 0.75rem;
    background: linear-gradient(to top, rgba(0,0,0,0.9), transparent);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.pelicula-card:hover .pelicula-overlay {
    opacity: 1;
}

.pelicula-rating {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    font-size: 0.85rem;
    font-weight: 600;
    color: #fff;
    background: rgba(0, 0, 0, 0.7);
    padding: 0.25rem 0.5rem;
    border-radius: 0.25rem;
}

.pelicula-rating::before {
    content: '\2605';
    color: #ffc107;
}

.pelicula-titulo {
    margin: 0.75rem 0 0 0;
    font-size: 0.9rem;
    font-weight: 500;
    color: rgba(255, 255, 255, 0.85);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    transition: color 0.2s ease;
}

.pelicula-card:hover .pelicula-titulo {
    color: #fff;
}

.no-results {
    grid-column: 1 / -1;
    text-align: center;
    padding: 3rem;
    color: rgba(255, 255, 255, 0.5);
    font-size: 1.1rem;
}

/* Responsive para grid de peliculas */
@media (max-width: 768px) {
    .page-header {
        padding: 1.5rem 0;
        margin-bottom: 1rem;
    }

    .page-title {
        font-size: 1.5rem;
    }

    .page-subtitle {
        font-size: 0.9rem;
    }

    .peliculas-grid {
        grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
        gap: 1rem;
    }

    .pelicula-titulo {
        font-size: 0.8rem;
    }
}

@media (max-width: 480px) {
    .peliculas-grid {
        grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
        gap: 0.75rem;
    }

    .page-title {
        font-size: 1.25rem;
    }
}
