/**
 * Custom Product Gallery Styles
 * Ersetzt Porto's Owl Carousel mit einer modernen Galerie
 */

/* Container — kein max-width, Breite wird von .brandner-gallery-col bestimmt */
.custom-gallery {
    width: 100%;
    margin: 0;
}

/* Hauptbild Container */
.custom-gallery__main {
    position: relative;
    width: 100%;
    aspect-ratio: 4 / 3;
    background: #f8f8f8;
    border-radius: 8px;
    overflow: hidden;
    margin-bottom: 12px;
}

.custom-gallery__main-image {
    width: 100%;
    height: 100%;
    object-fit: cover;  /* Bild fuellt Container komplett */
    cursor: zoom-in;
    transition: opacity 0.3s ease;
}

.custom-gallery__main-image.is-loading {
    opacity: 0.5;
}

/* Navigation Pfeile */
.custom-gallery__nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 44px;
    height: 44px;
    background: rgba(255, 255, 255, 0.9);
    border: none;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.2s ease, background-color 0.2s ease;
    z-index: 10;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.custom-gallery__main:hover .custom-gallery__nav {
    opacity: 1;
}

.custom-gallery__nav:hover {
    background: #fff;
}

.custom-gallery__nav:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.custom-gallery__nav--prev {
    left: 12px;
}

.custom-gallery__nav--next {
    right: 12px;
}

.custom-gallery__nav svg {
    width: 20px;
    height: 20px;
    fill: #333;
}

/* Thumbnail Container */
.custom-gallery__thumbs {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding: 4px 0;
    scrollbar-width: thin;
    scrollbar-color: #ccc transparent;
}

.custom-gallery__thumbs::-webkit-scrollbar {
    height: 6px;
}

.custom-gallery__thumbs::-webkit-scrollbar-track {
    background: transparent;
}

.custom-gallery__thumbs::-webkit-scrollbar-thumb {
    background-color: #ccc;
    border-radius: 3px;
}

/* Einzelnes Thumbnail */
.custom-gallery__thumb {
    flex: 0 0 auto;
    width: 70px;
    height: 70px;
    border: 2px solid transparent;
    border-radius: 6px;
    overflow: hidden;
    cursor: pointer;
    transition: border-color 0.2s ease, transform 0.2s ease;
    background: #f8f8f8;
}

.custom-gallery__thumb:hover {
    border-color: #999;
}

.custom-gallery__thumb.is-active {
    border-color: #267bbd;
}

.custom-gallery__thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Lightbox / Modal */
.custom-gallery__lightbox {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.95);
    z-index: 99999;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.custom-gallery__lightbox.is-open {
    opacity: 1;
    visibility: visible;
}

.custom-gallery__lightbox-content {
    position: relative;
    max-width: 95vw;
    max-height: 95vh;
}

.custom-gallery__lightbox-image {
    width: 95vw;
    height: 90vh;
    object-fit: contain;
}

.custom-gallery__lightbox-close {
    position: absolute;
    top: -40px;
    right: 0;
    width: 36px;
    height: 36px;
    background: transparent;
    border: none;
    cursor: pointer;
    color: #fff;
    font-size: 32px;
    line-height: 1;
    opacity: 0.8;
    transition: opacity 0.2s ease;
}

.custom-gallery__lightbox-close:hover {
    opacity: 1;
}

.custom-gallery__lightbox-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 60px;
    height: 60px;
    background: rgba(255, 255, 255, 0.3);
    border: none;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.2s ease;
}

.custom-gallery__lightbox-nav:hover {
    background: rgba(255, 255, 255, 0.4);
}

.custom-gallery__lightbox-nav svg {
    width: 28px;
    height: 28px;
    fill: #fff;
}

.custom-gallery__lightbox-nav--prev {
    left: 20px;
}

.custom-gallery__lightbox-nav--next {
    right: 20px;
}

/* Counter im Lightbox */
.custom-gallery__lightbox-counter {
    position: absolute;
    bottom: -35px;
    left: 50%;
    transform: translateX(-50%);
    color: #fff;
    font-size: 14px;
    opacity: 0.8;
}

/* Responsive */
@media (max-width: 768px) {
    .custom-gallery__nav {
        opacity: 1;
        width: 44px;
        height: 44px;
    }

    .custom-gallery__nav--prev {
        left: 8px;
    }

    .custom-gallery__nav--next {
        right: 8px;
    }

    .custom-gallery__thumb {
        width: 60px;
        height: 60px;
    }

    .custom-gallery__lightbox-nav--prev {
        left: 10px;
    }

    .custom-gallery__lightbox-nav--next {
        right: 10px;
    }
}

@media (max-width: 767px) {
    .custom-gallery__main {
        border-radius: 0;
    }
}

/* Wenn nur ein Bild vorhanden ist */
.custom-gallery--single .custom-gallery__nav,
.custom-gallery--single .custom-gallery__thumbs {
    display: none;
}

/* Lade-Indikator */
.custom-gallery__loading {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 40px;
    height: 40px;
    border: 3px solid #f3f3f3;
    border-top: 3px solid #267bbd;
    border-radius: 50%;
    animation: custom-gallery-spin 1s linear infinite;
}

@keyframes custom-gallery-spin {
    0% { transform: translate(-50%, -50%) rotate(0deg); }
    100% { transform: translate(-50%, -50%) rotate(360deg); }
}
