/**
 * Estilos para el Visor Público Flipbook 360
 * Color institucional primario: #007e67
 * Optimizado para máxima escala adaptativa, sin colisión con controles y realismo de papel
 */

:root {
    --rv360-primary: #007e67;
    --rv360-primary-hover: #006754;
    --rv360-primary-active: #005041;
    --rv360-primary-light: #e6f5f2;
    --rv360-viewer-bg: #f4f6f8;
}

/* ENCAPSULACIÓN DEL VISOR */
.rv360-viewer-main-wrapper {
    background-color: var(--rv360-viewer-bg);
    min-height: calc(100vh - 80px);
    width: 100%;
    position: relative;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    align-items: center;
    box-sizing: border-box;
    overflow-x: hidden;
    user-select: none;
    -webkit-user-select: none;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

.rv360-viewer-main-wrapper * {
    box-sizing: border-box;
}

.rv360-viewer-content-container {
    width: 100%;
    max-width: 100%;
    flex: 1;
    margin: 0 auto;
    padding: 8px 16px 20px 16px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    position: relative;
}

/* ENCABEZADO EDITORIAL COMPACTO (deja el máximo espacio posible a la gaceta) */
.rv360-magazine-intro-header {
    width: 100%;
    max-width: 1080px;
    margin: 0 auto 6px auto;
    text-align: left;
    color: #0f172a;
    flex-shrink: 0;
    padding: 4px 16px 0 16px;
    box-sizing: border-box;
    animation: rv360FadeIn 0.3s ease-out;
}

@keyframes rv360FadeIn {
    from {
        opacity: 0;
        transform: translateY(-6px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Migas de pan (Breadcrumbs) */
.rv360-editorial-breadcrumbs {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    font-size: 12.5px;
    line-height: 1.3;
    color: #64748b;
    margin-bottom: 6px;
}

.rv360-editorial-breadcrumbs a {
    color: #64748b;
    text-decoration: none;
    font-weight: 500;
    transition: color 0.15s ease;
}

.rv360-editorial-breadcrumbs a:hover {
    color: var(--rv360-primary);
    text-decoration: underline;
}

.rv360-bc-sep {
    margin: 0 8px;
    color: #94a3b8;
    font-weight: 400;
}

.rv360-bc-current {
    color: #0f172a;
    font-weight: 600;
}

/* Fila de metadatos (Badge / Categoría / Fecha) */
.rv360-editorial-meta-row {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 6px;
    font-size: 13px;
}

.rv360-editorial-badge {
    background: #0f172a;
    color: #ffffff;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.6px;
    text-transform: uppercase;
    padding: 3px 10px;
    border-radius: 4px;
    display: inline-block;
    line-height: 1.3;
}

.rv360-editorial-divider {
    color: #cbd5e1;
    font-weight: 300;
    margin: 0 2px;
}

.rv360-editorial-dept {
    color: #475569;
    font-weight: 600;
    font-size: 13px;
}

.rv360-editorial-date {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    color: #64748b;
    font-size: 12.5px;
    margin-left: 6px;
}

.rv360-editorial-date svg {
    color: #94a3b8;
    vertical-align: middle;
}

/* Título principal H1 */
.rv360-magazine-public-title {
    font-size: 40px;
    font-weight: 800;
    color: #0f172a;
    margin: 0 0 6px 0;
    line-height: 1.15;
    letter-spacing: -0.5px;
    text-align: left;
}

/* Sección de descripción: va debajo de la gaceta */
.rv360-magazine-summary {
    width: 100%;
    max-width: 1080px;
    margin: 28px auto 8px auto;
    padding: 0 16px;
}

/* Descripción / Resumen con línea verde institucional a la izquierda */
.rv360-magazine-public-description {
    font-size: 15.5px;
    font-weight: 400;
    color: #334155;
    line-height: 1.65;
    margin: 0;
    padding: 10px 18px;
    border-left: 3.5px solid var(--rv360-primary);
    background: rgba(0, 126, 103, 0.035);
    border-radius: 0 8px 8px 0;
    text-align: left;
}

.rv360-magazine-public-description p {
    margin: 0 0 8px 0;
}

.rv360-magazine-public-description p:last-child {
    margin-bottom: 0;
}

/* APLICACIÓN DEL FLIPBOOK */
.rv360-flipbook-app {
    width: 100%;
    flex: 0 0 auto;
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
}

/* ESCENARIO DEL LIBRO: su alto lo fija viewer.js según la pantalla (la gaceta llena la primera vista) */
.rv360-stage-wrapper {
    width: 100%;
    flex: 0 0 auto;
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
    overflow: visible;
    padding: 12px 0 24px 0 !important;
    min-height: 60vh; /* solo mientras carga; luego viewer.js fija el alto exacto */
    box-sizing: border-box !important;
}

/* Con zoom mayor a 100% la página se recorta dentro del escenario y no tapa título ni barra */
.rv360-stage-wrapper.is-zoomed {
    overflow: hidden;
}

.rv360-zoom-viewport {
    transform-origin: center center;
    transition: transform 0.2s cubic-bezier(0.2, 0, 0, 1);
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: default;
    width: 100%;
    height: 100%;
}

.rv360-zoom-viewport.is-zoomed {
    cursor: grab;
}

.rv360-zoom-viewport.is-dragging {
    cursor: grabbing;
    transition: none;
}

/* CONTENEDOR OBJETIVO DEL LIBRO CON CENTRADO DINÁMICO */
.rv360-flipbook-target {
    margin: 0 auto;
    background-color: transparent;
    box-shadow: none !important;
    position: relative;
    transition: transform 0.45s cubic-bezier(0.25, 1, 0.5, 1);
}

/* Centrado automático en modo escritorio (spread) */
.rv360-flipbook-target.is-cover {
    transform: translateX(-25%);
}

.rv360-flipbook-target.is-spread {
    transform: translateX(0);
}

.rv360-flipbook-target.is-back-cover {
    transform: translateX(25%);
}

/* PÁGINAS INDIVIDUALES DEL LIBRO CON TEXTURA Y SOMBRA DE PAPEL EN FONDO CLARO */
.rv360-page {
    background-color: #ffffff;
    overflow: hidden;
    position: relative;
    box-shadow: 0 16px 38px -8px rgba(15, 23, 42, 0.22), 0 6px 16px -4px rgba(15, 23, 42, 0.12), 0 0 0 1px rgba(0, 0, 0, 0.06);
    border-radius: 2px;
}

.rv360-page canvas {
    width: 100%;
    height: 100%;
    display: block;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
}

.rv360-page-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    background-color: #f8fafc;
    color: #64748b;
    font-size: 13px;
    font-weight: 500;
}

/* EFECTO REALISTA: SOMBRA DEL LOMO (PLIEGUE CENTRAL SUAVE) */
.stf__item.--left .rv360-page::after {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    width: 48px;
    height: 100%;
    background: linear-gradient(to left, rgba(0, 0, 0, 0.18) 0%, rgba(0, 0, 0, 0.07) 28%, rgba(0, 0, 0, 0.01) 70%, transparent 100%);
    pointer-events: none;
    z-index: 10;
}

.stf__item.--right .rv360-page::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 48px;
    height: 100%;
    background: linear-gradient(to right, rgba(0, 0, 0, 0.18) 0%, rgba(0, 0, 0, 0.07) 28%, rgba(0, 0, 0, 0.01) 70%, transparent 100%);
    pointer-events: none;
    z-index: 10;
}

/* EFECTO REALISTA: BRILLO Y GROSOR DE BORDE EXTERIOR */
.stf__item.--left .rv360-page::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 4px;
    height: 100%;
    background: linear-gradient(to right, rgba(255, 255, 255, 0.4), transparent);
    pointer-events: none;
    z-index: 10;
}

.stf__item.--right .rv360-page::before {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    width: 4px;
    height: 100%;
    background: linear-gradient(to left, rgba(255, 255, 255, 0.4), transparent);
    pointer-events: none;
    z-index: 10;
}

/* PORTADA PRINCIPAL (DATA-PAGE="1"): LOMO Y BRILLO EDITORIAL */
.rv360-page[data-page="1"]::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 14px;
    height: 100%;
    background: linear-gradient(to right, rgba(0, 0, 0, 0.22) 0%, rgba(0, 0, 0, 0.06) 40%, transparent 100%);
    pointer-events: none;
    z-index: 10;
}

/* SOMBRAS FÍSICAS DE PASO DE PÁGINA */
.stf__outerShadow,
.stf__innerShadow,
.stf__hardShadow,
.stf__hardInnerShadow {
    pointer-events: none;
    filter: blur(1px);
}

/* FLECHAS DE NAVEGACIÓN LATERAL DESTACADAS (ALTO CONTRASTE Y TAMAÑO VISIBLE) */
button.rv360-side-nav {
    all: unset;
    box-sizing: border-box !important;
    position: absolute !important;
    top: 50% !important;
    transform: translateY(-50%) !important;
    width: 54px !important;
    height: 54px !important;
    min-width: 54px !important;
    max-width: 54px !important;
    min-height: 54px !important;
    max-height: 54px !important;
    border-radius: 50% !important;
    background: var(--rv360-primary) !important;
    backdrop-filter: blur(8px) !important;
    border: 2px solid rgba(255, 255, 255, 0.8) !important;
    color: #ffffff !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    cursor: pointer !important;
    z-index: 1000 !important;
    box-shadow: 0 8px 24px rgba(0, 126, 103, 0.38), 0 2px 8px rgba(0, 0, 0, 0.1) !important;
    transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1) !important;
    outline: none !important;
    padding: 0 !important;
    margin: 0 !important;
}

button.rv360-side-nav svg {
    width: 28px !important;
    height: 28px !important;
    stroke: #ffffff !important;
    fill: none !important;
    stroke-width: 2.8 !important;
    display: block !important;
    margin: auto !important;
}

button.rv360-side-nav:hover {
    background: #006754 !important;
    border-color: #ffffff !important;
    transform: translateY(-50%) scale(1.15) !important;
    box-shadow: 0 10px 30px rgba(0, 126, 103, 0.65) !important;
}

.rv360-side-prev {
    left: 24px !important;
}

.rv360-side-next {
    right: 24px !important;
}

button.rv360-side-nav:disabled,
button.rv360-side-nav.is-disabled {
    opacity: 0.18 !important;
    cursor: not-allowed !important;
    pointer-events: none !important;
    transform: translateY(-50%) scale(1) !important;
}

/* BARRA DE CONTROLES: en el flujo normal, justo debajo de la gaceta (ya no flota sobre el sitio) */
.rv360-controls-bar {
    position: relative;
    z-index: 20;
    margin: 0 auto;
    background: rgba(15, 23, 42, 0.94);
    backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.16) !important;
    border-radius: 40px;
    padding: 5px 16px;
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
    gap: 14px !important;
    box-shadow: 0 12px 36px rgba(15, 23, 42, 0.28);
    max-width: 100%;
    min-height: 48px;
    box-sizing: border-box !important;
}

.rv360-controls-left,
.rv360-controls-right {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 6px !important;
    min-height: 34px;
}

/* BOTONES DEL VISOR CON ESPECIFICIDAD ESTRICTA */
.rv360-controls-bar button.rv360-ctrl-btn,
.rv360-controls-bar a.rv360-ctrl-btn {
    all: unset;
    box-sizing: border-box !important;
    background: transparent !important;
    border: 1px solid transparent !important;
    color: #e2e8f0 !important;
    width: 34px !important;
    height: 34px !important;
    min-width: 34px !important;
    max-width: 34px !important;
    min-height: 34px !important;
    max-height: 34px !important;
    border-radius: 50% !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    cursor: pointer !important;
    padding: 0 !important;
    margin: 0 !important;
    box-shadow: none !important;
    outline: none !important;
    text-decoration: none !important;
    transition: all 0.15s ease !important;
    vertical-align: middle !important;
}

.rv360-controls-bar button.rv360-ctrl-btn svg,
.rv360-controls-bar a.rv360-ctrl-btn svg {
    display: block !important;
    margin: auto !important;
    stroke: currentColor !important;
}

.rv360-controls-bar button.rv360-ctrl-btn:hover,
.rv360-controls-bar a.rv360-ctrl-btn:hover {
    background: rgba(255, 255, 255, 0.16) !important;
    color: #ffffff !important;
    border-color: rgba(255, 255, 255, 0.25) !important;
    transform: scale(1.08) !important;
}

.rv360-controls-bar button.rv360-ctrl-btn:active,
.rv360-controls-bar a.rv360-ctrl-btn:active {
    background: var(--rv360-primary) !important;
    color: #ffffff !important;
    border-color: var(--rv360-primary) !important;
}

/* INDICADOR DE PÁGINA 100% SIMÉTRICO Y ALINEADO HORIZONTALMENTE */
.rv360-page-indicator {
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 6px !important;
    color: #94a3b8 !important;
    font-size: 13px !important;
    padding: 0 4px !important;
    white-space: nowrap !important;
    line-height: 1 !important;
    height: 34px !important;
}

.rv360-indicator-label {
    font-weight: 500 !important;
    font-size: 13px !important;
    line-height: 1 !important;
    display: inline-block !important;
    vertical-align: middle !important;
}

.rv360-page-input {
    all: unset;
    box-sizing: border-box !important;
    width: 40px !important;
    height: 26px !important;
    line-height: 26px !important;
    background: rgba(255, 255, 255, 0.12) !important;
    border: 1px solid rgba(255, 255, 255, 0.25) !important;
    border-radius: 6px !important;
    color: #ffffff !important;
    font-size: 13px !important;
    font-weight: 600 !important;
    text-align: center !important;
    padding: 0 !important;
    margin: 0 !important;
    outline: none !important;
    box-shadow: none !important;
    vertical-align: middle !important;
    transition: border-color 0.2s !important;
}

.rv360-page-input:focus {
    border-color: var(--rv360-primary) !important;
    background: rgba(0, 126, 103, 0.25) !important;
}

.rv360-page-slash {
    color: #94a3b8 !important;
    font-size: 13px !important;
    font-weight: 600 !important;
    line-height: 1 !important;
    margin: 0 2px !important;
    display: inline-block !important;
    vertical-align: middle !important;
}

.rv360-page-total-number {
    color: #cbd5e1 !important;
    font-weight: 600 !important;
    font-size: 13px !important;
    line-height: 1 !important;
    display: inline-block !important;
    vertical-align: middle !important;
}

.rv360-controls-divider {
    width: 1px;
    height: 18px;
    background: rgba(255, 255, 255, 0.2);
    margin: 0 4px;
}

.rv360-zoom-controls {
    display: flex;
    align-items: center;
    gap: 4px;
}

.rv360-zoom-badge {
    width: auto !important;
    min-width: 46px !important;
    padding: 0 8px !important;
    border-radius: 12px !important;
    font-size: 11px !important;
    font-weight: 600 !important;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace !important;
    line-height: 32px !important;
    height: 32px !important;
    text-align: center !important;
}

/* CAJÓN DE MINIATURAS: se abre justo encima de la barra, dentro del visor */
.rv360-thumbnails-drawer {
    position: absolute;
    bottom: 64px;
    left: 50%;
    transform: translateX(-50%);
    width: 96%;
    max-width: 940px;
    background: rgba(15, 23, 42, 0.96);
    backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.18);
    border-radius: 14px;
    padding: 16px 20px;
    z-index: 30;
    box-shadow: 0 15px 40px rgba(0, 0, 0, 0.65);
    animation: rv360SlideUp 0.22s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes rv360SlideUp {
    from {
        opacity: 0;
        transform: translate(-50%, 20px);
    }
    to {
        opacity: 1;
        transform: translate(-50%, 0);
    }
}

.rv360-thumbnails-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: #e2e8f0;
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 12px;
}

.rv360-close-thumbs-btn {
    all: unset;
    cursor: pointer;
    color: #94a3b8;
    font-size: 18px;
    line-height: 1;
    padding: 2px 6px;
}

.rv360-close-thumbs-btn:hover {
    color: #ffffff;
}

.rv360-thumbnails-track {
    display: flex;
    gap: 12px;
    overflow-x: auto;
    padding-bottom: 8px;
    scroll-behavior: smooth;
}

.rv360-thumb-item {
    flex: 0 0 85px;
    height: 115px;
    background: #ffffff;
    border: 2px solid transparent;
    border-radius: 4px;
    overflow: hidden;
    cursor: pointer;
    position: relative;
    transition: all 0.2s;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.4);
}

.rv360-thumb-item:hover {
    transform: scale(1.06);
    border-color: var(--rv360-primary);
}

.rv360-thumb-item.is-active {
    border-color: var(--rv360-primary);
    box-shadow: 0 0 0 2px rgba(0, 126, 103, 0.6);
}

.rv360-thumb-item canvas {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.rv360-thumb-label {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    background: rgba(0, 0, 0, 0.75);
    color: #ffffff;
    font-size: 10px;
    font-weight: 600;
    text-align: center;
    padding: 2px 0;
}

/* OVERLAY DE CARGA Y ERRORES */
.rv360-loading-overlay,
.rv360-error-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--rv360-viewer-bg);
    z-index: 500;
}

.rv360-spinner-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
}

.rv360-spinner {
    width: 52px;
    height: 52px;
    border: 4px solid #e2e8f0;
    border-top-color: var(--rv360-primary);
    border-radius: 50%;
    animation: rv360Spin 0.85s linear infinite;
}

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

.rv360-loading-text {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    color: #0f172a;
}

#rv360-loading-title {
    font-weight: 700;
    font-size: 16px;
    color: #0f172a;
}

#rv360-loading-progress {
    font-size: 13px;
    color: #64748b;
}

.rv360-error-box {
    background: #ffffff;
    border-radius: 12px;
    padding: 32px;
    max-width: 480px;
    text-align: center;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.3);
}

.rv360-error-icon {
    font-size: 40px;
    margin-bottom: 12px;
}

.rv360-error-box h3 {
    margin: 0 0 8px 0;
    color: #991b1b;
    font-size: 18px;
}

.rv360-error-box p {
    color: #4b5563;
    font-size: 14px;
    margin: 0 0 20px 0;
}

/* PANTALLA COMPLETA */
:fullscreen .rv360-viewer-main-wrapper,
:-webkit-full-screen .rv360-viewer-main-wrapper {
    min-height: 100vh;
    height: 100vh;
    padding: 0;
    justify-content: center;
    background-color: #0b0f15;
}

:fullscreen .rv360-viewer-content-container,
:-webkit-full-screen .rv360-viewer-content-container {
    justify-content: center;
    padding-top: 0;
    padding-bottom: 0;
}

:fullscreen .rv360-magazine-intro-header,
:-webkit-full-screen .rv360-magazine-intro-header,
:fullscreen .rv360-magazine-summary,
:-webkit-full-screen .rv360-magazine-summary {
    display: none;
}

/* ACCESIBILIDAD: PREFERS REDUCED MOTION */
@media (prefers-reduced-motion: reduce) {
    .rv360-zoom-viewport,
    .rv360-side-nav,
    .rv360-ctrl-btn,
    .rv360-thumbnails-drawer,
    .rv360-flipbook-target {
        transition: none !important;
        animation: none !important;
    }
}

/* RESPONSIVE MÓVIL Y TABLET */
@media (max-width: 768px) {
    .rv360-viewer-content-container {
        padding: 6px 8px 16px 8px;
    }

    .rv360-magazine-intro-header {
        padding: 2px 6px 0 6px;
        margin-bottom: 2px;
    }

    .rv360-editorial-breadcrumbs {
        display: none; /* En celular se ahorra espacio para la gaceta */
    }

    .rv360-magazine-public-title {
        font-size: 24px;
        letter-spacing: -0.2px;
    }

    .rv360-magazine-summary {
        padding: 0 6px;
        margin-top: 20px;
    }

    .rv360-magazine-public-description {
        font-size: 14.5px;
        padding: 8px 14px;
    }

    .rv360-side-nav {
        display: none !important; /* En móviles se usa gesto táctil swipe */
    }

    /* Barra en DOS filas para que se vean todas las opciones:
       fila 1 = navegación de páginas, fila 2 = zoom, miniaturas, descarga y pantalla completa */
    .rv360-controls-bar {
        width: 100%;
        max-width: 420px;
        padding: 6px 8px;
        gap: 2px !important;
        border-radius: 22px;
        flex-wrap: wrap !important;
        justify-content: center !important;
    }

    .rv360-controls-left,
    .rv360-controls-right {
        flex: 0 0 100%;
        width: 100%;
        gap: 4px !important;
    }

    .rv360-zoom-controls {
        gap: 4px;
    }

    .rv360-controls-divider {
        display: none;
    }

    .rv360-controls-bar button.rv360-ctrl-btn,
    .rv360-controls-bar a.rv360-ctrl-btn {
        width: 30px !important;
        height: 30px !important;
        min-width: 30px !important;
        max-width: 30px !important;
    }

    .rv360-page-input {
        width: 34px !important;
        font-size: 12px !important;
        height: 24px !important;
        line-height: 24px !important;
    }

    .rv360-page-indicator {
        font-size: 11px !important;
        padding: 0 2px !important;
    }

    .rv360-stage-wrapper {
        min-height: 50vh;
        padding: 6px 0 14px 0 !important;
    }

    .rv360-thumbnails-drawer {
        bottom: 110px; /* barra de dos filas */
        padding: 12px;
    }

    /* En móvil siempre vista simple centrada sin desplazamiento */
    .rv360-flipbook-target.is-cover,
    .rv360-flipbook-target.is-spread,
    .rv360-flipbook-target.is-back-cover {
        transform: none !important;
    }
}
