/* === VARIABLES BASE === */
:root {
    --netflix-red: #E50914;
    --netflix-red-hover: #b81d24;
    --bg-dark: #141414;
    --bg-light: #1f1f1f;
    --text-main: #ffffff;
    --text-muted: #808080;
    --nav-bg: rgba(20, 20, 20, 0.95);
    --border-color: #333;
    
    /* Variables Premium Añadidas */
    --accent-color: #E50914; 
    --gold-premium: linear-gradient(135deg, #bf953f, #fcf6ba, #b38728, #fbf5b7, #aa771c);
}

/* === MODO DIURNO (Light Mode) === */
body.light-mode {
    --bg-dark: #f0f0f0;
    --bg-light: #ffffff;
    --text-main: #141414;
    --text-muted: #666666;
    --nav-bg: rgba(255, 255, 255, 0.95);
    --border-color: #cccccc;
}

body.light-mode .item-card { background: #e0e0e0; }
body.light-mode .category-title { color: #141414; }
body.light-mode .login-box { background: rgba(255, 255, 255, 0.9); box-shadow: 0 4px 15px rgba(0,0,0,0.1); }
body.light-mode .login-box h2 { color: #141414; }
body.light-mode .input-group input { background: #e6e6e6; color: #141414; }
body.light-mode .nav-links a { color: #555; }
body.light-mode .nav-links a:hover { color: #141414; }
body.light-mode .nav-links a.active { color: #141414; border-bottom: 2px solid #b38728; }
body.light-mode .sidebar li { color: #666; }
body.light-mode .sidebar li:hover { background: #e6e6e6; color: #141414; }
body.light-mode .sidebar li.active { background: #e6e6e6; color: #141414; border-left: 3px solid #b38728; }
body.light-mode .main-area { background: linear-gradient(to bottom, #ffffff 0%, #f0f0f0 300px); }
body.light-mode .search-box { border-color: #999; }
body.light-mode .search-box input { color: #141414; }

/* === RESET Y TIPOGRAFÍA === */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Roboto', 'Helvetica Neue', Helvetica, Arial, sans-serif;
}

body {
    background-color: var(--bg-dark);
    color: var(--text-main);
    overflow-x: hidden;
    transition: background-color 0.3s ease, color 0.3s ease;
}

/* Utilitarios */
.hidden { display: none !important; }
.active { display: block !important; }
.view { display: none; height: 100vh; width: 100vw; }

/* === PANTALLA DE LOGIN === */
#login-view {
    position: relative;
    background: #000;
}

.login-bg {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background-image: url('https://assets.nflxext.com/ffe/siteui/vlv3/f841d4c7-10e1-40af-bcae-07a3f8dc141a/f6d7434e-d6de-4185-a6d4-c77a2d08737b/US-en-20220502-popsignuptwoweeks-perspective_alpha_website_medium.jpg');
    background-size: cover;
    background-position: center;
    opacity: 0.5;
    z-index: 1;
}

.login-overlay {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.4);
    background-image: linear-gradient(to top, rgba(0,0,0,0.8) 0, rgba(0,0,0,0) 60%, rgba(0,0,0,0.8) 100%);
    z-index: 2;
}

.login-header {
    position: absolute;
    top: 0; left: 0;
    width: 100%;
    padding: 20px 50px;
    z-index: 10;
}

.logo {
    color: var(--netflix-red);
    font-size: 2.5rem;
    font-weight: 700;
    letter-spacing: 2px;
}
.logo span { color: #fff; }
body.light-mode .logo span { color: #141414; }

.login-container {
    position: absolute;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    z-index: 10;
    width: 100%;
    max-width: 450px;
}

.login-box {
    background: rgba(0, 0, 0, 0.75);
    padding: 60px 68px 40px;
    border-radius: 4px;
    transition: background 0.3s ease;
}

.login-box h2 {
    color: #fff;
    font-size: 32px;
    font-weight: 500;
    margin-bottom: 28px;
}

.input-group {
    position: relative;
    margin-bottom: 16px;
}

.input-group input {
    width: 100%;
    background: #333;
    border: none;
    border-radius: 4px;
    padding: 20px 20px 10px;
    color: #fff;
    font-size: 16px;
    outline: none;
    transition: background 0.3s ease;
}

.input-group input:focus {
    background: #454545;
}

.input-group label {
    position: absolute;
    top: 50%;
    left: 20px;
    transform: translateY(-50%);
    color: #8c8c8c;
    font-size: 16px;
    transition: 0.2s ease all;
    pointer-events: none;
}

.input-group input:focus ~ label,
.input-group input:valid ~ label {
    top: 14px;
    font-size: 11px;
}

.btn-primary {
    width: 100%;
    padding: 16px;
    background: var(--netflix-red);
    color: #fff;
    font-size: 16px;
    font-weight: 500;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    margin-top: 24px;
    transition: background 0.2s;
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
}

.btn-primary:hover {
    background: var(--netflix-red-hover);
}

.btn-primary:disabled {
    opacity: 0.7;
    cursor: not-allowed;
}

.error-msg {
    color: #e87c03;
    font-size: 13px;
    margin-top: 15px;
    text-align: center;
}

.spinner {
    border: 3px solid rgba(255,255,255,0.3);
    border-radius: 50%;
    border-top: 3px solid #fff;
    width: 20px;
    height: 20px;
    animation: spin 1s linear infinite;
    position: absolute;
}

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

/* === PANTALLA PRINCIPAL === */
#main-view {
    display: flex;
    flex-direction: column;
    height: 100vh;
}

/* Navbar */
.navbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 4%;
    background: var(--nav-bg);
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 2px 10px rgba(0,0,0,0.5);
    transition: background 0.3s ease;
}

.nav-left { display: flex; align-items: center; gap: 40px; }

.mobile-menu-btn {
    display: none;
    font-size: 24px; 
    cursor: pointer;
    color: var(--text-main);
    transition: color 0.2s;
    margin-right: 15px; 
}
.mobile-menu-btn:hover { color: var(--netflix-red); }

.logo-small { color: var(--netflix-red); font-size: 1.5rem; letter-spacing: 1px; }
.logo-small span { color: #fff; }
body.light-mode .logo-small span { color: #141414; }

.nav-links { display: flex; list-style: none; gap: 20px; }
.nav-links a { color: #e5e5e5; text-decoration: none; font-size: 14px; transition: color 0.3s, border-color 0.3s; }
.nav-links a:hover, .nav-links a.active { color: #fff; font-weight: 500; }
.nav-links a.active { border-bottom: 2px solid var(--netflix-red); padding-bottom: 5px; }

.nav-right { display: flex; align-items: center; gap: 20px; }
.btn-icon { background: transparent; border: none; color: var(--text-main); font-size: 18px; cursor: pointer; transition: 0.2s; }
.btn-icon:hover { color: var(--netflix-red); }

.search-box {
    display: flex;
    align-items: center;
    background: rgba(0,0,0,0.5);
    border: 1px solid #fff;
    padding: 5px 10px;
    border-radius: 3px;
    transition: 0.3s;
}
.search-box input {
    background: transparent;
    border: none;
    color: white;
    outline: none;
    margin-left: 8px;
    width: 150px;
    font-size: 14px;
}
.user-profile {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
}
.user-profile img { width: 32px; height: 32px; border-radius: 4px; }
.user-profile span { font-size: 14px; }

/* Contenedor Principal Layout */
.content-container {
    display: flex;
    flex: 1;
    overflow: hidden; 
}

/* Sidebar Categorías con Scroll Premium */
.sidebar {
    width: 250px;
    background: var(--bg-light);
    border-right: 1px solid var(--border-color);
    overflow-y: auto;
    padding: 20px 0;
    transition: left 0.3s ease, background 0.3s ease, border-color 0.3s ease;
}

.sidebar h3 {
    padding: 0 20px 15px;
    color: var(--text-muted);
    font-size: 14px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.sidebar ul { list-style: none; }
.sidebar li {
    padding: 12px 20px;
    cursor: pointer;
    font-size: 15px;
    color: #ccc;
    transition: 0.2s;
    border-left: 3px solid transparent;
}
.sidebar li:hover { background: #333; color: #fff; }
.sidebar li.active {
    background: #333;
    color: #fff;
    border-left: 3px solid var(--netflix-red);
    font-weight: 500;
}

/* Área Principal de Contenido (Ajustada para Scroll Independiente) */
.main-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden; /* Evitamos el scroll general aquí */
    padding: 20px 4% 0; /* Ajustamos el padding para el reproductor */
    position: relative;
    background: linear-gradient(to bottom, #1f1f1f 0%, #141414 300px);
    transition: background 0.3s ease;
}

.category-title {
    font-size: 24px;
    margin-bottom: 20px;
    color: #fff;
    transition: color 0.3s;
}

/* Evitamos que el reproductor o las herramientas se compriman */
#scraper-tools, #player-container {
    flex-shrink: 0; 
}

/* Damos scroll independiente solo a la lista de ítems y a los detalles de series */
#content-grid-container, #series-info-container {
    flex: 1;
    overflow-y: auto;
    padding-bottom: 30px;
    padding-right: 5px;
}

/* Estilo Premium para las barras de scroll */
#content-grid-container::-webkit-scrollbar, 
#series-info-container::-webkit-scrollbar, 
.sidebar::-webkit-scrollbar {
    width: 6px;
}

#content-grid-container::-webkit-scrollbar-thumb, 
#series-info-container::-webkit-scrollbar-thumb, 
.sidebar::-webkit-scrollbar-thumb {
    background: var(--gold-premium); 
    border-radius: 4px;
}

#content-grid-container::-webkit-scrollbar-track, 
#series-info-container::-webkit-scrollbar-track, 
.sidebar::-webkit-scrollbar-track {
    background: transparent;
}

/* Grid de Items */
.grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 15px;
}

.item-card {
    background: #222;
    border-radius: 4px;
    overflow: hidden;
    cursor: pointer;
    transition: transform 0.3s, box-shadow 0.3s, background 0.3s ease;
    position: relative;
    aspect-ratio: 16/9;
}

.item-card.poster-aspect {
    aspect-ratio: 2/3; 
}

.item-card:hover {
    transform: scale(1.05);
    box-shadow: 0 8px 20px rgba(0,0,0,0.6);
    z-index: 10;
}

.item-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    background: #333;
}

.item-overlay {
    position: absolute;
    bottom: 0; left: 0; right: 0;
    background: linear-gradient(to top, rgba(0,0,0,0.9) 0%, rgba(0,0,0,0) 100%);
    padding: 20px 10px 10px;
    color: #fff;
}

.item-title {
    font-size: 14px;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Loader de Contenido */
.loader-container {
    display: flex;
    justify-content: center;
    padding: 50px;
}
.netflix-spinner {
    width: 50px;
    height: 50px;
    border: 4px solid rgba(229, 9, 20, 0.3);
    border-radius: 50%;
    border-top: 4px solid var(--netflix-red);
    animation: spin 1s linear infinite;
}

/* Reproductor */
#player-container {
    background: #000;
    border-radius: 8px;
    padding: 15px;
    margin-bottom: 30px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.8);
}

.player-header {
    display: flex;
    align-items: center;
    justify-content: space-between; 
    flex-wrap: wrap; 
    gap: 15px;
    margin-bottom: 15px;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 15px;
}

.player-header-left {
    display: flex;
    align-items: center;
    gap: 15px;
}

.btn-back {
    background: transparent;
    color: var(--text-main);
    border: 1px solid var(--border-color);
    padding: 8px 15px;
    border-radius: 4px;
    cursor: pointer;
    transition: 0.2s;
    font-size: 14px;
}

.btn-back:hover {
    background: var(--bg-light);
    border-color: var(--text-main);
}

.btn-back.active {
    background: var(--text-main);
    color: var(--bg-dark);
    font-weight: bold;
}

.video-wrapper {
    width: 100%;
    aspect-ratio: 16/9;
    background: #000;
}

.video-js {
    width: 100% !important;
    height: 100% !important;
}

/* === MODAL DE EXPORTACIÓN AVANZADA === */
#global-export-modal select, #category-export-format, #series-export-format {
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    background-image: url("data:image/svg+xml;charset=US-ASCII,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%22292.4%22%20height%3D%22292.4%22%3E%3Cpath%20fill%3D%22%23ffffff%22%20d%3D%22M287%2069.4a17.6%2017.6%200%200%200-13-5.4H18.4c-5%200-9.3%201.8-12.9%205.4A17.6%2017.6%200%200%200%200%2082.2c0%205%201.8%209.3%205.4%2012.9l128%20127.9c3.6%203.6%207.8%205.4%2012.8%205.4s9.2-1.8%2012.8-5.4L287%2095c3.5-3.5%205.4-7.8%205.4-12.8%200-5-1.9-9.2-5.5-12.8z%22%2F%3E%3C%2Fsvg%3E");
    background-repeat: no-repeat;
    background-position: right 15px top 50%;
    background-size: 12px auto;
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
}

#global-export-modal select:focus, #category-export-format:focus, #series-export-format:focus {
    border-color: #bf953f; 
    box-shadow: 0 0 10px rgba(191, 149, 63, 0.4);
}

#global-export-modal select option, #category-export-format option, #series-export-format option {
    background-color: #222;
    color: #fff;
    padding: 10px;
}

#export-progress-bar {
    position: relative;
    box-shadow: 0 0 10px rgba(229, 9, 20, 0.6);
}

#export-progress-bar::after {
    content: "";
    position: absolute;
    top: 0; left: 0; bottom: 0; right: 0;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.3), transparent);
    animation: progress-shine 1.5s infinite;
}

@keyframes progress-shine {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(100%); }
}

/* === BOTÓN DE DESCARGA INDIVIDUAL EN EL REPRODUCTOR === */
.btn-download-item {
    background: var(--gold-premium);
    color: #000;
    border: 1px solid #bf953f;
    padding: 8px 18px;
    border-radius: 4px;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    font-size: 13px;
    font-weight: 700;
    text-shadow: 0px 1px 1px rgba(255,255,255,0.5);
    display: flex;
    align-items: center;
    gap: 8px;
}

.btn-download-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(191, 149, 63, 0.4);
}

body.light-mode .btn-download-item {
    box-shadow: 0 4px 10px rgba(0,0,0,0.15);
}

/* =========================================
   === RESPONSIVE DESIGN (VISTA MÓVIL) === 
   ========================================= */
@media (max-width: 768px) {
    .navbar { 
        flex-wrap: wrap; 
        padding: 15px; 
    }
    
    .nav-left { 
        width: 100%; 
        justify-content: flex-start;
        margin-bottom: 15px; 
        gap: 15px;
    }
    
    .mobile-menu-btn { 
        display: block !important; 
    }
    
    .nav-links { 
        width: 100%; 
        justify-content: space-around; 
        padding-top: 10px; 
        border-top: 1px solid var(--border-color); 
        margin-top: 5px;
    }
    
    .nav-right { 
        width: 100%; 
        justify-content: space-between; 
        margin-top: 15px;
    }
    
    .search-box { flex: 1; margin: 0 10px; }
    .search-box input { width: 100%; }
    
    .content-container { 
        position: relative; 
        flex-direction: column; 
    }
    
    .sidebar { 
        position: absolute; 
        top: 0; 
        left: -100%; 
        width: 260px; 
        height: 100%; 
        z-index: 999; 
        box-shadow: 5px 0 20px rgba(0,0,0,0.8);
        border-right: none;
    }
    
    .sidebar.show { 
        left: 0; 
    }

    .grid { grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); }
    .series-content { flex-direction: column; }
    .series-details { max-width: 100%; }
    
    .btn-download-item {
        width: 100%;
        justify-content: center;
        padding: 12px;
        font-size: 14px;
    }
}