/* Shop Fullwidth & Off-Canvas Sidebar Styles */

/* Override Storefront sidebar layout on shop pages */
.full-width-shop.woocommerce-shop .content-area,
.full-width-shop.archive.tax-product_cat .content-area,
.full-width-shop.archive.tax-product_tag .content-area {
    width: 100%;
    float: none;
    margin: 0;
}

/* Filter Button */
.shop-filter-toggle {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 12px 24px;
    background: var(--accent-green);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    margin-left: 15px;
}

.shop-filter-toggle svg {
    width: 18px;
    height: 18px;
}

.shop-filter-toggle:hover {
    background: var(--border-brown);
    color: #fff;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(47, 79, 79, 0.2);
}

/* Position button in storefront-sorting */
.storefront-sorting {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
}

/* Desktop order: ordering, result-count, button, pagination (right) */
.storefront-sorting .woocommerce-ordering {
    order: 1;
    margin-right: 15px;
}

.storefront-sorting .woocommerce-result-count {
    order: 2;
    margin-right: 15px;
}

.storefront-sorting .shop-filter-toggle {
    order: 3;
    margin-right: 15px;
}

.storefront-sorting nav.woocommerce-pagination {
    order: 4;
    margin-left: auto;
}

/* Off-Canvas Overlay */
.offcanvas-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    z-index: 999;
}

.offcanvas-overlay.active {
    opacity: 1;
    visibility: visible;
}

/* Off-Canvas Sidebar */
.offcanvas-sidebar {
    position: fixed;
    top: 0;
    left: -350px;
    width: 350px;
    max-width: 90vw;
    height: 100%;
    background: var(--bg-warm-white);
    overflow-y: auto;
    transition: left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 1000;
    box-shadow: 2px 0 15px rgba(0, 0, 0, 0.1);
}

.offcanvas-sidebar.active {
    left: 0;
}

.offcanvas-sidebar-inner {
    padding: 0;
}

/* Sidebar Header - Full width, no horizontal padding */
.offcanvas-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0;
    padding: 25px;
    border-bottom: 2px solid var(--bg-soft-beige);
    width: 100%;
}

/* Content with padding */
.offcanvas-sidebar-content {
    padding: 25px;
}

.offcanvas-title {
    font-family: 'Source Sans 3', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-size: 22px;
    font-weight: 700;
    color: var(--text-dark);
    margin: 0;
}

.offcanvas-close {
    width: 36px;
    height: 36px;
    background: var(--bg-soft-beige);
    border: none;
    cursor: pointer;
    color: var(--text-dark);
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    flex-shrink: 0;
    padding: 0;
}

.offcanvas-close:hover {
    background: var(--accent-green);
}

.offcanvas-close svg {
    width: 20px;
    height: 20px;
    stroke: currentColor;
    fill: none;
}

.offcanvas-close:hover svg {
    stroke: white;
}

/* Sidebar Widgets Styling */
.offcanvas-sidebar .widget {
    margin-bottom: 30px;
    padding-bottom: 25px;
    border-bottom: 1px solid var(--bg-soft-beige);
}

.offcanvas-sidebar .widget:last-child {
    border-bottom: none;
    margin-bottom: 0;
}

.offcanvas-sidebar .widget-title {
    font-family: 'Source Sans 3', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-size: 18px;
    font-weight: 600;
    color: var(--text-dark);
    margin-bottom: 15px;
}

/* Product Filter Widget */
.product-filter-widget {
    padding: 0;
}

.filter-section {
    margin-bottom: 25px;
}

.filter-section:last-of-type {
    margin-bottom: 20px;
}

.filter-section-title {
    font-family: 'Source Sans 3', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-size: 16px;
    font-weight: 600;
    color: var(--text-dark);
    margin: 0 0 12px 0;
    padding-bottom: 8px;
    border-bottom: 2px solid var(--bg-soft-beige);
}

/* Category Tree Styles */
.category-tree {
    list-style: none;
    padding: 0;
    margin: 0;
}

.category-tree-item {
    margin-bottom: 4px;
}

.category-tree-item > .category-link {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 12px 10px 10px;
    color: var(--text-dark);
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    border-radius: 6px;
    transition: all 0.2s ease;
    background: white;
    position: relative; /* Position toggle button relative to link, not item */
}

.category-tree-item.has-children > .category-link {
    padding-left: 32px; /* Space for toggle button */
}

.category-tree-item > .category-link:hover {
    background: var(--bg-soft-beige);
    color: var(--accent-green);
}

.category-tree-item.active > .category-link {
    background: var(--accent-green);
    color: white;
    font-weight: 600;
}

.category-name {
    flex: 1;
}

.category-count {
    font-size: 11px;
    opacity: 0.7;
    margin-left: 8px;
}

/* Category Toggle Button - positioned relative to .category-link */
.category-toggle {
    position: absolute;
    left: 6px;
    top: 50%;
    transform: translateY(-50%);
    width: 22px;
    height: 22px;
    padding: 0;
    background: transparent;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: background 0.2s ease;
    z-index: 2; /* Ensure it stays on top */
}

.category-toggle:hover {
    background: var(--bg-soft-beige);
}

.category-toggle svg {
    width: 14px;
    height: 14px;
    stroke: #666;
    stroke-width: 2.5;
    transition: transform 0.25s ease, stroke 0.25s ease;
}

/* Arrow points right when closed */
.category-tree-item:not(.expanded) > .category-link > .category-toggle svg {
    transform: rotate(0deg);
}

/* Arrow points down when expanded - make it more visible */
.category-tree-item.expanded > .category-link > .category-toggle svg {
    transform: rotate(90deg);
    stroke: var(--accent-green);
}

/* Keep toggle button visible when expanded */
.category-tree-item.expanded > .category-link > .category-toggle {
    background: rgba(47, 79, 79, 0.08);
}

/* All nested toggle buttons use the same positioning since they're relative to their links */
.category-tree-children .category-tree-item > .category-link > .category-toggle {
    left: 6px; /* Same position for all levels */
}

/* Subcategories */
.category-tree-children {
    list-style: none;
    padding: 6px 8px 6px 32px; /* Increased left padding from 20px to 32px */
    margin: 0;
    display: none;
    background: #f8f9fa; /* Light gray background for subcategories */
    border-radius: 6px;
    margin-top: 4px;
    margin-left: 4px; /* Add slight left margin for better visual separation */
    border-left: 2px solid #e0e3e6; /* Vertical line to show hierarchy */
}

.category-tree-item.expanded > .category-tree-children {
    display: block;
}

/* Nested levels styling */
.category-tree-children .category-tree-item {
    margin-bottom: 2px; /* Tighter spacing */
}

.category-tree-children .category-tree-item > .category-link {
    font-size: 13px;
    padding: 8px 12px 8px 24px; /* More padding-left from 16px to 24px */
    background: transparent; /* Override white background */
    border-radius: 4px;
    position: relative; /* Position nested toggle buttons relative to their links */
}

.category-tree-children .category-tree-item > .category-link:hover {
    background: rgba(255, 255, 255, 0.7); /* White overlay on hover */
}

.category-tree-children .category-tree-item.active > .category-link {
    background: var(--accent-green);
    color: white;
}

.category-tree-children .category-tree-item.has-children > .category-link {
    padding-left: 44px; /* More space for nested toggle button - from 36px to 44px */
}

/* Nested subcategories - darker gray and more indented */
.category-tree-children .category-tree-children {
    background: #eff1f3; /* Slightly darker for nested levels */
    margin-left: 12px; /* More indentation from 8px to 12px */
    padding-left: 28px; /* More padding */
    border-left-color: #d0d4d8; /* Darker border for nested */
}

/* Third level and deeper */
.category-tree-children .category-tree-children .category-tree-children {
    background: #e8eaed; /* Even darker for deep nesting */
    margin-left: 16px; /* Even more indentation */
    padding-left: 24px;
    border-left-color: #c0c4c8; /* Even darker border */
}

/* Filter buttons for attributes */
.filter-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.filter-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    background: white;
    color: var(--text-dark);
    border: 2px solid var(--bg-soft-beige);
    border-radius: 20px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    text-decoration: none;
}

.filter-btn:hover {
    border-color: var(--accent-green);
    color: var(--accent-green);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(47, 79, 79, 0.15);
}

.filter-btn.active {
    background: var(--accent-green);
    color: white;
    border-color: var(--accent-green);
}

.filter-count {
    font-size: 11px;
    opacity: 0.7;
}

.filter-actions {
    margin-top: 20px;
    padding-top: 20px;
    border-top: 2px solid var(--bg-soft-beige);
}

.clear-filters-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    background: var(--border-brown);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    text-decoration: none;
    width: 100%;
    justify-content: center;
}

.clear-filters-btn:hover {
    background: var(--accent-green);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(47, 79, 79, 0.2);
}

.clear-filters-btn svg {
    width: 16px;
    height: 16px;
}

.offcanvas-sidebar .widget ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.offcanvas-sidebar .widget ul li {
    margin-bottom: 10px;
}

.offcanvas-sidebar .widget ul li a {
    color: #6d6d6d;
    text-decoration: none;
    transition: color 0.3s ease;
    font-size: 14px;
}

.offcanvas-sidebar .widget ul li a:hover {
    color: var(--accent-green);
}

/* Price Filter Widget */
.offcanvas-sidebar .widget_price_filter .price_slider_wrapper {
    padding: 10px 0;
}

.offcanvas-sidebar .widget_price_filter .ui-slider {
    background: var(--bg-soft-beige);
    border: none;
    border-radius: 4px;
    height: 6px;
}

.offcanvas-sidebar .widget_price_filter .ui-slider .ui-slider-range {
    background: var(--accent-green);
    border-radius: 4px;
}

.offcanvas-sidebar .widget_price_filter .ui-slider .ui-slider-handle {
    background: var(--accent-green);
    border: 2px solid white;
    border-radius: 50%;
    width: 18px;
    height: 18px;
    top: -6px;
    cursor: pointer;
}

.offcanvas-sidebar .widget_price_filter button {
    background: var(--accent-green);
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 6px;
    cursor: pointer;
    margin-top: 15px;
    transition: background 0.3s ease;
    font-size: 14px;
    font-weight: 600;
}

.offcanvas-sidebar .widget_price_filter button:hover {
    background: var(--border-brown);
}

/* Product Columns Grid - Override Storefront float layout */
.full-width-shop .woocommerce ul.products,
.full-width-shop .site-main ul.products,
.woocommerce.full-width-shop ul.products {
    display: grid !important;
    grid-template-columns: repeat(4, 1fr) !important;
    gap: 30px !important;
    clear: both;
    margin-left: 0 !important;
    margin-bottom: 0 !important;
    padding: 0 !important;
    list-style: none !important;
}

.full-width-shop .woocommerce ul.products li.product,
.full-width-shop .site-main ul.products li.product,
.woocommerce.full-width-shop ul.products li.product {
    width: auto !important;
    float: none !important;
    margin: 0 !important;
    padding: 0 !important;
}

/* Bottom sorting and pagination fix */
.woocommerce nav.woocommerce-pagination {
    clear: both;
    float: none;
}

/* Bottom storefront-sorting (after products) */
.woocommerce .products + .storefront-sorting {
    clear: both;
    width: 100%;
    float: none;
    margin-top: 30px;
}

/* Responsive Grid */
@media (max-width: 1200px) {
    .full-width-shop .woocommerce ul.products,
    .full-width-shop .site-main ul.products,
    .woocommerce.full-width-shop ul.products {
        grid-template-columns: repeat(3, 1fr) !important;
        gap: 25px !important;
    }
}

@media (max-width: 768px) {
    .full-width-shop .woocommerce ul.products,
    .full-width-shop .site-main ul.products,
    .woocommerce.full-width-shop ul.products {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 20px !important;
    }

    .offcanvas-sidebar {
        width: 320px;
        max-width: 85vw;
        left: -320px;
    }

    /* Mobile layout for storefront-sorting */
    .storefront-sorting {
        flex-direction: column;
        align-items: center;
        text-align: center;
    }

    .storefront-sorting .woocommerce-ordering {
        order: 1;
        margin: 0 0 15px 0;
        width: 100%;
        max-width: 300px;
    }

    .storefront-sorting .woocommerce-ordering select {
        width: 100%;
        text-align: center;
    }

    .storefront-sorting .shop-filter-toggle {
        order: 2;
        margin: 0 0 15px 0;
        width: 100%;
        max-width: 300px;
        justify-content: center;
    }

    /* Pagination in the middle on mobile */
    .storefront-sorting nav.woocommerce-pagination {
        order: 3;
        width: 100%;
        margin: 0 0 15px 0;
    }

    .storefront-sorting .woocommerce-result-count {
        order: 4;
        margin: 0;
        width: 100%;
    }
}

@media (max-width: 480px) {
    .full-width-shop .woocommerce ul.products,
    .full-width-shop .site-main ul.products,
    .woocommerce.full-width-shop ul.products {
        grid-template-columns: 1fr !important;
        gap: 20px !important;
    }

    .shop-filter-toggle {
        padding: 10px 20px;
        font-size: 14px;
    }

    .offcanvas-sidebar {
        width: 280px;
        max-width: 80vw;
        left: -280px;
    }
}
}

/* Ensure fullwidth shop */
.full-width-shop .col-full {
    max-width: 100%;
}

@media (min-width: 768px) {
    .full-width-shop .col-full {
        max-width: 100%;
    }
}
