/* ============================================
   VISOR DE COMIC (overlay)
   ============================================ */

.comic-viewer {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.92);
    z-index: 1000;
    flex-direction: column;
    align-items: center;
    cursor: none;
}

.comic-viewer.active {
    display: flex;
}

.comic-viewer.interaction * {
    cursor: auto;
}

/* ============================================
   TOOLBAR
   ============================================ */

.viewer-toolbar {
    width: 100%;
    padding: 10px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #111;
    border-bottom: 2px solid #444;
    color: #ccc;
    font-family: 'Courier New', monospace;
    flex-shrink: 0;
    gap: 10px;
    z-index: 20;
}

.viewer-toolbar-center {
    display: flex;
    align-items: center;
}

.viewer-toolbar-right {
    display: flex;
    align-items: center;
    gap: 15px;
}

.viewer-toolbar .close-btn {
    background: none;
    border: 2px solid #f55;
    color: #f55;
    padding: 4px 14px;
    font-size: 1.1em;
    cursor: pointer;
    font-family: 'Courier New', monospace;
    font-weight: bold;
    transition: all 0.2s;
    white-space: nowrap;
}

.viewer-toolbar .close-btn:hover {
    background: #f55;
    color: #111;
}

.page-indicator {
    font-size: 1em;
    color: #aaa;
}

/* ============================================
   MARQUEE DE CANCIÓN EN EL VISOR
   ============================================ */

.viewer-song-marquee {
    display: none;
    width: 100%;
    background: #0a0a0a;
    border-bottom: 1px solid #333;
    overflow: hidden;
    white-space: nowrap;
    padding: 4px 0;
    flex-shrink: 0;
    z-index: 15;
    transition: transform 0.4s ease, opacity 0.4s ease;
}

.viewer-song-marquee.visible {
    display: block;
}

.viewer-song-marquee span {
    display: inline-block;
    font-family: 'Courier New', monospace;
    font-size: 0.8em;
    color: #0f0;
    animation: song-marquee 15s linear infinite;
    padding-left: 100%;
}

@keyframes song-marquee {
    0% {
        transform: translateX(0);
    }

    100% {
        transform: translateX(-100%);
    }
}

/* ============================================
   VIEWER CONTENT
   ============================================ */

.viewer-content {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    position: relative;
    overflow: hidden;
    user-select: none;
}

/* ============================================
   ZOOM CONTAINER
   ============================================ */

.zoom-container {
    display: flex;
    align-items: center;
    justify-content: center;
    max-height: 85vh;
    max-width: 90vw;
    overflow: hidden;
    position: relative;
}

.zoom-container img {
    max-height: 85vh;
    max-width: 90vw;
    object-fit: contain;
    border: 2px solid #555;
    transition: transform 0.3s ease, opacity 0.25s ease;
    cursor: zoom-in;
    transform-origin: center center;
}

.zoom-container img.zoomed {
    cursor: grab;
    transform: scale(1.05);
    transition: transform 0.3s ease;
}

.zoom-container img.zoomed.dragging {
    cursor: grabbing;
    transition: none;
}

/* Cuando hay zoom, el container recorta el contenido */
.zoom-container.zoomed-active {
    overflow: hidden;
    cursor: zoom-out;
}

.zoom-container.zoomed-active img {
    max-height: none;
    max-width: none;
}

/* ============================================
   NAV BUTTONS
   ============================================ */

.nav-btn {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(255, 255, 255, 0.08);
    border: 2px solid rgba(255, 255, 255, 0.3);
    color: #ddd;
    font-size: 2.5em;
    padding: 15px 20px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-family: monospace;
    line-height: 1;
    z-index: 10;
}

.nav-btn:hover {
    background: rgba(255, 255, 255, 0.15);
    border-color: #fff;
    color: #fff;
}

.nav-btn.prev {
    left: 15px;
}

.nav-btn.next {
    right: 15px;
}

.nav-btn:disabled {
    opacity: 0.2;
    cursor: default;
}

/* ============================================
   CONTROLES DE MÚSICA
   ============================================ */

.music-controls {
    display: none;
    align-items: center;
    gap: 8px;
    padding: 4px 10px;
    border: 1px solid #444;
    border-radius: 4px;
    background: rgba(255, 255, 255, 0.05);
}

.music-controls.visible {
    display: flex;
}

.music-toggle-btn {
    background: none;
    border: 1px solid #0f0;
    color: #0f0;
    padding: 2px 10px;
    font-size: 1.1em;
    cursor: pointer;
    font-family: 'Courier New', monospace;
    transition: all 0.2s;
    border-radius: 3px;
}

.music-toggle-btn:hover {
    background: #0f0;
    color: #111;
}

.music-toggle-btn.paused {
    border-color: #f55;
    color: #f55;
}

.music-toggle-btn.paused:hover {
    background: #f55;
    color: #111;
}

.volume-slider {
    -webkit-appearance: none;
    appearance: none;
    width: 80px;
    height: 6px;
    background: #444;
    border-radius: 3px;
    outline: none;
    cursor: pointer;
}

.volume-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 14px;
    height: 14px;
    background: #0f0;
    border-radius: 50%;
    cursor: pointer;
    border: none;
}

.volume-slider::-moz-range-thumb {
    width: 14px;
    height: 14px;
    background: #0f0;
    border-radius: 50%;
    cursor: pointer;
    border: none;
}

.volume-label {
    font-size: 0.75em;
    color: #888;
    min-width: 30px;
    text-align: right;
    font-family: 'Courier New', monospace;
}

/* ============================================
   MODAL DE MÚSICA (prompt)
   ============================================ */

.music-prompt-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    z-index: 2000;
    justify-content: center;
    align-items: center;
}

.music-prompt-overlay.active {
    display: flex;
}

.music-prompt-box {
    background: #1a1a1a;
    border: 3px solid #0f0;
    padding: 30px 40px;
    text-align: center;
    max-width: 420px;
    width: 90%;
    font-family: 'Courier New', monospace;
    box-shadow: 0 0 40px rgba(0, 255, 0, 0.15);
}

.music-prompt-title {
    font-size: 1.3em;
    color: #0f0;
    margin-bottom: 10px;
}

.music-prompt-song {
    font-size: 1em;
    color: #fff;
    margin-bottom: 8px;
    font-style: italic;
    padding: 8px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px dashed #555;
}

.music-prompt-desc {
    font-size: 0.85em;
    color: #999;
    margin-bottom: 20px;
}

.music-prompt-buttons {
    display: flex;
    gap: 12px;
    justify-content: center;
    flex-wrap: wrap;
}

.music-prompt-btn {
    padding: 8px 20px;
    font-size: 1em;
    cursor: pointer;
    font-family: 'Courier New', monospace;
    font-weight: bold;
    transition: all 0.2s;
    border: 2px solid;
}

.music-prompt-btn.yes {
    background: none;
    border-color: #0f0;
    color: #0f0;
}

.music-prompt-btn.yes:hover {
    background: #0f0;
    color: #111;
}

.music-prompt-btn.no {
    background: none;
    border-color: #888;
    color: #888;
}

.music-prompt-btn.no:hover {
    background: #888;
    color: #111;
}

/* ============================================
   RESPONSIVE
   ============================================ */
@media (max-width: 600px) {
    .nav-btn {
        font-size: 1.5em;
        padding: 10px 14px;
    }

    .music-controls {
        gap: 4px;
        padding: 2px 6px;
    }

    .volume-slider {
        width: 50px;
    }

    .viewer-toolbar {
        flex-wrap: wrap;
        padding: 8px 10px;
        gap: 6px;
    }

    .viewer-toolbar-right {
        gap: 8px;
    }

    .music-prompt-box {
        padding: 20px;
    }

    .zoom-container img.zoomed {
        transform: scale(1.05);
    }
}

/* ============================================
   MOBILE COMPLETO
   ============================================ */
@media (max-width: 768px) {

    /* Toolbar compacta */
    .viewer-toolbar {
        padding: 6px 10px;
        gap: 4px;
        flex-wrap: wrap;
        justify-content: center;
    }

    .comic-viewer-title {
        font-size: 0.8em;
        width: 100%;
        text-align: center;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .viewer-toolbar-center {
        order: 1;
    }

    .viewer-toolbar-right {
        order: 2;
        gap: 6px;
    }

    .page-indicator {
        font-size: 0.85em;
    }

    .viewer-toolbar .close-btn {
        padding: 3px 10px;
        font-size: 0.9em;
    }

    /* Botones de navegación adaptados a toque */
    .nav-btn {
        font-size: 1.8em;
        padding: 12px 14px;
        background: rgba(255, 255, 255, 0.06);
        border: 1px solid rgba(255, 255, 255, 0.2);
        -webkit-tap-highlight-color: transparent;
    }

    .nav-btn.prev {
        left: 5px;
    }

    .nav-btn.next {
        right: 5px;
    }

    /* Imagen del visor más grande en móvil */
    .zoom-container {
        max-height: 80vh;
        max-width: 98vw;
    }

    .zoom-container img {
        max-height: 80vh;
        max-width: 98vw;
        border-width: 1px;
    }

    /* Controles de música compactos */
    .music-controls {
        gap: 4px;
        padding: 2px 6px;
    }

    .music-toggle-btn {
        padding: 2px 8px;
        font-size: 0.95em;
    }

    .volume-slider {
        width: 55px;
        height: 5px;
    }

    .volume-label {
        font-size: 0.65em;
        min-width: 25px;
    }

    /* Marquee de canción */
    .viewer-song-marquee span {
        font-size: 0.7em;
    }

    /* Prompt de música */
    .music-prompt-box {
        padding: 20px 15px;
        max-width: 90%;
    }

    .music-prompt-title {
        font-size: 1.1em;
    }

    .music-prompt-song {
        font-size: 0.85em;
        padding: 6px;
    }

    .music-prompt-desc {
        font-size: 0.8em;
        margin-bottom: 15px;
    }

    .music-prompt-btn {
        padding: 10px 18px;
        font-size: 0.9em;
    }
}

/* ============================================
   MOBILE: NAVEGACIÓN POR ZONAS TÁCTILES
   ============================================ */
@media (max-width: 768px) {

    /* Zonas táctiles invisibles para pasar página */
    .viewer-content {
        position: relative;
    }

    .mobile-tap-zone {
        position: absolute;
        top: 0;
        height: 100%;
        width: 30%;
        z-index: 5;
        -webkit-tap-highlight-color: transparent;
        background: transparent;
        border: none;
        cursor: pointer;
    }

    .mobile-tap-zone.left {
        left: 0;
    }

    .mobile-tap-zone.right {
        right: 0;
    }

    .mobile-tap-zone:active {
        background: rgba(255, 255, 255, 0.04);
    }

    /* Ocultar botones de navegación clásicos en pantallas pequeñas */
    .nav-btn {
        display: none;
    }
}

/* ============================================
   MOBILE: SWIPE FEEDBACK
   ============================================ */
@media (max-width: 768px) {
    .zoom-container img {
        transition: transform 0.25s ease, opacity 0.2s ease;
    }

    .zoom-container img.swipe-left {
        transform: translateX(-30px);
        opacity: 0.7;
    }

    .zoom-container img.swipe-right {
        transform: translateX(30px);
        opacity: 0.7;
    }
}

/* ============================================
   PANTALLAS MUY PEQUEÑAS
   ============================================ */
@media (max-width: 380px) {
    .viewer-toolbar {
        padding: 4px 6px;
    }

    .comic-viewer-title {
        font-size: 0.7em;
    }

    .music-controls {
        padding: 1px 4px;
    }

    .volume-slider {
        width: 40px;
    }

    .music-prompt-box {
        padding: 15px 10px;
    }

    .music-prompt-btn {
        padding: 8px 14px;
        font-size: 0.8em;
    }
}

/* ============================================
   LANDSCAPE EN MÓVIL
   ============================================ */
@media (max-height: 500px) and (orientation: landscape) {
    .viewer-toolbar {
        padding: 3px 10px;
    }

    .zoom-container {
        max-height: 75vh;
    }

    .zoom-container img {
        max-height: 75vh;
    }

    .comic-viewer-title {
        font-size: 0.7em;
    }

    .music-prompt-box {
        padding: 10px 15px;
    }

    .music-prompt-title {
        font-size: 0.9em;
        margin-bottom: 5px;
    }

    .music-prompt-desc {
        margin-bottom: 10px;
    }
}