/* BLÅHAJ Product Gallery Enhancements */

/* Hide non-active gallery images on desktop */
@media (min-width: 56.25em) {
  .pip-product-gallery__media {
    display: none;
  }
  
  .pip-product-gallery__media--active {
    display: block !important;
  }
}

/* Zoom modal styles */
.blahaj-zoom-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 10000;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.blahaj-zoom-modal--active {
    opacity: 1;
}

.blahaj-zoom-modal__overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.9);
    cursor: pointer;
}

.blahaj-zoom-modal__content {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 60px 20px 20px;
    box-sizing: border-box;
}

.blahaj-zoom-modal__close {
    position: absolute;
    top: 20px;
    right: 20px;
    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;
    z-index: 10001;
    transition: background 0.2s ease, transform 0.2s ease;
}

.blahaj-zoom-modal__close:hover {
    background: rgb(255, 255, 255);
    transform: scale(1.1);
}

.blahaj-zoom-modal__close:active {
    transform: scale(0.95);
}

.blahaj-zoom-modal__close svg {
    width: 24px;
    height: 24px;
    color: #111;
}

.blahaj-zoom-modal__image-wrapper {
    max-width: 90%;
    max-height: 90%;
    overflow: auto;
    cursor: grab;
    position: relative;
}

.blahaj-zoom-modal__image-wrapper:active {
    cursor: grabbing;
}

.blahaj-zoom-modal__image {
    max-width: 100%;
    max-height: 90vh;
    width: auto;
    height: auto;
    display: block;
    object-fit: contain;
    pointer-events: none;
    user-select: none;
}

/* Enhanced hover states for thumbnails */
.pip-product-gallery__thumbnail {
    cursor: pointer;
    transition: border-color 0.2s ease, transform 0.2s ease;
}

.pip-product-gallery__thumbnail:hover {
    transform: scale(1.05);
}

.pip-product-gallery__thumbnail:active {
    transform: scale(0.98);
}

/* Enhanced zoom container */
.pip-zoom-image {
    position: relative;
    overflow: hidden;
    transition: background-size 0.3s ease;
    cursor: zoom-in;
}

.pip-zoom-image__zoomed {
    cursor: zoom-out !important;
}

.pip-zoom-image__zoomed .pip-image {
    opacity: 0;
}

/* Add subtle shadow to thumbnails */
.pip-product-gallery__thumbnail img {
    transition: opacity 0.2s ease;
}

.pip-product-gallery__thumbnail:hover img {
    opacity: 0.85;
}

.pip-product-gallery__thumbnail--active:hover img {
    opacity: 1;
}

/* Responsive adjustments */
@media (max-width: 900px) {
    .blahaj-zoom-modal__content {
        padding: 80px 10px 10px;
    }
    
    .blahaj-zoom-modal__close {
        top: 10px;
        right: 10px;
        width: 40px;
        height: 40px;
    }
    
    .blahaj-zoom-modal__image-wrapper {
        max-width: 95%;
        max-height: 85%;
    }
    
    .blahaj-zoom-modal__image {
        max-height: 80vh;
    }
    
    /* Remove hover effects on mobile */
    .pip-product-gallery__thumbnail:hover {
        transform: none;
    }
}

/* Accessibility improvements */
.pip-product-gallery__thumbnail:focus {
    outline: 2px solid #0058ab;
    outline-offset: 2px;
}

.blahaj-zoom-modal__close:focus {
    outline: 2px solid #0058ab;
    outline-offset: 2px;
}

/* Loading state */
.pip-zoom-image img {
    transition: opacity 0.3s ease;
}

/* Smooth main image transitions */
.pip-product-gallery__media {
    transition: opacity 0.3s ease;
}

/* All Media Modal Styles */
.pip-modal-wrapper {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 10001;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.75);
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
}

.pip-modal-wrapper--open {
    opacity: 1;
    pointer-events: auto;
}

.pip-modal-wrapper--close {
    opacity: 0;
    pointer-events: none;
}

.pip-modal-wrapper__backdrop {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.4);
    z-index: 1;
    cursor: pointer;
}

.pip-modal-wrapper__backdrop--dark {
    background: rgba(0, 0, 0, 0.6);
}

.pip-skapa-focus-lock {
    position: relative;
    z-index: 2;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
}

.pip-theatre {
    background: white;
    width: 90%;
    max-width: 1200px;
    max-height: 90vh;
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transform: scale(0.9);
    opacity: 0;
    transition: transform 0.3s ease, opacity 0.3s ease;
    pointer-events: auto;
    position: relative;
    z-index: 3;
}

.pip-theatre--enter {
    transform: scale(1);
    opacity: 1;
}

.pip-modal-header {
    padding: 20px;
    border-bottom: 1px solid #e0e0e0;
    display: flex;
    justify-content: flex-end;
    background: white;
    position: relative;
    z-index: 4;
}

.pip-modal-header__close {
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 8px;
    border-radius: 50%;
    transition: background 0.2s ease;
    position: relative;
    z-index: 5;
}

.pip-modal-header__close:hover {
    background: rgba(0, 0, 0, 0.05);
}

.pip-modal-header__close .pip-svg-icon {
    display: block;
}

.pip-btn__inner {
    display: flex;
    align-items: center;
    justify-content: center;
}

.pip-theatre__animation-group {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    overflow: hidden;
}

.pip-theatre__content-wrapper {
    overflow-y: auto;
    flex: 1;
    min-height: 0;
}

.pip-product-gallery-modal-filters {
    padding: 20px;
    border-bottom: 1px solid #e0e0e0;
}

.pip-product-gallery-modal-filters__wrapper {
    display: flex;
    gap: 16px;
}

.pip-product-gallery-modal-filters__button {
    background: transparent;
    border: none;
    padding: 12px 20px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    position: relative;
    color: #484848;
    transition: color 0.2s ease;
}

.pip-product-gallery-modal-filters__button--active {
    color: #0058a3;
}

.pip-product-gallery-modal-filters__button--active::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: #0058a3;
}

.pip-product-gallery-modal {
    padding: 40px 20px;
}

.pip-product-gallery-modal__wrapper {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(400px, 1fr));
    gap: 32px;
    max-width: 1400px;
    margin: 0 auto;
}

.pip-product-gallery-modal__media {
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    border-radius: 4px;
    overflow: hidden;
}

.pip-product-gallery-modal__media:hover {
    transform: translateY(-4px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

@media (max-width: 1400px) {
    .pip-product-gallery-modal__wrapper {
        grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
        gap: 24px;
    }
}

@media (max-width: 1100px) {
    .pip-product-gallery-modal__wrapper {
        grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
        gap: 20px;
    }
}

.pip-aspect-ratio-box {
    display: block;
    position: relative;
    overflow: hidden;
}

.pip-aspect-ratio-box--square {
    padding-bottom: 100%;
}

.pip-aspect-ratio-box img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Responsive adjustments for modal */
@media (max-width: 768px) {
    .pip-theatre {
        width: 95%;
        max-height: 95vh;
    }
    
    .pip-product-gallery-modal__wrapper {
        grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
        gap: 16px;
    }
    
    .pip-product-gallery-modal {
        padding: 20px 12px;
    }
}

@media (max-width: 500px) {
    .pip-product-gallery-modal__wrapper {
        grid-template-columns: 1fr;
        gap: 12px;
    }
}

.pip-product-gallery__media:not(.pip-product-gallery__media--active) {
    display: none;
}
