/* Custom Sorting Filter Bar Styles */
.custom-sorting-wrapper {
    position: relative;
    margin-bottom: 24px;
    overflow: visible; /* Ensure dropdown can extend outside */
}

/* Hide the original FacetWP dropdown on desktop */
@media (min-width: 768px) {
    .facetwp-facet-order {
        display: none !important;
    }
}

/* Custom sorting tabs for desktop */
.custom-sorting-tabs {
    display: none;
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    overflow: visible; /* Allow dropdown to extend outside */
    border: 1px solid #e5e7eb;
}

@media (min-width: 768px) {
    .custom-sorting-tabs {
        display: flex;
        flex-wrap: wrap;
    }
}

.custom-sorting-tab {
    flex: 1;
    padding: 12px 20px;
    background: #fff;
    border: none;
    border-right: 1px solid #e5e7eb;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    color: #6b7280;
    transition: all 0.3s ease;
    white-space: nowrap;
    text-align: center;
    min-width: 0;
}

.custom-sorting-tab:last-child {
    border-right: none;
}

.custom-sorting-tab:hover {
    background: #f9fafb;
    color: #374151;
}

.custom-sorting-tab.active {
    background: #19325c;
    color: #fff;
    font-weight: 600;
}

.custom-sorting-tab.active:hover {
    background: #2563eb;
}

/* Responsive adjustments */
@media (max-width: 1024px) {
    .custom-sorting-tab {
        padding: 10px 16px;
        font-size: 13px;
    }
}

@media (max-width: 768px) {
    .custom-sorting-tabs {
        display: none;
    }
    
    .facetwp-facet-order {
        display: none !important;
    }
    
    .sorting {
        display: none;
    }
}

/* Loading state */
.custom-sorting-tabs.loading {
    opacity: 0.6;
    pointer-events: none;
}

/* Font Awesome icons spacing */
.custom-sorting-tab i {
    margin-right: 8px;
    width: 16px;
    text-align: center;
}

.custom-sorting-dropdown-item i {
    margin-right: 8px;
    width: 16px;
    text-align: center;
}

/* Dropdown Styles */
.custom-sorting-dropdown {
    position: relative;
    display: inline-block;
    z-index: 1000; /* Ensure proper stacking context */
}

.custom-sorting-dropdown-button {
    position: relative;
}


.custom-sorting-dropdown-menu {
    position: absolute;
    top: 100%;
    right: 0;
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    z-index: 99999;
    min-width: 200px;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all 0.2s ease;
}

.custom-sorting-dropdown.open .custom-sorting-dropdown-menu {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.custom-sorting-dropdown-item {
    display: block;
    width: 100%;
    padding: 10px 16px;
    border: none;
    background: #fff;
    text-align: left;
    cursor: pointer;
    font-size: 14px;
    color: #6b7280;
    transition: all 0.2s ease;
    border-bottom: 1px solid #f3f4f6;
}

.custom-sorting-dropdown-item:last-child {
    border-bottom: none;
    border-radius: 0 0 6px 6px;
}

.custom-sorting-dropdown-item:first-child {
    border-radius: 6px 6px 0 0;
}

.custom-sorting-dropdown-item:hover {
    background: #f9fafb;
    color: #374151;
}

.custom-sorting-dropdown-item.active {
    background: #eff6ff;
    color: #3b82f6;
    font-weight: 500;
}

.custom-sorting-dropdown-item.active:hover {
    background: #dbeafe;
}

/* Responsive adjustments for dropdown */
@media (max-width: 1024px) {
    .custom-sorting-dropdown-menu {
        min-width: 180px;
    }
    
    .custom-sorting-dropdown-item {
        padding: 8px 14px;
        font-size: 13px;
    }
}

/* Mobile Actions Bar */
.mobile-actions {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: #fff;
    border-top: 1px solid #e5e7eb;
    box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.1);
    z-index: 1000;
    padding: 12px;
    gap: 12px;
}

@media (max-width: 767px) {
    .mobile-actions {
        display: flex;
    }
}

.mobile-actions .button {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 16px;
    border-radius: 8px;
    text-decoration: none;
    font-weight: 500;
    font-size: 14px;
    border: 1px solid #e5e7eb;
    transition: all 0.2s ease;
}

.mobile-actions .button--sort {
    background: #f9fafb;
    color: #374151;
    border: 1px solid #d1d5db;
}

.mobile-actions .button--sort:hover,
.mobile-actions .button--sort.active {
    background: #19325c;
    color: #fff;
    border-color: #19325c;
}

.mobile-actions .button--filters {
    background: #19325c;
    color: #fff;
    border-color: #19325c;
}

.mobile-actions .button--filters:hover {
    background: #1e3a8a;
    border-color: #1e3a8a;
}

.mobile-actions .button i {
    font-size: 16px;
}

/* Mobile Sort Dropdown */
.mobile-sort-dropdown {
    position: fixed;
    bottom: 80px; /* Above the mobile actions bar */
    left: 12px;
    right: 12px;
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.15);
    z-index: 9999;
    max-height: 60vh;
    overflow-y: auto;
    opacity: 0;
    visibility: hidden;
    transform: translateY(20px);
    transition: all 0.3s ease;
}

.mobile-sort-dropdown.open {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.mobile-sort-dropdown-header {
    padding: 16px;
    border-bottom: 1px solid #f3f4f6;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.mobile-sort-dropdown-header h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    color: #111827;
}

.mobile-sort-dropdown-close {
    background: none;
    border: none;
    padding: 4px;
    cursor: pointer;
    color: #6b7280;
    font-size: 18px;
}

.mobile-sort-dropdown-close:hover {
    color: #374151;
}

.mobile-sort-options {
    padding: 8px 0;
}

.mobile-sort-option {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border: none;
    background: none;
    width: 100%;
    text-align: left;
    cursor: pointer;
    font-size: 14px;
    color: #374151;
    transition: background-color 0.2s ease;
}

.mobile-sort-option:hover {
    background: #f9fafb;
}

.mobile-sort-option.active {
    background: #eff6ff;
    color: #3b82f6;
    font-weight: 500;
}

.mobile-sort-option i {
    width: 20px;
    text-align: center;
    color: #6b7280;
}

.mobile-sort-option.active i {
    color: #3b82f6;
}

/* Mobile Sort Backdrop */
.mobile-sort-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 9998;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

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