/**
 * Estilos para Visor Simple Tipo Slider
 * Para: 4-Koma, Tira Cómica, Una Viñeta
 * Sin: Vista 3D, Zoom, Páginas Dobles
 * Fecha: 1 de diciembre de 2025
 */

/* ==================== CONTENEDOR PRINCIPAL ==================== */
.slider-reader {
    width: 100%;
    height: 100vh;
    max-height: 100vh;
    background: #0a0a0a;
    position: relative;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ✅ En móvil, estructura flex-column para visor + barra */
@media (max-width: 1080px) {
    .slider-reader {
        /* ✅ Usar dvh para ajuste dinámico con barra de direcciones */
        height: 100dvh;
        max-height: 100dvh;
        flex-direction: column;
        justify-content: space-between;
    }
}

/* Temas */
.slider-reader[data-theme="dark"],
.slider-reader[data-theme="auto"] {
    background: #0a0a0a;
    background: url(../img/bg-visor_oscuro.webp);
    background-size: cover;
}

.slider-reader[data-theme="light"] {
    background: #f5f5f5;
    background: url(../img/bg-visor_claro.webp);
    background-size: cover;
}

/* ==================== SIDEBAR IZQUIERDO SUPERIOR ==================== */
.slider-sidebar-left {
    position: absolute;
    left: 15px;
    top: 55px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    z-index: 100;
    transition: all 0.3s ease;
}

.sidebar-icon-btn {
    width: 50px;
    height: 50px;
    border-radius: 12px;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: #fff;
    font-size: 20px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

.sidebar-icon-btn:hover {
    background: rgba(0, 212, 255, 0.2);
    border-color: #00d4ff;
    color: #00d4ff;
    transform: scale(1.1);
}

.sidebar-icon-btn:active {
    transform: scale(0.95);
}

/* Tooltips */
.sidebar-icon-btn::after {
    content: attr(data-tooltip);
    position: absolute;
    left: calc(100% + 10px);
    top: 50%;
    transform: translateY(-50%);
    background: rgba(0, 0, 0, 0.9);
    color: #fff;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 13px;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.sidebar-icon-btn:hover::after {
    opacity: 1;
}

/* ==================== WRAPPER DE CONTENIDO (Contiene imagen + flechas) ==================== */
.slider-content-wrapper {
    width: 100%;
    height: 100vh;
}

/* ✅ En móvil, ajustar altura para dejar espacio a la barra */
@media (max-width: 1080px) {
    .slider-content-wrapper {
        /* ✅ Usar dvh para ajuste dinámico con barra de direcciones */
        height: calc(100dvh - 85px); /* 85px aprox de la barra móvil */
        flex: 1;
        display: flex;
        align-items: center;
        justify-content: center;
    }
}

.slider-content-wrapper-continued {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ==================== CONTENEDOR DE SLIDES ==================== */
.slider-container {
    width: 100%;
    height: 100%;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}

.slider-slide {
    position: absolute;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.slider-slide.active {
    opacity: 1;
    visibility: visible;
    z-index: 1;
}

.slider-slide img {
    max-width: 90%;
    max-height: 90vh;
    object-fit: contain;
    user-select: none;
    -webkit-user-drag: none;
    border-radius: 6px;
}

/* GAP entre imágenes */
.slider-slide.with-gap {
    padding-bottom: 20px;
}

/* ==================== FLECHAS DE NAVEGACIÓN (Relativas al contenedor) ==================== */
.slider-arrow {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(10px);
    border: 2px solid rgba(255, 255, 255, 0.2);
    color: #fff;
    font-size: 20px;
    cursor: pointer;
    transition: all 0.25s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    z-index: 90;
}

/* Ocultar flechas en categoría una-vineta */
.slider-reader[data-category-slug="una-vineta"] .slider-arrow {
    display: none !important;
}

.slider-arrow:hover:not(.disabled) {
    background: rgba(0, 212, 255, 0.9);
    border-color: #00d4ff;
    transform: translateY(-50%) scale(1.15);
    box-shadow: 0 6px 16px rgba(0, 212, 255, 0.4);
}

.slider-arrow:active:not(.disabled) {
    transform: translateY(-50%) scale(1.05);
}

.slider-arrow.disabled {
    opacity: 0.25;
    cursor: not-allowed;
    pointer-events: none;
}

/* Posicionar flechas LTR pegadas a la imagen */
.slider-arrow-prev {
    left: 5%;
}

.slider-arrow-next {
    right: 5%;
}

/* Posicionar flechas RTL (invertidas) */
.slider-arrow-prev-rtl {
    right: 5%; /* Prev en RTL avanza, va a la derecha */
}

.slider-arrow-next-rtl {
    left: 5%; /* Next en RTL retrocede, va a la izquierda */
}

/* Ocultar/mostrar según dirección */
.slider-reader[data-reading-direction="ltr"] .rtl-only {
    display: none !important;
}

.slider-reader[data-reading-direction="rtl"] .ltr-only {
    display: none !important;
}

/* ==================== BOTONES DE NAVEGACIÓN DE VIÑETAS ==================== */
.vineta-nav-btn {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 24px;
    border-radius: 50px;
    background: linear-gradient(135deg, #81d742 0%, #3ac403 100%);
    border: 2px solid rgba(255, 255, 255, 0.3);
    color: #feffee;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 6px 20px rgba(129, 215, 66, 0.4);
    z-index: 95;
    backdrop-filter: blur(10px);
}

.vineta-nav-btn:hover:not(:disabled) {
    transform: translateY(-50%) scale(1.05);
    box-shadow: 0 8px 25px rgba(129, 215, 66, 0.6);
    border-color: rgba(255, 255, 255, 0.5);
}

.vineta-nav-btn:active:not(:disabled) {
    transform: translateY(-50%) scale(0.98);
}

.vineta-nav-btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
    filter: grayscale(0.8);
}

.vineta-nav-btn i {
    font-size: 18px;
}

.vineta-nav-label {
    font-size: 15px;
    letter-spacing: 0.3px;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.vineta-nav-prev {
    left: 20px; /* Valor inicial, JavaScript lo calculará dinámicamente */
}

.vineta-nav-next {
    right: 20px; /* Valor inicial, JavaScript lo calculará dinámicamente */
}

/* Responsive para botones de viñeta */
@media (max-width: 1080px) {
    .vineta-nav-btn {
        display: none; /* Ocultar en móvil, usar barra inferior */
    }
}

/* ==================== INDICADOR DE PÁGINA (Inferior Centro) ==================== */
.slider-page-indicator {
    position: absolute;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(10px);
    padding: 10px 20px;
    border-radius: 25px;
    color: #fff;
    font-size: 14px;
    font-weight: 600;
    border: 1px solid rgba(255, 255, 255, 0.2);
    z-index: 90;
}

/* ==================== CONTADOR DE PÁGINAS (Superior Derecha) ==================== */
.slider-page-counter-right {
    position: absolute;
    top: 15px;
    right: 15px;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(10px);
    padding: 12px 20px;
    border-radius: 25px;
    color: #fff;
    font-size: 16px;
    font-weight: 700;
    border: 1px solid rgba(255, 255, 255, 0.2);
    z-index: 100;
    min-width: 60px;
    text-align: center;
}

/* ==================== MODAL DE MINIATURAS ==================== */
.thumbnails-modal {
    /* position: absolute; */
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.95);
    backdrop-filter: blur(20px);
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
    display: flex;
    flex-direction: column;
}

.thumbnails-modal.active {
    opacity: 1;
    visibility: visible;
}

.thumbnails-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 30px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.thumbnails-modal-header h3 {
    color: #fff;
    font-size: 20px;
    font-weight: 600;
    margin: 0;
}

.thumbnails-modal-close {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.1);
    border: none;
    color: #fff;
    font-size: 20px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.thumbnails-modal-close:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: rotate(90deg);
}

.thumbnails-grid {
    flex: 1;
    overflow-y: auto;
    padding: 30px;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 20px;
    align-content: start;
}

/* RTL: Invertir dirección del grid de miniaturas */
.thumbnails-grid[data-reading-direction="rtl"] {
    direction: rtl;
}

.thumbnail-item {
    position: relative;
    aspect-ratio: 3/4;
    border-radius: 8px;
    overflow: hidden;
    cursor: pointer;
    transition: all 0.3s ease;
    border: 2px solid transparent;
}

.thumbnail-item:hover {
    transform: translateY(-5px);
    border-color: #00d4ff;
    box-shadow: 0 10px 30px rgba(0, 212, 255, 0.3);
}

.thumbnail-item.current {
    border-color: #00d4ff;
    box-shadow: 0 0 20px rgba(0, 212, 255, 0.5);
}

.thumbnail-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.thumbnail-number {
    position: absolute;
    bottom: 5px;
    right: 5px;
    background: rgba(0, 0, 0, 0.8);
    color: #fff;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 600;
}

/* ==================== BARRA DE EPISODIOS ==================== */
/* ==================== SELECTOR DE EPISODIOS (BARRA HORIZONTAL COMPACTA) ==================== */
.slider-reader .episode-selector-bar {
    position: absolute;
    bottom: 100px; /* Justo sobre la barra móvil */
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.9);
    backdrop-filter: blur(10px);
    padding: 12px 16px;
    border-radius: 30px;
    border: 2px solid rgba(255, 255, 255, 0.2);
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.8);
    z-index: 999; /* Muy alto para estar sobre todo */
    display: none; /* Oculto por defecto */
    flex-direction: row;
    align-items: center;
    justify-content: center;
    gap: 12px;
    max-width: 90vw;
    min-width: 300px;
}

.slider-reader .episode-nav-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 16px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 20px;
    color: #fff;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
    min-width: 100px;
}

.slider-reader .episode-nav-btn:hover:not(.disabled) {
    background: rgba(0, 212, 255, 0.25);
    border-color: #00d4ff;
    transform: translateY(-2px);
    box-shadow: 0 3px 10px rgba(0, 212, 255, 0.4);
}

.slider-reader .episode-nav-btn.disabled {
    opacity: 0.25;
    cursor: not-allowed;
    pointer-events: none;
}

.slider-reader .episode-nav-btn i {
    font-size: 14px;
    flex-shrink: 0;
}

/* ==================== MENSAJE DE PÁGINA ÚNICA ==================== */
.single-page-message {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.95) 0%, rgba(0, 0, 0, 0.85) 100%);
    backdrop-filter: blur(20px);
    padding: 20px;
    border-top: 2px solid rgba(0, 212, 255, 0.3);
    z-index: 95;
    display: none;
    flex-direction: column;
    align-items: center;
    gap: 12px;
}

.single-page-content {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: center;
    gap: 20px;
    width: 100%;
    max-width: 600px;
}

.single-page-content i {
    font-size: 32px;
    color: #00d4ff;
    flex-shrink: 0;
}

.single-page-content p {
    color: #fff;
    font-size: 15px;
    margin: 0;
    text-align: center;
    flex: 1;
}

.btn-change-episode {
    padding: 10px 24px;
    background: linear-gradient(135deg, #00d4ff 0%, #0099cc 100%);
    border: none;
    border-radius: 25px;
    color: #fff;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.btn-change-episode:hover {
    transform: scale(1.05);
    box-shadow: 0 5px 20px rgba(0, 212, 255, 0.4);
}

/* ==================== BARRA MÓVIL INFERIOR ==================== */
.slider-mobile-bar {
    /* ✅ CAMBIO: relative para que esté en el flujo, no fixed encima */
    position: relative;
    width: 100%;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.95), rgba(0, 0, 0, 0.7));
    backdrop-filter: blur(10px);
    padding: 15px 20px;
    display: none;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    z-index: 95;
    flex-shrink: 0; /* ✅ No reducir tamaño */
}

.mobile-btn {
    width: 45px;
    height: 45px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: #fff;
    font-size: 18px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.mobile-btn:hover:not(.disabled) {
    background: rgba(0, 212, 255, 0.3);
    border-color: #00d4ff;
    color: #00d4ff;
}

.mobile-btn.disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

/* Botón de volver a serie destacado */
#mobileBackBtn {
    background: rgba(129, 215, 66, 0.15);
    border-color: rgba(129, 215, 66, 0.3);
}

#mobileBackBtn:hover {
    background: rgba(129, 215, 66, 0.25);
    border-color: #81d742;
    color: #81d742;
}

.mobile-page-info {
    color: #fff;
    font-size: 14px;
    font-weight: 600;
    padding: 8px 15px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 20px;
    display: flex; /* Visible por defecto */
    align-items: center;
    gap: 5px;
}

/* ==================== RESPONSIVE ==================== */
@media (max-width: 1080px) {
    /* Ocultar sidebar en móvil */
    .slider-sidebar-left {
        display: none;
    }
    
    /* Ocultar flechas desktop en móvil */
    .slider-arrows,
    .slider-arrow {
        display: none !important;
    }
    
    /* Ocultar indicador desktop en móvil */
    .slider-page-indicator {
        display: none;
    }
    
    /* Mostrar barra móvil */
    .slider-mobile-bar {
        display: flex;
    }
    
    /* Ajustar slides en móvil */
    .slider-slide img {
        max-width: 95%;
        /* ✅ Usar dvh para ajuste dinámico con barra de direcciones */
        max-height: calc(100dvh - 100px);
    }
    
    /* Ajustar miniaturas en móvil */
    .thumbnails-grid {
        grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
        gap: 15px;
        padding: 20px;
    }
    
    /* Ajustar barra de episodios en móvil */
    .slider-reader .episode-selector-bar {
        bottom: 80px; /* Más espacio en móvil por la barra inferior */
        padding: 6px 10px;
        gap: 6px;
    }
    
    .slider-reader .episode-nav-btn {
        padding: 6px 12px;
        font-size: 12px;
        min-width: 90px;
        gap: 4px;
    }
    
    .slider-reader .episode-nav-btn i {
        font-size: 12px;
    }
    
    /* Ajustar mensaje de página única */
    .single-page-message {
        padding: 15px;
    }
    
    .single-page-content {
        flex-direction: column;
        gap: 12px;
    }
    
    .single-page-content i {
        font-size: 28px;
    }
    
    .single-page-content p {
        font-size: 14px;
    }
    
    .btn-change-episode {
        padding: 8px 20px;
        font-size: 13px;
    }
    
    /* Ocultar contador superior derecho en móvil */
    .slider-page-counter-right {
        display: none;
    }
    
    /* Ajustar sidebar en móvil */
    .slider-sidebar-left {
        top: 10px;
        left: 10px;
        gap: 8px;
    }
    
    .sidebar-icon-btn {
        width: 40px;
        height: 40px;
        font-size: 16px;
    }
    
    /* Modal de reacciones responsive */
    .reactions-modal-content {
        padding: 20px;
        max-height: 85vh;
    }
    
    .reactions-grid-compact {
        grid-template-columns: repeat(3, 1fr);
        gap: 10px;
    }
    
    .emoji-large {
        font-size: 28px;
    }
}

@media (max-width: 480px) {
    .mobile-btn {
        width: 40px;
        height: 40px;
        font-size: 16px;
    }
    
    .mobile-page-info {
        font-size: 12px;
        padding: 6px 12px;
    }
    
    .thumbnails-grid {
        grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
        gap: 10px;
        padding: 15px;
    }
}

/* ==================== SCROLLBAR PERSONALIZADO ==================== */
.thumbnails-grid::-webkit-scrollbar {
    width: 8px;
}

.thumbnails-grid::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.05);
}

.thumbnails-grid::-webkit-scrollbar-thumb {
    background: rgba(0, 212, 255, 0.5);
    border-radius: 4px;
}

.thumbnails-grid::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 212, 255, 0.8);
}

/* ==================== ANIMACIONES ==================== */
@keyframes slideIn {
    from {
        opacity: 0;
        transform: scale(0.95);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.slider-slide.active {
    animation: slideIn 0.3s ease;
}

/* Animación de flechas palpitantes cuando hay episodio siguiente/anterior */
.slider-arrow.next-episode-available {
    opacity: 1 !important;
    color: rgba(114, 207, 26, 0.9) !important;
    background: rgba(114, 207, 26, 0.15) !important;
    border-color: rgba(114, 207, 26, 0.6) !important;
    animation: pulseNextEpisodeDesktop 1.5s ease-in-out infinite;
    cursor: pointer !important;
}

.mobile-btn.next-episode-available {
    opacity: 1 !important;
    color: rgba(114, 207, 26, 0.9) !important;
    background: rgba(114, 207, 26, 0.15) !important;
    border-color: rgba(114, 207, 26, 0.6) !important;
    animation: pulseNextEpisodeMobile 1.5s ease-in-out infinite;
    cursor: pointer !important;
}

.slider-arrow.next-episode-available:hover {
    color: rgba(114, 207, 26, 1) !important;
    background: rgba(114, 207, 26, 0.25) !important;
    border-color: rgba(114, 207, 26, 1) !important;
    transform: translateY(-50%) scale(1.15);
    animation: none;
    box-shadow: 0 6px 20px rgba(114, 207, 26, 0.7);
}

.mobile-btn.next-episode-available:hover {
    color: rgba(114, 207, 26, 1) !important;
    background: rgba(114, 207, 26, 0.25) !important;
    border-color: rgba(114, 207, 26, 1) !important;
    transform: scale(1.15);
    animation: none;
    box-shadow: 0 4px 16px rgba(114, 207, 26, 0.7);
}

/* Animación para flechas desktop (mantienen translateY para centrado) */
@keyframes pulseNextEpisodeDesktop {
    0%, 100% {
        transform: translateY(-50%) scale(1);
        opacity: 0.9;
        box-shadow: 0 4px 12px rgba(114, 207, 26, 0.3);
    }
    50% {
        transform: translateY(-50%) scale(1.15);
        opacity: 1;
        box-shadow: 0 6px 20px rgba(114, 207, 26, 0.6);
    }
}

/* Animación para botones móviles (solo scale) */
@keyframes pulseNextEpisodeMobile {
    0%, 100% {
        transform: scale(1);
        opacity: 0.9;
        box-shadow: 0 2px 8px rgba(114, 207, 26, 0.3);
    }
    50% {
        transform: scale(1.15);
        opacity: 1;
        box-shadow: 0 4px 16px rgba(114, 207, 26, 0.6);
    }
}


@keyframes pulseGlow {
    0%, 100% {
        transform: translate(-50%, -50%) scale(1);
        opacity: 1;
        box-shadow: 
            0 8px 32px rgba(34, 197, 94, 0.4),
            0 0 0 1px rgba(255, 255, 255, 0.1) inset;
    }
    50% {
        transform: translate(-50%, -50%) scale(1.03);
        opacity: 0.95;
        box-shadow: 
            0 12px 48px rgba(34, 197, 94, 0.6),
            0 0 0 1px rgba(255, 255, 255, 0.2) inset;
    }
}

.hint-text {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    white-space: nowrap;
}

.hint-text::before {
    content: '→';
    font-size: 20px;
    font-weight: bold;
    animation: arrowBounce 1s ease-in-out infinite;
    display: inline-block;
}

@keyframes arrowBounce {
    0%, 100% {
        transform: translateX(0);
        opacity: 1;
    }
    50% {
        transform: translateX(6px);
        opacity: 0.7;
    }
}

/* ==================== ANTI-SELECCIÓN ==================== */
.slider-reader * {
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
}

img {
    -webkit-user-drag: none;
    -khtml-user-drag: none;
    -moz-user-drag: none;
    -o-user-drag: none;
    user-drag: none;
    pointer-events: none;
}
