/**
 * Inline styles for the carousel display
 */
.pictaffil-frontend-carousel[data-show-ratings="no"] .pictaffil-product-rating,
.pictaffil-hide-ratings .pictaffil-product-rating {
    display: none !important;
    visibility: hidden !important;
    height: 0 !important;
    overflow: hidden !important;
    opacity: 0 !important;
    margin: 0 !important;
    padding: 0 !important;
}

.pictaffil-frontend-carousel[data-show-prices="no"] .pictaffil-product-price,
.pictaffil-hide-prices .pictaffil-product-price {
    display: none !important;
    visibility: hidden !important;
    height: 0 !important;
    overflow: hidden !important;
    opacity: 0 !important;
    margin: 0 !important;
    padding: 0 !important;
}

/* Hide product name when disabled - MUST OVERRIDE OTHER STYLES */
.pictaffil-frontend-carousel[data-show-product-name="no"] .pictaffil-product-title,
.pictaffil-hide-product-names .pictaffil-product-title {
    display: none !important;
    visibility: hidden !important;
    height: 0 !important;
    overflow: hidden !important;
    opacity: 0 !important;
    margin: 0 !important;
    padding: 0 !important;
}

/* Ensure product cards display properly in carousel */
.pictaffil-saved-products-container {
    display: flex;
    overflow-x: auto;
    scroll-behavior: smooth;
    gap: 15px;
    padding: 10px 5px;
    -ms-overflow-style: none;  /* IE and Edge */
    scrollbar-width: none;  /* Firefox */
    /* Allow height to adjust dynamically */
    height: auto;
    min-height: 150px;
}

/* Add specific styling for product container when height is set */
.pictaffil-frontend-carousel[style*="min-height"] .pictaffil-saved-products-container {
    height: auto;
    min-height: calc(100% - 60px); /* Adjust for header and padding */
}

.pictaffil-saved-products-container::-webkit-scrollbar {
    display: none;  /* Chrome, Safari, Opera */
}

.pictaffil-saved-product {
    flex: 0 0 auto;
    width: 220px; /* Standardized width for better proportions */
    border: 1px solid #eee;
    border-radius: 8px;
    overflow: hidden;
    background-color: white;
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
    display: flex;
    flex-direction: column;
    height: auto;
    min-height: 320px; /* Set minimum height to prevent layout shifts */
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.pictaffil-saved-product:hover {
    transform: translateY(-3px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
}

/* Improved image container with proper aspect ratio */
.pictaffil-product-image {
    position: relative;
    width: 100%;
    padding-bottom: 75%; /* 4:3 aspect ratio */
    height: 0;
    overflow: hidden;
    background-color: #f9f9f9;
}

.pictaffil-product-image a {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.pictaffil-product-image img {
    max-width: 90%;
    max-height: 90%;
    object-fit: contain;
    transition: transform 0.3s ease;
}

.pictaffil-product-image a:hover img {
    transform: scale(1.05);
}

/* Improved product details section */
.pictaffil-product-details {
    padding: 12px;
    display: flex;
    flex-direction: column;
    flex-grow: 1;
    justify-content: space-between;
}

.pictaffil-product-info {
    margin-bottom: 10px;
}

.pictaffil-product-title {
    font-size: 14px;
    font-weight: 500;
    line-height: 1.3;
    margin: 0 0 8px 0;
    max-height: 36px;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    color: #333;
}

.pictaffil-product-title a {
    color: inherit;
    text-decoration: none;
}

.pictaffil-product-title a:hover {
    color: #0066cc;
    text-decoration: underline;
}

.pictaffil-product-price {
    font-weight: 700;
    font-size: 15px;
    color: #d63031;
    margin-bottom: 6px;
}

.pictaffil-product-rating {
    display: flex;
    align-items: center;
    margin-bottom: 8px;
    font-size: 13px;
}

.pictaffil-stars {
    color: #f39c12;
    letter-spacing: -1px;
    margin-right: 4px;
}

/* Enhanced button styling */
.pictaffil-button-container {
    margin-top: auto;
    text-align: center;
}

.pictaffil-product-button {
    display: inline-block;
    width: 90% !important; /* Better proportion than exactly 50% */
    max-width: 160px;
    padding: 8px 12px;
    text-decoration: none;
    border-radius: 4px;
    text-align: center;
    font-size: 13px;
    font-weight: 500;
    transition: all 0.2s ease;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    box-sizing: border-box;
    margin: 0 auto !important;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    background-color: #4f46e5;
    color: white;
}

.pictaffil-product-button:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 5px rgba(0,0,0,0.15);
    opacity: 0.95;
}

/* Collapse button styling */
.pictaffil-frontend-carousel-collapse {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 14px;
    padding: 0 5px;
    color: inherit;
    transition: transform 0.3s ease;
}

.pictaffil-frontend-carousel.collapsed .pictaffil-saved-products-carousel {
    display: none;
}

.pictaffil-frontend-carousel.collapsed .pictaffil-frontend-carousel-collapse {
    transform: rotate(180deg);
}

/* Navigation buttons - general styling */
.pictaffil-carousel-nav {
    position: absolute;
    width: 30px;
    height: 30px;
    background: rgba(255,255,255,0.8);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 2;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}

/* Horizontal carousel navigation positioning (default) */
.pictaffil-carousel-prev {
    left: 5px;
    top: 50%;
    transform: translateY(-50%);
}

.pictaffil-carousel-next {
    right: 5px;
    top: 50%;
    transform: translateY(-50%);
}

/* Side carousel navigation positioning - override the default positioning completely */
.pictaffil-position-side .pictaffil-carousel-nav,
.pictaffil-position-side-left .pictaffil-carousel-nav {
    left: 50% !important; /* Center horizontally */
    transform: translateX(-50%) !important; /* Center adjustment */
    right: auto !important; /* Override any right positioning */
}

.pictaffil-position-side .pictaffil-carousel-prev,
.pictaffil-position-side-left .pictaffil-carousel-prev {
    top: 10px !important; /* Position at the top with some padding */
    bottom: auto !important; /* Ensure it's not at the bottom */
}

.pictaffil-position-side .pictaffil-carousel-next,
.pictaffil-position-side-left .pictaffil-carousel-next {
    bottom: 10px !important; /* Position at the bottom with some padding */
    top: auto !important; /* Override the default top positioning */
}

/* Icons for vertical navigation */
.pictaffil-position-side .pictaffil-carousel-prev .dashicons,
.pictaffil-position-side-left .pictaffil-carousel-prev .dashicons {
    transform: rotate(0deg);
}

.pictaffil-position-side .pictaffil-carousel-next .dashicons,
.pictaffil-position-side-left .pictaffil-carousel-next .dashicons {
    transform: rotate(0deg);
}

.pictaffil-saved-products-carousel {
    position: relative;
    /* Remove fixed height to allow dynamic adjustment */
    height: auto;
}

/* Position styles */
.pictaffil-position-top {
    margin-bottom: 20px !important;
    width: 100% !important;
}

.pictaffil-position-bottom {
    margin-top: 20px !important;
    width: 100% !important;
}

.pictaffil-position-side {
    float: right;
    margin-left: 20px;
    margin-bottom: 20px;
    max-width: 300px;
}

.pictaffil-position-side-left {
    float: left;
    margin-right: 20px;
    margin-bottom: 20px;
    max-width: 300px;
}

/* Minimal style optimizations */
.pictaffil-style-minimal .pictaffil-saved-product {
    width: 150px; /* Smaller width for minimal style */
    border-radius: 4px; /* Less rounded corners */
    box-shadow: 0 1px 2px rgba(0,0,0,0.05) !important;
    border: 1px solid #eee !important;
}

/* Ensure header is visible when title is shown */
.pictaffil-carousel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

/* Fix for collapse icon when title is hidden */
.pictaffil-carousel-header.no-title {
    justify-content: flex-end;
    display: flex !important; /* Always show the header for collapse button */
}

.pictaffil-carousel-title {
    margin: 0;
    padding: 0;
}

/* Clearfix for floated carousels */
.pictaffil-clearfix::after {
    content: "";
    clear: both;
    display: table;
}

/* Sticky carousel styles */
.pictaffil-sticky-active {
    position: fixed;
    top: 20px;
    z-index: 999;
}

/* Subtitle styles */
.pictaffil-carousel-subtitle {
    font-size: 13px;
    font-weight: normal;
    margin: 0 0 8px 0;
    padding: 0;
    color: #666;
    line-height: 1.4;
}

/* Hide subtitle when not needed */
.pictaffil-frontend-carousel[data-show-subtitle="no"] .pictaffil-carousel-subtitle,
.pictaffil-hide-subtitle .pictaffil-carousel-subtitle {
    display: none !important;
    visibility: hidden !important;
    height: 0 !important;
    overflow: hidden !important;
    opacity: 0 !important;
    margin: 0 !important;
    padding: 0 !important;
}

/* Ensure header layout works with subtitle */
.pictaffil-carousel-header {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    position: relative;
    padding: 8px;
    margin-bottom: 10px;
}

.pictaffil-carousel-header .pictaffil-title-container {
    display: flex;
    width: 100%;
    justify-content: space-between;
    align-items: center;
}

/* Collapse button positioning */
.pictaffil-frontend-carousel-collapse {
    position: absolute;
    right: 8px;
    top: 8px;
}

/* Mobile adjustments */
@media (max-width: 768px) {
    .pictaffil-mobile-hidden {
        display: none !important;
    }
    
    /* Reset side positions on mobile */
    .pictaffil-position-side, .pictaffil-position-side-left {
        float: none;
        margin: 20px 0;
        width: 100% !important;
        max-width: none;
    }
    
    /* Optimized smaller collapse icon for mobile */
    .pictaffil-frontend-carousel .pictaffil-frontend-carousel-collapse {
        padding: 3px !important;
        margin: 0 !important;
        width: 24px !important;
        height: 24px !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        background-color: rgba(0,0,0,0.05) !important;
        border-radius: 4px !important;
    }
    
    /* Smaller icon in collapse button */
    .pictaffil-frontend-carousel .pictaffil-frontend-carousel-collapse .dashicons {
        font-size: 14px !important;
        width: 14px !important;
        height: 14px !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
    }
    
    /* More compact header spacing */
    .pictaffil-carousel-header {
        padding: 3px !important;
        margin-bottom: 4px !important;
    }
    
    /* Improved navigation buttons for mobile */
    .pictaffil-carousel-nav {
        width: 26px !important;
        height: 26px !important;
        background: rgba(255,255,255,0.7) !important;
        box-shadow: 0 1px 3px rgba(0,0,0,0.15) !important;
        opacity: 0.9 !important;
        top: 40% !important; /* Position slightly higher to avoid finger blocking */
    }
    
    /* Make navigation icons smaller */
    .pictaffil-carousel-nav .dashicons {
        font-size: 16px !important;
        width: 16px !important;
        height: 16px !important;
    }
    
    /* Adjust prev/next positions */
    .pictaffil-carousel-prev {
        left: 2px !important;
    }
    
    .pictaffil-carousel-next {
        right: 2px !important;
    }
    
    /* Much more compact product cards with reduced height */
    .pictaffil-saved-product {
        width: 130px !important;
        min-height: 210px !important; /* Significantly reduced height */
        margin-bottom: 0 !important;
    }
    
    /* Optimize product details spacing */
    .pictaffil-product-details {
        padding: 4px !important;
    }
    
    /* Smaller title text */
    .pictaffil-product-title {
        font-size: 12px !important;
        line-height: 1.2 !important;
        margin: 0 0 3px 0 !important; /* Reduced bottom margin */
        max-height: 28px !important;
    }
}