/* ============================================
   Mobile Filter Bottom Sheet Styles
   ============================================ */

/* Box Sizing for all filter elements */
.filter-bottom-sheet *,
.filter-bottom-sheet *::before,
.filter-bottom-sheet *::after {
    box-sizing: border-box;
}

/* Filter Button */
.mobile-filter-btn {
    position: fixed;
    bottom: 85px;
    right: 20px;
    z-index: 1001;
    background: linear-gradient(135deg, var(--main-color-one, #1e40af) 0%, var(--main-color-two, #3b82f6) 100%);
    color: white;
    border: none;
    border-radius: 50px;
    padding: 12px 24px;
    font-size: 16px;
    font-weight: 600;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.3s ease;
    cursor: pointer;
}

.mobile-filter-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.3);
}

.mobile-filter-btn i {
    font-size: 18px;
}

/* Responsive positioning - on desktop, no bottom nav, so lower position */
@media (min-width: 768px) {
    .mobile-filter-btn {
        bottom: 20px;
    }
}

/* Overlay */
.filter-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(2px);
    z-index: 1002;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.filter-overlay.active {
    opacity: 1;
    visibility: visible;
}

/* Bottom Sheet */
.filter-bottom-sheet {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    width: 100%;
    background: white;
    border-radius: 20px 20px 0 0;
    z-index: 1003;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    transform: translateY(100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.15);
    overflow: hidden;
}

.filter-bottom-sheet.active {
    transform: translateY(0);
}

/* Sheet Handle */
.sheet-handle {
    width: 40px;
    height: 4px;
    background: #d1d5db;
    border-radius: 2px;
    margin: 12px auto 8px;
    flex-shrink: 0;
}

/* Sheet Header */
.sheet-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 20px;
    border-bottom: 1px solid #e5e7eb;
    flex-shrink: 0;
    max-width: 100%;
    gap: 12px;
}

.sheet-title {
    font-size: 18px;
    font-weight: 700;
    color: #1f2937;
    margin: 0;
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.sheet-close-btn {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f3f4f6;
    border: none;
    border-radius: 50%;
    color: #6b7280;
    font-size: 18px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.sheet-close-btn:hover {
    background: #e5e7eb;
    color: #374151;
}

/* Sheet Body */
.sheet-body {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 20px;
    max-width: 100%;
}

/* Form Container */
#mobileFilterForm {
    width: 100%;
    max-width: 100%;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    height: 100%;
}

/* Custom scrollbar for sheet */
.sheet-body::-webkit-scrollbar {
    width: 6px;
}

.sheet-body::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 3px;
}

.sheet-body::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 3px;
}

.sheet-body::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}

/* Filter Group */
.filter-group {
    margin-bottom: 24px;
    max-width: 100%;
    overflow: visible;
    position: relative;
}

.filter-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    font-weight: 600;
    color: #374151;
    margin-bottom: 10px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.filter-label i {
    color: var(--main-color-one, #1e40af);
    font-size: 16px;
}

/* Select Input */
.filter-select {
    width: 100%;
    max-width: 100%;
    padding: 12px 16px;
    border: 1.5px solid #d1d5db;
    border-radius: 10px;
    font-size: 15px;
    font-weight: 500;
    color: #1f2937;
    background-color: #fff;
    transition: all 0.2s ease;
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%236b7280' d='M10.293 3.293L6 7.586 1.707 3.293A1 1 0 00.293 4.707l5 5a1 1 0 001.414 0l5-5a1 1 0 10-1.414-1.414z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 12px;
    padding-right: 40px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    box-sizing: border-box;
    cursor: pointer;
    line-height: 1.5;
}

.filter-select:hover {
    border-color: #9ca3af;
}

.filter-select option {
    padding: 12px 16px;
    font-size: 15px;
    font-weight: 500;
    line-height: 1.6;
    color: #1f2937;
    background-color: #fff;
    border-radius: 0;
    min-height: 44px;
}

.filter-select option:hover {
    background-color: #f3f4f6;
    color: #1f2937;
}

.filter-select option:checked,
.filter-select option:active,
.filter-select option[selected] {
    background-color: var(--main-color-one, #1e40af);
    background: linear-gradient(135deg, var(--main-color-one, #1e40af) 0%, var(--main-color-two, #3b82f6) 100%);
    color: #fff;
    font-weight: 600;
}

.filter-select option:disabled {
    color: #9ca3af;
    background-color: #f9fafb;
    cursor: not-allowed;
}

/* First option (placeholder style) */
.filter-select option:first-child {
    color: #9ca3af;
    font-style: italic;
}

/* Optgroup styling if needed */
.filter-select optgroup {
    font-weight: 700;
    color: #374151;
    font-style: normal;
    background-color: #f9fafb;
    padding: 8px 12px;
}

.filter-select:focus {
    outline: none;
    border-color: var(--main-color-one, #1e40af);
    box-shadow: 0 0 0 3px rgba(30, 64, 175, 0.1);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%231e40af' d='M10.293 3.293L6 7.586 1.707 3.293A1 1 0 00.293 4.707l5 5a1 1 0 001.414 0l5-5a1 1 0 10-1.414-1.414z'/%3E%3C/svg%3E");
}

.filter-select:active {
    border-color: var(--main-color-one, #1e40af);
}

/* Remove default select styling on various browsers */
.filter-select::-ms-expand {
    display: none; /* IE */
}

.filter-select:-moz-focusring {
    color: transparent;
    text-shadow: 0 0 0 #1f2937;
}

/* Mobile-specific select improvements */
@supports (-webkit-touch-callout: none) {
    /* iOS specific */
    .filter-select {
        font-size: 16px; /* Prevents zoom on iOS */
        -webkit-tap-highlight-color: transparent;
    }
    
    .filter-select option {
        font-size: 16px;
    }
}

/* Android specific improvements */
@media screen and (-webkit-min-device-pixel-ratio: 0) {
    .filter-select {
        padding-top: 12px;
        padding-bottom: 12px;
    }
}

/* Ensure select dropdown stays within viewport on mobile */
@media (max-width: 768px) {
    select.filter-select {
        max-width: calc(100vw - 80px);
    }
    
    /* Prevent horizontal scroll when select dropdown opens */
    .filter-group select {
        width: 100%;
        max-width: 100%;
    }
    
    /* Container constraints */
    .sheet-body {
        padding-left: 20px;
        padding-right: 20px;
    }
}

/* Smaller mobile devices */
@media (max-width: 480px) {
    select.filter-select {
        max-width: calc(100vw - 60px);
        font-size: 16px; /* Prevent iOS zoom */
        padding: 10px 14px;
        padding-right: 36px;
    }
    
    .filter-select option {
        font-size: 16px;
        padding: 10px 14px;
        min-height: 40px;
    }
    
    .sheet-body {
        padding-left: 16px;
        padding-right: 16px;
    }
}

/* Extra small devices */
@media (max-width: 360px) {
    select.filter-select {
        max-width: calc(100vw - 50px);
        font-size: 16px;
    }
    
    .filter-select option {
        font-size: 15px;
        padding: 8px 12px;
    }
}

/* Price Inputs */
.price-inputs {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: nowrap;
}

.filter-input {
    flex: 1;
    min-width: 80px;
    padding: 12px 16px;
    border: 1.5px solid #d1d5db;
    border-radius: 10px;
    font-size: 15px;
    color: #1f2937;
    background-color: #fff;
    transition: all 0.2s ease;
}

.filter-input:focus {
    outline: none;
    border-color: var(--main-color-one, #1e40af);
    box-shadow: 0 0 0 3px rgba(30, 64, 175, 0.1);
}

.filter-input::placeholder {
    color: #9ca3af;
}

.price-separator {
    color: #6b7280;
    font-weight: 600;
}

/* Condition Options */
.condition-options {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.condition-radio {
    flex: 1;
    min-width: 80px;
    position: relative;
    cursor: pointer;
}

.condition-radio input[type="radio"] {
    position: absolute;
    opacity: 0;
    cursor: pointer;
}

.radio-label {
    display: block;
    padding: 10px 16px;
    border: 1.5px solid #d1d5db;
    border-radius: 10px;
    text-align: center;
    font-size: 14px;
    font-weight: 500;
    color: #6b7280;
    background-color: #fff;
    transition: all 0.2s ease;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.condition-radio input[type="radio"]:checked + .radio-label {
    border-color: var(--main-color-one, #1e40af);
    background-color: var(--main-color-one, #1e40af);
    color: white;
}

.condition-radio:hover .radio-label {
    border-color: var(--main-color-one, #1e40af);
}

/* Sheet Footer */
.sheet-footer {
    display: flex;
    gap: 12px;
    padding: 16px 20px;
    border-top: 1px solid #e5e7eb;
    background: #f9fafb;
    border-radius: 0 0 20px 20px;
    flex-shrink: 0;
    max-width: 100%;
}

.filter-clear-btn,
.filter-apply-btn {
    flex: 1;
    padding: 14px 20px;
    border: none;
    border-radius: 10px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all 0.2s ease;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.filter-clear-btn {
    background: white;
    color: #6b7280;
    border: 1.5px solid #d1d5db;
}

.filter-clear-btn:hover {
    background: #f3f4f6;
    border-color: #9ca3af;
    color: #374151;
}

.filter-apply-btn {
    background: linear-gradient(135deg, var(--main-color-one, #1e40af) 0%, var(--main-color-two, #3b82f6) 100%);
    color: white;
    box-shadow: 0 2px 8px rgba(30, 64, 175, 0.3);
}

.filter-apply-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(30, 64, 175, 0.4);
}

/* Hide on desktop */
@media (min-width: 768px) {
    .mobile-filter-btn {
        display: none !important;
    }
}

/* Responsive adjustments */
@media (max-width: 480px) {
    .filter-bottom-sheet {
        max-height: 90vh;
    }
    
    .sheet-body {
        padding: 16px;
    }
    
    .sheet-header {
        padding: 10px 16px;
    }
    
    .sheet-footer {
        padding: 12px 16px;
    }
    
    .filter-group {
        margin-bottom: 20px;
    }
    
    .filter-select {
        font-size: 16px; /* Keep 16px to prevent iOS zoom */
        padding: 10px 14px;
        padding-right: 36px;
    }
    
    .filter-input {
        font-size: 16px; /* Keep 16px to prevent iOS zoom */
        padding: 10px 14px;
    }
    
    .filter-select {
        padding-right: 36px;
    }
    
    .condition-options {
        gap: 8px;
    }
    
    .filter-clear-btn,
    .filter-apply-btn {
        padding: 12px 16px;
        font-size: 14px;
    }
}

/* Extra small devices - ensure text never overflows */
@media (max-width: 360px) {
    .sheet-title {
        font-size: 16px;
    }
    
    .filter-label {
        font-size: 13px;
    }
    
    .radio-label {
        padding: 8px 12px;
        font-size: 13px;
    }
}

/* Infinite Scroll Loading Indicator */
#loadingIndicator {
    padding: 2rem 0;
    text-align: center;
}

#loadingIndicator .spinner-border {
    width: 3rem;
    height: 3rem;
    border-width: 0.3rem;
}

#loadingIndicator p {
    margin-top: 1rem;
    font-size: 14px;
    color: #6b7280;
    font-weight: 500;
}

/* Hide desktop pagination when infinite scroll is enabled */
.desktop-pagination {
    display: none !important;
}

/* ============================================
   Mobile Filter/Sort Bar
   ============================================ */

.mobile-filter-sort-bar {
    background: #fff;
    padding: 12px 16px;
    margin-bottom: 16px;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
    transition: all 0.3s ease;
    position: relative;
    z-index: 998;
}

.mobile-filter-sort-bar.sticky {
    position: sticky;
    top: 0;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    animation: slideDown 0.3s ease;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.filter-sort-container {
    display: flex;
    gap: 10px;
    align-items: center;
}

.filter-sort-btn {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 20px;
    border: 1.5px solid #e5e7eb;
    border-radius: 25px;
    background: #fff;
    color: #374151;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
}

.filter-sort-btn:hover {
    border-color: #d1d5db;
    background: #f9fafb;
}

.filter-sort-btn:active {
    transform: scale(0.98);
}

.filter-sort-btn.active {
    border-color: var(--main-color-one, #1e40af);
    background: linear-gradient(135deg, var(--main-color-one, #1e40af) 0%, var(--main-color-two, #3b82f6) 100%);
    color: #fff;
}

.filter-sort-btn i {
    font-size: 18px;
    transition: transform 0.2s ease;
}

.filter-sort-btn.active i.la-angle-down {
    transform: rotate(180deg);
}

/* Filter Badge - Active indicator */
.filter-badge {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 8px;
    height: 8px;
    background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
    border-radius: 50%;
    border: 2px solid #fff;
    box-shadow: 0 2px 4px rgba(239, 68, 68, 0.4);
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% {
        opacity: 1;
        transform: scale(1);
    }
    50% {
        opacity: 0.8;
        transform: scale(1.1);
    }
}

/* Sort Dropdown */
.sort-dropdown {
    position: absolute;
    top: calc(100% + 8px);
    right: 16px;
    left: auto;
    width: calc(50% - 21px);
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 999;
    overflow: hidden;
}

.sort-dropdown.active {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.sort-option {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    color: #374151;
    text-decoration: none;
    font-size: 15px;
    font-weight: 500;
    border-bottom: 1px solid #f3f4f6;
    transition: all 0.2s ease;
}

.sort-option:last-child {
    border-bottom: none;
}

.sort-option:hover {
    background: #f9fafb;
    color: var(--main-color-one, #1e40af);
}

.sort-option.active {
    background: linear-gradient(135deg, rgba(30, 64, 175, 0.1) 0%, rgba(59, 130, 246, 0.1) 100%);
    color: var(--main-color-one, #1e40af);
    font-weight: 600;
}

.sort-option i {
    font-size: 18px;
    opacity: 0.7;
}

.sort-option.active i {
    opacity: 1;
}

/* Responsive adjustments */
@media (max-width: 480px) {
    .mobile-filter-sort-bar {
        padding: 10px 12px;
        margin-bottom: 12px;
    }
    
    .filter-sort-btn {
        padding: 10px 16px;
        font-size: 14px;
    }
    
    .filter-sort-btn i {
        font-size: 16px;
    }
    
    .sort-dropdown {
        right: 12px;
        width: calc(50% - 17px);
    }
    
    .sort-option {
        padding: 12px 14px;
        font-size: 14px;
    }
}

/* Hide on desktop */
@media (min-width: 768px) {
    .mobile-filter-sort-bar {
        display: none !important;
    }
}
