/* ==============================================
   WOOCOMMERCE CATEGORY TREE STYLES v2.0
   Enhanced with custom backgrounds and compact design
   File: /wp-content/themes/your-child-theme/assets/css/woo-category-tree.css
   ============================================== */

/* Container */
.woo-category-tree {
    /*font-family: 'Open Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;*/
    max-width: 100%;
    margin: 0 auto;
    background: #ffffff;
    border-radius: 8px;
	border: solid 1px rgba(0, 0, 0, 0.1);
    /*box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);*/
    overflow: hidden;
    position: relative;
}

/* Mobile Header (Hidden by default) */
.mobile-header {
    display: none;
    background: #f8f9fa;
    border-bottom: 1px solid #e9ecef;
    padding: 0;
}

.mobile-toggle {
    display: flex;
    align-items: center;
    width: 100%;
    padding: 12px 16px;
    background: none;
    border: none;
    cursor: pointer;
    font-size: 15px;
    font-weight: 600;
    color: #333333;
    transition: all 0.3s ease;
}

.mobile-toggle:hover {
    background: #e9ecef;
    color: #009542;
}

.mobile-toggle:focus {
    outline: 2px solid #009542;
    outline-offset: -2px;
}

/* Hamburger Icon */
.hamburger-line {
    display: block;
    width: 20px;
    height: 2px;
    background: currentColor;
    margin: 3px 0;
    transition: all 0.3s ease;
    transform-origin: center;
}

.mobile-toggle.active .hamburger-line:nth-child(1) {
    transform: rotate(45deg) translate(6px, 6px);
}

.mobile-toggle.active .hamburger-line:nth-child(2) {
    opacity: 0;
}

.mobile-toggle.active .hamburger-line:nth-child(3) {
    transform: rotate(-45deg) translate(6px, -6px);
}

.mobile-toggle-text {
    margin-left: 12px;
    flex-grow: 1;
    text-align: left;
}

/* Category Tree Content */
.category-tree-content {
    display: block;
}

/* Category List - No indentation, flat alignment */
.category-list {
    list-style: none !important;
    list-style-type: none !important;
    margin: 0;
    padding: 0;
}

.category-list ul {
    list-style: none !important;
    list-style-type: none !important;
    margin: 0;
    padding: 0;
}

/* Ensure no list styling at any level */
.category-list,
.category-list ul,
.category-list li {
    list-style: none !important;
    list-style-type: none !important;
}

/* Category Item - Compact design */
.category-item {
    position: relative;
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
}

.category-item:last-child {
    border-bottom: none;
}

/* Category Link Wrapper - No indentation */
.category-link-wrapper {
    display: flex;
    align-items: center;
    position: relative;
    transition: all 0.3s ease;
}

.category-link-wrapper:hover {
    background: rgba(0, 123, 186, 0.05);
}

/* Category Name Link (for navigation) - Compact */
.category-name-link {
    display: flex;
    align-items: center;
    flex-grow: 1;
    padding: 8px 16px;
    text-decoration: none;
    color: #333333;
    background: transparent;
    transition: all 0.3s ease;
    cursor: pointer;
    font-size: 15px;
    line-height: 1.3;
}

.category-name-link:hover {
    color: #009542;
}

.category-name-link:focus {
    outline: 2px solid #009542;
    outline-offset: -2px;
    background: rgba(0, 123, 186, 0.1);
}

/* Category Name */
.category-name {
    flex-grow: 1;
    font-weight: 500;
    margin-right: 8px;
    margin-left: 0;
}

/* Product Count - Hidden by default */
.product-count {
    background: #e7f3ff;
    color: #009542;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
    margin-left: 8px;
    min-width: 24px;
    text-align: center;
    transition: all 0.3s ease;
    display: none;
}

/* Show counts when enabled */
.woo-category-tree[data-show-counts="true"] .product-count {
    display: inline-block;
}

.category-name-link:hover .product-count {
    background: #009542;
    color: #ffffff;
}

/* Expand Toggle Button - Compact */
.expand-toggle {
    color: #666666;
    font-size: 12px;
    transition: all 0.3s ease;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    cursor: pointer;
    margin-right: 4px;
    border-radius: 3px;
}

.expand-toggle:hover {
    background: #e9ecef;
    color: #009542;
}

.expand-toggle:focus {
    outline: 2px solid #009542;
    outline-offset: -2px;
}

.expand-toggle.expanded {
    transform: rotate(180deg);
    color: #009542;
}

.expand-toggle.expanded:hover {
    background: #009542;
    color: #ffffff;
}

/* Subcategory Container - Flat alignment */
.subcategories {
    display: none;
    border-top: 1px solid rgba(0, 0, 0, 0.05);
    animation: slideDown 0.2s ease-out;
}

.subcategories.active {
    display: block;
}

@keyframes slideDown {
    from {
        opacity: 0;
        max-height: 0;
    }
    to {
        opacity: 1;
        max-height: 1000px;
    }
}

/* Background Colors for Different Levels */

/* Main Categories (Level 0) */
.category-item[data-level="0"] .category-link-wrapper {
    background: var(--main-bg-color, #ffffff);
}

.category-item[data-level="0"] .category-link-wrapper:hover {
    background: color-mix(in srgb, var(--main-bg-color, #ffffff) 90%, #009542 10%);
}

/* Subcategory Level 1 */
.category-item[data-level="1"] .category-link-wrapper {
    background: var(--sub1-bg-color, #f8f9fa);
}

.category-item[data-level="1"] .category-link-wrapper:hover {
    background: color-mix(in srgb, var(--sub1-bg-color, #f8f9fa) 90%, #009542 10%);
}

/* Subcategory Level 2 */
.category-item[data-level="2"] .category-link-wrapper {
    background: var(--sub2-bg-color, #dbe0e6);
}

.category-item[data-level="2"] .category-link-wrapper:hover {
    background: color-mix(in srgb, var(--sub2-bg-color, #dbe0e6) 90%, #009542 10%);
}

/* Subcategory Level 3+ */
.category-item[data-level="3"] .category-link-wrapper,
.category-item[data-level="4"] .category-link-wrapper,
.category-item[data-level="5"] .category-link-wrapper {
    background: var(--sub3-bg-color, #bdc7d0);
}

.category-item[data-level="3"] .category-link-wrapper:hover,
.category-item[data-level="4"] .category-link-wrapper:hover,
.category-item[data-level="5"] .category-link-wrapper:hover {
    background: color-mix(in srgb, var(--sub3-bg-color, #bdc7d0) 90%, #009542 10%);
}

/* Current Category Background */
.current-category .category-link-wrapper {
    background: var(--current-bg-color, #e7f3ff) !important;
}

.current-category .category-link-wrapper:hover {
    background: color-mix(in srgb, var(--current-bg-color, #e7f3ff) 85%, #009542 15%) !important;
}

/* Current Category Name Highlighting */
.current-category .category-name-link {
    color: #009542;
    font-weight: 600;
}

.current-category .category-name-link:hover {
    color: #005a87;
}

/* Loading State */
.loading {
    padding: 16px;
    text-align: center;
    color: #666666;
    font-size: 14px;
}

.loading::after {
    content: "";
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid #f3f3f3;
    border-top: 2px solid #009542;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-left: 8px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Empty State */
.empty-categories {
    padding: 32px 16px;
    text-align: center;
    color: #666666;
    font-size: 14px;
}

/* Error State */
.error-state {
    padding: 32px 16px;
    text-align: center;
    color: #dc3545;
    background: #f8d7da;
    border: 1px solid #f5c6cb;
    border-radius: 6px;
    font-size: 14px;
}

/* DIVI Specific Overrides */
.et_pb_module .woo-category-tree {
    margin: 0;
    font-family: inherit;
}

.et_pb_section .woo-category-tree {
    width: 100%;
}

/* DIVI Button Reset */
.woo-category-tree .category-name-link {
    font-family: inherit;
    line-height: 1.3;
}

/* Mobile Responsive Design - Below 990px */
@media (max-width: 989px) {
    /* Show mobile header */
    .mobile-header {
        display: block;
    }
    
    /* Hide category content by default on mobile */
    .category-tree-content {
        display: none;
        animation: mobileSlideDown 0.3s ease-out;
    }
    
    /* Show when mobile menu is active */
    .woo-category-tree.mobile-active .category-tree-content {
        display: block;
    }
    
    @keyframes mobileSlideDown {
        from {
            opacity: 0;
            max-height: 0;
            transform: translateY(-10px);
        }
        to {
            opacity: 1;
            max-height: 2000px;
            transform: translateY(0);
        }
    }
    
    .woo-category-tree {
        border-radius: 0;
        box-shadow: none;
        border: 1px solid #e9ecef;
    }
    
    /* Larger touch-friendly category links */
    .category-name-link {
        padding: 16px 20px; /* Increased from 6px 12px to 16px 20px */
        font-size: 16px; /* Increased from 14px to 16px */
        min-height: 44px; /* Apple's recommended minimum touch target */
        display: flex;
        align-items: center;
    }
    
    .product-count {
        padding: 4px 10px; /* Increased padding */
        font-size: 13px; /* Increased from 11px to 13px */
        margin-left: 10px;
        min-width: 28px; /* Increased min-width */
    }
    
    /* Larger expand toggle for easier touching */
    .expand-toggle {
        width: 44px; /* Increased from 28px to 44px */
        height: 44px; /* Increased from 28px to 44px */
        margin-right: 4px;
        font-size: 14px; /* Increased from 11px to 14px */
    }
    
    /* Mobile toggle adjustments */
    .mobile-toggle {
        padding: 16px 20px; /* Increased padding */
        font-size: 16px; /* Increased font size */
        min-height: 56px; /* Larger touch target */
    }
    
    .hamburger-line {
        width: 20px; /* Increased from 16px */
        height: 2px; /* Increased from 1.5px */
    }
    
    /* Category items with better spacing */
    .category-item {
        border-bottom: 1px solid rgba(0, 0, 0, 0.1); /* Slightly more visible border */
    }
    
    /* Better touch targets for category wrappers */
    .category-link-wrapper {
        min-height: 44px; /* Minimum touch target height */
    }
}

@media (max-width: 767px) {
    /* Even larger touch targets for smaller screens */
    .category-name-link {
        padding: 18px 20px; /* Even more padding for very small screens */
        font-size: 16px;
        min-height: 48px; /* Larger minimum height */
    }
    
    .product-count {
        padding: 4px 8px;
        font-size: 12px;
        margin-left: 8px;
        min-width: 24px;
    }
    
    .expand-toggle {
        width: 48px; /* Even larger for small screens */
        height: 48px;
        font-size: 14px;
    }
    
    .mobile-toggle {
        min-height: 60px; /* Larger mobile toggle */
        padding: 18px 20px;
    }
    
    .category-link-wrapper {
        min-height: 48px; /* Larger wrapper height */
    }
}

/* Desktop - Above 990px */
@media (min-width: 990px) {
    .et_pb_module .woo-category-tree {
        margin-left: 0;
        margin-right: 0;
    }
}

/* High Contrast Mode Support */
@media (prefers-contrast: high) {
    .category-name-link,
    .expand-toggle {
        border: 1px solid #333333;
    }
    
    .product-count {
        border: 1px solid #009542;
    }
    
    .mobile-toggle {
        border: 1px solid #333333;
    }
}

/* Reduced Motion Support */
@media (prefers-reduced-motion: reduce) {
    .category-name-link,
    .product-count,
    .expand-toggle,
    .mobile-toggle,
    .hamburger-line,
    .category-link-wrapper {
        transition: none;
    }
    
    .subcategories,
    .category-tree-content {
        animation: none;
    }
    
    .expand-toggle.expanded {
        transform: none;
    }
    
    .mobile-toggle.active .hamburger-line:nth-child(1),
    .mobile-toggle.active .hamburger-line:nth-child(3) {
        transform: none;
    }
}

/* Print Styles */
@media print {
    .woo-category-tree {
        box-shadow: none;
        border: 1px solid #333333;
    }
    
    .expand-toggle,
    .mobile-header {
        display: none;
    }
    
    .subcategories,
    .category-tree-content {
        display: block !important;
    }
    
    .product-count {
        display: inline-block !important;
    }
}

/* Custom Size Variations */
.woo-category-tree.size-compact .category-name-link {
    padding: 4px 12px;
    font-size: 13px;
}

.woo-category-tree.size-compact .expand-toggle {
    width: 24px;
    height: 24px;
    font-size: 10px;
}

.woo-category-tree.size-large .category-name-link {
    padding: 12px 20px;
    font-size: 16px;
}

.woo-category-tree.size-large .expand-toggle {
    width: 40px;
    height: 40px;
    font-size: 14px;
}

/* Custom Border Styles */
.woo-category-tree.border-none {
    box-shadow: none;
    border: none;
}

.woo-category-tree.border-thick {
    border: 2px solid #e9ecef;
}

/* Animation Variations */
.woo-category-tree.animation-fade .subcategories {
    animation: fadeIn 0.3s ease-out;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.woo-category-tree.animation-slide-left .subcategories {
    animation: slideInLeft 0.3s ease-out;
}

@keyframes slideInLeft {
    from {
        opacity: 0;
        transform: translateX(-20px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* Focus styles for accessibility */
.category-name-link:focus-visible,
.expand-toggle:focus-visible,
.mobile-toggle:focus-visible {
    outline: 2px solid #009542;
    outline-offset: 2px;
}

/* Smooth transitions for all interactive elements */
.category-link-wrapper,
.category-name-link,
.expand-toggle,
.mobile-toggle,
.product-count {
    transition: all 0.2s ease;
}

/* Ensure text is always readable */
.category-name {
    color: inherit;
    text-decoration: none;
}

/* Final overrides to ensure flat design */
.category-list .category-list .category-item,
.category-list .category-list .category-list .category-item,
.category-list .category-list .category-list .category-list .category-item {
    margin-left: 0 !important;
    padding-left: 0 !important;
}

.subcategories .category-name-link,
.subcategories .subcategories .category-name-link,
.subcategories .subcategories .subcategories .category-name-link {
    padding-left: 16px !important;
}

/* JavaScript-applied background colors - Fallback for older browsers */
.woo-category-tree[style*="--main-bg-color"] .category-item[data-level="0"] .category-link-wrapper {
    background: var(--main-bg-color) !important;
}

.woo-category-tree[style*="--sub1-bg-color"] .category-item[data-level="1"] .category-link-wrapper {
    background: var(--sub1-bg-color) !important;
}

.woo-category-tree[style*="--sub2-bg-color"] .category-item[data-level="2"] .category-link-wrapper {
    background: var(--sub2-bg-color) !important;
}

.woo-category-tree[style*="--sub3-bg-color"] .category-item[data-level="3"] .category-link-wrapper,
.woo-category-tree[style*="--sub3-bg-color"] .category-item[data-level="4"] .category-link-wrapper,
.woo-category-tree[style*="--sub3-bg-color"] .category-item[data-level="5"] .category-link-wrapper {
    background: var(--sub3-bg-color) !important;
}

.woo-category-tree[style*="--current-bg-color"] .current-category .category-link-wrapper {
    background: var(--current-bg-color) !important;
}

/* Hover effects for dynamic background colors */
.woo-category-tree[style*="--main-bg-color"] .category-item[data-level="0"] .category-link-wrapper:hover {
    filter: brightness(0.95);
}

.woo-category-tree[style*="--sub1-bg-color"] .category-item[data-level="1"] .category-link-wrapper:hover {
    filter: brightness(0.95);
}

.woo-category-tree[style*="--sub2-bg-color"] .category-item[data-level="2"] .category-link-wrapper:hover {
    filter: brightness(0.95);
}

.woo-category-tree[style*="--sub3-bg-color"] .category-item[data-level="3"] .category-link-wrapper:hover,
.woo-category-tree[style*="--sub3-bg-color"] .category-item[data-level="4"] .category-link-wrapper:hover,
.woo-category-tree[style*="--sub3-bg-color"] .category-item[data-level="5"] .category-link-wrapper:hover {
    filter: brightness(0.95);
}

.woo-category-tree[style*="--current-bg-color"] .current-category .category-link-wrapper:hover {
    filter: brightness(0.9);
}

ul.category-list {
	padding: 0 !important;
}