/* === GALERÍA DESKTOP (sin controles, limpia, 2 columnas principales al 50%) === */
.gallery-desktop {
    display: flex;
    gap: 10px;
}

/* Columna izquierda: Imagen principal */
.gallery-main-col {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}
.gallery-main-col .gallery-main {
    width: 98%;
    padding-bottom: 85%;
    position: relative;
}

/* Imagen principal centrada y SIEMPRE con altura fija */
.gallery-main-col img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 10px;
    cursor: pointer;
    transition: transform 0.3s ease;
}

/* Galería secundaria a la derecha */
.gallery-secondary {
    display: grid;
    grid-template-columns: 1fr 1fr;
    grid-template-rows: 1fr 1fr;
    flex: 1;
    gap: 12px;
}

.gallery-secondary .gallery-item {
    position: relative;
    width: 100%;
    padding-bottom: 75%;
    overflow: hidden;
    border-radius: 10px;
}

.gallery-secondary .gallery-item img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 10px;
    cursor: pointer;
    transition: transform 0.3s ease;
}

/* === CONTROLES MÓVILES (Swiper) === */
.swiper-container {
    display: none;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 10px 30px rgba(0,0,0,0.1);
    background: transparent !important;
    margin-left: 0 !important;
    margin-right: 0 !important;
}

.swiper-main {
    background: transparent !important;
}

.swiper-slide {
    height: 300px;
    position: relative;
    background: transparent !important;
}

.swiper-slide img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    cursor: pointer;
}

.swiper-button-next,
.swiper-button-prev {
    background: none !important;
    color: #fff !important;
    border-radius: 50%;
    width: 44px !important;
    height: 44px !important;
    margin-top: -22px !important;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s, color 0.2s, box-shadow 0.2s;
    box-shadow: none;
    border: none;
    outline: none;
}
.swiper-button-next:after,
.swiper-button-prev:after {
    font-size: 32px !important;
    font-weight: bold;
    color: #fff;
    background: none;
    border-radius: 50%;
    transition: color 0.2s;
}
.swiper-button-next:hover:after,
.swiper-button-prev:hover:after {
    color: #007bff;
    background: none;
    box-shadow: 0 0 12px #007bff44;
}

.swiper-pagination-bullet {
    background: rgba(255,255,255,0.7) !important;
    opacity: 1 !important;
    border: 2px solid transparent;
    transition: all 0.3s ease;
}
.swiper-pagination-bullet-active {
    background: #007bff !important;
    border-color: rgba(255,255,255,0.8);
    transform: scale(1.2);
}

/* === LIGHTBOX MEJORADO Y ADAPTADO A MOBILE === */
.lightbox-overlay {
    position: fixed;
    top: 0; left: 0;
    width: 100vw;
    height: 100svh;
    min-height: 100svh;
    max-height: 100svh;
    height: 100dvh;
    min-height: 100dvh;
    max-height: 100dvh;
    height: 100vh;
    min-height: 100vh;
    max-height: 100vh;
    background: rgba(0,0,0,0.95);
    z-index: 1000000000;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    backdrop-filter: blur(5px);
}
.lightbox-overlay.active {
    opacity: 1;
    visibility: visible;
}

.lightbox-content {
    width: 95vw;
    height: 100svh;
    min-height: 100svh;
    max-height: 100svh;
    height: 100dvh;
    min-height: 100dvh;
    max-height: 100dvh;
    height: 100vh;
    min-height: 100vh;
    max-height: 100vh;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    align-items: center;
    background: transparent !important;
    box-sizing: border-box;
    padding: 10px;
}

/* === FILAS === */
.lightbox-row {
    width: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
}

.lightbox-row.controls {
    justify-content: space-between;
    margin-bottom: 10px;
    min-height: 55px;
    flex-shrink: 0;
    padding: 0 10px;
}

.lightbox-row.image {
    flex: 1 1 auto;
    align-items: center;
    justify-content: center;
    display: flex;
    margin-bottom: 10px;
    min-height: 0;
    overflow: hidden;
}
.lightbox-row.thumbs {
    justify-content: center;
    margin-bottom: 21px;
    flex-shrink: 0;
    max-height: 90px;
    overflow-x: auto;
}

/* === CONTADOR === */
.lightbox-counter {
    background: rgba(0,0,0,0.75);
    color: #fff;
    padding: 8px 24px;
    border-radius: 25px;
    font-size: 17px;
    font-weight: 600;
    margin-right: auto;
    margin-left: 10px;
    z-index: 10001;
    border: 1px solid rgba(255,255,255,0.1);
    box-shadow: 0 2px 8px #0002;
    backdrop-filter: blur(8px);
}

/* === BOTONES SUPERIORES === */
.lightbox-controls {
    display: flex;
    gap: 12px;
    z-index: 10001;
    margin-left: auto;
    margin-right: 10px;
}
.lightbox-control {
    background: none !important;
    color: #fff;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    cursor: pointer;
    font-size: 18px;
    transition: background 0.2s, color 0.2s, box-shadow 0.2s;
    user-select: none;
    border: none;
    outline: none;
}
.lightbox-control i {
    font-size: 20px;
}
.lightbox-control:hover {
    color: #007bff;
    background: none !important;
    box-shadow: 0 0 10px #007bff44;
}
.lightbox-control.active {
    color: #fff;
    background: #007bff !important;
}

/* === FLECHAS LATERALES === */
.lightbox-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: none !important;
    color: #fff;
    width: 60px;
    height: 100px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 38px;
    transition: color 0.2s, transform 0.2s;
    user-select: none;
    z-index: 10001;
}
.lightbox-prev { left: 10px; }
.lightbox-next { right: 10px; }
.lightbox-nav:hover {
    color: #007bff;
    transform: translateY(-50%) scale(1.10);
    box-shadow: none;
}

/* === IMAGEN PRINCIPAL === */
.lightbox-image-container {
    position: relative;
    width: 100%;
    height: 100%;
    min-height: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}
.lightbox-img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    transition: transform 0.4s ease;
    cursor: zoom-in;
    border-radius: 8px;
    box-shadow: 0 0 40px rgba(0,0,0,0.5);
}
.lightbox-img.zoomed {
    transform: scale(2.5);
    cursor: zoom-out;
}

/* === MINIATURAS === */
.lightbox-thumbs {
    display: flex;
    gap: 12px;
    background: rgba(0,0,0,0.85);
    padding: 12px 16px;
    border-radius: 15px;
    max-width: 90vw;
    overflow-x: auto;
    border: 1px solid rgba(255,255,255,0.1);
    z-index: 10001;
    backdrop-filter: blur(8px);
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}
.lightbox-thumbs.hidden {
    opacity: 0;
    visibility: hidden;
    transform: translateY(20px);
}
.lightbox-thumb {
    width: 70px;
    height: 70px;
    border-radius: 8px;
    cursor: pointer;
    opacity: 0.6;
    transition: all 0.3s ease;
    border: 3px solid transparent;
    object-fit: cover;
    flex-shrink: 0;
}
.lightbox-thumb.active {
    opacity: 1;
    border-color: #007bff;
    box-shadow: 0 0 15px rgba(0,123,255,0.5);
}
.lightbox-thumb:hover {
    opacity: 1;
    transform: scale(1.1);
}

/* === BOTÓN PLAY ANIMADO === */
.play-button.playing {
    color: #28a745 !important;
    animation: pulse 2s infinite;
}
@keyframes pulse {
    0% { box-shadow: 0 0 0 0 rgba(40,167,69,0.7); }
    70% { box-shadow: 0 0 0 10px rgba(40,167,69,0); }
    100% { box-shadow: 0 0 0 0 rgba(40,167,69,0); }
}

/* === SCROLL MINIATURAS === */


/* === RESPONSIVE y ESPACIO SEGURO SOLO EN PANTALLAS PEQUEÑAS === */
@media (max-width: 900px) {
    .gallery-desktop { display: none; }
    .swiper-container {
        display: block;
        background: transparent !important;
        margin-left: 0 !important;
        margin-right: 0 !important;
        padding-left: 0 !important;
        padding-right: 0 !important;
    }
    .gallery-container {
        padding: 0 !important;
        margin: 0 !important;
    }
    .swiper-main { background: transparent !important; }
    .swiper-slide { height: 250px; background: transparent !important; }
    .lightbox-content {
        width: 100vw;
        height: 100svh;
        min-height: 100svh;
        max-height: 100svh;
        height: 100dvh;
        min-height: 100dvh;
        max-height: 100dvh;
        height: 100vh;
        min-height: 100vh;
        max-height: 100vh;
        /* Espacio seguro para barra inferior del sistema solo en pantallas pequeñas */
        padding-bottom: env(safe-area-inset-bottom, 16px);
    }
    .lightbox-thumbs {
        gap: 7px; padding: 8px 8px;
        max-width: 98vw;
        /* Espacio seguro para barra inferior del sistema solo en pantallas pequeñas */
        padding-bottom: env(safe-area-inset-bottom, 8px);
    }
    .lightbox-row.controls {
        min-height: 44px; margin-bottom: 6px;
    }
    .lightbox-counter {
        padding: 6px 12px;
        font-size: 14px;
        margin-left: 4px;
    }
    .lightbox-controls { gap: 7px; margin-right: 4px; }
    .lightbox-control {
        width: 36px; height: 36px; font-size: 15px;
    }
    .lightbox-nav {
        width: 44px; height: 70px; font-size: 28px;
    }
    .lightbox-thumb { width: 48px; height: 48px; }
}
@media (max-width: 480px) {
    .lightbox-row.controls { min-height: 36px; }
    .lightbox-counter { font-size: 12px; padding: 4px 8px;}
    .lightbox-controls { gap: 4px; }
    .lightbox-control { width: 30px; height: 30px; font-size: 13px; }
    .lightbox-thumb { width: 38px; height: 38px; }
}

/* Mejoras adicionales */
.gallery-item::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: linear-gradient(135deg, transparent 0%, rgba(0,123,255,0.1) 100%);
    opacity: 0;
    transition: opacity 0.3s ease;
    z-index: 1;
}
.gallery-item:hover::before { opacity: 1; }

.loading {
    display: inline-block;
    width: 20px; height: 20px;
    border: 3px solid rgba(255,255,255,.3);
    border-radius: 50%;
    border-top-color: #fff;
    animation: spin 1s ease-in-out infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }