/* Reader v2.0 - Estilos Base y Utilidades */

/* Reset y estilos base */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: #000;
    color: #fff;
    overflow-x: hidden;
}

/* Clases de utilidad para barras del reader */
.reader-bar {
    position: fixed;
    left: 0;
    right: 0;
    background: rgba(0, 0, 0, 0.9);
    backdrop-filter: blur(10px);
    padding: 1rem;
    z-index: 1000;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.reader-bar-content {
    width: 100%;
    padding: 0 1rem;
    display: flex;
    align-items: center;
}

/* Header del reader */
.reader-header {
    top: 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    border-top: none;
    border-left: none;
    border-right: none;
    transition: transform 0.3s ease;
}

.reader-header.hidden {
    transform: translateY(-100%);
}

.header-content {
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 1rem;
}

.series-info {
    flex: 1;
    min-width: 200px;
}

.series-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: #fff;
    margin-bottom: 0.25rem;
}

.chapter-title {
    font-size: 0.9rem;
    color: #ccc;
}

.reader-controls {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
}

.reader-header-buttons {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.page-info {
    font-size: 1.05rem;
    color: #aaa;
    white-space: nowrap;
    font-weight: 500;
    letter-spacing: 0.02em;
}

.page-info #currentPageDisplay {
    color: #a855f7;
    font-weight: 600;
}

/* Header buttons - DiseÃ±o tÃ¡ctil mejorado */
.reader-header-btn {
    background: linear-gradient(180deg, #2d2d2d 0%, #1a1a1a 100%);
    border: 1px solid #404040;
    color: #e5e5e5;
    padding: 0.5rem 1rem;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.15s ease;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    font-weight: 500;
    min-height: 44px;
    font-size: 0.95rem;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
}

.reader-header-btn:hover {
    background: linear-gradient(180deg, #3a3a3a 0%, #2a2a2a 100%);
    border-color: #525252;
}

.reader-header-btn:active {
    background: linear-gradient(180deg, #1a1a1a 0%, #0f0f0f 100%);
    transform: scale(0.97);
}

.reader-header-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    transform: none;
}

/* BotÃ³n de ayuda - Icono circular */
.btn-help {
    min-width: 44px;
    width: 44px;
    height: 44px;
    padding: 0;
    font-size: 1.2rem;
    font-weight: 700;
    border-radius: 50%;
    background: linear-gradient(180deg, #3d3d3d 0%, #2a2a2a 100%);
}

/* BotÃ³n de pantalla completa - Icono circular */
.btn-fullscreen {
    min-width: 44px;
    width: 44px;
    height: 44px;
    padding: 0;
    font-size: 1.1rem;
    border-radius: 50%;
    background: linear-gradient(180deg, #3d3d3d 0%, #2a2a2a 100%);
}

/* BotÃ³n cerrar - MÃ¡s prominente */
.btn-close {
    background: linear-gradient(180deg, #4a3a3a 0%, #2d1f1f 100%);
    border-color: #5a4040;
    padding: 0.5rem 1.25rem;
    font-weight: 600;
}

.btn-close:hover {
    background: linear-gradient(180deg, #5a4545 0%, #3a2828 100%);
    border-color: #6a5050;
}

.btn-close:active {
    background: linear-gradient(180deg, #3a2828 0%, #2a1a1a 100%);
}


/* Legacy btn class for compatibility */
.btn {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: #fff;
    padding: 0.35rem 1rem;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
    display: inline-block;
}

.btn:hover {
    background: rgba(255, 255, 255, 0.2);
    border-color: rgba(255, 255, 255, 0.3);
}

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


/* Contenedor principal */
.reader-container {
    margin-top: 0; /* âœ… Sin margen - Cada modo maneja su espaciado */
    min-height: 100vh; /* âœ… Altura completa disponible */
}

/* Loading placeholder */
.image-loading {
    background: #111;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 200px;
    color: #666;
}

/* Indicador de pÃ¡gina al arrastrar slider */
.page-indicator {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(0, 0, 0, 0.8);
    color: #fff;
    padding: 1rem 2rem;
    border-radius: 12px;
    z-index: 2000;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.2s ease;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
}

.page-indicator .label {
    font-size: 1rem;
    font-weight: normal;
    opacity: 0.8;
}

.page-indicator .number {
    font-size: 2.5rem;
    font-weight: bold;
    line-height: 1;
}

.page-indicator.visible {
    opacity: 1;
}

/* Responsive base */
@media (max-width: 768px) {
    /* Header ocupa 100% ancho con solo 3px laterales */
    .reader-bar-content {
        padding: 0 3px; /* âœ… SOLO 3PX LATERAL IGUAL QUE IMAGEN */
    }
    
    .header-content {
        flex-direction: column;
        align-items: flex-start;
        width: 100%; /* âœ… ANCHO COMPLETO */
        gap: 0.5rem; /* SeparaciÃ³n entre elementos */
    }
    
    .reader-controls {
        width: 100%;
        justify-content: space-between;
    }
    
    .reader-container {
        margin-top: 0; /* âœ… SIN MARGEN - Cada modo maneja su espaciado */
    }
    
    /* SOLO MODO MANGA: Reducir altura del header 51% total (30% + 30% adicional) */
    .manga-mode .reader-header {
        padding: 0.49rem 1rem; /* âœ… REDUCIDO DE 0.7rem A 0.49rem (-30% adicional) SOLO MANGA */
    }
    
    /* SOLO MODO MANGA: Reducir altura del footer/navegaciÃ³n 30% */
    .manga-mode .page-navigation {
        padding: 0.7rem 1rem; /* âœ… REDUCIDO DE 1rem A 0.7rem (-30%) SOLO MANGA */
    }
    
    /* Header buttons responsive - Mantener tamaÃ±o tÃ¡ctil */
    .reader-header-btn {
        padding: 0.4rem 0.8rem;
        min-height: 44px;
        font-size: 0.85rem;
    }

    .btn-help,
    .btn-fullscreen {
        min-width: 44px;
        width: 44px;
        height: 44px;
        padding: 0;
        font-size: 1rem;
    }

    .btn-close {
        padding: 0.4rem 1rem;
        font-size: 0.85rem;
    }

    .reader-header-buttons {
        gap: 0.75rem;
    }

    /* Page info mÃ¡s compacto pero legible */
    .page-info {
        font-size: 0.95rem;
        padding: 0.3rem 0.6rem;
        background: rgba(255, 255, 255, 0.05);
        border-radius: 6px;
    }
}

/* =========================================
   HEADER DINÃMICO - Estados de Visibilidad
   ========================================= */

/* Cuando el header estÃ¡ oculto dinÃ¡micamente - EXPANSIÃ“N HACIA ARRIBA */
body.header-hidden .manga-mode .page-container {
    height: calc(100vh - 80px); /* Altura total menos navegaciÃ³n */
    margin-top: 0; /* Sin margen superior */
    padding-top: 0px; /* âœ… SIN SEPARACIÃ“N DEL BORDE SUPERIOR */
    padding-bottom: 80px; /* âœ… RESERVAR ESPACIO PARA MENÃš INFERIOR */
    box-sizing: border-box; /* âœ… INCLUIR PADDING EN ALTURA TOTAL */
}

body.header-hidden .manga-mode .page-image {
    max-height: calc(100vh - 160px); /* âœ… ALTURA REAL DISPONIBLE */
    margin-top: 0; /* âœ… PEGADA AL TOP */
    margin-bottom: 0;
}

/* Header oculto en mÃ³viles - mismo principio */
@media (max-width: 768px) {
    body.header-hidden .manga-mode .page-container {
        height: calc(100vh - 80px); 
        margin-top: 0;
        padding-top: 0px; /* âœ… SIN SEPARACIÃ“N EN MÃ“VIL */
        padding-bottom: 80px; /* âœ… ESPACIO PARA NAVEGACIÃ“N */
        box-sizing: border-box;
    }
    
    body.header-hidden .manga-mode .page-image {
        max-height: calc(100vh - 160px); /* âœ… ALTURA REAL MENOS NAVEGACIÃ“N */
    }
}

/* Header oculto en pantallas pequeÃ±as */
@media (max-width: 380px) {
    body.header-hidden .manga-mode .page-container {
        height: calc(100vh - 80px);
        margin-top: 0;
        padding-top: 0px;
        padding-bottom: 80px;
        box-sizing: border-box;
    }
}

/* =========================================
   PANTALLAS MUY PEQUEÃ‘AS (380px)
   ========================================= */
@media (max-width: 380px) {
    .reader-bar {
        padding: 0.5rem;
    }

    .reader-bar-content {
        padding: 0 2px;
    }

    .header-content {
        gap: 0.35rem;
    }

    .series-info {
        min-width: 0;
    }

    .series-title {
        font-size: 0.9rem;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .chapter-title {
        font-size: 0.75rem;
    }

    .reader-controls {
        gap: 0.5rem;
    }

    .reader-header-buttons {
        gap: 0.5rem;
    }

    /* Botones mantienen 44px mÃ­nimo pero mÃ¡s compactos */
    .reader-header-btn {
        padding: 0.35rem 0.7rem;
        min-height: 44px;
        font-size: 0.8rem;
    }

    .btn-help,
    .btn-fullscreen {
        min-width: 42px;
        width: 42px;
        height: 42px;
        font-size: 0.95rem;
    }

    .btn-close {
        padding: 0.35rem 0.8rem;
        font-size: 0.8rem;
    }

    .page-info {
        font-size: 0.85rem;
        padding: 0.25rem 0.5rem;
    }
}