/* Admin Gallery Preview */
.aibp-gallery-preview {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 16px;
}

.aibp-gallery-thumb {
    position: relative;
    width: 90px;
    height: 90px;
    overflow: hidden;
    border-radius: 8px;
    border: 1px solid #ddd;
    background: #fff;
    cursor: move;
}

    .aibp-gallery-thumb img {
        width: 100%;
        height: 100%;
        object-fit: cover;
        display: block;
    }

    .aibp-gallery-thumb .aibp-remove-image {
        position: absolute;
        top: 4px;
        right: 4px;
        width: 24px;
        height: 24px;
        padding: 0;
        border: none;
        border-radius: 50%;
        background: rgba(220, 38, 38, 0.9);
        color: #fff;
        font-size: 18px;
        line-height: 1;
        cursor: pointer;
        opacity: 0;
        transition: opacity 0.2s ease;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    .aibp-gallery-thumb:hover .aibp-remove-image {
        opacity: 1;
    }

    .aibp-gallery-thumb .aibp-remove-image:hover {
        background: rgba(220, 38, 38, 1);
    }

/* Frontend Gallery */
.aibp-gallerie-list {
    display: flex;
    flex-direction: column;
    gap: 40px;
}

.aibp-galleria-card {
    padding: 24px;
    border: 1px solid #e8e8e8;
    border-radius: 16px;
    background: #fff;
}

.aibp-galleria-header {
    text-align: center;
    margin-bottom: 24px;
    color: #064848;
}

.aibp-galleria-title {
    margin: 0 0 8px 0;
    font-family: 'Playfair Display', Georgia, serif;
    font-size: clamp(32px, 5vw, 48px);
    line-height: 1.2;
    font-weight: 700;
    color: #064848 !important
}

.aibp-photo-count {
    font-size: 14px;
    color: #666;
    white-space: nowrap;
}

.aibp-galleria-description {
    margin-bottom: 20px;
    color: #333;
}

    .aibp-galleria-description p:last-child {
        margin-bottom: 0;
    }

.aibp-galleria-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
}

.aibp-galleria-item {
    display: block;
    overflow: hidden;
    text-decoration: none;
    height: 250px;
    cursor: pointer;
}

.aibp-galleria-item.hidden {
    display: none;
}

    .aibp-galleria-item img {
        width: 100%;
        height: 250px;
        min-height: 250px;
        max-height: 250px;
        object-fit: cover;
        object-position: center;
        display: block;
        transition: transform 0.25s ease;
    }

    .aibp-galleria-item:hover img {
        transform: scale(1.03);
    }

.aibp-no-galleries,
.aibp-no-photos {
    padding: 24px;
    text-align: center;
    color: #666;
    font-size: 16px;
    background: #f9fafb;
    border-radius: 8px;
}

.aibp-show-more-wrapper {
    text-align: center;
    margin-top: 24px;
}

.aibp-show-more-btn {
    display: inline-block;
    padding: 12px 32px;
    background: #064848;
    color: #fff;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s ease;
    text-decoration: none;
}

.aibp-show-more-btn:hover {
    background: #1d4ed8;
}

.aibp-show-more-btn.hidden {
    display: none;
}

/* Responsive */
@media (max-width: 768px) {
    .aibp-galleria-card {
        padding: 16px;
    }

    .aibp-galleria-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 12px;
    }

    .aibp-galleria-item {
        height: 150px;
    }

    .aibp-galleria-item img {
        height: 150px;
        min-height: 150px;
        max-height: 150px;
    }
}

/* Lightbox Nativa */
.aibp-lightbox {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.95);
    z-index: 9999;
    display: none;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.aibp-lightbox.active {
    display: flex;
    opacity: 1;
}

.aibp-lightbox-content {
    position: relative;
    max-width: 90%;
    max-height: 90vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

.aibp-lightbox-image {
    max-width: 100%;
    max-height: 90vh;
    object-fit: contain;
    border-radius: 4px;
    box-shadow: 0 0 50px rgba(0, 0, 0, 0.5);
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    -webkit-touch-callout: none;
    pointer-events: none;
    -webkit-user-drag: none;
    -khtml-user-drag: none;
    -moz-user-drag: none;
    -o-user-drag: none;
    user-drag: none;
}

/* Bottone Chiudi (X) */
.aibp-lightbox-close {
    position: absolute;
    top: 20px;
    right: 20px;
    width: 44px;
    height: 44px;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(10px);
    border: none;
    border-radius: 50%;
    color: #fff;
    font-size: 0;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    z-index: 10001;
}

.aibp-lightbox-close::before,
.aibp-lightbox-close::after {
    content: '';
    position: absolute;
    width: 20px;
    height: 2px;
    background: #fff;
    border-radius: 2px;
}

.aibp-lightbox-close::before {
    transform: rotate(45deg);
}

.aibp-lightbox-close::after {
    transform: rotate(-45deg);
}

.aibp-lightbox-close:hover {
    background: rgba(0, 0, 0, 0.8);
    transform: scale(1.1);
}

/* Frecce Navigazione */
.aibp-lightbox-prev,
.aibp-lightbox-next {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 44px;
    height: 44px;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(10px);
    border: none;
    border-radius: 50%;
    color: #fff;
    font-size: 0;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    z-index: 10001;
}

.aibp-lightbox-prev::before,
.aibp-lightbox-next::before {
    content: '';
    width: 0;
    height: 0;
    border-style: solid;
}

.aibp-lightbox-prev::before {
    border-width: 8px 12px 8px 0;
    border-color: transparent #fff transparent transparent;
    margin-right: 2px;
}

.aibp-lightbox-next::before {
    border-width: 8px 0 8px 12px;
    border-color: transparent transparent transparent #fff;
    margin-left: 2px;
}

.aibp-lightbox-prev {
    left: 20px;
}

.aibp-lightbox-next {
    right: 20px;
}

.aibp-lightbox-prev:hover,
.aibp-lightbox-next:hover {
    background: rgba(255, 255, 255, 0.2);
    border-color: rgba(255, 255, 255, 0.5);
    transform: translateY(-50%) scale(1.1);
}

.aibp-lightbox-prev.disabled,
.aibp-lightbox-next.disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

/* Contatore foto */
.aibp-lightbox-counter {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.7);
    color: #fff;
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 14px;
    font-weight: 500;
    z-index: 10001;
}

/* Responsive Lightbox */
@media (max-width: 768px) {
    .aibp-lightbox-close {
        width: 36px;
        height: 36px;
        top: 10px;
        right: 10px;
    }

    .aibp-lightbox-close::before,
    .aibp-lightbox-close::after {
        width: 16px;
    }

    .aibp-lightbox-prev,
    .aibp-lightbox-next {
        width: 36px;
        height: 36px;
    }

    .aibp-lightbox-prev::before {
        border-width: 6px 10px 6px 0;
    }

    .aibp-lightbox-next::before {
        border-width: 6px 0 6px 10px;
    }

    .aibp-lightbox-prev {
        left: 10px;
    }

    .aibp-lightbox-next {
        right: 10px;
    }

    .aibp-lightbox-counter {
        bottom: 10px;
        font-size: 12px;
        padding: 6px 12px;
    }
}

/* Disabilita completamente il lightbox di Elementor per le nostre gallerie */
.aibp-galleria-item[data-elementor-open-lightbox="no"] {
    pointer-events: auto !important;
}

/* Nascondi slideshow di Elementor se appare */
.elementor-lightbox .elementor-slideshow__header,
.elementor-lightbox .elementor-swiper-button {
    display: none !important;
}
