/* WooCommerce Product Slider Block Styles */

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 24px;
}

/* Main slider container */
.wcpsb-product-slider {
    width: 100%;
    margin: 0;
    padding: 0;
}

/* Slider container with proper layout */
.wcpsb-slider-container {
    position: relative;
    width: 100%;
}

/* Slider track - horizontal scrolling container */
.wcpsb-slider-track {
    display: flex;
    gap: 20px;
    overflow-x: auto;
    padding-bottom: 18px;
    margin-bottom: 12px;
    scrollbar-width: none;
    scroll-behavior: smooth;
    /* Enhanced touch support for iOS */
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-x: contain;
}

/* Hide scrollbar */
.wcpsb-slider-track::-webkit-scrollbar {
    display: none;
}

/* Slider item - individual product card */
.wcpsb-slider-item {
    flex: 0 0 calc((100% / var(--wcpsb-products-per-view, 4)) - 15px);
    text-align: left;
    background: #fff;
    cursor: pointer;
    transition: all .3s ease;
    position: relative;
    border: 2px solid transparent;
    border-radius: 8px;
    padding: 2px;
    /* Prevent products from being pushed off screen */
    min-width: 0;
    flex-shrink: 0;
}

.wcpsb-slider-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

/* Product card */
.wcpsb-product-card {
    border: 1px solid #e5e5e5;
    border-radius: 8px;
    overflow: hidden;
    background: #fff;
    height: 100%;
    display: flex;
    flex-direction: column;
}

/* Product image */
.wcpsb-product-image {
    position: relative;
    overflow: hidden;
    aspect-ratio: 1;
}

.wcpsb-product-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    image-rendering: -webkit-optimize-contrast;
    image-rendering: crisp-edges;
    image-rendering: pixelated;
    transition: transform 0.3s ease;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
}

.wcpsb-product-image:hover img {
    transform: scale(1.05);
}

/* Product content */
.wcpsb-product-content {
    padding: 12px;
    flex-grow: 1;
    display: flex;
    flex-direction: column;
}

/* Product title */
.wcpsb-product-title {
    font-size: 14px;
    font-weight: 600;
    color: #333;
    margin: 0 0 8px 0;
    line-height: 1.3;
}

.wcpsb-product-title a {
    color: inherit;
    text-decoration: none;
}

.wcpsb-product-title a:hover {
    color: #007cba;
}

/* Product price */
.wcpsb-product-price {
    font-size: 14px;
    font-weight: 400;
    color: #666;
    margin-bottom: 12px;
}

.wcpsb-product-price .amount {
    font-weight: 600;
    color: #333;
}

.wcpsb-product-price del {
    color: #999;
    margin-right: 5px;
}

.wcpsb-product-price ins {
    text-decoration: none;
    color: #e2401c;
}

/* Product actions */
.wcpsb-product-actions {
    margin-top: auto;
}

.wcpsb-add-to-cart-btn {
    display: inline-block;
    width: 100%;
    padding: 8px 12px;
    background: #007cba;
    color: #fff;
    text-decoration: none;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 500;
    text-align: center;
    transition: all 0.3s ease;
    border: none;
    cursor: pointer;
}

.wcpsb-add-to-cart-btn:hover {
    background: #005a87;
    color: #fff;
    text-decoration: none;
}

/* Slider controls */
.wcpsb-slider-controls {
    max-width: 1200px;
    margin: 8px auto 0 auto;
    padding: 0 24px;
    display: flex;
    align-items: center;
    gap: 16px;
}

/* Progress bar */
.wcpsb-slider-progress {
    flex-grow: 1;
    height: 2px;
    background: #e5e5e5;
    border-radius: 1px;
}

.wcpsb-slider-progress-bar {
    height: 100%;
    width: 0;
    background: #007cba;
    border-radius: 1px;
    transition: width 0.2s ease-out;
}

/* Arrow controls */
.wcpsb-slider-arrows {
    display: flex;
    gap: 8px;
}

.wcpsb-slider-arrow {
    width: 48px;
    height: 48px;
    min-width: 48px;
    min-height: 48px;
    max-width: 48px;
    max-height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid #ccc;
    background: #fff;
    border-radius: 50%;
    cursor: pointer;
    transition: background 0.2s, border 0.2s, transform 0.1s;
    padding: 0;
    box-sizing: border-box;
    font-size: 0;
    line-height: 0;
    overflow: hidden;
    position: relative;
    z-index: 10;
    outline: none;
}

.wcpsb-slider-arrow:hover:not(:disabled) {
    background: #f0f0f0;
    border-color: #999;
}

.wcpsb-slider-arrow:active:not(:disabled) {
    transform: scale(0.95);
}

.wcpsb-slider-arrow:focus:not(:disabled) {
    border-color: #007cba;
    box-shadow: 0 0 0 2px rgba(0, 124, 186, 0.2);
}

.wcpsb-slider-arrow.swiper-button-disabled {
    opacity: 0.5;
    cursor: not-allowed;
    background: #f5f5f5;
}

.wcpsb-slider-arrow svg {
    width: 20px;
    height: 20px;
    display: block;
    margin: 0;
    background: none;
    border: none;
    pointer-events: none;
}

.wcpsb-slider-arrow svg path {
    stroke: #333 !important;
    fill: none !important;
    stroke-width: 2;
    transition: stroke 0.2s;
}

.wcpsb-slider-arrow:hover:not(:disabled) svg path {
    stroke: #000 !important;
}

.wcpsb-slider-arrow:disabled svg path {
    stroke: #999 !important;
}

/* No products message */
.wcpsb-no-products {
    text-align: center;
    color: #666;
    font-style: italic;
    padding: 40px 20px;
}

/* Responsive design */
@media (max-width: 1200px) {
    .wcpsb-slider-item {
        flex-basis: calc((100% / 3) - 15px);
    }
}

@media (max-width: 768px) {
    .wcpsb-slider-item {
        flex-basis: calc((100% / 2) - 15px);
    }
    .wcpsb-product-content {
        padding: 10px;
    }
    
    .wcpsb-product-title {
        font-size: 13px;
    }
    
    .wcpsb-product-price {
        font-size: 13px;
    }
    
    .wcpsb-add-to-cart-btn {
        font-size: 11px;
        padding: 6px 10px;
    }
    
    .wcpsb-slider-controls {
        padding: 0 20px;
    }
}

@media (max-width: 480px) {
    .wcpsb-slider-track {
        padding-left: 0;
        gap: 12px;
        /* Ensure smooth scrolling on iOS */
        -webkit-overflow-scrolling: touch;
        scroll-snap-type: x mandatory;
        /* Prevent overscroll bounce */
        overscroll-behavior-x: contain;
    }
    
    .wcpsb-slider-item {
        /* Show 1 full product + 30% of next product */
        flex: 0 0 calc(100% / 1.3);
        scroll-snap-align: start;
        /* Ensure consistent sizing */
        min-width: 0;
        flex-shrink: 0;
        /* Prevent layout shifts */
        contain: layout;
    }
    
    .wcpsb-product-content {
        padding: 8px;
    }
    
    .wcpsb-product-title {
        font-size: 12px;
        margin-bottom: 6px;
    }
    
    .wcpsb-product-price {
        font-size: 12px;
        margin-bottom: 8px;
    }
    
    .wcpsb-add-to-cart-btn {
        font-size: 10px;
        padding: 5px 8px;
    }
    
    .wcpsb-slider-controls {
        padding: 0 16px;
        gap: 12px;
    }
}

/* Loading state */
.wcpsb-product-slider.loading {
    opacity: 0.7;
    pointer-events: none;
}

.wcpsb-product-slider.loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    margin: -10px 0 0 -10px;
    border: 2px solid #f3f3f3;
    border-top: 2px solid #007cba;
    border-radius: 50%;
    animation: wcpsb-spin 1s linear infinite;
}

@keyframes wcpsb-spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Sale badge */
.wcpsb-product-image .onsale {
    position: absolute;
    top: 8px;
    left: 8px;
    background: #e2401c;
    color: #fff;
    font-size: 10px;
    font-weight: 600;
    padding: 2px 6px;
    border-radius: 3px;
    z-index: 1;
}

/* Featured badge */
.wcpsb-product-image .featured {
    position: absolute;
    top: 8px;
    right: 8px;
    background: #007cba;
    color: #fff;
    font-size: 10px;
    font-weight: 600;
    padding: 2px 6px;
    border-radius: 3px;
    z-index: 1;
}

/* Out of stock overlay */
.wcpsb-product-image .out-of-stock {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
}

/* iPhone and iOS specific optimizations */
@supports (-webkit-touch-callout: none) {
    .wcpsb-slider-track {
        /* Enhanced touch scrolling for iOS */
        -webkit-overflow-scrolling: touch;
        scroll-snap-type: x mandatory;
        overscroll-behavior-x: contain;
    }
    
    .wcpsb-slider-item {
        scroll-snap-align: start;
        /* Prevent iOS bounce effect from affecting slider */
        -webkit-transform: translateZ(0);
        transform: translateZ(0);
    }
    
    /* Prevent iOS Safari from interfering with touch events */
    .wcpsb-product-slider {
        -webkit-touch-callout: none;
        -webkit-user-select: none;
        user-select: none;
    }
    
    /* Allow text selection within product cards */
    .wcpsb-product-title,
    .wcpsb-product-price {
        -webkit-user-select: text;
        user-select: text;
    }
}

/* Additional mobile optimizations */
@media (max-width: 480px) and (-webkit-min-device-pixel-ratio: 2) {
    .wcpsb-slider-item {
        /* Ensure crisp rendering on high-DPI mobile screens */
        image-rendering: -webkit-optimize-contrast;
        image-rendering: crisp-edges;
    }
}
