/* Product Categories Page Styles */

main {
    /* overrides default margin */
    margin-top: 0 !important;
}

.product-categories-page {
    display: flex;
    gap: 2rem;
    max-width: 1200px;
    margin: 0 auto;
    padding: 1rem 0 4rem;
    font-family: var(--font-body, 'Inter', sans-serif);
}

.product-categories-whole-page{
    max-width: 1200px;
}


/* Categories Sidebar */
.categories-sidebar {
    flex: 0 0 250px;
    margin-bottom: 1.5rem;
}

.categories-sidebar h3 {
    font-family: var(--font-body, 'Gilda Display', serif);
    font-size: 1.25rem;
    font-weight: normal;
    margin-bottom: 1.25rem;
    color: #1F2937;
    border-bottom: 1px solid #E5E7EB;
    padding-bottom: 0.75rem;
}

/* Category Filter List */
.category-filter-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.category-filter-item {
    margin-bottom: 0.25rem;
    border-radius: 0;
    transition: all 0.2s ease;
    background-color: transparent;
}

/* Base category item styling with consistent left padding that includes border space */
.category-item-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 0 0.75rem 1rem; /* Fixed left padding that accounts for border */
    cursor: pointer;
    color: var(--text-color, #4B5563);
    transition: color 0.2s ease; /* Only animate color, not borders or padding */
    border-radius: 0;
    background-color: transparent;
    border-bottom: 1px solid #E5E7EB;
    border-left: 3px solid transparent; /* Always reserve space for border */
}

.category-item-content:hover {
    background-color: transparent; /* Keep transparent on hover */
    color: #111827;
}

/* Active category left border highlight - no padding changes */
.category-filter-item.active > .category-item-content {
    background-color: transparent;
    color: #111827;
    font-weight: 600;
    border-left: 3px solid var(--btn-bck, #1DB5BE); /* Just change border color */
    /* No padding changes - keeps text in same position */
}

/* Category Content Wrapper - for name and left side content */
.category-content-wrapper {
    display: flex;
    align-items: center;
    flex: 1;
}

/* Category Toggle (Expand/Collapse) - Now on the right */
.category-toggle {
    display: flex;
    align-items: center;
    transition: transform 0.2s ease;
    min-width: 12px;
    margin-left: 0.5rem; /* Space from the category name */
}

.category-filter-item.expanded > .category-item-content .category-toggle {
    transform: rotate(180deg); /* Point up when expanded */
}

.toggle-icon {
    color: currentColor;
}

/* Category Name and Count */
.category-name {
    flex: 1;
    font-weight: 500;
}

.product-count {
    font-size: 0.875rem;
    opacity: 0.7;
    margin-left: 0.5rem;
}

/* Parent Categories */
.category-filter-item.parent-category > .category-item-content {
    font-weight: 600;
}

/* All Products item - make it consistent with other categories */
.category-filter-item[data-type="all"] .category-item-content {
    padding: 0.75rem 0 0.75rem 1rem; /* Same padding as other categories */
    border-bottom: 1px solid #E5E7EB;
    background-color: transparent;
    border-left: 3px solid transparent; /* Always reserve space for border */
}

.category-filter-item[data-type="all"].active .category-item-content {
    font-weight: 600;
    color: #111827;
    border-left: 3px solid var(--btn-bck, #1DB5BE); /* Just change border color */
}

/* Subcategories */
.subcategory-list {
    list-style: none;
    padding: 0;
    margin: 0;
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
    background-color: transparent; /* Removed background */
    border-radius: 0;
}

.category-filter-item.expanded .subcategory-list {
    max-height: 500px; /* Adjust based on your needs */
}

.category-filter-item.subcategory {
    margin-bottom: 0;
}

/* Subcategories - consistent indentation with border space reserved */
.category-filter-item.subcategory .category-item-content {
    padding: 0.5rem 0 0.5rem 2rem; /* Fixed padding that includes border space */
    background-color: transparent;
    border-radius: 0;
    font-weight: normal;
    font-size: 0.95rem;
    position: relative;
    border-bottom: 1px solid #F3F4F6;
    border-left: 3px solid transparent; /* Always reserve space for border */
}

.category-filter-item.subcategory .category-item-content:before {
    content: '';
    position: absolute;
    left: 0.75rem;
    top: 50%;
    transform: translateY(-50%);
    width: 4px;
    height: 4px;
    background-color: currentColor;
    border-radius: 50%;
    opacity: 0.5;
}

.category-filter-item.subcategory .category-item-content:hover {
    background-color: transparent; /* Keep transparent */
    color: #111827;
}

/* Active subcategory styling - no padding changes */
.category-filter-item.subcategory.active > .category-item-content {
    background-color: transparent;
    color: #111827;
    font-weight: 600;
    border-left: 3px solid var(--btn-bck, #1DB5BE); /* Just change border color */
}

/* Level-based indentation - consistent padding with border space */
.category-filter-item.level-2 .category-item-content {
    padding-left: 2.5rem; /* Fixed padding */
    border-left: 3px solid transparent; /* Always reserve space */
}

.category-filter-item.level-2.active .category-item-content {
    border-left: 3px solid var(--btn-bck, #1DB5BE); /* Just change border color */
}

.category-filter-item.level-3 .category-item-content {
    padding-left: 3.5rem; /* Fixed padding */
    border-left: 3px solid transparent; /* Always reserve space */
}

.category-filter-item.level-3.active .category-item-content {
    border-left: 3px solid var(--btn-bck, #1DB5BE); /* Just change border color */
}

/* Products Grid */
.products-grid-container {
    flex: 1;
}

.current-category-title {
    font-family: var(--font-heading, 'Gilda Display', serif);
    font-size: 2rem;
    margin-bottom: 1.5rem;
    color: var(--wp--preset--color--contrast);
    font-weight: 500;
    text-align: center;    
}

.products-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 2rem;
}

.product-item {
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    background-color: white;
    border-radius: 8px;
    overflow: hidden;
    text-align: center;
    box-shadow: none;
}

.product-link {
    text-decoration: none;
    color: inherit;
    display: block;
}

.product-image {
    position: relative;
    padding-top: 100%; /* 1:1 Aspect Ratio */
    background-color: #F9FAFB;
    overflow: hidden;
}

.product-image img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Image hover functionality */
.product-image .primary-image {
    transition: opacity 0.2s ease;
    z-index: 2;
}

.product-image .hover-image {
    opacity: 0;
    transition: opacity 0.2s ease;
    z-index: 1;
}

/* Show hover image on product hover (only for products with listing images) */
.product-item.has-hover-image:hover .primary-image {
    opacity: 0;
}

.product-item.has-hover-image:hover .hover-image {
    opacity: 1;
}

/* Product Info Section */
.product-info {
    padding: 1rem;
    text-align: left;
}

.product-title {
    margin: 0 0 0.5rem 0;
    font-size: 1rem;
    font-weight: 500;
    color: #1F2937;
    line-height: 1.2;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.product-title:hover {
    text-decoration: underline;
}

/* Product Rating Styles */
.product-rating {
    display: flex;
    align-items: center;
    justify-content: flex-start; /* Changed from space-between to flex-start */
    margin-bottom: 0.5rem;
    gap: 0.5rem;
}

.product-rating-stars {
    font-size: 16px;
    line-height: 1;
    flex-shrink: 0;
}
.product-rating-stars .star {
    color: #ddd;
    margin: 0 1px;
}

.product-rating-stars .star.full {
    color: #ffc107;
}

.product-rating-stars .star.half {
    background: linear-gradient(90deg, #ffc107 50%, #ddd 50%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.product-review-count {
    color: #666;
    font-size: 0.875rem;
    white-space: nowrap;
    flex-shrink: 0;
    margin-left: 0; /* Remove any existing margin */
}

/* Product Price */
.product-price {
    color: #1F2937;
    font-weight: 600;
    font-size: 1rem;
}

.product-price small {
    color: #666;
   font-weight: 400;
   font-size: .8rem; 
}

.no-products {
    grid-column: 1 / -1;
    text-align: center;
    padding: 3rem;
    color: #6B7280;
    font-style: italic;
}

.category-link {
    display: block;
    text-decoration: none;
    color: inherit;
    width: 100%;
    padding: 0;
    transition: color 0.2s ease;
}

.category-link:hover {
    text-decoration: none;
}


/* Category description styling */
.category-description {
    margin: 1rem 0 2rem 0;
    padding: 1rem;
    background-color: #f8f9fa;
    border-left: 4px solid #007cba;
    border-radius: 4px;
}

.category-description p {
    margin: 0;
    color: #666;
    font-size: 1.1em;
    line-height: 1.5;
}

/* Ensure proper spacing and layout */
.category-content-wrapper {
    flex: 1;
    display: flex;
    align-items: center;
}

.category-filter-item.has-children .category-item-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
}

/* Toggle button styling for parent categories */
.category-toggle {
    margin-left: 0.5rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    border-radius: 4px;
    transition: background-color 0.2s ease;
}

.category-toggle:hover {
    background-color: rgba(0, 0, 0, 0.1);
}

.toggle-icon {
    transition: transform 0.2s ease;
}

.category-filter-item.expanded .toggle-icon {
    transform: rotate(180deg);
}

/* Responsive */
@media (max-width: 1024px) {
    .product-categories-page {
        flex-direction: column;
    }
    
    .categories-sidebar {
        flex: none;
        width: 100%;
    }
    
    /* Mobile category layout - keep hierarchical structure but make it more compact */
    .category-filter-list {
        max-height: 300px;
        overflow-y: auto;
        border: 1px solid #E5E7EB;
        border-radius: 8px;
        padding: 0.5rem;
        background-color: white;
    }
    
    /* IMPORTANT: Preserve subcategory expand/collapse functionality */
    .subcategory-list {
        max-height: 0; /* Keep collapsed by default */
        overflow: hidden;
        transition: max-height 0.3s ease;
        background-color: transparent;
        border-radius: 0;
    }
    
    .category-filter-item.expanded .subcategory-list {
        max-height: 500px; /* Adjust based on your needs */
    }
    
    .category-item-content {
        padding: 0.5rem 0.75rem 0.5rem 1rem;
        font-size: 0.9rem;
    }
    
    .category-filter-item.subcategory .category-item-content {
        padding: 0.4rem 0.75rem 0.4rem 2rem;
    }
    
    .category-filter-item.level-2 .category-item-content {
        padding-left: 2.5rem;
    }
    
    .category-filter-item.level-3 .category-item-content {
        padding-left: 3rem;
    }
    
    .products-grid {
        grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
        gap: 1.5rem;
    }
}

@media (max-width: 768px) {
    .categories-sidebar {
        margin-bottom: 1rem;
    }
    
    .category-filter-list {
        max-height: 250px;
    }
    
    /* IMPORTANT: Preserve subcategory expand/collapse functionality */
    .subcategory-list {
        max-height: 0; /* Keep collapsed by default */
        overflow: hidden;
        transition: max-height 0.3s ease;
    }
    
    .category-filter-item.expanded .subcategory-list {
        max-height: 400px; /* Slightly smaller for tablets */
    }
    
    .products-grid {
        grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
        gap: 1rem;
    }
    
    .product-rating {
        flex-direction: row; /* Changed from column to row */
        align-items: center; /* Keep centered alignment */
        gap: 0.5rem; /* Maintain consistent gap */
    }
    
    .product-rating-stars {
        font-size: 14px;
    }
    
    .product-review-count {
        font-size: 0.75rem;
    }
}

/* Enhanced mobile styles for screens smaller than 420px */
@media (max-width: 420px) {
    .product-categories-page {
        padding: 0.5rem 0 2rem;
        gap: 1rem;
    }
    
    /* Enhanced categories sidebar for very small screens */
    .categories-sidebar {
        margin-bottom: 0.75rem;
        position: relative;
    }
    
    .categories-sidebar h3 {
        font-size: 1.1rem;
        margin-bottom: 0.75rem;
        padding-bottom: 0.5rem;
        text-align: center;
        background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
        border-radius: 8px 8px 0 0;
        margin: -0.5rem -0.5rem 0.75rem -0.5rem;
        padding: 0.75rem 0.5rem 0.5rem 0.5rem;
    }
    
    /* Compact category filter list */
    .category-filter-list {
        max-height: 200px; /* Reduced height for small screens */
        border-radius: 8px;
        padding: 0.25rem;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
        background: white;
        border: 1px solid #e5e7eb;
    }
    
    /* IMPORTANT: Preserve subcategory expand/collapse functionality */
    .subcategory-list {
        max-height: 0; /* Keep collapsed by default */
        overflow: hidden;
        transition: max-height 0.3s ease;
        background: #fafbfc;
        border-radius: 0 0 6px 6px;
        margin-top: 0.125rem;
        border: 1px solid #e5e7eb;
        border-top: none;
    }
    
    /* Only expand when parent has .expanded class */
    .category-filter-item.expanded .subcategory-list {
        max-height: 250px; /* Smaller for mobile phones */
    }
    
    /* Improved category item styling */
    .category-item-content {
        padding: 0.6rem 0.5rem 0.6rem 0.75rem;
        font-size: 0.85rem;
        border-radius: 6px;
        margin-bottom: 0.125rem;
        border-bottom: none; /* Remove bottom borders for cleaner look */
        border-left: 2px solid transparent; /* Reduced border width */
        transition: all 0.2s ease;
    }
    
    .category-item-content:hover {
        background-color: #f8f9fa;
        transform: translateX(2px);
    }
    
    /* Active category styling */
    .category-filter-item.active > .category-item-content {
        background-color: #f0f9ff;
        border-left: 2px solid var(--btn-bck, #1DB5BE);
        color: #0369a1;
        font-weight: 600;
    }
    
    /* All Products item styling */
    .category-filter-item[data-type="all"] .category-item-content {
        padding: 0.6rem 0.5rem 0.6rem 0.75rem;
        border-bottom: none;
        border-left: 2px solid transparent;
        background: #fafbfc;
        border-radius: 6px;
        margin-bottom: 0.25rem;
    }
    
    .category-filter-item[data-type="all"].active .category-item-content {
        background-color: #f0f9ff;
        border-left: 2px solid var(--btn-bck, #1DB5BE);
        color: #0369a1;
    }
    
    /* Parent category styling */
    .category-filter-item.parent-category > .category-item-content {
        font-weight: 600;
        background: linear-gradient(135deg, #f8f9fa 0%, #f1f3f4 100%);
        border-radius: 6px;
        margin-bottom: 0.125rem;
    }
    
    /* Category toggle icon */
    .category-toggle {
        min-width: 20px;
        padding: 0.25rem;
        border-radius: 4px;
        background: rgba(0, 0, 0, 0.05);
    }
    
    .category-toggle:hover {
        background: rgba(0, 0, 0, 0.1);
    }
    
    .toggle-icon {
        width: 10px;
        height: 10px;
    }
    
    .category-filter-item.subcategory .category-item-content {
        padding: 0.5rem 0.5rem 0.5rem 1.5rem; /* Reduced indentation */
        font-size: 0.8rem;
        background: transparent;
        border-radius: 4px;
        margin: 0.125rem;
        border-bottom: none;
        border-left: 1px solid transparent; /* Thinner border for subcategories */
    }
    
    .category-filter-item.subcategory .category-item-content:before {
        left: 0.5rem;
        width: 3px;
        height: 3px;
    }
    
    .category-filter-item.subcategory .category-item-content:hover {
        background: #f0f9ff;
    }
    
    .category-filter-item.subcategory.active > .category-item-content {
        background: #e0f2fe;
        border-left: 1px solid var(--btn-bck, #1DB5BE);
        color: #0369a1;
    }
    
    /* Level-based indentation adjustments */
    .category-filter-item.level-2 .category-item-content {
        padding-left: 1.75rem;
        border-left: 1px solid transparent;
    }
    
    .category-filter-item.level-2.active .category-item-content {
        border-left: 1px solid var(--btn-bck, #1DB5BE);
    }
    
    .category-filter-item.level-3 .category-item-content {
        padding-left: 2.25rem;
        border-left: 1px solid transparent;
    }
    
    .category-filter-item.level-3.active .category-item-content {
        border-left: 1px solid var(--btn-bck, #1DB5BE);
    }
    
    /* Product count styling */
    .product-count {
        font-size: 0.75rem;
        background: rgba(0, 0, 0, 0.05);
        padding: 0.125rem 0.375rem;
        border-radius: 12px;
        margin-left: 0.25rem;
    }
    
    /* Category name improvements */
    .category-name {
        line-height: 1.3;
        word-break: break-word;
    }
    
    /* Products grid improvements for small screens */
    .products-grid-container {
        margin-top: 0.5rem;
    }
    
    .current-category-title {
        font-size: 1.5rem;
        margin-bottom: 1rem;
        text-align: center;
        padding: 0.5rem;
        background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
        border-radius: 8px;
        border: 1px solid #e5e7eb;
    }
    
    .products-grid {
        grid-template-columns: repeat(2, 1fr); /* Force 2 columns on very small screens */
        gap: 0.75rem;
        padding: 0 0.25rem;
    }
    
    /* Product item improvements */
    .product-item {
        border-radius: 8px;
        overflow: hidden;
        box-shadow: 0 1px 4px rgba(0, 0, 0, 0.1);
        transition: all 0.2s ease;
    }
    
    .product-item:hover {
        transform: translateY(-2px);
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    }
    
    .product-info {
        padding: 0.75rem 0.5rem;
    }
    
    .product-title {
        font-size: 0.85rem;
        line-height: 1.2;
        margin-bottom: 0.375rem;
        height: 2.4rem; /* Fixed height for consistency */
        overflow: hidden;
    }
    
    .product-rating {
        margin-bottom: 0.375rem;
        justify-content: center;
        flex-wrap: wrap;
        gap: 0.25rem;
    }
    
    .product-rating-stars {
        font-size: 12px;
    }
    
    .product-review-count {
        font-size: 0.7rem;
        text-align: center;
        width: 100%;
        margin-top: 0.125rem;
    }
    
    .product-price {
        font-size: 0.9rem;
        text-align: center;
        font-weight: 700;
        color: var(--btn-bck, #1DB5BE);
    }
    
    /* Scrollbar styling for category list */
    .category-filter-list::-webkit-scrollbar {
        width: 4px;
    }
    
    .category-filter-list::-webkit-scrollbar-track {
        background: #f1f3f4;
        border-radius: 2px;
    }
    
    .category-filter-list::-webkit-scrollbar-thumb {
        background: #cbd5e0;
        border-radius: 2px;
    }
    
    .category-filter-list::-webkit-scrollbar-thumb:hover {
        background: #9ca3af;
    }
    
    /* Touch-friendly improvements */
    .category-item-content,
    .product-item {
        -webkit-tap-highlight-color: transparent;
        touch-action: manipulation;
    }
    
    /* Loading states and animations */
    @keyframes shimmer {
        0% { background-position: -200px 0; }
        100% { background-position: calc(200px + 100%) 0; }
    }
    
    .category-item-content {
        background-size: 200px 100%;
        background-repeat: no-repeat;
    }
}

/* Extra small screens (less than 360px) */
@media (max-width: 360px) {
    .product-categories-page {
        padding: 0.25rem 0 1.5rem;
    }
    
    .category-filter-list {
        max-height: 180px;
        padding: 0.125rem;
    }
    
    /* IMPORTANT: Preserve subcategory expand/collapse functionality */
    .subcategory-list {
        max-height: 0; /* Keep collapsed by default */
        overflow: hidden;
        transition: max-height 0.3s ease;
    }
    
    .category-filter-item.expanded .subcategory-list {
        max-height: 200px; /* Even smaller for tiny screens */
    }
    
    .category-item-content {
        padding: 0.5rem 0.375rem 0.5rem 0.625rem;
        font-size: 0.8rem;
    }
    
    .category-filter-item.subcategory .category-item-content {
        padding: 0.4rem 0.375rem 0.4rem 1.25rem;
        font-size: 0.75rem;
    }
    
    .products-grid {
        gap: 0.5rem;
        padding: 0;
    }
    
    .product-info {
        padding: 0.5rem 0.375rem;
    }
    
    .product-title {
        font-size: 0.8rem;
        height: 2.2rem;
    }
    
    .current-category-title {
        font-size: 1.25rem;
        padding: 0.375rem;
    }
}