/**
 * Product Image Carousel Styles
 * Leskovački Kutak
 */

/* Base Carousel Container */
.product-carousel {
    position: relative;
    width: 100%;
    overflow: hidden;
    border-radius: var(--radius-lg, 12px);
    background: var(--gray-100, #f3f4f6);
}

.carousel-inner {
    position: relative;
    width: 100%;
    /* Fallback for Safari < 15 that doesn't support aspect-ratio */
    padding-bottom: 75%; /* 4:3 ratio fallback */
    height: 0;
}

@supports (aspect-ratio: 4/3) {
    .carousel-inner {
        aspect-ratio: 4/3;
        padding-bottom: 0;
        height: auto;
    }
}

/* Slides */
.carousel-slide {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    transition: opacity 0.5s ease-in-out;
    z-index: 1;
}

.carousel-slide.active {
    opacity: 1;
    z-index: 2;
}

.carousel-slide img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

/* Vertical image support */
.product-carousel.vertical .carousel-inner {
    aspect-ratio: 3/4;
}

.product-carousel.vertical .carousel-slide img {
    object-fit: contain;
    background: var(--gray-50, #f9fafb);
}

/* Navigation Arrows */
.carousel-arrow {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    z-index: 10;
    width: 40px;
    height: 40px;
    border: none;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.9);
    color: var(--gray-700, #374151);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: all 0.3s ease;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.product-carousel:hover .carousel-arrow {
    opacity: 1;
}

.carousel-arrow:hover {
    background: white;
    transform: translateY(-50%) scale(1.1);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.carousel-arrow:active {
    transform: translateY(-50%) scale(0.95);
}

.carousel-arrow svg {
    width: 20px;
    height: 20px;
}

.carousel-prev {
    left: 12px;
}

.carousel-next {
    right: 12px;
}

/* Indicators/Dots */
.carousel-indicators {
    position: absolute;
    bottom: 12px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 8px;
    z-index: 10;
    padding: 6px 10px;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 20px;
}

.carousel-indicator {
    width: 8px;
    height: 8px;
    min-width: 8px;
    min-height: 8px;
    max-width: 8px;
    max-height: 8px;
    border: none;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.5);
    cursor: pointer;
    padding: 0;
    margin: 0;
    transition: all 0.3s ease;
    /* iOS Safari fixes */
    -webkit-appearance: none;
    appearance: none;
    -webkit-tap-highlight-color: transparent;
    -webkit-touch-callout: none;
    box-sizing: border-box;
    flex: 0 0 8px;
    display: block;
    font-size: 0;
    line-height: 0;
    text-indent: -9999px;
    overflow: hidden;
}

.carousel-indicator:hover {
    background: rgba(255, 255, 255, 0.8);
}

.carousel-indicator.active {
    background: white;
    width: 24px;
    border-radius: 4px;
}

/* Product Card Carousel (smaller version) */
.product-card .product-carousel {
    border-radius: var(--radius-lg, 12px) var(--radius-lg, 12px) 0 0;
}

.product-card .carousel-inner {
    aspect-ratio: 1/1;
}

.product-card .carousel-arrow {
    width: 32px;
    height: 32px;
}

.product-card .carousel-arrow svg {
    width: 16px;
    height: 16px;
}

.product-card .carousel-indicators {
    bottom: 8px;
    padding: 4px 8px;
    gap: 6px;
}

.product-card .carousel-indicator {
    width: 6px;
    height: 6px;
}

.product-card .carousel-indicator.active {
    width: 18px;
}

/* Touch device optimizations */
@media (hover: none) {
    .carousel-arrow {
        opacity: 1;
        width: 36px;
        height: 36px;
    }
    
    .product-card .carousel-arrow {
        width: 28px;
        height: 28px;
    }
}

/* Mobile adjustments */
@media (max-width: 768px) {
    .carousel-arrow {
        width: 36px;
        height: 36px;
    }
    
    .carousel-prev {
        left: 8px;
    }
    
    .carousel-next {
        right: 8px;
    }
    
    .carousel-indicators {
        bottom: 8px;
        padding: 4px 8px;
    }
    
    /* Use vertical images on mobile */
    .product-carousel.responsive .carousel-inner {
        aspect-ratio: 3/4;
    }
}

/* Hero Section Carousel */
.hero-carousel {
    position: relative;
    width: 100%;
    height: 100%;
    min-height: 400px;
}

.hero-carousel .carousel-inner {
    aspect-ratio: auto;
    height: 100%;
}

.hero-carousel .carousel-slide img {
    object-fit: cover;
    object-position: center;
}

.hero-carousel .carousel-arrow {
    width: 48px;
    height: 48px;
}

.hero-carousel .carousel-prev {
    left: 24px;
}

.hero-carousel .carousel-next {
    right: 24px;
}

@media (max-width: 768px) {
    .hero-carousel {
        min-height: 300px;
    }
    
    .hero-carousel .carousel-arrow {
        width: 40px;
        height: 40px;
    }
    
    .hero-carousel .carousel-prev {
        left: 12px;
    }
    
    .hero-carousel .carousel-next {
        right: 12px;
    }
}

/* Loading state */
.product-carousel.loading .carousel-inner {
    background: linear-gradient(90deg, var(--gray-100) 25%, var(--gray-200) 50%, var(--gray-100) 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
}

@keyframes shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* Image counter badge */
.carousel-counter {
    position: absolute;
    top: 12px;
    right: 12px;
    z-index: 10;
    padding: 4px 10px;
    background: rgba(0, 0, 0, 0.6);
    color: white;
    font-size: 12px;
    font-weight: 500;
    border-radius: 12px;
}

.product-card .carousel-counter {
    top: 8px;
    right: 8px;
    padding: 2px 8px;
    font-size: 11px;
}
