/* ==========================================
   UNIFIED RESPONSIVE CAROUSELS
   Fixes all carousels to be fully responsive
   ========================================== */

/* ===== BASE CAROUSEL STYLES ===== */
.carousel {
    position: relative;
    width: 100%;
    overflow: hidden;
    touch-action: pan-y pinch-zoom;
}

.carousel-inner {
    width: 100%;
    position: relative;
    overflow: hidden;
}

.carousel-item {
    width: 100%;
    position: relative;
    display: none;
    float: left;
    margin-right: -100%;
    backface-visibility: hidden;
    transition: transform 0.6s ease-in-out;
}

.carousel-item.active,
.carousel-item-next,
.carousel-item-prev {
    display: block;
}

.carousel-item-next:not(.carousel-item-start),
.active.carousel-item-end {
    transform: translateX(100%);
}

.carousel-item-prev:not(.carousel-item-end),
.active.carousel-item-start {
    transform: translateX(-100%);
}

/* ===== RESPONSIVE PRODUCT CAROUSELS ===== */
/* Applies to: Offers, Best Sellers, New Arrivals */

.product-carousel,
.offers-carousel {
    position: relative;
    padding: 1rem 0 3rem;
    width: 100%;
}

.product-carousel .carousel-inner,
.offers-carousel .carousel-inner {
    padding: 1rem 0;
    width: 100%;
}

.product-carousel .carousel-item .row,
.offers-carousel .carousel-item .row {
    margin-left: 0;
    margin-right: 0;
    width: 100%;
    display: flex;
    flex-wrap: wrap;
}

/* Desktop (> 1400px): 4 products per slide */
@media (min-width: 1400px) {
    .product-carousel .carousel-item .row > [class*="col-"],
    .offers-carousel .carousel-item .row > [class*="col-"] {
        flex: 0 0 25%;
        max-width: 25%;
    }
}

/* Large Desktop (1200px - 1399px): 4 products per slide */
@media (min-width: 1200px) and (max-width: 1399px) {
    .product-carousel .carousel-item .row > [class*="col-"],
    .offers-carousel .carousel-item .row > [class*="col-"] {
        flex: 0 0 25%;
        max-width: 25%;
    }
}

/* Desktop (992px - 1199px): 3 products per slide */
@media (min-width: 992px) and (max-width: 1199px) {
    .product-carousel .carousel-item .row > [class*="col-"],
    .offers-carousel .carousel-item .row > [class*="col-"] {
        flex: 0 0 33.333333%;
        max-width: 33.333333%;
    }
}

/* Tablet (768px - 991px): 2 products per slide */
@media (min-width: 768px) and (max-width: 991px) {
    .product-carousel .carousel-item .row > [class*="col-"],
    .offers-carousel .carousel-item .row > [class*="col-"] {
        flex: 0 0 50% !important;
        max-width: 50% !important;
        width: 50% !important;
    }
    
    .product-carousel .carousel-item .row > [class*="col-"]:nth-child(n+3),
    .offers-carousel .carousel-item .row > [class*="col-"]:nth-child(n+3) {
        display: none !important;
    }
}

/* Mobile (576px - 767px): Smooth sliding with peek effect - 85% width items */
@media (min-width: 576px) and (max-width: 767px) {
    .product-carousel,
    .offers-carousel {
        padding: 0.5rem 0 2.5rem;
        overflow: visible;
    }
    
    .product-carousel .carousel-inner,
    .offers-carousel .carousel-inner {
        overflow: visible;
        padding: 1rem 0.5rem;
    }
    
    .product-carousel .carousel-item,
    .offers-carousel .carousel-item {
        padding: 0 0.5rem;
        transform: none;
    }
    
    .product-carousel .carousel-item .row,
    .offers-carousel .carousel-item .row {
        display: flex !important;
        flex-wrap: nowrap !important;
        margin-left: 0 !important;
        margin-right: 0 !important;
        gap: 0.5rem;
    }
    
    .product-carousel .carousel-item .row > [class*="col-"],
    .offers-carousel .carousel-item .row > [class*="col-"] {
        flex: 0 0 85% !important;
        max-width: 85% !important;
        width: 85% !important;
        min-width: 85% !important;
        padding-left: 0.5rem !important;
        padding-right: 0.5rem !important;
        transition: transform 0.5s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.5s ease;
    }
    
    /* Show all items for smooth transition */
    .product-carousel .carousel-item .row > [class*="col-"],
    .offers-carousel .carousel-item .row > [class*="col-"] {
        display: block !important;
    }
    
    /* Enable smooth transitions */
    .product-carousel .carousel-item,
    .offers-carousel .carousel-item {
        transition: transform 0.6s cubic-bezier(0.4, 0, 0.2, 1);
    }
}

/* Small Mobile (< 576px): Smooth sliding with peek effect - 80% width items, smaller size */
@media (max-width: 575px) {
    .product-carousel,
    .offers-carousel {
        padding: 0.5rem 0 2.5rem;
        overflow: visible;
    }
    
    .product-carousel .carousel-inner,
    .offers-carousel .carousel-inner {
        overflow: visible;
        padding: 0.75rem 0.5rem;
    }
    
    .product-carousel .carousel-item,
    .offers-carousel .carousel-item {
        padding: 0 0.5rem;
        transform: none;
    }
    
    .product-carousel .carousel-item .row,
    .offers-carousel .carousel-item .row {
        display: flex !important;
        flex-wrap: nowrap !important;
        margin-left: 0 !important;
        margin-right: 0 !important;
        gap: 0.5rem;
    }
    
    .product-carousel .carousel-item .row > [class*="col-"],
    .offers-carousel .carousel-item .row > [class*="col-"] {
        flex: 0 0 80% !important;
        max-width: 80% !important;
        width: 80% !important;
        min-width: 80% !important;
        padding-left: 0.5rem !important;
        padding-right: 0.5rem !important;
        transition: transform 0.5s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.5s ease;
    }
    
    /* Show all items for smooth transition */
    .product-carousel .carousel-item .row > [class*="col-"],
    .offers-carousel .carousel-item .row > [class*="col-"] {
        display: block !important;
    }
    
    /* Enable smooth transitions */
    .product-carousel .carousel-item,
    .offers-carousel .carousel-item {
        transition: transform 0.6s cubic-bezier(0.4, 0, 0.2, 1);
    }
}

/* ===== CAROUSEL CONTROLS - RESPONSIVE ===== */
.carousel-control-prev,
.carousel-control-next {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 50px;
    height: 50px;
    background: rgba(255, 255, 255, 0.95);
    border: 2px solid rgba(0, 0, 0, 0.1);
    border-radius: 50%;
    opacity: 1;
    z-index: 15;
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
    display: flex;
    align-items: center;
    justify-content: center;
}

.carousel-control-prev {
    left: -25px;
}

.carousel-control-next {
    right: -25px;
}

.carousel-control-prev-icon,
.carousel-control-next-icon {
    width: 24px;
    height: 24px;
    background-size: 24px 24px;
}

.carousel-control-prev:hover,
.carousel-control-next:hover {
    background: rgba(59, 130, 246, 0.95);
    border-color: #3b82f6;
    transform: translateY(-50%) scale(1.1);
}

.carousel-control-prev:hover .carousel-control-prev-icon,
.carousel-control-next:hover .carousel-control-next-icon {
    filter: brightness(0) invert(1);
}

/* Responsive Controls */
@media (max-width: 1400px) {
    .carousel-control-prev {
        left: -15px;
    }
    
    .carousel-control-next {
        right: -15px;
    }
}

@media (max-width: 992px) {
    .carousel-control-prev {
        left: 5px;
        width: 42px;
        height: 42px;
    }
    
    .carousel-control-next {
        right: 5px;
        width: 42px;
        height: 42px;
    }
    
    .carousel-control-prev-icon,
    .carousel-control-next-icon {
        width: 20px;
        height: 20px;
        background-size: 20px 20px;
    }
}

@media (max-width: 768px) {
    .carousel-control-prev {
        left: 5px;
        width: 40px;
        height: 40px;
    }
    
    .carousel-control-next {
        right: 5px;
        width: 40px;
        height: 40px;
    }
    
    .carousel-control-prev-icon,
    .carousel-control-next-icon {
        width: 18px;
        height: 18px;
        background-size: 18px 18px;
    }
}

@media (max-width: 576px) {
    .carousel-control-prev {
        left: 5px;
        width: 36px;
        height: 36px;
    }
    
    .carousel-control-next {
        right: 5px;
        width: 36px;
        height: 36px;
    }
    
    .carousel-control-prev-icon,
    .carousel-control-next-icon {
        width: 16px;
        height: 16px;
        background-size: 16px 16px;
    }
}

@media (max-width: 400px) {
    .carousel-control-prev {
        left: 2px;
        width: 32px;
        height: 32px;
    }
    
    .carousel-control-next {
        right: 2px;
        width: 32px;
        height: 32px;
    }
    
    .carousel-control-prev-icon,
    .carousel-control-next-icon {
        width: 14px;
        height: 14px;
        background-size: 14px 14px;
    }
}

/* ===== CAROUSEL INDICATORS - RESPONSIVE ===== */
.carousel-indicators {
    position: absolute;
    bottom: -2.5rem;
    left: 0;
    right: 0;
    z-index: 15;
    display: flex;
    justify-content: center;
    padding: 0;
    margin: 0 0 1rem;
    list-style: none;
    gap: 0.5rem;
}

.carousel-indicators button {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: #d1d5db;
    border: none;
    opacity: 1;
    transition: all 0.3s ease;
    cursor: pointer;
    padding: 0;
    margin: 0;
}

.carousel-indicators button:hover {
    background: #9ca3af;
    transform: scale(1.2);
}

.carousel-indicators button.active {
    background: #3b82f6;
    width: 32px;
    border-radius: 16px;
}

@media (max-width: 768px) {
    .carousel-indicators {
        bottom: -2rem;
        gap: 0.375rem;
    }
    
    .carousel-indicators button {
        width: 10px;
        height: 10px;
    }
    
    .carousel-indicators button.active {
        width: 28px;
    }
}

@media (max-width: 576px) {
    .carousel-indicators {
        bottom: -1.5rem;
        gap: 0.25rem;
    }
    
    .carousel-indicators button {
        width: 8px;
        height: 8px;
    }
    
    .carousel-indicators button.active {
        width: 24px;
        height: 8px;
    }
}

/* ===== FLASH SALE CAROUSEL RESPONSIVE ===== */
.flash-sale-carousel-wrapper {
    position: relative;
    max-width: 100%;
    margin: 0 auto;
    padding: 0 3rem;
}

@media (max-width: 992px) {
    .flash-sale-carousel-wrapper {
        padding: 0 2.5rem;
    }
}

@media (max-width: 768px) {
    .flash-sale-carousel-wrapper {
        padding: 0 2.5rem;
    }
    
    .flash-sale-slide {
        min-height: 300px;
    }
    
    .flash-sale-slide-image,
    .flash-sale-slide-placeholder {
        height: 300px;
    }
    
    .flash-sale-carousel-nav {
        width: 36px;
        height: 36px;
        font-size: 1.2rem;
    }
    
    .flash-sale-carousel-nav.prev {
        left: 0.25rem;
    }
    
    .flash-sale-carousel-nav.next {
        right: 0.25rem;
    }
}

@media (max-width: 576px) {
    .flash-sale-carousel-wrapper {
        padding: 0 2rem;
    }
    
    .flash-sale-slide {
        min-height: 250px;
    }
    
    .flash-sale-slide-image,
    .flash-sale-slide-placeholder {
        height: 250px;
    }
    
    .flash-sale-carousel-nav {
        width: 32px;
        height: 32px;
        font-size: 1rem;
    }
}

@media (max-width: 400px) {
    .flash-sale-carousel-wrapper {
        padding: 0 1.5rem;
    }
    
    .flash-sale-slide {
        min-height: 200px;
    }
    
    .flash-sale-slide-image,
    .flash-sale-slide-placeholder {
        height: 200px;
    }
    
    .flash-sale-carousel-nav {
        display: none;
    }
}

/* ===== TOUCH/SWIPE SUPPORT ===== */
.carousel {
    touch-action: pan-y pinch-zoom;
    -webkit-overflow-scrolling: touch;
}

/* Prevent carousel from breaking on mobile */
@media (max-width: 768px) {
    .carousel-inner {
        overflow: visible;
    }
    
    .carousel-item {
        width: 100% !important;
        margin-right: 0 !important;
    }
    
    /* Enhanced mobile carousel with peek effect */
    .carousel-inner.enhanced-mobile {
        overflow-x: auto;
        overflow-y: visible;
        scroll-behavior: smooth;
        scroll-snap-type: x mandatory;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        -ms-overflow-style: none;
        display: flex;
        flex-wrap: nowrap;
        padding-left: 10%;
        padding-right: 10%;
    }
    
    .carousel-inner.enhanced-mobile::-webkit-scrollbar {
        display: none;
    }
    
    .carousel-inner.enhanced-mobile .carousel-item {
        flex: 0 0 80%;
        width: 80%;
        min-width: 80%;
        max-width: 80%;
        scroll-snap-align: center;
        scroll-snap-stop: always;
        margin-right: 1rem;
    }
    
    .carousel-inner.enhanced-mobile .carousel-item .row {
        margin: 0;
        width: 100%;
    }
    
    .carousel-inner.enhanced-mobile .carousel-item .row > [class*="col-"] {
        width: 100%;
        max-width: 100%;
        flex: 0 0 100%;
    }
}

/* ===== PRODUCT CARDS IN CAROUSELS - RESPONSIVE ===== */
.product-card-simple,
.offer-card {
    min-height: auto;
    height: 100%;
}

/* Tablet - Medium size */
@media (max-width: 768px) {
    .product-card-simple,
    .offer-card {
        margin: 0 auto;
        max-width: 100%;
    }
    
    .product-card-image,
    .offer-card-image {
        height: 180px !important;
        padding: 1rem !important;
    }
    
    .product-card-content,
    .offer-card-content {
        padding: 0.875rem !important;
    }
    
    .product-card-title,
    .offer-card-title {
        font-size: 0.875rem !important;
        min-height: 2.5em !important;
        margin-bottom: 0.5rem !important;
    }
    
    .product-price-current,
    .offer-price-new {
        font-size: 1.125rem !important;
    }
    
    .product-price-old,
    .offer-price-old {
        font-size: 0.75rem !important;
    }
}

/* Mobile - Smaller size */
@media (max-width: 576px) {
    .product-card-simple,
    .offer-card {
        border-radius: 12px !important;
        box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08) !important;
    }
    
    .product-card-image,
    .offer-card-image {
        height: 160px !important;
        padding: 0.75rem !important;
    }
    
    .product-card-content,
    .offer-card-content {
        padding: 0.75rem !important;
    }
    
    .product-card-title,
    .offer-card-title {
        font-size: 0.8rem !important;
        min-height: 2.25em !important;
        margin-bottom: 0.5rem !important;
        line-height: 1.4 !important;
    }
    
    .product-price-current,
    .offer-price-new {
        font-size: 1rem !important;
    }
    
    .product-price-old,
    .offer-price-old {
        font-size: 0.7rem !important;
    }
    
    .product-badge-best-seller,
    .product-badge-discount,
    .product-badge-new,
    .offer-badge {
        font-size: 0.75rem !important;
        padding: 0.3rem 0.6rem !important;
        top: 0.5rem !important;
        right: 0.5rem !important;
    }
    
    .product-badge-best-seller-trophy {
        width: 32px !important;
        height: 32px !important;
        top: 0.5rem !important;
        left: 0.5rem !important;
    }
    
    .product-badge-best-seller-trophy i {
        font-size: 1rem !important;
    }
}

/* ===== SERVICES CAROUSEL ===== */
.services-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 2rem;
}

@media (max-width: 992px) {
    .services-grid {
        grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
        gap: 1.5rem;
    }
}

@media (max-width: 768px) {
    .services-grid {
        grid-template-columns: 1fr;
        gap: 1.5rem;
    }
    
    .service-card-image-wrapper {
        height: 240px;
    }
}

@media (max-width: 576px) {
    .service-card-image-wrapper {
        height: 200px;
    }
    
    .service-card-content {
        padding: 1.25rem;
    }
}

/* ===== FIX BOOTSTRAP CAROUSEL ISSUES ===== */
.carousel-item.active {
    display: block;
}

/* Let Bootstrap handle transitions - don't override */

/* ===== MOBILE: PREVENT VERTICAL STACKING DURING TRANSITIONS ===== */
@media (max-width: 767px) {
    .carousel {
        overflow-x: hidden;
        overflow-y: hidden; /* Prevent vertical overflow during transitions */
    }
    
    .carousel-inner {
        overflow-x: hidden;
        overflow-y: hidden; /* Prevent vertical overflow */
        position: relative;
        /* Ensure consistent height */
        min-height: 400px;
    }
    
    /* Force all carousel items to same vertical position */
    .product-carousel .carousel-item,
    .offers-carousel .carousel-item {
        position: relative !important;
        float: left !important;
        width: 100% !important;
        margin-right: -100% !important;
        /* Force same vertical position - prevent stacking */
        top: 0 !important;
        left: 0 !important;
        /* Only horizontal transforms allowed */
        transform: translateX(0) translateY(0) !important;
    }
    
    /* During active transition - prevent vertical offset */
    .product-carousel .carousel-item.active,
    .product-carousel .carousel-item.carousel-item-next,
    .product-carousel .carousel-item.carousel-item-prev,
    .product-carousel .carousel-item.active.carousel-item-start,
    .product-carousel .carousel-item.active.carousel-item-end,
    .offers-carousel .carousel-item.active,
    .offers-carousel .carousel-item.carousel-item-next,
    .offers-carousel .carousel-item.carousel-item-prev,
    .offers-carousel .carousel-item.active.carousel-item-start,
    .offers-carousel .carousel-item.active.carousel-item-end {
        top: 0 !important;
        /* Override Bootstrap transforms to prevent vertical movement */
        transform-origin: center center !important;
    }
    
    /* Hide non-transitioning items completely */
    .product-carousel .carousel-item:not(.active):not(.carousel-item-next):not(.carousel-item-prev),
    .offers-carousel .carousel-item:not(.active):not(.carousel-item-next):not(.carousel-item-prev) {
        display: none !important;
        visibility: hidden !important;
    }
}

/* ===== ENSURE PROPER COLUMN WIDTHS ===== */
.product-carousel .row > [class*="col-"],
.offers-carousel .row > [class*="col-"] {
    width: 100%;
}

/* Force proper sizing on mobile */
@media (max-width: 767px) {
    .product-carousel .carousel-item .row,
    .offers-carousel .carousel-item .row {
        display: block !important;
    }
    
    .product-carousel .carousel-item .row > *,
    .offers-carousel .carousel-item .row > * {
        width: 100% !important;
        max-width: 100% !important;
        flex: 0 0 100% !important;
    }
    
    /* Hide all but first child */
    .product-carousel .carousel-item .row > *:not(:first-child),
    .offers-carousel .carousel-item .row > *:not(:first-child) {
        display: none !important;
    }
}

/* ===== ACCESSIBILITY & PERFORMANCE ===== */
/* Let Bootstrap handle performance optimizations */

/* Reduce motion for users who prefer it */
@media (prefers-reduced-motion: reduce) {
    .carousel-item {
        transition: none;
    }
    
    .carousel-control-prev,
    .carousel-control-next {
        transition: none;
    }
}

