/**
 * Sistema de Galería de Imágenes - Estilos
 * Compatible con el diseño de Albergue Casa del Río
 */

/* ========================================
   ÍCONO DE GALERÍA EN TARJETAS
   ======================================== */

.custom-block-image-wrapper {
    position: relative;
    overflow: hidden;
}

.custom-block-image-wrapper[data-gallery-id]:not([data-gallery-id="none"]) {
    cursor: pointer;
}

/* Ocultar ícono cuando no hay galería */
.custom-block-image-wrapper[data-gallery-id="none"] .gallery-icon-overlay {
    display: none;
}

.gallery-icon-overlay {
    position: absolute;
    bottom: 12px;
    right: 12px;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(8px);
    color: white;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    transition: all 0.3s ease;
    z-index: 2;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

/* Hover en toda la imagen wrapper */
.custom-block-image-wrapper[data-gallery-id]:not([data-gallery-id="none"]):hover .gallery-icon-overlay {
    background: var(--color-azul-oscuro, #1a3a52);
    transform: scale(1.1);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.4);
}

/* Efecto hover en la imagen */
.custom-block-image-wrapper[data-gallery-id]:not([data-gallery-id="none"]):hover .custom-block-image {
    transform: scale(1.05);
    transition: transform 0.3s ease;
}

.custom-block-image-wrapper .custom-block-image {
    transition: transform 0.3s ease;
}

.gallery-icon-overlay i {
    pointer-events: none;
}

/* Tooltip */
.gallery-tooltip {
    position: absolute;
    bottom: 100%;
    right: 0;
    background: rgba(0, 0, 0, 0.9);
    color: white;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 13px;
    white-space: nowrap;
    margin-bottom: 8px;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    pointer-events: none;
}

.gallery-tooltip::after {
    content: '';
    position: absolute;
    top: 100%;
    right: 16px;
    border: 6px solid transparent;
    border-top-color: rgba(0, 0, 0, 0.9);
}

.custom-block-image-wrapper[data-gallery-id]:not([data-gallery-id="none"]):hover .gallery-tooltip {
    opacity: 1;
    visibility: visible;
    transform: translateY(-4px);
}

/* ========================================
   MODAL DE GALERÍA
   ======================================== */

.gallery-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.95);
    z-index: 10000;
    overflow: hidden;
}

.gallery-modal.active {
    display: flex;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

.gallery-modal-content {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    position: relative;
}

/* ========================================
   HEADER DEL MODAL
   ======================================== */

.gallery-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 30px;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.gallery-modal-title {
    color: white;
    font-size: 24px;
    font-weight: 600;
    margin: 0;
}

.gallery-modal-close {
    background: transparent;
    border: none;
    color: white;
    font-size: 40px;
    line-height: 1;
    cursor: pointer;
    padding: 0;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.3s ease;
}

.gallery-modal-close:hover {
    background: rgba(255, 255, 255, 0.1);
    transform: rotate(90deg);
}

/* ========================================
   BODY DEL MODAL
   ======================================== */

.gallery-modal-body {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    padding: 20px;
    overflow: hidden;
}

/* Imagen principal */
.gallery-main-image {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    border-radius: 8px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
    animation: imageZoomIn 0.3s ease;
}

@keyframes imageZoomIn {
    from {
        opacity: 0;
        transform: scale(0.9);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* Loading */
.gallery-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: white;
}

.gallery-loading-spinner {
    width: 60px;
    height: 60px;
    border: 4px solid rgba(255, 255, 255, 0.2);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

.gallery-loading-text {
    margin-top: 20px;
    font-size: 16px;
    color: rgba(255, 255, 255, 0.8);
}

/* Error */
.gallery-error {
    text-align: center;
    color: white;
}

.gallery-error i {
    font-size: 48px;
    margin-bottom: 16px;
    color: #ff6b6b;
}

.gallery-error p {
    font-size: 16px;
    color: rgba(255, 255, 255, 0.8);
}

/* ========================================
   BOTONES DE NAVEGACIÓN
   ======================================== */

.gallery-nav-btn {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(10px);
    border: 2px solid rgba(255, 255, 255, 0.2);
    color: white;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
    cursor: pointer;
    transition: all 0.3s ease;
    z-index: 10;
}

.gallery-nav-btn:hover:not(:disabled) {
    background: var(--color-azul-oscuro, #1a3a52);
    border-color: white;
    transform: translateY(-50%) scale(1.1);
}

.gallery-nav-btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.gallery-nav-btn.prev {
    left: 30px;
}

.gallery-nav-btn.next {
    right: 30px;
}

/* ========================================
   CONTADOR
   ======================================== */

.gallery-counter {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(10px);
    color: white;
    padding: 10px 20px;
    border-radius: 25px;
    font-size: 16px;
    font-weight: 500;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

/* ========================================
   THUMBNAILS
   ======================================== */

.gallery-thumbnails {
    display: flex;
    gap: 12px;
    padding: 20px 30px;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(10px);
    overflow-x: auto;
    overflow-y: hidden;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.3) transparent;
}

.gallery-thumbnails::-webkit-scrollbar {
    height: 8px;
}

.gallery-thumbnails::-webkit-scrollbar-track {
    background: transparent;
}

.gallery-thumbnails::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.3);
    border-radius: 4px;
}

.gallery-thumbnails::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.5);
}

.gallery-thumbnail {
    flex-shrink: 0;
    width: 100px;
    height: 70px;
    border-radius: 6px;
    overflow: hidden;
    cursor: pointer;
    border: 3px solid transparent;
    transition: all 0.3s ease;
    opacity: 0.6;
}

.gallery-thumbnail:hover {
    opacity: 1;
    transform: translateY(-4px);
}

.gallery-thumbnail.active {
    border-color: var(--color-azul-oscuro, #1a3a52);
    opacity: 1;
}

.gallery-thumbnail img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* ========================================
   RESPONSIVE
   ======================================== */

@media (max-width: 768px) {
    .gallery-modal-header {
        padding: 15px 20px;
    }

    .gallery-modal-title {
        font-size: 18px;
    }

    .gallery-modal-close {
        font-size: 32px;
        width: 36px;
        height: 36px;
    }

    .gallery-modal-body {
        padding: 15px;
    }

    .gallery-nav-btn {
        width: 50px;
        height: 50px;
        font-size: 24px;
    }

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

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

    .gallery-counter {
        bottom: 15px;
        padding: 8px 16px;
        font-size: 14px;
    }

    .gallery-thumbnails {
        padding: 15px 20px;
        gap: 8px;
    }

    .gallery-thumbnail {
        width: 80px;
        height: 56px;
    }

    .gallery-icon-overlay {
        width: 40px;
        height: 40px;
        font-size: 20px;
        bottom: 8px;
        right: 8px;
    }

    .gallery-tooltip {
        font-size: 12px;
        padding: 6px 10px;
    }
}

@media (max-width: 480px) {
    .gallery-modal-title {
        font-size: 16px;
    }

    .gallery-nav-btn {
        width: 44px;
        height: 44px;
        font-size: 20px;
    }

    .gallery-nav-btn.prev {
        left: 10px;
    }

    .gallery-nav-btn.next {
        right: 10px;
    }

    .gallery-thumbnails {
        padding: 12px 15px;
    }

    .gallery-thumbnail {
        width: 70px;
        height: 50px;
    }
}

/* ========================================
   ACCESIBILIDAD
   ======================================== */

.gallery-nav-btn:focus,
.gallery-modal-close:focus,
.gallery-thumbnail:focus {
    outline: 2px solid white;
    outline-offset: 2px;
}

/* Prevenir scroll del body cuando el modal está abierto */
body.gallery-open {
    overflow: hidden;
}
