/**
 * WooCommerce Product Carousel Styles
 * Designed to work seamlessly with Astra theme and Spectra plugin
 * 
 * Typography Customization:
 * Use CSS custom properties to customize typography:
 * 
 * --wpc-title-font-family: Font family for product titles
 * --wpc-title-font-size: Font size for product titles
 * --wpc-title-font-weight: Font weight for product titles
 * --wpc-title-line-height: Line height for product titles
 * --wpc-title-color: Color for product titles
 * --wpc-title-hover-color: Color for product titles on hover
 * 
 * --wpc-price-font-family: Font family for prices
 * --wpc-price-font-size: Font size for prices
 * --wpc-price-font-weight: Font weight for prices
 * --wpc-price-color: Color for prices
 * --wpc-price-amount-color: Color for price amounts
 * --wpc-price-del-color: Color for deleted prices
 * --wpc-price-sale-color: Color for sale prices
 * 
 * Example usage:
 * .wpc-carousel-wrapper {
 *   --wpc-title-font-family: 'Helvetica, Arial, sans-serif';
 *   --wpc-title-font-size: 1.2rem;
 *   --wpc-title-color: #2c3e50;
 *   --wpc-price-font-size: 1.3rem;
 *   --wpc-price-color: #e74c3c;
 * }
 */

/* ==========================================================================
   Carousel Wrapper & Container
   ========================================================================== */

.wpc-carousel-wrapper {
    position: relative;
    margin: 2rem 0;
    padding: 0 60px; /* Default padding for arrows */
    clear: both;
}

.wpc-carousel {
    position: relative;
    overflow: hidden;
}

/* Remove default Slick margins and ensure equal heights */
.wpc-carousel .slick-list {
    margin: 0 -10px;
}

.wpc-carousel .slick-slide {
    padding: 0 10px;
    height: auto;
}

.wpc-carousel .slick-slide > div {
    height: 100%;
}

/* ==========================================================================
   Product Item & Card Styles
   ========================================================================== */

.wpc-product-item {
    outline: none;
    border: none;
    margin: 0;
    padding: 0;
    height: 100%;
    display: flex;
    flex-direction: column;
}

.wpc-product-card {
    background: transparent;
    border: none;
    border-radius: 0;
    overflow: visible;
    transition: all 0.3s ease;
    box-shadow: none;
    height: 100%;
    display: flex;
    flex-direction: column;
}

.wpc-product-card:hover {
    transform: none;
    box-shadow: none;
    border-color: transparent;
}

/* ==========================================================================
   Product Image Styles
   ========================================================================== */

.wpc-product-image {
    position: relative;
    overflow: hidden;
    margin-bottom: 1rem;
    flex-shrink: 0;
}

.wpc-product-link {
    display: block;
    position: relative;
    text-decoration: none;
}

.wpc-product-img {
    width: 100%;
    height: auto;
    aspect-ratio: 1 / 1;
    object-fit: cover;
    object-position: center;
    transition: transform 0.3s ease;
}

.wpc-product-img.wpc-placeholder {
    aspect-ratio: 1 / 1;
    background: #f0f0f0;
    display: flex;
    align-items: center;
    justify-content: center;
    object-fit: cover;
}

.wpc-product-card:hover .wpc-product-img {
    transform: scale(1.02);
}

/* Sale Badge */
.wpc-sale-badge {
    position: absolute;
    top: 10px;
    left: 10px;
    background: #e74c3c;
    color: #fff;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    z-index: 2;
}

/* ==========================================================================
   Product Info & Content
   ========================================================================== */

.wpc-product-info {
    padding: 0;
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    text-align: left;
}

.wpc-product-title {
    margin: 0 0 0.25rem 0 !important;
    font-size: var(--wpc-title-font-size, 1rem);
    line-height: var(--wpc-title-line-height, 1.4);
    font-weight: var(--wpc-title-font-weight, 600);
    font-family: var(--wpc-title-font-family, inherit);
    color: var(--wpc-title-color, #333);
    text-align: left;
}

/* Override theme h3 margins specifically for product titles */
.wpc-carousel-wrapper .wpc-product-title,
.wpc-carousel-wrapper .wpc-product-info .wpc-product-title,
.entry-content .wpc-carousel-wrapper .wpc-product-title,
.entry-content .wpc-product-title {
    margin-top: 0 !important;
    margin-bottom: 0.25rem !important;
}

.wpc-product-title-link {
    color: inherit;
    text-decoration: none;
    transition: color 0.3s ease;
}

.wpc-product-title-link:hover {
    color: var(--wpc-title-hover-color, #0073aa);
}

.wpc-product-price {
    margin: 0.5rem 0 1rem 0;
    font-size: var(--wpc-price-font-size, 1.1rem);
    font-weight: var(--wpc-price-font-weight, 600);
    font-family: var(--wpc-price-font-family, inherit);
    color: var(--wpc-price-color, #333);
    text-align: left;
}

.wpc-product-price .amount {
    color: var(--wpc-price-amount-color, #0073aa);
}

.wpc-product-price del {
    color: var(--wpc-price-del-color, #999);
    font-weight: normal;
    margin-right: 0.5rem;
}

.wpc-product-price ins {
    text-decoration: none;
    color: var(--wpc-price-sale-color, #e74c3c);
}

/* ==========================================================================
   Product Actions & Buttons
   ========================================================================== */

.wpc-product-actions {
    margin-top: auto;
    padding-top: 0.5rem;
}

.wpc-btn {
    display: inline-block;
    width: 100%;
    padding: 0.75rem 1rem;
    background: #0073aa;
    color: #fff;
    text-decoration: none;
    border: 2px solid #0073aa;
    border-radius: 4px;
    font-weight: 600;
    text-align: center;
    transition: all 0.3s ease;
    cursor: pointer;
    font-size: 0.9rem;
}

.wpc-btn:hover {
    background: #005a87;
    border-color: #005a87;
    color: #fff;
    transform: translateY(-1px);
}

.wpc-btn:active {
    transform: translateY(0);
}

.wpc-btn.wpc-view-product {
    background: #666;
    border-color: #666;
}

.wpc-btn.wpc-view-product:hover {
    background: #555;
    border-color: #555;
}

.wpc-btn.wpc-select-options {
    background: #f39c12;
    border-color: #f39c12;
}

.wpc-btn.wpc-select-options:hover {
    background: #e67e22;
    border-color: #e67e22;
}

/* Loading state */
.wpc-btn.wpc-loading {
    position: relative;
    color: transparent;
    pointer-events: none;
}

.wpc-btn.wpc-loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 16px;
    height: 16px;
    margin: -8px 0 0 -8px;
    border: 2px solid #fff;
    border-top-color: transparent;
    border-radius: 50%;
    animation: wpc-spin 1s linear infinite;
}

@keyframes wpc-spin {
    to {
        transform: rotate(360deg);
    }
}

/* ==========================================================================
   Responsive Design
   ========================================================================== */

/* Tablet Styles */
@media (max-width: 1024px) {
    .wpc-carousel-wrapper {
        padding: 0 40px; /* Reduce padding for smaller arrows */
    }
    
    .wpc-product-img {
        aspect-ratio: 1 / 1;
    }
    
    .wpc-product-title {
        font-size: 0.95rem;
    }
}

/* Mobile Styles */
@media (max-width: 768px) {
    .wpc-carousel-wrapper {
        margin: 1.5rem 0;
        padding: 0 20px; /* Smaller padding for mobile */
    }
    
    .wpc-carousel .slick-list {
        margin: 0 -8px;
    }
    
    .wpc-carousel .slick-slide {
        padding: 0 8px;
    }
    
    .wpc-product-img {
        aspect-ratio: 1 / 1;
    }
    
    .wpc-product-title {
        font-size: 0.9rem;
        margin-bottom: 0.2rem !important;
    }
    
    .wpc-product-price {
        font-size: 1rem;
        margin: 0.4rem 0 0.75rem 0;
    }
    
    .wpc-btn {
        padding: 0.6rem 0.8rem;
        font-size: 0.85rem;
    }
}

/* Small Mobile Styles */
@media (max-width: 480px) {
    .wpc-carousel-wrapper {
        padding: 0 10px; /* Minimal padding for small screens */
    }
    
    .wpc-product-img {
        aspect-ratio: 1 / 1;
    }
    
    .wpc-product-title {
        font-size: 0.85rem;
    }
    
    .wpc-product-price {
        font-size: 0.95rem;
    }
    
    .wpc-btn {
        padding: 0.5rem 0.6rem;
        font-size: 0.8rem;
    }
}

/* ==========================================================================
   No Products Message
   ========================================================================== */

.wpc-no-products {
    text-align: center;
    padding: 3rem 1rem;
    color: #666;
    font-style: italic;
    font-size: 1.1rem;
}

/* ==========================================================================
   Error Messages
   ========================================================================== */

.wpc-error {
    background: #f8d7da;
    color: #721c24;
    padding: 1rem;
    border: 1px solid #f5c6cb;
    border-radius: 4px;
    margin: 1rem 0;
}

/* ==========================================================================
   Astra Theme Compatibility
   ========================================================================== */

.ast-container .wpc-carousel-wrapper {
    width: 100%;
}

.ast-article-post .wpc-carousel-wrapper {
    margin: 2em 0;
}

/* ==========================================================================
   Spectra/UAGB Compatibility
   ========================================================================== */

.uagb-block-grid .wpc-carousel-wrapper,
.wp-block-group .wpc-carousel-wrapper {
    margin: 1.5em 0;
}

/* ==========================================================================
   Accessibility Improvements
   ========================================================================== */

.wpc-carousel:focus {
    outline: 2px solid #0073aa;
    outline-offset: 2px;
}

.wpc-btn:focus {
    outline: 2px solid #0073aa;
    outline-offset: 2px;
}

/* ==========================================================================
   Print Styles
   ========================================================================== */

@media print {
    .wpc-carousel {
        overflow: visible;
    }
    
    .wpc-product-card {
        break-inside: avoid;
        box-shadow: none;
        border: 1px solid #ccc;
    }
}

/* ==========================================================================
   Typography Utility Classes
   ========================================================================== */

/* Small Typography */
.wpc-carousel-wrapper.wpc-typography-small {
    --wpc-title-font-size: 0.9rem;
    --wpc-price-font-size: 1rem;
}

/* Large Typography */
.wpc-carousel-wrapper.wpc-typography-large {
    --wpc-title-font-size: 1.2rem;
    --wpc-price-font-size: 1.4rem;
}

/* Bold Typography */
.wpc-carousel-wrapper.wpc-typography-bold {
    --wpc-title-font-weight: 700;
    --wpc-price-font-weight: 700;
}

/* Light Typography */
.wpc-carousel-wrapper.wpc-typography-light {
    --wpc-title-font-weight: 400;
    --wpc-price-font-weight: 500;
}

/* Dark Theme Typography */
.wpc-carousel-wrapper.wpc-typography-dark {
    --wpc-title-color: #ffffff;
    --wpc-title-hover-color: #60a5fa;
    --wpc-price-color: #f3f4f6;
    --wpc-price-amount-color: #60a5fa;
}

/* ==========================================================================
   Carousel Controls - Progress Bar and Counter
   ========================================================================== */

.wpc-carousel-controls {
    display: flex;
    align-items: center;
    justify-content: flex-start; /* Align items to the start */
    margin-top: 15px;
    width: 100%;
}

.wpc-progress-bar-container {
    width: 25%;
    max-width: 250px; 
    height: 3px; /* Even thinner progress bar */
    background-color: #e0e0e0; /* Track color */
    border-radius: 2px; /* Adjusted for thinner bar */
    margin-right: 15px; /* Space between progress bar and the arrow/counter group */
    overflow: hidden;
    order: 1; /* Progress bar first */
}

.wpc-progress-bar {
    height: 100%;
    background-color: #000000; /* Black progress */
    border-radius: 2px; /* Adjusted for thinner bar */
    transition: width 0.3s ease-in-out;
    width: 0%;
}

.wpc-slide-counter {
    font-size: 14px;
    color: #000000; /* Black text for counter */
    font-weight: bold;
    white-space: nowrap;
    order: 3; /* Counter after prev arrow */
    margin: 0 10px; /* Space around the counter */
}

/* Slick Arrow Overrides and Ordering */
.wpc-carousel-controls .slick-arrow {
    position: static; /* Remove absolute positioning from Slick defaults */
    transform: none; /* Remove transforms from Slick defaults */
    background: transparent !important; /* Remove default background */
    border: none !important; /* Remove default border */
    padding: 0;
    cursor: pointer;
    font-size: 18px; /* Adjust size as needed */
    line-height: 1; /* Ensure proper vertical alignment */
    border-radius: 0 !important; /* Ensure no rounded corners */
    width: auto !important; /* Prevent fixed dimensions from creating shapes */
    height: auto !important; /* Prevent fixed dimensions from creating shapes */
    box-shadow: none !important; /* Remove any box shadows */
}

.wpc-carousel-controls .slick-prev {
    order: 2; /* Prev arrow before counter */
    margin-right: 10px;
}

.wpc-carousel-controls .slick-next {
    order: 4; /* Next arrow after counter */
    margin-left: 10px;
}

/* Arrow pseudo-elements for the arrow icons - Simple black arrows */
.wpc-carousel-controls .slick-prev:before,
.wpc-carousel-controls .slick-next:before {
    font-family: Arial, sans-serif; /* Use system font for reliable display */
    font-weight: bold;
    color: #000000; /* Black arrows */
    opacity: 1; /* Ensure they are fully visible */
    background: transparent !important; /* Ensure no background on pseudo-element */
    border: none !important; /* Ensure no border on pseudo-element */
    border-radius: 0 !important; /* Ensure no rounded corners on pseudo-element */
    box-shadow: none !important; /* Remove any shadows */
    text-shadow: none !important; /* Remove any text shadows */
    font-size: 20px; /* Control arrow size */
    display: inline-block;
    width: auto;
    height: auto;
}

.wpc-carousel-controls .slick-prev:before {
    content: '‹'; /* Unicode single left-pointing angle quotation mark */
}

.wpc-carousel-controls .slick-next:before {
    content: '›'; /* Unicode single right-pointing angle quotation mark */
}

/* Styling for disabled state */
.wpc-carousel-controls .slick-prev.slick-disabled:before,
.wpc-carousel-controls .slick-next.slick-disabled:before {
    color: #cccccc !important; /* Light grey for disabled state, !important to override */
    opacity: 0.7; /* Slightly more visible than default disabled state */
}

/* Hide original Slick arrows if they are still appearing elsewhere */
.wpc-carousel > .slick-prev,
.wpc-carousel > .slick-next {
    display: none !important;
}

/* Optional: Style for disabled arrows if not using infinite scroll */
.slick-prev.slick-disabled,
.slick-next.slick-disabled {
    opacity: 0.5;
    cursor: default;
}

/* Align arrows with the counter if they are outside the carousel */
.slick-slider {
    position: relative; /* Needed if arrows are positioned absolutely */
}

/* ==========================================================================
   Static Display Styles (when slider is not needed)
   ========================================================================== */

.wpc-carousel.wpc-static-display {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    justify-content: flex-start;
}

.wpc-carousel.wpc-static-display .wpc-product-item {
    flex: 0 0 auto;
    width: calc(25% - 15px); /* Default for desktop (4 items) */
    min-width: 0;
}

/* Static display responsive widths based on wrapper classes */
.wpc-carousel-wrapper.wpc-1-desktop .wpc-carousel.wpc-static-display .wpc-product-item {
    width: 100%;
}

.wpc-carousel-wrapper.wpc-2-desktop .wpc-carousel.wpc-static-display .wpc-product-item {
    width: calc(50% - 10px);
}

.wpc-carousel-wrapper.wpc-3-desktop .wpc-carousel.wpc-static-display .wpc-product-item {
    width: calc(33.333% - 14px);
}

.wpc-carousel-wrapper.wpc-4-desktop .wpc-carousel.wpc-static-display .wpc-product-item {
    width: calc(25% - 15px);
}

.wpc-carousel-wrapper.wpc-5-desktop .wpc-carousel.wpc-static-display .wpc-product-item {
    width: calc(20% - 16px);
}

.wpc-carousel-wrapper.wpc-6-desktop .wpc-carousel.wpc-static-display .wpc-product-item {
    width: calc(16.666% - 17px);
}

/* Static display tablet responsive */
@media (max-width: 1024px) {
    .wpc-carousel-wrapper.wpc-1-tablet .wpc-carousel.wpc-static-display .wpc-product-item {
        width: 100%;
    }
    
    .wpc-carousel-wrapper.wpc-2-tablet .wpc-carousel.wpc-static-display .wpc-product-item {
        width: calc(50% - 10px);
    }
    
    .wpc-carousel-wrapper.wpc-3-tablet .wpc-carousel.wpc-static-display .wpc-product-item {
        width: calc(33.333% - 14px);
    }
    
    .wpc-carousel-wrapper.wpc-4-tablet .wpc-carousel.wpc-static-display .wpc-product-item,
    .wpc-carousel-wrapper.wpc-5-tablet .wpc-carousel.wpc-static-display .wpc-product-item,
    .wpc-carousel-wrapper.wpc-6-tablet .wpc-carousel.wpc-static-display .wpc-product-item {
        width: calc(33.333% - 14px);
    }
}

/* Static display mobile responsive */
@media (max-width: 768px) {
    .wpc-carousel-wrapper.wpc-1-mobile .wpc-carousel.wpc-static-display .wpc-product-item,
    .wpc-carousel-wrapper.wpc-2-mobile .wpc-carousel.wpc-static-display .wpc-product-item,
    .wpc-carousel-wrapper.wpc-3-mobile .wpc-carousel.wpc-static-display .wpc-product-item {
        width: calc(50% - 10px);
    }
}

@media (max-width: 480px) {
    .wpc-carousel.wpc-static-display .wpc-product-item {
        width: 100% !important;
    }
    
    .wpc-carousel.wpc-static-display {
        gap: 15px;
    }
}

/* Hide carousel controls when in static mode */
.wpc-carousel.wpc-static-display + .wpc-carousel-controls {
    display: none !important;
}