/* Shop Page Enhancements Styles */

:root {
    --mwai-shop-accent-1: #6366f1;
    --mwai-shop-accent-2: #4f46e5;
    --mwai-shop-bg: #ffffff;
    --mwai-shop-text: #0f172a;
    --mwai-shop-muted: #9ca3af;
    --mwai-shop-border: #e5e7eb;
    --mwai-shop-light-bg: #f8fafc;
    --mwai-shop-filter-bg: #f0f4f8; /* Light background for filter section */
    --mwai-shop-filter-border: #d1d5db; /* Border for filter elements */
    --mwai-shop-shadow: rgba(0,0,0,0.05); /* Subtle shadow */
}

/* Hide original WooCommerce content when our enhancements are loading */
body.mwai-shop-loading .woocommerce-products-header,
body.mwai-shop-loading .woocommerce-notices-wrapper,
body.mwai-shop-loading .woocommerce-archive-description,
body.mwai-shop-loading .woocommerce-result-count,
body.mwai-shop-loading .woocommerce-ordering,
body.mwai-shop-loading ul.products, /* Re-add ul.products to be hidden during loading */
body.mwai-shop-loading .woocommerce-pagination { /* Hide pagination during loading */
    display: none !important;
}

/* Main container for shop enhancements */
.mwai-shop-enhancements {
    margin-bottom: 30px;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
}

/* New styles for filter and sort section */
.mwai-shop-filters-sort-wrapper {
    display: flex;
    flex-wrap: wrap; /* Allow wrapping on smaller screens */
    gap: 20px;
    margin-bottom: 20px;
    align-items: flex-start; /* Align items to the top */
}

.mwai-shop-filters-sidebar {
    flex: 0 0 250px; /* Fixed width for sidebar on larger screens */
    background-color: var(--mwai-shop-bg);
    border: 1px solid var(--mwai-shop-border);
    border-radius: 8px;
    padding: 20px;
    box-shadow: 0 4px 12px var(--mwai-shop-shadow);
}

.mwai-shop-filters-sidebar h3 {
    font-size: 18px;
    font-weight: 700;
    color: var(--mwai-shop-text);
    margin-top: 0;
    margin-bottom: 15px;
    border-bottom: 1px solid var(--mwai-shop-filter-border);
    padding-bottom: 10px;
}

.mwai-filter-group {
    margin-bottom: 20px;
}

.mwai-filter-group label {
    display: block;
    font-size: 15px;
    font-weight: 600;
    color: var(--mwai-shop-text);
    margin-bottom: 10px;
}

/* Price Slider */
.mwai-price-range-display {
    font-size: 14px;
    color: var(--mwai-shop-text);
    margin-bottom: 10px;
    text-align: center;
}

.mwai-price-slider-container {
    padding: 10px 5px; /* Padding for the slider itself */
}

/* Basic jQuery UI Slider styles (if used, otherwise custom styles) */
.ui-slider {
    position: relative;
    text-align: left;
    background: var(--mwai-shop-filter-border);
    border: none;
    height: 6px;
    border-radius: 3px;
}
.ui-slider .ui-slider-handle {
    position: absolute;
    z-index: 2;
    width: 16px;
    height: 16px;
    cursor: default;
    -ms-touch-action: none;
    touch-action: none;
    background: var(--mwai-shop-accent-1);
    border: 2px solid var(--mwai-shop-bg);
    border-radius: 50%;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
    top: -5px; /* Adjust to center handle on track */
    margin-left: -8px; /* Center handle */
}
.ui-slider .ui-slider-range {
    position: absolute;
    z-index: 1;
    font-size: .7em;
    display: block;
    border: 0;
    background-position: 0 0;
    background: var(--mwai-shop-accent-2);
    border-radius: 3px;
}

/* Checkbox/Radio styles for attributes and stock */
.mwai-filter-options {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.mwai-filter-options label {
    display: flex;
    align-items: center;
    font-size: 14px;
    font-weight: 400;
    color: var(--mwai-shop-text);
    cursor: pointer;
    margin-bottom: 0; /* Override default label margin */
}

.mwai-filter-options input[type="checkbox"],
.mwai-filter-options input[type="radio"] {
    margin-right: 6px;
    width: 16px;
    height: 16px;
    accent-color: var(--mwai-shop-accent-1); /* Modern checkbox color */
}

/* Sorting Dropdown */
.mwai-sort-options {
    flex: 1; /* Take remaining space */
    display: flex;
    justify-content: flex-end; /* Align to the right */
    align-items: center;
    gap: 10px;
    margin-bottom: 20px; /* Space below sorting */
}

.mwai-sort-options label {
    font-size: 14px;
    font-weight: 600;
    color: var(--mwai-shop-text);
    margin-bottom: 0;
}

.mwai-sort-options select {
    padding: 8px 12px;
    border: 1px solid var(--mwai-shop-border);
    border-radius: 6px;
    background-color: var(--mwai-shop-bg);
    color: var(--mwai-shop-text);
    font-size: 14px;
    cursor: pointer;
    outline: none;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.mwai-sort-options select:hover {
    border-color: var(--mwai-shop-accent-1);
}

.mwai-sort-options select:focus {
    border-color: var(--mwai-shop-accent-2);
    box-shadow: 0 0 0 2px rgba(79, 70, 229, 0.2);
}

/* Main content area for products, next to filters */
.mwai-shop-products-content {
    flex: 1; /* Take up remaining space */
    min-width: 0; /* Allow content to shrink */
    /* Ensure content is constrained on smaller screens */
    width: 100%;
    overflow-x: hidden; /* Hide horizontal overflow within this container */
}

/* Scroller Wrapper (for scroll buttons and blur effect) */
.mwai-category-scroller-wrapper,
.mwai-product-scroller-wrapper {
    position: relative;
    margin-bottom: 20px;
    background-color: transparent; /* Changed to transparent */
    box-shadow: none; /* Removed box-shadow */
    border-radius: 8px;
    padding: 0 10px; /* Padding for blur effect */
    z-index: 5; /* Ensure wrapper has a stacking context */
}

/* Scroller Title */
.mwai-scroller-title {
    font-size: 22px;
    font-weight: 700;
    color: var(--mwai-shop-text);
    margin: 15px 10px 15px 10px; /* Adjust margin to align with scroller padding */
    padding-top: 10px;
}

/* Category Scroller & Product Scroller */
.mwai-category-scroller,
.mwai-product-scroller {
    display: flex;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch; /* For smooth scrolling on iOS */
    padding: 10px 0; /* Adjust padding to account for wrapper padding */
    border-bottom: 1px solid var(--mwai-shop-border); /* Keep border on the scroller itself */
    /* Hide scrollbar for all devices, buttons will handle scrolling */
    scrollbar-width: none; /* Firefox */
    -ms-overflow-style: none;  /* IE and Edge */
}

.mwai-category-scroller.mwai-centered-content {
    justify-content: center;
}

.mwai-category-scroller::-webkit-scrollbar,
.mwai-product-scroller::-webkit-scrollbar {
    display: none; /* Chrome, Safari, Opera */
}

/* Filter Toggle Button for Mobile */
.mwai-filter-toggle-button {
    /* display: none; Remove default hide on larger screens */
    padding: 10px 15px;
    background-color: var(--mwai-shop-accent-1);
    color: #fff;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    /* font-size: 15px; Removed as text is gone */
    /* font-weight: 600; Removed as text is gone */
    margin-bottom: 20px;
    transition: background-color 0.2s ease, transform 0.2s ease;
    align-self: flex-start; /* Align to the start of the flex container */
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    
    /* Styles for the image button */
    display: flex; /* Use flexbox to center the image */
    justify-content: center;
    align-items: center;
    width: 40px; /* Fixed width for the button */
    height: 40px; /* Fixed height for the button */
    padding: 0; /* Remove padding for image button */
}

.mwai-filter-toggle-button img {
    max-width: 24px; /* Size of the icon */
    max-height: 24px;
    filter: invert(1); /* Invert color for white icon on colored button */
}

.mwai-filter-toggle-button:hover {
    background-color: var(--mwai-shop-accent-2);
    transform: translateY(-1px);
}

/* Modal Overlay for Filters */
.mwai-filter-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    justify-content: flex-start; /* Align to left (filters slide from left) */
    align-items: flex-start;
    z-index: 100000;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.mwai-filter-modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

/* Modal Content for Filter Sidebar */
.mwai-filter-modal-content {
    background: var(--mwai-shop-bg);
    padding: 20px;
    border-radius: 0 8px 8px 0; /* Rounded only on the right side */
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
    width: 80%; /* Take 80% width on mobile */
    max-width: 300px; /* Max width for the filter panel */
    height: 100%;
    display: flex;
    flex-direction: column;
    transform: translateX(-100%); /* Start off-screen to the left */
    transition: transform 0.3s ease;
    overflow-y: auto; /* Enable scrolling for filter content */
}

.mwai-filter-modal-overlay.active .mwai-filter-modal-content {
    transform: translateX(0); /* Slide in from the left */
}

.mwai-filter-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--mwai-shop-border);
    padding-bottom: 15px;
    margin-bottom: 15px;
}

.mwai-filter-modal-header h2 {
    margin: 0;
    font-size: 18px;
    color: var(--mwai-shop-text);
}

.mwai-filter-modal-close {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: var(--mwai-shop-muted);
    line-height: 1;
    padding: 0;
}

.mwai-filter-modal-close:hover {
    color: var(--mwai-shop-text);
}

/* Responsive adjustments for filters and sorting */
@media (min-width: 768px) { /* On larger screens, hide the filter button and show the sidebar */
    .mwai-filter-toggle-button {
        display: none;
    }
    .mwai-shop-filters-sidebar {
        display: block; /* Ensure sidebar is visible on larger screens */
    }
}

@media (max-width: 1024px) {
    .mwai-shop-filters-sidebar {
        flex: 0 0 200px; /* Slightly smaller sidebar on tablets */
        padding: 15px;
    }
    .mwai-shop-filters-sidebar h3 {
        font-size: 16px;
    }
    .mwai-filter-group label,
    .mwai-filter-options label,
    .mwai-sort-options label,
    .mwai-sort-options select {
        font-size: 13px;
    }
}

@media (max-width: 767px) { /* Changed from 768px to 767px for consistency */
    .mwai-shop-filters-sidebar {
        display: none; /* Hide original sidebar on small screens */
    }

    .mwai-filter-toggle-button {
        display: flex; /* Show filter button on small screens (now defaults to flex) */
    }

    .mwai-shop-filters-sort-wrapper {
        flex-direction: column; /* Stack filters and products vertically */
        gap: 15px;
        align-items: flex-start; /* Align button and sort options to start */
    }
    .mwai-sort-options {
        width: 100%; /* Take full width on mobile */
        justify-content: flex-start; /* Align sorting to the left on mobile */
        margin-bottom: 15px;
    }
    .mwai-scroll-button {
        display: none; /* Hide buttons on mobile, rely on touch scroll */
    }
    .mwai-category-scroller-wrapper,
    .mwai-product-scroller-wrapper {
        padding: 0; /* Remove padding on mobile if buttons are hidden */
        width: 100%; /* Ensure scroller wrappers take full width */
        overflow-x: hidden; /* Hide horizontal overflow within scroller wrappers */
    }
}

.mwai-category-scroller .mwai-category-tab,
.mwai-product-scroller .mwai-shop-product-card {
    flex-shrink: 0; /* Prevent items from shrinking */
    margin: 0 5px; /* Spacing between items */
    background-color: var(--mwai-shop-light-bg);
    border: 1px solid var(--mwai-shop-border);
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 2px 6px rgba(0,0,0,0.03);
}

.mwai-category-scroller .mwai-category-tab {
    padding: 8px 16px;
    font-size: 14px;
    font-weight: 500;
    color: var(--mwai-shop-text);
    white-space: normal; /* Allow text to wrap */
    display: flex; /* Make it a flex container */
    justify-content: center; /* Center horizontally */
    align-items: center; /* Center vertically */
    min-width: 100px; /* Ensure a minimum width for tabs */
    text-align: center;
}

/* Specific styles for category cards within the scroller */
.mwai-category-scroller .mwai-category-card {
    flex-direction: column; /* Stack image and text vertically */
    padding: 10px;
    width: 120px; /* Fixed width for cards */
    height: auto; /* Allow height to adjust based on content */
    border-radius: 12px; /* More rounded corners for cards */
    justify-content: center; /* Distribute space */
    text-align: center;
    box-shadow: 0 2px 6px rgba(0,0,0,0.03);
    align-items: center;
}

.mwai-category-scroller .mwai-category-card img {
    max-width: 60px; /* Smaller image size */
    max-height: 60px;
    width: auto;
    height: auto;
    border-radius: 8px;
    margin-bottom: 5px;
    object-fit: contain; /* Ensure image fits without cropping */
}

.mwai-category-scroller .mwai-category-card span {
    font-size: 13px;
    font-weight: 600;
    color: var(--mwai-shop-text);
    white-space: normal; /* Allow text to wrap */
    display: -webkit-box;
    -webkit-line-clamp: 2; /* Limit to 2 lines */
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.3;
}

.mwai-category-scroller .mwai-category-card:hover,
.mwai-product-scroller .mwai-shop-product-card:hover {
    background-color: #eef2ff;
    border-color: var(--mwai-shop-accent-1);
    color: var(--mwai-shop-accent-2);
    transform: translateY(-2px);
    box-shadow: 0 4px 10px rgba(79, 70, 229, 0.1);
}

.mwai-category-scroller .mwai-category-card.active,
.mwai-product-scroller .mwai-shop-product-card.active {
    background: linear-gradient(135deg, var(--mwai-shop-accent-1), var(--mwai-shop-accent-2));
    color: #fff;
    border-color: var(--mwai-shop-accent-2);
    box-shadow: 0 4px 12px rgba(79, 70, 229, 0.15);
}

.mwai-category-scroller .mwai-category-card.active span {
    color: #fff;
}

/* Scroll Buttons */
.mwai-scroll-button {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(5px);
    border: 1px solid var(--mwai-shop-border);
    border-radius: 50%;
    width: 36px;
    height: 36px;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    z-index: 10; /* Increased z-index */
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    transition: all 0.2s ease;
    color: var(--mwai-shop-text);
    font-size: 18px;
    font-weight: bold;
}

.mwai-scroll-button:hover {
    background: var(--mwai-shop-accent-1);
    color: #fff;
    border-color: var(--mwai-shop-accent-1);
    box-shadow: 0 4px 12px rgba(79, 70, 229, 0.2);
}

.mwai-scroll-button.left {
    left: -10px; /* Adjust positioning slightly to be outside the padding if needed */
}

.mwai-scroll-button.right {
    right: -10px; /* Adjust positioning slightly to be outside the padding if needed */
}

.mwai-scroll-button.hidden {
    opacity: 0;
    pointer-events: none;
}

/* Responsive adjustments for buttons */
@media (max-width: 768px) {
    .mwai-scroll-button {
        display: none; /* Hide buttons on mobile, rely on touch scroll */
    }
    .mwai-category-scroller-wrapper,
    .mwai-product-scroller-wrapper {
        padding: 0; /* Remove padding on mobile if buttons are hidden */
    }
}

.mwai-category-scroller .mwai-category-tab:hover,
.mwai-product-scroller .mwai-shop-product-card:hover {
    background-color: #eef2ff;
    border-color: var(--mwai-shop-accent-1);
    color: var(--mwai-shop-accent-2);
}

.mwai-category-scroller .mwai-category-tab.active,
.mwai-product-scroller .mwai-shop-product-card.active {
    background: linear-gradient(135deg, var(--mwai-shop-accent-1), var(--mwai-shop-accent-2));
    color: #fff;
    border-color: var(--mwai-shop-accent-2);
    box-shadow: 0 4px 12px rgba(79, 70, 229, 0.15);
}

/* Product Grid for custom shortcode and default WooCommerce */
.mwai-products-grid,
ul.products { /* Apply grid styles to both custom shortcode and default WooCommerce product lists */
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 20px;
    padding: 10px 0;
    list-style: none; /* Remove default list styling */
    margin: 0; /* Remove default margin */
}

/* Responsive columns for the custom shortcode */
.mwai-products-grid.columns-1 { grid-template-columns: repeat(1, 1fr); }
.mwai-products-grid.columns-2 { grid-template-columns: repeat(2, 1fr); }
.mwai-products-grid.columns-3 { grid-template-columns: repeat(3, 1fr); }
.mwai-products-grid.columns-4 { grid-template-columns: repeat(4, 1fr); }
.mwai-products-grid.columns-5 { grid-template-columns: repeat(5, 1fr); }
.mwai-products-grid.columns-6 { grid-template-columns: repeat(6, 1fr); }

@media (max-width: 1024px) {
    .mwai-products-grid.columns-5,
    .mwai-products-grid.columns-6 {
        grid-template-columns: repeat(4, 1fr);
    }
}

@media (max-width: 768px) {
    .mwai-products-grid.columns-3,
    .mwai-products-grid.columns-4,
    .mwai-products-grid.columns-5,
    .mwai-products-grid.columns-6,
    ul.products { /* Apply to default WooCommerce products as well */
        grid-template-columns: repeat(2, 1fr);
    }
    .mwai-products-grid,
    ul.products {
        gap: 15px;
    }
}

@media (max-width: 480px) {
    .mwai-products-grid,
    ul.products { /* Apply to default WooCommerce products as well */
        grid-template-columns: repeat(2, 1fr); /* Force 2 columns on smallest screens */
        gap: 10px;
    }
}

/* Product Card specific styles for scroller */
.mwai-product-scroller .mwai-shop-product-card {
    width: 160px; /* Slightly reduced fixed width for product cards in scroller */
    height: auto; /* Allow height to adjust */
    padding: 0; /* Remove padding from card itself, it's inside the anchor */
    text-align: left; /* Align text left within the card */
}

.mwai-shop-product-card {
    background-color: var(--mwai-shop-bg);
    border: 1px solid var(--mwai-shop-border);
    border-radius: 10px; /* Slightly smaller border-radius for modern look */
    overflow: hidden;
    text-align: center;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05); /* Softer initial shadow */
    padding: 0;
}

.mwai-shop-product-card:hover {
    transform: translateY(-3px); /* Less pronounced lift */
    box-shadow: 0 8px 20px rgba(0,0,0,0.1); /* Adjusted hover shadow */
}

.mwai-shop-product-card a {
    text-decoration: none;
    color: inherit;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    height: 100%;
}

.mwai-shop-product-card .mwai-product-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
}

.mwai-shop-product-card .mwai-product-meta {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    text-align: center;
}

.mwai-product-image-slideshow {
    position: relative;
    width: 100%;
    padding-top: 100%;
    overflow: hidden;
    border-radius: 6px; /* Slightly smaller border-radius for images */
    margin-bottom: 0;
}

.mwai-product-image-slideshow img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    opacity: 0;
    transition: opacity 0.4s ease-in-out; /* Slightly faster transition */
    z-index: 1;
}

.mwai-product-image-slideshow img.active {
    opacity: 1;
    z-index: 2;
}

.mwai-shop-product-card img {
    max-width: 100%;
    height: auto;
    border-radius: 6px; /* Consistency with slideshow images */
    margin-bottom: 0;
}

.mwai-shop-product-card h3 {
    font-size: 15px; /* Slightly smaller font size */
    font-weight: 600;
    color: var(--mwai-shop-text);
    margin: 0 0 4px 0; /* Reduced margin */
    line-height: 1.3;
    height: 2.6em;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.mwai-shop-product-card .price {
    font-size: 14px; /* Slightly smaller font size */
    font-weight: 700;
    color: var(--mwai-shop-accent-2);
    margin: 0;
}

/* Loading indicator */
.mwai-loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.7);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 10;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.mwai-loading-overlay.active {
    opacity: 1;
    visibility: visible;
}

.mwai-spinner {
    border: 4px solid rgba(0, 0, 0, 0.1);
    border-left-color: var(--mwai-shop-accent-1);
    border-radius: 50%;
    width: 30px;
    height: 30px;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .mwai-product-grid {
        grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
        gap: 15px;
    }
.mwai-category-scroller.mwai-centered-content {
    justify-content: center;
}
    .mwai-category-scroller .mwai-category-tab {
        padding: 6px 12px;
        font-size: 13px;
        min-width: 80px; /* Smaller min-width for mobile tabs */
    }
    .mwai-category-scroller .mwai-category-card {
        width: 100px; /* Adjust card width for mobile */
        height: auto; /* Ensure height adjusts */
    }
}

@media (max-width: 480px) {
    .mwai-product-grid,
    ul.products { /* Consistent styling for default WooCommerce products */
        grid-template-columns: repeat(2, 1fr); /* Force 2 columns on smallest screens */
        gap: 10px;
    }
    .mwai-shop-product-card {
        padding: 0 !important;
    }
    .mwai-shop-product-card h3 {
        font-size: 13px; /* Smaller font size for mobile titles */
    }
    .mwai-shop-product-card .price {
        font-size: 12px; /* Smaller font size for mobile prices */
    }
    .mwai-product-scroller .mwai-shop-product-card {
        width: 140px; /* Adjusted fixed width for scroller cards on smallest screens */
    }
}
