
.category-search-container {
    position: sticky;
    top: 60px; /* Keep this to position below navbar */
    z-index: 999;
    background: white;
    margin-bottom: 1rem;
    margin-top: 0; /* Remove the 7rem top margin */
    padding-top: 0; /* Remove the 20px top padding */
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.search-row {
    display: flex;
    align-items: center;
    gap: 15px;
    max-width: 85%;
    margin: 0 auto 1rem;
    width: 100%;
}

.category-dropdown-container {
    position: relative;
    flex-shrink: 0;
}

.category-dropdown-btn {
    background: linear-gradient(135deg, #c82333 0%, #800511ff 100%);
    border: none;
    color: white;
    padding: 12px 20px;
    border-radius: 25px;
    font-size: 16px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3);
    position: relative;
    overflow: hidden;
    white-space: nowrap;
    min-width: 150px;
}

.category-dropdown-btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.2), transparent);
    transition: left 0.5s;
}

.category-dropdown-btn:hover::before {
    left: 100%;
}

.category-dropdown-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.4);
}

.category-dropdown-btn i {
    margin-left: 10px;
    transition: transform 0.3s ease;
}

.category-dropdown-btn.active i {
    transform: rotate(180deg);
}

.categories-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    background: white;
    border: 1px solid #e0e0e0;
    border-radius: 15px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.1);
    z-index: 1000;
    width: 320px;
    max-height: 400px;
    overflow-y: auto;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all 0.3s ease;
    margin-top: 10px;
}

.categories-dropdown.show {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.categories-dropdown::-webkit-scrollbar {
    width: 6px;
}

.categories-dropdown::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 10px;
}

.categories-dropdown::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 10px;
}

.categories-dropdown::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}

.category-item {
    position: relative;
    border-bottom: 1px solid #f0f0f0;
}

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

.category-link {
    display: block;
    padding: 12px 20px;
    text-decoration: none;
    color: #333;
    transition: all 0.3s ease;
    position: relative;
    font-weight: 500;
}

.category-link::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    height: 100%;
    width: 3px;
    background: #dc3545;
    transform: scaleY(0);
    transition: transform 0.3s ease;
}

.category-link:hover,
.category-link.active {
    background: linear-gradient(90deg, #fdf2f2, #fff);
    color: #dc3545;
    padding-left: 25px;
}

.category-link:hover::before,
.category-link.active::before {
    transform: scaleY(1);
}

.subcategories-panel {
    position: absolute;
    left: 318px; /* Reduced gap - positioned right next to the dropdown */
    top: 0; /* Initial position - will be adjusted dynamically */
    background: white;
    border: 1px solid #e0e0e0;
    border-radius: 15px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.15);
    width: 280px;
    max-height: 350px; /* Slightly smaller to prevent overflow */
    overflow-y: auto;
    z-index: 1001;
    opacity: 0;
    visibility: hidden;
    transform: translateX(-10px);
    transition: all 0.3s ease;
}

.subcategories-panel.show {
    opacity: 1;
    visibility: visible;
    transform: translateX(0);
}

.subcategories-panel::-webkit-scrollbar {
    width: 6px;
}

.subcategories-panel::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 10px;
}

.subcategories-panel::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 10px;
}

.subcategories-panel .panel-header {
    background: linear-gradient(135deg, #dc3545 0%, #a91e2e 100%);
    color: white;
    padding: 15px 20px;
    font-weight: 600;
    border-radius: 15px 15px 0 0;
    position: sticky;
    top: 0;
}

.subcategory-link {
    display: block;
    padding: 10px 20px;
    text-decoration: none;
    color: #555;
    border-bottom: 1px solid #f0f0f0;
    transition: all 0.3s ease;
    position: relative;
}

.subcategory-link::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    height: 100%;
    width: 2px;
    background: #28a745;
    transform: scaleY(0);
    transition: transform 0.3s ease;
}

.subcategory-link:hover {
    background: linear-gradient(90deg, #f0fff4, #fff);
    color: #28a745;
    padding-left: 25px;
}

.subcategory-link:hover::before {
    transform: scaleY(1);
}

.subcategory-link:last-child {
    border-bottom: none;
}

/* Responsive Design */
@media (max-width: 768px) {
    .search-row {
        flex-direction: column;
        gap: 15px;
        align-items: stretch;
    }
    
    .category-dropdown-container {
        order: 1;
        width: 100%;
    }
    
    .search-bar {
        order: 2;
        width: 100%;
    }
    
    .category-dropdown-btn {
        width: 100%;
        justify-content: center;
    }
    
    .categories-dropdown {
        width: 100%;
        left: 0;
        right: 0;
    }
    
    .subcategories-panel {
        position: fixed;
        left: 50%;
        top: 50%;
        transform: translate(-50%, -50%);
        width: 85vw;
        max-width: 300px;
        max-height: 70vh;
    }
    
    .subcategories-panel.show {
        transform: translate(-50%, -50%);
    }
}

@media (max-width: 480px) {
    .category-dropdown-btn {
        padding: 10px 15px;
        font-size: 14px;
        min-width: auto;
    }
    
    .search-input {
        font-size: 14px;
        padding: 10px 40px 10px 15px;
    }
    
    .search-btn {
        width: 35px;
        height: 35px;
    }
}

/* Loading Animation */
.loading-spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 2px solid #f3f3f3;
    border-top: 2px solid #007bff;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

.categories-horizontal {
    display: flex;
    gap: 20px;
    justify-content: flex-start;
    align-items: center;
    margin: 1rem 0;
    overflow-x: auto; 
    flex-wrap: nowrap; 
}

.category-link-horizontal {
    padding: 8px 16px;
    background: #f8f9fa;
    border-radius: 20px;
    text-decoration: none;
    color: #333;
    transition: all 0.3s ease;
    white-space: nowrap;
    flex-shrink: 0; 
}

.category-link-horizontal:hover {
    background: #dc3545;
    color: white;
}

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

/* Hide panels on mobile when dropdown is closed */
@media (max-width: 768px) {
    .categories-dropdown:not(.show) .subcategories-panel {
        display: none;
    }
}

/* Backdrop for mobile */
.mobile-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    z-index: 999;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.mobile-backdrop.show {
    opacity: 1;
    visibility: visible;
}
