/* ==========================================================================
   ESTILOS PREMIUM - LIBRERA DIGITAL EDITORIAL BOONSTRA
   ========================================================================== */

:root {
    --bg-color: #070913;
    --card-bg: rgba(20, 24, 45, 0.7);
    --card-border: rgba(59, 105, 237, 0.15);
    --text-primary: #ffffff;
    --text-secondary: #90a0d0;
    
    /* Paleta Eléctrica Azul (General) */
    --primary: #3b69ed;
    --primary-glow: rgba(59, 105, 237, 0.3);
    
    /* Paleta Fuego Naranja (Específico de Fariseos) */
    --fariseos: #df781d;
    --fariseos-glow: rgba(223, 120, 29, 0.45);
    
    --font-heading: 'Outfit', sans-serif;
    --font-body: 'Inter', sans-serif;
    
    --transition: all 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

/* Reset General */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

body {
    background-color: var(--bg-color);
    background-image: 
        radial-gradient(circle at 50% 0%, rgba(59, 105, 237, 0.1), transparent 50%);
    color: var(--text-primary);
    font-family: var(--font-body);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
}

/* Header */
header {
    padding: 28px 20px 10px 20px;
    text-align: center;
}

.main-title {
    font-family: var(--font-heading);
    font-size: 1.75rem;
    font-weight: 800;
    letter-spacing: -0.02em;
    background: linear-gradient(135deg, #ffffff 40%, #90a0d0 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    text-transform: uppercase;
}

.subtitle {
    font-size: 0.75rem;
    color: var(--text-secondary);
    font-weight: 400;
    margin-top: 4px;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

/* Layout de Contenedor */
.container {
    width: 100%;
    max-width: 550px;
    margin: 0 auto;
    padding: 15px;
    flex: 1;
    display: flex;
    flex-direction: column;
}

/* ==========================================================================
   PÁGINA PRINCIPAL: INDEX.HTML — Selector de idiomas
   ========================================================================== */

.primary-language-container {
    display: flex;
    justify-content: center;
    margin-bottom: 18px;
    width: 100%;
}

.lang-primary-card {
    width: 100%;
    max-width: 320px;
    background: linear-gradient(135deg, rgba(59, 105, 237, 0.15) 0%, rgba(20, 24, 45, 0.8) 100%);
    border: 1.5px solid rgba(59, 105, 237, 0.4);
    border-radius: 16px;
    padding: 16px;
    text-align: center;
    text-decoration: none;
    transition: var(--transition);
    box-shadow: 0 10px 25px rgba(59, 105, 237, 0.1);
    display: block;
}

.lang-primary-card:hover {
    transform: translateY(-2px);
    border-color: var(--primary);
    box-shadow: 0 15px 30px rgba(59, 105, 237, 0.35);
}

.lang-primary-title {
    font-family: var(--font-heading);
    font-size: 1.4rem;
    font-weight: 800;
    color: #ffffff;
    letter-spacing: 0.05em;
}

.flag-primary {
    font-size: 2rem;
    margin-top: 4px;
    display: inline-block;
    filter: drop-shadow(0 4px 8px rgba(0,0,0,0.3));
}

/* Matriz 3x3 de Idiomas */
.matrix-3x3 {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    width: 100%;
}

.lang-card {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 12px;
    padding: 10px 4px;
    text-align: center;
    text-decoration: none;
    transition: var(--transition);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    backdrop-filter: blur(10px);
}

.lang-card:hover {
    transform: translateY(-2px);
    border-color: #5d8aff;
    background: rgba(59, 105, 237, 0.08);
}

.lang-title {
    font-family: var(--font-heading);
    font-size: 0.78rem;
    font-weight: 700;
    color: #ffffff;
    text-transform: uppercase;
    letter-spacing: 0.02em;
    margin-bottom: 2px;
}

.flag-small {
    font-size: 1.4rem;
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.2));
}

/* Botón de volver */
.back-btn {
    align-self: flex-start;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.78rem;
    margin-bottom: 14px;
    transition: var(--transition);
    background: rgba(59, 105, 237, 0.05);
    padding: 6px 12px;
    border-radius: 50px;
    border: 1px solid var(--card-border);
}

.back-btn:hover {
    color: #ffffff;
    border-color: rgba(59, 105, 237, 0.4);
}

/* ==========================================================================
   ESTANTERÍA DIGITAL CON IMAGEN REAL DE MADERA
   ========================================================================== */

/* Contenedor principal: fondo oscuro que enmarca la librería */
.bookshelf-container {
    width: 100%; /* Llena el ancho disponible */
    max-width: 360px; /* Limitado al tamaño estricto en escritorio/tablet */
    height: 599px; /* Tamaño estricto de altura */
    margin: 0 auto 18px auto; /* Centrado en pantalla */
    align-self: center; /* Garantizar centrado en flex-column */
    background-image: url('estantes_E.jpg');
    background-size: 100% 100%; /* Se adapta perfectamente al contenedor */
    background-repeat: no-repeat;
    background-position: top center;
    border-radius: 0;
    border: none;
    box-shadow: 0 20px 40px rgba(0,0,0,0.7);
    overflow: hidden;
    position: relative; /* ¡Clave! Permite posicionar los libros libremente adentro */
}

/* Contenedor individual de cada libro para posicionarlo milimétricamente */
.book-slot {
    position: absolute;
    width: 95px;
    height: 145px;
    display: flex;
    flex-direction: column;
    align-items: center;
}

/* Etiqueta de texto debajo del libro */
.book-title-label {
    position: absolute;
    top: 155px; /* 10px por debajo del libro (145px) */
    width: 140px; /* Un poco más ancho que el libro para que quepa el texto */
    text-align: center;
    color: white;
    font-family: 'Outfit', sans-serif;
    font-size: 15px; /* Modificado a 15px a petición del usuario */
    font-weight: 700;
    line-height: 1.1;
    text-shadow: 1px 1px 3px rgba(0,0,0,0.8);
    pointer-events: none; /* Para que no bloquee los clics en el libro */
}

/* ====================================================
   POSICIONES EXACTAS DE LOS 6 LIBROS
   (Modifica estos valores 'top' y 'left' milimétricamente)
==================================================== */

/* FILA DE ARRIBA */
#slot-1 { top: 15px;  left: 10px; }   /* Libro 1 (Fariseos) */
#slot-2 { top: 15px;  left: 129px; }  /* Libro 2 */
#slot-3 { top: 15px;  left: 250px; }  /* Libro 3 */

/* FILA DE ABAJO */
#slot-4 { top: 340px; left: 10px; }   /* Libro 4 */
#slot-5 { top: 340px; left: 129px; }  /* Libro 5 */
#slot-6 { top: 340px; left: 250px; }  /* Libro 6 */

/* En móviles, quitamos los paddings laterales del cuerpo para que la madera toque los bordes físicos de la pantalla */
@media (max-width: 550px) {
    .container {
        padding-left: 0 !important;
        padding-right: 0 !important;
    }
    .bookshelf-container {
        max-width: 100%; /* Permite expandirse hasta tocar los bordes del móvil */
        box-shadow: none; /* Opcional: remueve sombra lateral en móvil para limpieza visual */
    }
}

/* Cada libro sobre la estantería */
.book-spine-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-end;
    position: relative;
    cursor: pointer;
    perspective: 600px;
    padding: 0 5px;
}

/* ==========================================================================
   LIBRO 3D BASE (Slots vacíos — gris azulado oscuro)
   ========================================================================== */

.book-3d-model {
    width: 80px;
    height: 118px;
    border-radius: 2px 7px 7px 2px;
    /* Gris azulado oscuro para los slots vacíos */
    background: linear-gradient(100deg, 
        #1a1f32 0%, 
        #242a42 8%, 
        #1e2438 15%, 
        #141828 100%
    );
    border: 1px solid rgba(59, 105, 237, 0.08);
    box-shadow: 
        -4px 6px 12px rgba(0,0,0,0.7),
        inset -2px 0 4px rgba(255,255,255,0.04),
        inset 0 0 0 1px rgba(255,255,255,0.03);
    transform-style: preserve-3d;
    transition: var(--transition);
    position: relative;
    overflow: hidden;
}

/* Lomo izquierdo del libro */
.book-3d-model::before {
    content: '';
    position: absolute;
    top: 0; left: 0;
    width: 6px; height: 100%;
    background: linear-gradient(180deg, 
        rgba(255,255,255,0.1) 0%,
        rgba(255,255,255,0.04) 50%,
        rgba(255,255,255,0.08) 100%
    );
    border-right: 1px solid rgba(0,0,0,0.3);
    z-index: 3;
}

/* Hover en contenedor base también eliminado para que todo sea estático */

/* Contenido interior del libro vacío */
.book-cover-text {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 10px 6px;
    gap: 6px;
}

.locked-icon {
    font-size: 1.1rem;
    opacity: 0.18;
}

/* ==========================================================================
   LIBRO FARISEOS — Portada flotante PNG real
   ========================================================================== */

/* El slot de Fariseos usa posición relativa para el efecto de elevación */
.book-fariseos {
    z-index: 10;
}

/* La imagen PNG de la portadita flota con sombra dramática */
.book-fariseos .book-3d-model {
    background: transparent;
    border: none;
    box-shadow: none;
    overflow: visible;
    width: 95px;
    height: 145px;
}

.book-fariseos .book-3d-model::before {
    display: none; /* Sin lomo falso, la imagen tiene el suyo */
}

/* La imagen de la portadita como fondo de la tarjeta */
.fariseos-cover-img {
    width: 95px;
    height: 145px;
    object-fit: cover;
    border-radius: 4px;
    display: block;
    /* Sombra dramática de libro real parado */
    filter: 
        drop-shadow(-6px 8px 12px rgba(0,0,0,0.85))
        drop-shadow(-2px 2px 4px rgba(0,0,0,0.6));
    transition: var(--transition);
}

/* Efecto Hover Eliminado a petición del usuario (sin movimiento, sin brillo) */

/* ==========================================================================
   DRAWER INTERACTIVO DE DESCARGA — Fariseos
   ========================================================================== */

.download-drawer {
    display: none;
    width: 100%;
    background: linear-gradient(180deg, rgba(18, 22, 42, 0.98) 0%, rgba(9, 11, 22, 0.99) 100%);
    border: 1.5px solid rgba(223, 120, 29, 0.4);
    border-radius: 18px;
    padding: 20px;
    margin-bottom: 18px;
    box-shadow: 
        0 20px 40px rgba(0,0,0,0.7),
        0 0 30px rgba(223, 120, 29, 0.12);
    animation: drawer-slide-up 0.4s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes drawer-slide-up {
    from { opacity: 0; transform: translateY(20px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* Layout interior del drawer: imagen a la izquierda, texto a la derecha */
.drawer-inner {
    display: flex;
    gap: 16px;
    align-items: flex-start;
    margin-bottom: 16px;
}

/* Portada mediana del libro en el drawer */
.drawer-cover {
    flex-shrink: 0;
    width: 105px;
}

.drawer-cover img {
    width: 100%;
    border-radius: 4px 10px 10px 4px;
    display: block;
    box-shadow: 
        -6px 8px 16px rgba(0,0,0,0.8),
        0 0 20px rgba(223, 120, 29, 0.2);
}

.drawer-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.drawer-badge {
    background: rgba(223, 120, 29, 0.12);
    color: #ff9d42;
    border: 1px solid rgba(223, 120, 29, 0.3);
    font-size: 0.65rem;
    font-weight: 700;
    padding: 3px 9px;
    border-radius: 50px;
    width: fit-content;
    letter-spacing: 0.04em;
}

.drawer-close-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.close-drawer {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 1.4rem;
    cursor: pointer;
    line-height: 1;
    padding: 0;
}

.close-drawer:hover { color: #ffffff; }

.drawer-title {
    font-family: var(--font-heading);
    font-size: 1.15rem;
    font-weight: 800;
    color: #ffffff;
    line-height: 1.1;
}

.drawer-author {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.drawer-desc {
    font-size: 0.73rem;
    color: #a5b4d4;
    line-height: 1.45;
}

/* Botones de descarga en el drawer */
.download-options {
    display: flex;
    gap: 10px;
    width: 100%;
}

.dl-btn {
    flex: 1;
    border: none;
    border-radius: 10px;
    padding: 13px 10px;
    font-family: var(--font-heading);
    font-size: 0.82rem;
    font-weight: 700;
    cursor: pointer;
    display: inline-flex;
    justify-content: center;
    align-items: center;
    gap: 6px;
    transition: var(--transition);
    text-decoration: none;
}

.dl-pdf {
    background: linear-gradient(135deg, #bf5e0e 0%, var(--fariseos) 50%, #f08020 100%);
    color: #ffffff;
    box-shadow: 0 4px 18px rgba(223, 120, 29, 0.45);
}

.dl-pdf:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(223, 120, 29, 0.65);
}

.dl-epub {
    background: rgba(255, 255, 255, 0.07);
    color: #d0daf8;
    border: 1px solid rgba(59, 105, 237, 0.2);
}

.dl-epub:hover {
    background: rgba(59, 105, 237, 0.12);
    border-color: rgba(59, 105, 237, 0.4);
    transform: translateY(-2px);
}

/* ==========================================================================
   PANEL ADMIN SECRETO
   ========================================================================== */

.admin-overlay {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background-color: rgba(5, 7, 15, 0.97);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    z-index: 1000;
    display: none;
    justify-content: center;
    align-items: center;
    padding: 15px;
}

.admin-overlay.active {
    display: flex;
}

.admin-modal {
    width: 100%;
    max-width: 440px;
    background: #0c0f22;
    border: 1px solid rgba(59, 105, 237, 0.2);
    border-radius: 20px;
    padding: 28px;
    position: relative;
    box-shadow: 0 30px 60px rgba(0,0,0,0.7);
}

.close-admin {
    position: absolute;
    top: 14px; right: 16px;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 1.5rem;
    cursor: pointer;
}

.close-admin:hover { color: #fff; }

.password-form {
    text-align: center;
}

.password-form h3 {
    font-family: var(--font-heading);
    font-size: 1.3rem;
    margin-bottom: 8px;
}

.password-form p {
    color: var(--text-secondary);
    font-size: 0.78rem;
    margin-bottom: 20px;
}

.password-input-group {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.password-input-group input {
    background: rgba(255,255,255,0.04);
    border: 1px solid rgba(59, 105, 237, 0.2);
    border-radius: 10px;
    padding: 13px;
    color: #ffffff;
    font-size: 1rem;
    text-align: center;
    outline: none;
    transition: var(--transition);
}

.password-input-group input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 12px var(--primary-glow);
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary), #5d8aff);
    border: none;
    border-radius: 10px;
    padding: 13px;
    color: #fff;
    font-family: var(--font-heading);
    font-size: 0.9rem;
    font-weight: 700;
    cursor: pointer;
    transition: var(--transition);
    box-shadow: 0 4px 15px var(--primary-glow);
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 8px 20px rgba(59, 105, 237, 0.5);
}

/* Dashboard Admin */
.admin-dashboard {
    display: none;
    flex-direction: column;
    width: 100%;
    max-width: 800px;
    max-height: 88vh;
    background: #09111f;
    border: 1.5px solid rgba(59, 105, 237, 0.18);
    border-radius: 20px;
    padding: 20px;
    overflow-y: auto;
    box-shadow: 0 30px 60px rgba(0,0,0,0.8);
}

.dashboard-title {
    font-family: var(--font-heading);
    font-size: 1.2rem;
    font-weight: 800;
    margin-bottom: 14px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.map-wrapper {
    height: 380px; /* Incrementado para móviles (más vertical) */
    width: 100%;
    border-radius: 12px;
    overflow: hidden;
    border: 1px solid rgba(59,105,237,0.12);
    margin-bottom: 14px;
    background: #060c18;
}

#map { height: 100%; width: 100%; }

.admin-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    margin-bottom: 14px;
}

.admin-stat-box {
    background: rgba(59, 105, 237, 0.05);
    border: 1px solid rgba(59, 105, 237, 0.1);
    border-radius: 10px;
    padding: 10px 6px;
    text-align: center;
}

.admin-stat-label {
    font-size: 0.6rem;
    color: var(--text-secondary);
    display: block;
    margin-bottom: 3px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.admin-stat-val {
    font-family: var(--font-heading);
    font-size: 1.15rem;
    font-weight: 700;
    color: #ffffff;
}

.admin-feed-section h4 {
    font-family: var(--font-heading);
    font-size: 0.85rem;
    margin-bottom: 8px;
    border-bottom: 1px solid rgba(59,105,237,0.12);
    padding-bottom: 5px;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.admin-feed-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 5px;
    max-height: 150px;
    overflow-y: auto;
}

.admin-feed-item {
    background: rgba(255,255,255,0.015);
    border: 1px solid rgba(255,255,255,0.04);
    border-radius: 7px;
    padding: 7px 10px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.7rem;
}

.admin-feed-time {
    color: var(--primary);
    font-weight: 600;
}

/* ==========================================================================
   FOOTER
   ========================================================================== */

footer {
    padding: 20px;
    text-align: center;
    border-top: 1px solid rgba(59, 105, 237, 0.07);
    margin-top: auto;
}

.copyright {
    font-size: 0.68rem;
    color: rgba(144, 160, 208, 0.5);
    letter-spacing: 0.03em;
}

.admin-trigger {
    cursor: pointer;
    user-select: none;
    transition: color 0.2s;
}
.admin-trigger:active { color: #ffffff; }

/* Custom Markers del mapa */
.glowing-marker {
    background: var(--fariseos);
    border: 1.5px solid #FFF;
    border-radius: 50%;
    box-shadow: 0 0 8px var(--fariseos-glow);
}

.glowing-marker-pulse {
    position: absolute;
    width: 24px; height: 24px;
    border-radius: 50%;
    background: transparent;
    border: 2px solid var(--fariseos);
    box-shadow: 0 0 10px var(--fariseos-glow);
    animation: marker-pulse 1.8s infinite cubic-bezier(0.25, 0, 0, 1);
    pointer-events: none;
    transform: translate(-30%, -30%);
}

@keyframes marker-pulse {
    0%   { transform: scale(0.3); opacity: 1; }
    100% { transform: scale(1.8); opacity: 0; }
}

/* ==========================================================================
   ADAPTACIÓN PARA ESCRITORIO (VERSIÓN MÁS AMPLIA)
   ========================================================================== */
@media (min-width: 768px) {
    .container {
        max-width: 800px; /* Expande la pantalla principal */
    }
    .admin-dashboard {
        max-width: 1100px; /* Panel de calor gigante */
    }
    .map-wrapper {
        height: 650px; /* Mapa mucho más alto en escritorio */
    }
    .admin-stats {
        grid-template-columns: repeat(4, 1fr);
    }
}

/* ==========================================================================
   ESTILOS PREMIUM PARA AGUA AZUL MARINO (#142e64) Y MAPA CUSTOM (ROBUSTO EN SAFARI)
   ========================================================================== */
.leaflet-tile {
    filter: brightness(0.9) contrast(1.15) !important;
    opacity: 0.45 !important; /* Mezcla perfecta para que el fondo azul marino brille a través del negro */
}

.leaflet-container {
    background: #142e64 !important;
}

/* ==========================================================================
   SECCIÓN DE IDIOMAS (BARRAS HORIZONTALES)
   ========================================================================== */
.admin-languages-section {
    margin-top: 18px;
    margin-bottom: 18px;
    border-top: 1.5px solid rgba(59, 105, 237, 0.08);
    padding-top: 18px;
}

.admin-languages-section h4 {
    font-family: var(--font-heading);
    font-size: 0.95rem;
    color: #FFF;
    margin-bottom: 12px;
    letter-spacing: 0.02em;
}

.admin-languages-container {
    background: rgba(59, 105, 237, 0.03);
    border: 1px solid rgba(59, 105, 237, 0.08);
    border-radius: 12px;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.language-bar-row {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.language-bar-info {
    display: flex;
    justify-content: space-between;
    font-family: var(--font-b);
    font-size: 0.75rem;
    color: #a0a5b5;
}

.language-bar-name {
    color: #FFF;
    font-weight: 600;
}

.language-bar-percentage {
    color: var(--fariseos);
    font-weight: 700;
}

.language-bar-track {
    width: 100%;
    height: 6px;
    background: rgba(255, 255, 255, 0.08);
    border-radius: 3px;
    overflow: hidden;
}

.language-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--fariseos) 0%, #3b82f6 100%);
    border-radius: 3px;
    width: 0%;
    transition: width 0.8s ease-out;
}

