@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

:root {
    --background: #060a1a;
    --panel: rgba(15, 23, 42, 0.6);
    --panel-solid: #0f172a;
    --color: #f1f5f9;
    --primary: #4f46e5;
    --primary-hover: #7c3aed;
    --accent: #3b82f6;
    --error: #ef4444;
    --gray: #94a3b8;
    --card-bg: #000;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Inter', sans-serif;
}

body {
    background: linear-gradient(135deg, #0a0f1a 0%, #0f172a 100%);
    color: var(--color);
    min-height: 100vh;
    overflow-x: hidden;
}

.hidden {
    display: none !important;
}

/* Utilidades */
.loader {
    width: 40px;
    height: 40px;
    border: 3px solid rgba(79, 70, 229, 0.3);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 40px auto;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

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

/* ============================================ */
/* SKELETON LOADING - EVITA FLASH EN BLANCO */
/* ============================================ */

.skeleton-card {
    position: relative;
    width: 200px;
    height: 300px;
    background: linear-gradient(110deg, rgba(15, 23, 42, 0.6) 8%, rgba(30, 41, 59, 0.8) 18%, rgba(15, 23, 42, 0.6) 33%);
    border-radius: 18px;
    background-size: 200% 100%;
    animation: skeleton-loading 1.2s ease-in-out infinite;
    flex-shrink: 0;
    overflow: hidden;
}

.skeleton-card::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 80px;
    background: linear-gradient(to top, rgba(0,0,0,0.8), transparent);
}

.skeleton-banner {
    height: 450px;
    border-radius: 20px;
    background: linear-gradient(110deg, rgba(15, 23, 42, 0.6) 8%, rgba(30, 41, 59, 0.8) 18%, rgba(15, 23, 42, 0.6) 33%);
    background-size: 200% 100%;
    animation: skeleton-loading 1.2s ease-in-out infinite;
}

.skeleton-text {
    height: 16px;
    background: rgba(255,255,255,0.1);
    border-radius: 8px;
    margin-bottom: 8px;
}

.skeleton-text-title {
    height: 24px;
    width: 70%;
    background: rgba(255,255,255,0.15);
    border-radius: 8px;
    margin-bottom: 12px;
}

.skeleton-text-small {
    height: 12px;
    width: 40%;
    background: rgba(255,255,255,0.08);
    border-radius: 6px;
}

@keyframes skeleton-loading {
    0% {
        background-position: 200% 0;
    }
    100% {
        background-position: -200% 0;
    }
}

/* Transiciones suaves para el contenido */
#dynamic-content {
    transition: opacity 0.2s ease;
}

.content-fade-in {
    animation: contentFadeIn 0.3s ease forwards;
}

@keyframes contentFadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

/* Loader mejorado para grids */
.grid-skeleton {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 1.5rem;
    width: 100%;
}

.grid-skeleton .skeleton-card {
    width: 100%;
    height: auto;
    aspect-ratio: 2 / 3;
}

/* Loader para el banner */
.banner-skeleton {
    width: 100%;
    height: 450px;
    border-radius: 20px;
    background: linear-gradient(110deg, rgba(15, 23, 42, 0.4) 8%, rgba(30, 41, 59, 0.6) 18%, rgba(15, 23, 42, 0.4) 33%);
    background-size: 200% 100%;
    animation: skeleton-loading 1.2s ease-in-out infinite;
}

/* Login */
.login-screen {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 1rem;
}

.login-card {
    background: rgba(15, 23, 42, 0.95);
    backdrop-filter: blur(20px);
    padding: 2.5rem;
    border-radius: 24px;
    width: 100%;
    max-width: 400px;
    box-shadow: 0 25px 50px -12px rgba(0,0,0,0.5);
    border: 1px solid rgba(79, 70, 229, 0.3);
    animation: fadeIn 0.5s ease;
}

.login-card h1 {
    font-size: 2rem;
    margin-bottom: 0.5rem;
    background: linear-gradient(135deg, #fff, var(--primary));
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    text-align: center;
}

.login-card p {
    text-align: center;
    color: var(--gray);
    margin-bottom: 2rem;
}

.input-group input {
    width: 100%;
    padding: 0.875rem 1rem;
    margin-bottom: 1rem;
    background: rgba(255,255,255,0.08);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 12px;
    color: white;
    transition: 0.2s;
}

.input-group input:focus {
    outline: none;
    border-color: var(--primary);
    background: rgba(255,255,255,0.12);
}

.btn-login {
    width: 100%;
    padding: 0.875rem;
    background: linear-gradient(135deg, var(--primary), var(--primary-hover));
    border: none;
    border-radius: 12px;
    color: white;
    font-weight: 600;
    cursor: pointer;
    transition: 0.2s;
}

.btn-login:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 20px rgba(79, 70, 229, 0.3);
}

.error-message {
    background: rgba(239,68,68,0.1);
    border-left: 3px solid var(--error);
    padding: 0.75rem;
    margin-bottom: 1rem;
    color: #fca5a5;
}

/* HEADER COMPACTO */
header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 20px;
    background: rgba(15, 23, 42, 0.95);
    position: sticky;
    top: 0;
    z-index: 100;
    border-bottom: 1px solid rgba(255,255,255,0.05);
    backdrop-filter: blur(10px);
    gap: 15px;
    flex-wrap: wrap;
}

.brand {
    font-weight: 700;
    font-size: 1.2rem;
    color: var(--primary);
    white-space: nowrap;
}

.brand span {
    color: white;
}

/* NAVEGACIÓN COMPACTA */
.top-nav-links {
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
    justify-content: center;
}

.nav-tab {
    padding: 6px 12px;
    background: transparent;
    border: none;
    color: var(--gray);
    font-weight: 500;
    cursor: pointer;
    border-radius: 6px;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.85rem;
}

.nav-tab i {
    font-size: 0.9rem;
}

.nav-tab:hover {
    background: rgba(79, 70, 229, 0.1);
    color: white;
}

.nav-tab.active {
    background: var(--primary);
    color: white;
    box-shadow: 0 2px 8px rgba(79, 70, 229, 0.3);
}

/* ACCIONES DEL HEADER */
.header-actions {
    display: flex;
    gap: 6px;
    align-items: center;
}

.btn-action {
    background: rgba(255,255,255,0.08);
    border: 1px solid rgba(255,255,255,0.1);
    color: white;
    padding: 6px 10px;
    border-radius: 6px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: all 0.2s ease;
    text-decoration: none;
    font-size: 0.85rem;
}

.btn-action i {
    font-size: 0.9rem;
}

.btn-action:hover {
    background: var(--primary);
    border-color: var(--primary);
}

.btn-icon {
    padding: 6px 10px;
}

.btn-danger {
    background: rgba(239, 68, 68, 0.2);
    border-color: rgba(239, 68, 68, 0.3);
    color: #fca5a5;
}

/* Contenedor principal */
.app-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 2rem 1rem;
}

.filters-bar {
    background: rgba(15, 23, 42, 0.8);
    border-radius: 12px;
    padding: 1rem;
    margin-bottom: 1.5rem;
    display: flex;
    gap: 1rem;
    border: 1px solid rgba(79, 70, 229, 0.2);
}

.search-input {
    flex: 1;
    padding: 0.8rem 1rem;
    background: rgba(0, 0, 0, 0.4);
    border: 1px solid rgba(79, 70, 229, 0.3);
    border-radius: 8px;
    color: white;
    font-size: 1rem;
}

.search-input:focus {
    outline: none;
    border-color: var(--primary);
}

/* ============================================ */
/* ESTILO MODERNO DE TARJETAS - CARD CON EFECTO HOVER */
/* ============================================ */

.content-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 24px;
    justify-content: center;
    margin-bottom: 2rem;
}

/* Tarjeta principal - estilo moderno */
.media-card {
    position: relative;
    width: 280px;
    height: 420px;
    background: #000;
    border-radius: 18px;
    overflow: hidden;
    box-shadow: 0 5px 10px rgba(0, 0, 0, .3);
    cursor: pointer;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.media-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 15px 30px rgba(0, 0, 0, .4);
}

/* Poster / Imagen */
.media-card .card-image {
    position: relative;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
}

.media-card .card-image::before {
    content: '';
    position: absolute;
    bottom: -45%;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
    transition: .3s;
    background: linear-gradient(to top, rgba(0,0,0,0.8), transparent);
}

.media-card:hover .card-image::before {
    bottom: 0;
}

.media-card .card-image img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: .3s;
}

.media-card:hover .card-image img {
    transform: scale(1.1);
}

/* Badge de tipo (Película/Serie) */
.type-badge-mini {
    position: absolute;
    top: 12px;
    right: 12px;
    background: rgba(79, 70, 229, 0.9);
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 0.7rem;
    font-weight: 600;
    z-index: 2;
    backdrop-filter: blur(4px);
    color: white;
}

.type-badge-mini i {
    font-size: 0.7rem;
    margin-right: 4px;
}

.type-badge-mini.series {
    background: #f59e0b;
}

.type-badge-mini.movie {
    background: var(--primary);
}

/* Barra de progreso */
.progress-bar-mini {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: rgba(0,0,0,0.5);
    z-index: 3;
}

.progress-fill-mini {
    height: 100%;
    background: linear-gradient(90deg, #4f46e5, #7c3aed);
    width: 0%;
    transition: width 0.3s;
}

/* Detalles que aparecen al hacer hover */
.media-card .card-info {
    position: absolute;
    bottom: -100%;
    left: 0;
    width: 100%;
    height: auto;
    padding: 1.5em 1.2em 1.5em;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(16px) saturate(120%);
    transition: bottom 0.3s ease;
    color: #fff;
    z-index: 2;
}

.media-card:hover .card-info {
    bottom: 0;
}

.media-card .card-title {
    font-size: 1.1rem;
    font-weight: 700;
    margin-bottom: 5px;
    white-space: normal;
    overflow: visible;
    text-overflow: unset;
    line-height: 1.3;
}

.media-card .card-meta {
    font-size: 0.75rem;
    opacity: 0.7;
    margin-bottom: 8px;
    display: flex;
    gap: 12px;
}

.media-card .card-meta span {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.media-card .card-meta i {
    font-size: 0.7rem;
}

.media-card .card-description {
    font-size: 0.75rem;
    line-height: 1.4;
    opacity: 0.8;
    margin-bottom: 12px;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.media-card .card-genres {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    margin-bottom: 10px;
}

.media-card .genre-tag {
    background: rgba(255,255,255,0.15);
    padding: 3px 8px;
    border-radius: 20px;
    font-size: 0.65rem;
    font-weight: 500;
    border: 1px solid rgba(255,255,255,0.2);
}

.media-card .card-progress {
    font-size: 0.7rem;
    color: #4f46e5;
    display: flex;
    align-items: center;
    gap: 5px;
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid rgba(255,255,255,0.1);
}

.media-card .card-progress i {
    font-size: 0.65rem;
}

/* Estilos para el género en tarjetas */
.media-card .card-genre {
    font-size: 0.7rem;
    color: var(--primary);
    display: flex;
    align-items: center;
    gap: 4px;
    margin: 4px 0;
    padding: 3px 8px;
    background: rgba(79, 70, 229, 0.15);
    border-radius: 12px;
    width: fit-content;
}

.media-card .card-genre ion-icon {
    font-size: 12px;
}

/* Estilos para la tarjeta "Ver más" */
.more-card {
    background: linear-gradient(135deg, rgba(79, 70, 229, 0.2), rgba(79, 70, 229, 0.05));
    border: 2px dashed rgba(79, 70, 229, 0.5);
}

.more-card:hover {
    transform: translateY(-5px);
    border-color: var(--primary);
}

.more-card .card-image {
    display: flex;
    align-items: center;
    justify-content: center;
}

.more-card .card-image div {
    color: white;
}

.more-card ion-icon {
    --ionicon-stroke-width: 32px;
}

/* Sección Headers */
.section-title {
    font-size: 1.5rem;
    margin-bottom: 1.5rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    border-bottom: 2px solid rgba(79, 70, 229, 0.3);
    padding-bottom: 0.5rem;
}

.section-title i {
    color: var(--primary);
}

/* Paginación */
.pagination-container {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin-top: 30px;
    flex-wrap: wrap;
    padding-bottom: 40px;
}

.page-btn {
    background: rgba(79, 70, 229, 0.2);
    border: 1px solid rgba(79, 70, 229, 0.3);
    color: white;
    padding: 10px 16px;
    border-radius: 8px;
    cursor: pointer;
    transition: 0.2s;
    font-weight: 600;
}

.page-btn:hover:not(:disabled) {
    background: var(--primary);
}

.page-btn.active {
    background: var(--primary);
    box-shadow: 0 0 12px rgba(79, 70, 229, 0.5);
}

.page-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

/* ============================================ */
/* MODAL DEL REPRODUCTOR - CORRECCIÓN TAMAÑO VERTICAL */
/* ============================================ */

#player-modal.hidden,
#player-modal.modal.hidden,
.modal.hidden {
    display: none !important;
    visibility: hidden !important;
    opacity: 0 !important;
    pointer-events: none !important;
}

#player-modal:not(.hidden) {
    display: flex !important;
    visibility: visible !important;
    opacity: 1 !important;
    pointer-events: auto !important;
}

#player-modal,
#player-modal .modal {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: 100% !important;
    height: 100% !important;
    background: var(--background) !important;
    background: linear-gradient(135deg, #0a0f1a 0%, #0f172a 100%) !important;
    z-index: 9999 !important;
    flex-direction: column !important;
    overflow-y: auto !important;
    overflow-x: hidden !important;
}

#player-modal header {
    position: sticky !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    z-index: 1000 !important;
    background: rgba(15, 23, 42, 0.95) !important;
    backdrop-filter: blur(10px) !important;
    padding: 12px 20px !important;
    margin: 0 !important;
    width: 100% !important;
    display: flex !important;
    justify-content: space-between !important;
    align-items: center !important;
    border-bottom: 1px solid rgba(79, 70, 229, 0.2) !important;
}

.btn-back-small {
    background: rgba(79, 70, 229, 0.2) !important;
    border: 1px solid rgba(79, 70, 229, 0.3) !important;
    color: white !important;
    padding: 8px 16px !important;
    border-radius: 8px !important;
    cursor: pointer !important;
    display: inline-flex !important;
    align-items: center !important;
    gap: 8px !important;
    transition: 0.2s !important;
    text-decoration: none !important;
    font-size: 0.85rem !important;
    font-weight: 500 !important;
}

.btn-back-small:hover {
    background: var(--primary) !important;
    border-color: var(--primary) !important;
    transform: translateY(-2px) !important;
}

/* Contenedor principal del modal - ocupa todo el espacio vertical */
.player-main-wrapper {
    max-width: 1400px !important;
    margin: 0 auto !important;
    padding: 20px !important;
    gap: 20px !important;
    display: flex !important;
    flex-direction: column !important;
    width: 100% !important;
    box-sizing: border-box !important;
    flex: 1 !important;
}

/* Wrapper del video - tamaño adecuado */
.player-video-wrapper {
    background: #000 !important;
    border-radius: 16px !important;
    overflow: hidden !important;
    width: 100% !important;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5) !important;
    border: 1px solid rgba(79, 70, 229, 0.2) !important;
    min-height: 400px !important;
}

/* Contenedor del video - relación de aspecto 16:9 */
.video-container {
    position: relative !important;
    width: 100% !important;
    background: #000 !important;
    aspect-ratio: 16 / 9 !important;
    min-height: 400px !important;
}

/* Video player */
video {
    width: 100% !important;
    height: 100% !important;
    object-fit: contain !important;
    background: #000 !important;
}

.plyr--video {
    background: #000 !important;
    height: 100% !important;
}

/* Panel de información - tamaño automático */
.player-info-panel {
    background: var(--panel-solid) !important;
    border-radius: 16px !important;
    padding: 20px !important;
    gap: 20px !important;
    display: flex !important;
    border: 1px solid rgba(79, 70, 229, 0.2) !important;
    width: 100% !important;
    box-sizing: border-box !important;
    margin-top: 0 !important;
}

.player-info-panel > div {
    display: flex !important;
    flex-wrap: wrap !important;
    gap: 20px !important;
    width: 100% !important;
}

/* Poster de la serie/película */
.info-poster {
    width: 120px !important;
    height: 180px !important;
    border-radius: 12px !important;
    object-fit: cover !important;
    flex-shrink: 0 !important;
}

/* Detalles de información */
.info-details {
    flex: 1 !important;
    min-width: 200px !important;
}

.info-details h1 {
    font-size: 1.5rem !important;
    margin-bottom: 10px !important;
    color: white !important;
    font-weight: 700 !important;
}

#player-plot {
    font-size: 0.9rem !important;
    margin-bottom: 15px !important;
    line-height: 1.5 !important;
    color: #cbd5e1 !important;
}

.info-meta {
    display: flex !important;
    gap: 15px !important;
    margin-bottom: 15px !important;
    font-size: 0.85rem !important;
    color: var(--gray) !important;
    flex-wrap: wrap !important;
}

/* Live Layout */
.live-layout {
    display: flex;
    gap: 1.5rem;
}

.sidebar {
    width: 280px;
    flex-shrink: 0;
    background: rgba(15, 23, 42, 0.95);
    border-radius: 16px;
    border: 1px solid rgba(255,255,255,0.05);
    height: calc(100vh - 120px);
    overflow-y: auto;
    position: sticky;
    top: 90px;
}

.sidebar-header {
    padding: 1rem;
    background: rgba(79, 70, 229, 0.15);
    border-bottom: 1px solid rgba(255,255,255,0.05);
    font-weight: 600;
    position: sticky;
    top: 0;
    z-index: 11;
}

.category-btn {
    width: 100%;
    text-align: left;
    padding: 0.7rem 1rem;
    background: transparent;
    border: none;
    color: #cbd5e1;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    border-bottom: 1px solid rgba(255,255,255,0.02);
}

.category-btn:hover,
.category-btn.active {
    background: var(--primary);
    color: white;
}

.main-content {
    flex: 1;
    min-width: 0;
}

/* Tarjeta flotante de usuario */
.floating-user-card {
    position: fixed;
    top: 80px;
    right: 20px;
    width: 320px;
    max-width: calc(100vw - 40px);
    background: var(--panel-solid);
    border-radius: 12px;
    border: 1px solid rgba(79, 70, 229, 0.3);
    box-shadow: 0 20px 25px -12px rgba(0,0,0,0.5);
    z-index: 1000;
    animation: fadeIn 0.2s ease;
    overflow: hidden;
}

.floating-user-card::before {
    content: '';
    position: absolute;
    top: -8px;
    right: 20px;
    width: 0;
    height: 0;
    border-left: 8px solid transparent;
    border-right: 8px solid transparent;
    border-bottom: 8px solid var(--panel-solid);
}

.user-card-header {
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 15px;
    border-bottom: 1px solid rgba(255,255,255,0.1);
    background: linear-gradient(135deg, rgba(79, 70, 229, 0.1), rgba(79, 70, 229, 0.05));
}

.user-card-body {
    padding: 15px;
    max-height: 400px;
    overflow-y: auto;
}

.user-info-item {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 8px 0;
    border-bottom: 1px solid rgba(255,255,255,0.05);
    font-size: 0.85rem;
}

.user-info-item i {
    width: 20px;
    color: var(--primary);
}

.user-card-footer {
    padding: 15px;
    border-top: 1px solid rgba(255,255,255,0.1);
}

/* Episodios y controles de series */
#series-controls {
    margin-top: 15px !important;
    display: flex !important;
    gap: 10px !important;
    flex-wrap: wrap !important;
}

#series-controls .btn-action {
    background: rgba(79, 70, 229, 0.15) !important;
    border: 1px solid rgba(79, 70, 229, 0.3) !important;
    color: white !important;
    padding: 8px 16px !important;
    border-radius: 8px !important;
    cursor: pointer !important;
}

#series-controls .btn-action:hover {
    background: var(--primary) !important;
}

/* ============================================ */
/* ESTILOS MEJORADOS PARA EPISODIOS */
/* ============================================ */

/* Contenedor de episodios */
.episodes-container {
    scrollbar-width: thin;
    scrollbar-color: var(--primary) rgba(79, 70, 229, 0.2);
}

.episodes-container::-webkit-scrollbar {
    width: 8px;
}

.episodes-container::-webkit-scrollbar-track {
    background: rgba(79, 70, 229, 0.1);
    border-radius: 10px;
}

.episodes-container::-webkit-scrollbar-thumb {
    background: var(--primary);
    border-radius: 10px;
}

.episodes-container::-webkit-scrollbar-thumb:hover {
    background: var(--primary-hover);
}

/* Botones de episodio mejorados */
.episode-btn {
    position: relative;
    overflow: hidden;
    transition: all 0.25s ease !important;
}

.episode-btn:active {
    transform: scale(0.98) !important;
}

/* Indicador de progreso en episodios */
.episode-progress-indicator {
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    background: linear-gradient(90deg, rgba(79, 70, 229, 0.15), rgba(79, 70, 229, 0.05));
    transition: width 0.3s ease;
}

/* Separación visual entre temporadas */
.season-divider {
    margin: 20px 0 10px;
    padding: 10px 0;
    border-bottom: 2px solid rgba(79, 70, 229, 0.3);
}

/* Wrapper de episodios */
.episodes-wrapper {
    animation: fadeInUp 0.4s ease;
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ============================================ */
/* FIX PARA EPISODIOS - EVITAR COLISIONES Y COMPRESIÓN */
/* ============================================ */

/* Asegurar que el wrapper de episodios no cause colisiones */
.episodes-wrapper {
    width: 100% !important;
    margin-top: 25px !important;
    margin-bottom: 20px !important;
    clear: both !important;
    display: block !important;
}

/* Contenedor de episodios - con altura fija para muchos episodios */
.episodes-container {
    display: flex !important;
    flex-direction: column !important;
    gap: 12px !important;
    width: 100% !important;
    min-width: 100% !important;
    height: 550px !important;
    max-height: 550px !important;
    overflow-y: auto !important;
    overflow-x: hidden !important;
    padding-right: 12px !important;
    padding-bottom: 8px !important;
}

/* Cada botón de episodio - ancho fijo para evitar compresión */
.episode-btn {
    display: block !important;
    width: 100% !important;
    min-width: 100% !important;
    max-width: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
    flex-shrink: 0 !important;
    flex-grow: 0 !important;
    position: relative !important;
}

/* Contenido interno con ancho mínimo */
.episode-btn > div {
    width: 100% !important;
    min-width: 280px !important;
    box-sizing: border-box !important;
}

/* Para el área de título - permitir wrap */
.episode-btn [style*="flex: 1"] {
    min-width: 0 !important;
    overflow: hidden !important;
}

/* ============================================ */
/* FIX PARA MODAL - TAMAÑO COMPLETO VERTICAL */
/* ============================================ */

/* Asegurar que el modal ocupe toda la pantalla verticalmente */
#player-modal {
    width: 100% !important;
    max-width: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
}

#player-modal .player-main-wrapper {
    max-width: 1400px !important;
    width: 100% !important;
    margin: 0 auto !important;
    padding: 20px !important;
    box-sizing: border-box !important;
    flex: 1 !important;
}

/* El reproductor de video debe ocupar el ancho completo y tener altura adecuada */
#player-modal .player-video-wrapper {
    width: 100% !important;
    max-width: 100% !important;
    min-height: 450px !important;
}

#player-modal .video-container {
    width: 100% !important;
    aspect-ratio: 16 / 9 !important;
    min-height: 450px !important;
}

#player-modal video {
    width: 100% !important;
    height: 100% !important;
    object-fit: contain !important;
}

/* Panel de información - ancho completo */
#player-modal .player-info-panel {
    width: 100% !important;
    box-sizing: border-box !important;
    margin-top: 20px !important;
}

#player-modal .info-details {
    flex: 1 !important;
    min-width: 200px !important;
}

/* Forzar tamaño completo del modal cuando está visible */
#player-modal:not(.hidden) {
    display: flex !important;
    flex-direction: column !important;
    width: 100vw !important;
    min-height: 100vh !important;
    height: auto !important;
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    overflow-y: auto !important;
    overflow-x: hidden !important;
}

#player-modal .player-main-wrapper {
    flex: 1 !important;
    width: 100% !important;
    max-width: 1400px !important;
    margin: 0 auto !important;
    padding: 20px !important;
}

/* Contenido relacionado en el modal */
#player-modal .related-section-modal {
    width: 100% !important;
    box-sizing: border-box !important;
    margin-top: 20px !important;
}

#player-modal .related-grid-modal {
    display: grid !important;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)) !important;
    gap: 15px !important;
    width: 100% !important;
}

/* ============================================ */
/* RESPONSIVE */
/* ============================================ */

@media (max-width: 768px) {
    header {
        padding: 6px 12px;
        gap: 8px;
    }
    
    .brand {
        font-size: 1rem;
    }
    
    .brand span {
        display: none;
    }
    
    .top-nav-links {
        order: 3;
        width: 100%;
        justify-content: space-around;
        gap: 2px;
        margin-top: 4px;
        padding-top: 4px;
        border-top: 1px solid rgba(255,255,255,0.05);
    }
    
    .nav-tab {
        padding: 5px 8px;
        font-size: 0.7rem;
        flex: 1;
        justify-content: center;
    }
    
    .nav-tab span {
        display: inline;
        font-size: 0.7rem;
    }
    
    .nav-tab i {
        font-size: 0.8rem;
    }
    
    .header-actions {
        order: 2;
        gap: 4px;
    }
    
    .btn-action {
        padding: 5px 8px;
        font-size: 0.75rem;
    }
    
    .media-card {
        width: 220px;
        height: 330px;
    }
    
    .media-card .card-title {
        font-size: 0.9rem;
    }
    
    .media-card .card-description {
        font-size: 0.7rem;
        -webkit-line-clamp: 2;
    }
    
    .player-info-panel {
        flex-direction: column !important;
        align-items: center !important;
        text-align: center !important;
    }
    
    .player-info-panel > div {
        flex-direction: column !important;
        align-items: center !important;
    }
    
    .live-layout {
        flex-direction: column;
    }
    
    .sidebar {
        width: 100%;
        height: 200px;
        position: relative;
        top: 0;
    }

    .episode-btn > div {
        padding: 12px 14px !important;
        min-width: 240px !important;
    }
    
    .episode-btn [style*="min-width: 70px"] {
        min-width: 60px !important;
    }
    
    .episodes-container {
        height: 450px !important;
        max-height: 450px !important;
    }
    
    /* Modal responsive */
    #player-modal .player-main-wrapper {
        padding: 15px !important;
    }
    
    #player-modal .player-video-wrapper {
        min-height: 300px !important;
    }
    
    #player-modal .video-container {
        min-height: 300px !important;
    }
    
    #player-modal .info-poster {
        width: 100px !important;
        height: 150px !important;
    }
    
    #player-modal .related-grid-modal {
        grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)) !important;
        gap: 10px !important;
    }
    
    .grid-skeleton {
        grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
        gap: 1rem;
    }
    
    .banner-skeleton {
        height: 350px;
    }
}

@media (max-width: 600px) {
    .nav-tab {
        flex-direction: column;
        padding: 4px 6px;
        gap: 3px;
    }
    
    .nav-tab i {
        font-size: 1rem;
    }
    
    .nav-tab span {
        font-size: 0.6rem;
    }
}

@media (max-width: 550px) {
    .episode-btn > div {
        flex-direction: column !important;
        align-items: flex-start !important;
        gap: 10px !important;
        min-width: 200px !important;
    }
    
    .episode-btn [style*="min-width: 70px"] {
        min-width: auto !important;
    }
    
    .episode-btn [style*="flex-shrink: 0"] {
        align-self: flex-end !important;
    }
}

@media (max-width: 480px) {
    .media-card {
        width: 180px;
        height: 270px;
    }
    
    .media-card .card-title {
        font-size: 0.8rem;
    }
    
    .media-card .card-meta {
        font-size: 0.6rem;
    }
    
    .media-card .card-info {
        padding: 1em 0.8em;
    }
    
    .nav-tab span {
        display: none;
    }
    
    .nav-tab {
        padding: 6px 8px;
    }
    
    .nav-tab i {
        font-size: 1.1rem;
        margin-bottom: 0;
    }
    
    .btn-action span {
        display: none;
    }
    
    .btn-action {
        padding: 6px 8px;
    }
    
    .btn-action i {
        font-size: 1rem;
        margin: 0;
    }
    
    .info-poster {
        width: 80px !important;
        height: 120px !important;
    }
    
    /* Modal responsive extra */
    #player-modal .player-main-wrapper {
        padding: 10px !important;
    }
    
    #player-modal .player-video-wrapper {
        min-height: 220px !important;
    }
    
    #player-modal .video-container {
        min-height: 220px !important;
    }
    
    #player-modal .episode-btn > div {
        padding: 10px 12px !important;
    }
    
    #player-modal .related-grid-modal {
        grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)) !important;
    }
    
    .grid-skeleton {
        grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
        gap: 0.75rem;
    }
    
    .banner-skeleton {
        height: 280px;
    }
}

/* Estilos para chips de filtros */
.filter-chip {
    background: rgba(79, 70, 229, 0.2);
    padding: 5px 12px;
    border-radius: 20px;
    font-size: 12px;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    transition: all 0.2s ease;
}

.filter-chip:hover {
    background: rgba(79, 70, 229, 0.4);
}

.filter-chip .fa-times-circle {
    cursor: pointer;
    opacity: 0.7;
    transition: opacity 0.2s ease;
}

.filter-chip .fa-times-circle:hover {
    opacity: 1;
    color: #ef4444;
}

/* Estilos para selects en modo oscuro */
select.search-input {
    appearance: none;
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><polyline points='6 9 12 15 18 9'></polyline></svg>");
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 14px;
    cursor: pointer;
}

select.search-input option {
    background: #0f172a;
    color: white;
}

/* Estilos para tarjetas relacionadas en el modal */
.related-grid-modal {
    scrollbar-width: thin;
}

.related-grid-modal::-webkit-scrollbar {
    height: 4px;
}

.related-grid-modal::-webkit-scrollbar-track {
    background: rgba(79, 70, 229, 0.1);
    border-radius: 10px;
}

.related-grid-modal::-webkit-scrollbar-thumb {
    background: var(--primary);
    border-radius: 10px;
}

.related-card-modal {
    transition: all 0.3s ease;
}

.related-card-modal:hover {
    transform: translateY(-5px);
    border-color: var(--primary) !important;
}

/* Estilos adicionales para el modal de confirmación */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(5px);
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.confirm-modal {
    background: var(--panel-solid);
    border-radius: 16px;
    padding: 1.5rem;
    max-width: 400px;
    width: 90%;
    border: 1px solid rgba(79, 70, 229, 0.3);
    animation: fadeInUp 0.2s ease;
}

.confirm-modal h4 {
    font-size: 1.2rem;
    margin-bottom: 0.5rem;
    color: white;
}

.confirm-modal p {
    color: var(--gray);
    margin-bottom: 1.5rem;
}

.confirm-actions {
    display: flex;
    gap: 1rem;
    justify-content: flex-end;
}

.confirm-actions button {
    padding: 0.5rem 1rem;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 500;
}

.btn-confirm {
    background: #ef4444;
    border: none;
    color: white;
}

.btn-cancel {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: white;
}

/* Toast notifications */
.custom-toast {
    position: fixed;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0,0,0,0.9);
    color: white;
    padding: 12px 24px;
    border-radius: 8px;
    z-index: 10001;
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 10px;
    backdrop-filter: blur(10px);
    animation: fadeInUp 0.3s ease;
}

/* Estilos para watching page */
.watching-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1.5rem;
}

.progress-card {
    background: rgba(15, 23, 42, 0.8);
    border-radius: 16px;
    overflow: hidden;
    transition: all 0.3s ease;
    border: 1px solid rgba(79, 70, 229, 0.15);
}

.progress-card:hover {
    transform: translateY(-4px);
    border-color: var(--primary);
}

.progress-card-content {
    display: flex;
    gap: 1rem;
    padding: 1rem;
}

.progress-poster {
    width: 100px;
    height: 150px;
    flex-shrink: 0;
    border-radius: 12px;
    overflow: hidden;
    background: #0a0e27;
}

.progress-poster img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.progress-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.progress-title {
    font-size: 1rem;
    font-weight: 700;
    color: white;
}

.progress-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    font-size: 0.7rem;
    color: var(--gray);
}

.progress-badge {
    background: rgba(79, 70, 229, 0.2);
    padding: 0.2rem 0.6rem;
    border-radius: 12px;
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--primary);
    width: fit-content;
}

.progress-bar-container {
    margin: 0.5rem 0;
}

.progress-label {
    display: flex;
    justify-content: space-between;
    font-size: 0.7rem;
    color: var(--gray);
    margin-bottom: 0.25rem;
}

.progress-bar-wrapper {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    height: 6px;
    overflow: hidden;
}

.progress-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary), var(--primary-hover));
    border-radius: 10px;
    width: 0%;
    transition: width 0.3s ease;
}

.progress-actions {
    display: flex;
    gap: 0.75rem;
    margin-top: 0.5rem;
    padding-top: 0.5rem;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.btn-reset {
    background: rgba(239, 68, 68, 0.15);
    border: 1px solid rgba(239, 68, 68, 0.3);
    color: #f87171;
    padding: 0.4rem 0.8rem;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.7rem;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    transition: all 0.2s ease;
}

.btn-reset:hover {
    background: rgba(239, 68, 68, 0.3);
    border-color: #ef4444;
}

.btn-play {
    background: var(--primary);
    border: none;
    color: white;
    padding: 0.4rem 1rem;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.7rem;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    transition: all 0.2s ease;
    font-weight: 600;
}

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

.empty-state-watching {
    text-align: center;
    padding: 3rem 2rem;
    background: rgba(15, 23, 42, 0.4);
    border-radius: 16px;
    border: 1px dashed rgba(79, 70, 229, 0.3);
}

.empty-state-watching ion-icon {
    font-size: 3rem;
    color: var(--gray);
    margin-bottom: 1rem;
    opacity: 0.5;
}

.empty-state-watching p {
    color: var(--gray);
    font-size: 0.85rem;
}

/* Forzar que el modal no tenga overflow issues */
#player-modal .player-main-wrapper {
    overflow-x: hidden !important;
    width: 100% !important;
    max-width: 1400px !important;
}

/* Asegurar que el panel de información no cause problemas */
.player-info-panel {
    overflow-x: hidden !important;
}

/* Para los controles de serie */
#series-controls {
    margin-bottom: 10px !important;
    flex-wrap: wrap !important;
}

/* Asegurar que el modal no tenga márgenes extra */
#player-modal .modal,
#player-modal .plyr {
    max-width: 100% !important;
}

/* Overlay de carga para prevenir múltiples clics */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.7);
    z-index: 10002;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: wait;
}

.loading-overlay .spinner {
    width: 60px;
    height: 60px;
    border: 4px solid rgba(79,70,229,0.3);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}