/* Main container */
.taxonomy-filter-container {
    max-width: 1200px;
    margin: 0 auto;
    font-family: 'Poppins', sans-serif;
    min-height: 500px; /* Set a minimum height based on expected content */

}


/* Enhanced Skeleton loading styles */
.skeleton-item {
    pointer-events: none;
    background-color: #f8f8f8 !important;  /* Slightly lighter than regular items */
    padding: 8px;
    height: 108px; /* Match actual content height */
    
}

.skeleton-image {

    margin-bottom: 5px;
    border-radius: 50%;
    background: linear-gradient(90deg, #eee 0%, #f5f5f5 50%, #eee 100%);
    background-size: 200% 100%;
    animation: 1.5s shimmer ease-in-out infinite;
}

.skeleton-title {
    display: block;
    width: 100px;
    height: 13px;
    margin: 0 auto;
    border-radius: 4px;
    background: linear-gradient(90deg, #eee 0%, #f5f5f5 50%, #eee 100%);
    background-size: 200% 100%;
    animation: 1.5s shimmer ease-in-out infinite;
}

@keyframes shimmer {
    0% {
        background-position: -100% 0;
    }
    100% {
        background-position: 100% 0;
    }
}



/* Main layout with gap between filter and content */
.taxonomy-filter-wrapper {
    display: flex;
    flex-direction: column;
}

@media (min-width: 768px) {
    .taxonomy-filter-wrapper {
        flex-direction: row;
        flex-wrap: wrap;
        gap: 30px; /* This creates the gap between left and right side */
    }
    
    .taxonomy-filter-parent-terms {
        width: 23%; /* Slightly reduced to account for the gap */
    }
    
    .taxonomy-filter-child-terms {
        width: 73%; /* Slightly reduced to account for the gap */
    }
}

/* Styled Parent Terms List with Custom Scrollbar */
.taxonomy-filter-parent-terms {
    margin-bottom: 20px;
    max-height: 500px;
    overflow-y: auto;
    border-radius: 4px;
    background-color: #fff;
    padding: 5px 0;
    box-sizing: border-box;
}

/* Custom Scrollbar - Webkit Browsers (Chrome, Safari, newer Edge) */
.taxonomy-filter-parent-terms::-webkit-scrollbar {
    width: 12px;
    background-color: transparent; /* No track background */
}

.taxonomy-filter-parent-terms::-webkit-scrollbar-thumb {
    background-color: rgb(224, 224, 224);
    border-radius: 10px;
}

.taxonomy-filter-parent-terms::-webkit-scrollbar-thumb:hover {
    background-color: #a8a8a8;
}

/* Firefox scrollbar */
.taxonomy-filter-parent-terms {
    scrollbar-width: thin;
    scrollbar-color: #c1c1c1 transparent; /* Thumb color and transparent track */
}

.parent-terms-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.parent-term-item {
    margin-bottom: 12px;
}


.parent-term-label {
    display: flex;
    align-items: center;
    cursor: pointer;
    font-size: 16px;
    width: 100%;
}

/* Checkbox styling to match the screenshot */
.parent-term-label input[type="checkbox"] {
    margin-right: 10px;
    width: 20px;
    height: 20px;
    min-width: 20px;
    border: 1px solid #D3d3d3;
    border-radius: 3px;
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    position: relative;
    cursor: pointer;
    outline: none;
}

.parent-term-label input[type="checkbox"]:checked {
    background-color: #0BB8CE;
    border: 1px solid #0BB8CE;
}

.parent-term-label input[type="checkbox"]:checked:after {
    content: "";
    position: absolute;
    left: 6px;
    top: 2px;
    width: 5px;
    height: 10px;
    border: solid white;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}

.term-name {
    font-size: 16px;
    font-weight: 400;
    color: #333;
}

/* Child Terms Grid */
.child-terms-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
    min-height: 200px; /* Reserve space for content */
}


/* See all category offers link */
.see-all-category {
    margin-bottom: 20px;
}

.see-all-link {
    display: inline-flex;
    align-items: center;
    color: #333;
    text-decoration: underline !important;
    font-weight: 400 !important;
    font-size: 14px !important;
    transition: color 0.2s;
}

.see-all-link:hover {
    color: #0BB8CE;
}

.see-all-link svg {
    margin-left: 5px;
}

/* Child Terms Grid */
.child-terms-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
}

/* Child term item - matching the design in the screenshot */
.child-term-item {
    border-radius: 8px;
    overflow: hidden;

}

.child-term-item:hover {
    background-color: #e5e5e5;

}

.child-term-link {
    display: block;
    text-decoration: none;
    color: #333;
    width: 100%;
    height: 100%;
    align-content: center;

}

.child-term-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 20px 15px;
    text-align: center;
}

/* Image styling to match screenshot */
.child-term-image {
    margin-bottom: 5px;
    display: flex;
    justify-content: center;
    align-items: center;
    aspect-ratio: 1/1; /* Force consistent aspect ratio */
}

.child-term-image img {
     width: 50px;
    height: 50px;
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.child-term-info {
    text-align: center;
}

/* Title styling to match the screenshot */
.child-term-title {
    margin: 0;
    font-size: 13px;
    color: #333;
}

.child-term-count {

    font-weight: normal;
    color: #666;
}

/* Loading and error states */
.loading-animation,
.loading-placeholder {
    padding: 30px;
    text-align: center;
    color: #777;
    grid-column: 1 / -1;
}

.no-terms-found {
    padding: 30px;
    text-align: center;
    color: #777;
    grid-column: 1 / -1;
}

.error-message {
    padding: 20px;
    text-align: center;
    color: #d32f2f;
    grid-column: 1 / -1;
}

/* Responsive styles */
@media (min-width: 768px) {
    .taxonomy-filter-wrapper {
        flex-direction: row;
        flex-wrap: wrap;
    }
    
    .taxonomy-filter-parent-terms {
        width: 25%;
        padding-right: 30px;
    }
    
    .view-all-categories {
        width: 75%;
        margin-left: auto;
    }
    
    .taxonomy-filter-child-terms {
        width: 70%;
        flex-grow: 1;
    }
}

/* Dropdown Menu for Mobile Parent Categories - FIXED VERSION */
@media (max-width: 767px) {
    /* Container styling */
    .taxonomy-filter-parent-terms {
        position: relative;
        max-height: none;
        border: 1px solid #D3D3D3;
        border-radius: 8px;
        padding: 0;
        margin-bottom: 25px;
        background: white;
        z-index: 100; /* Ensure dropdown appears above other content */
    }
    
    /* Dropdown header/toggle */
    .dropdown-toggle {
        display: flex;
        align-items: center;
        justify-content: space-between;
        padding: 12px 15px;
        cursor: pointer;
        border-radius: 8px;
        -webkit-tap-highlight-color: transparent; /* Remove tap highlight on mobile */
    }
    
    /* Toggle text styling */
    .dropdown-toggle-text {
        color: #333;
    }
    
    /* Arrow styling */
    .dropdown-arrow {
        transition: transform 0.2s ease;
        margin-left: 10px;
        font-size: 10px;
    }
    
    /* Rotate arrow when open */
    .taxonomy-filter-parent-terms.open .dropdown-arrow {
        transform: rotate(180deg);
    }
    
    /* Dropdown options container - FIXED POSITIONING */
    .parent-terms-list {
        display: none; /* Hidden by default */
        position: absolute;
        top: 100%;
        left: 0;
        right: 0;
        background: white;
        z-index: 999; /* Increased z-index */
        max-height: 300px;
        overflow-y: auto;
        border: 1px solid #eee;
        border-top: none;
        border-radius: 0 0 8px 8px;
        box-shadow: 0 5px 15px rgba(0,0,0,0.1);
        padding: 5px 0;
        margin-top: -1px; /* Connect with dropdown header */
        -webkit-overflow-scrolling: touch; /* Smooth scrolling on iOS */
        visibility: visible; /* Ensure visibility */
        opacity: 1; /* Ensure opacity */
        overflow-y: scroll !important;
    }
    
    /* Show dropdown when open - FIXED */
    .taxonomy-filter-parent-terms.open .parent-terms-list {
        display: block !important; /* Force display */
        height: auto !important; /* Ensure height */
        visibility: visible !important; /* Force visibility */
        overflow: visible; /* Allow overflow */
        transform: none !important; /* Reset any transforms */
    }
    
    /* ADDED: Adjust positioning for scroll issues */
    .taxonomy-filter-parent-terms.open {
        overflow: visible !important;
        position: relative;
        z-index: 1000;
    }
    
    /* Dropdown item styling */
    .parent-term-item {
        margin: 0;
        padding: 0;
        display: block !important; /* Force display */
    }
    
    /* Dropdown label styling */
    .parent-term-label {
        display: flex;
        align-items: center;
        width: 100%;
        padding: 12px 15px;
        transition: background-color 0.2s;
    }
    
    /* Hover effect */
    .parent-term-label:hover {
        background-color: #f8f8f8;
    }
    
    /* Active item styling */
    .parent-term-item.active .parent-term-label {
        background-color: #f0f9fb;
    }
    
    .parent-term-item.active .term-name {
        color: #0BB8CE;
    }
    
    /* Checkbox styling */
    .parent-term-label input[type="checkbox"] {
        margin-right: 10px;
    }
    
    /* Handle term overflow */
    .term-name {
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }
    
    /* Background overlay when dropdown is open */
    .dropdown-overlay {
        display: none;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background-color: rgba(0,0,0,0.3);
        z-index: 99;
    }
    
    /* Show overlay when dropdown is open */
    .dropdown-overlay.active {
        display: block;
    }
}



@media (max-width: 992px) {
    .child-terms-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 768px) {
    .taxonomy-filter-wrapper {
        flex-direction: column;
    }
    
    .taxonomy-filter-parent-terms,
    .view-all-categories,
    .taxonomy-filter-child-terms {
        width: 100%;
        padding-right: 0;
    }
    
    .child-terms-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 480px) {
    .child-terms-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}