/* iOS Compatibility Styles for Filter Buttons */

/* Force hardware acceleration and proper rendering on iOS */
.filter-buttons-section {
    -webkit-transform: translateZ(0);
    -webkit-backface-visibility: hidden;
    -webkit-perspective: 1000;
    transform: translateZ(0);
    backface-visibility: hidden;
    perspective: 1000;
}

/* iOS Safari specific fixes */
@supports (-webkit-touch-callout: none) {
    .filter-buttons-section {
        display: block !important;
        visibility: visible !important;
        opacity: 1 !important;
        margin-top: 1rem !important;
        margin-bottom: 1.5rem !important;
        padding: 0 !important;
        position: relative !important;
        z-index: 1 !important;
        -webkit-transform: translateZ(0) !important;
        transform: translateZ(0) !important;
    }

    .filter-buttons {
        display: block !important;
        visibility: visible !important;
        opacity: 1 !important;
        width: 100% !important;
    }

    .filter-btn {
        min-height: 48px !important;
        font-size: 16px !important;
        -webkit-appearance: none !important;
        border-radius: 8px !important;
        border: none !important;
        font-weight: 600 !important;
        text-transform: uppercase !important;
        letter-spacing: 0.5px !important;
        box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1) !important;
        transition: all 0.3s ease !important;
        display: block !important;
        visibility: visible !important;
        opacity: 1 !important;
        position: relative !important;
        z-index: 1 !important;
        pointer-events: auto !important;
        cursor: pointer !important;
        padding: 12px 16px !important;
        flex: 1 !important;
    }

    .reset-btn {
        background: #6c757d !important;
        color: white !important;
    }

    .apply-btn {
        background: #dc3545 !important;
        color: white !important;
    }

    .filter-btn:active {
        transform: scale(0.98) !important;
        box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2) !important;
    }

    .filter-btn:hover {
        transform: translateY(-2px) !important;
        box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15) !important;
    }

    /* Prevent iOS zoom on input focus */
    .form-select {
        font-size: 16px !important;
    }

    /* Ensure proper touch targets */
    .filter-btn {
        min-height: 48px !important;
        padding: 12px 16px !important;
    }

    /* Enhanced form styling for iOS */
    .filter-group {
        margin-bottom: 1.5rem !important;
    }

    .form-label {
        margin-bottom: 0.5rem !important;
        font-weight: 600 !important;
        font-size: 1.1em !important;
    }

    .form-select {
        font-size: 16px !important;
        padding: 12px 16px !important;
        border-radius: 8px !important;
        border: 1px solid #ddd !important;
    }

    .form-select:focus {
        border-color: #E12344 !important;
        box-shadow: 0 0 0 0.2rem rgba(225, 35, 68, 0.25) !important;
    }

    /* Filter content styling for iOS */
    .filter-content {
        -webkit-overflow-scrolling: touch !important;
    }
}

/* iPad specific styles */
@media only screen
and (min-device-width: 768px)
and (max-device-width: 1024px)
and (-webkit-min-device-pixel-ratio: 2) {
    .filter-buttons-section {
        margin-top: 1.5rem !important;
        margin-bottom: 2rem !important;
    }

    .filter-btn {
        min-height: 40px !important;
        font-size: 14px !important;
    }
}

/* Force visibility on all iOS devices */
.filter-buttons-section,
.filter-buttons,
.filter-btn {
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
}

/* Additional iOS touch improvements */
.filter-btn {
    -webkit-tap-highlight-color: transparent;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    -khtml-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
}

/* Ensure buttons are clickable on iOS */
.filter-btn {
    cursor: pointer;
    pointer-events: auto;
}

/* High contrast mode support for accessibility */
@media (prefers-contrast: high) {
    .filter-btn {
        border: 2px solid currentColor !important;
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    .filter-btn {
        transition: none !important;
    }
}

/* iPhone specific landscape orientation fixes */
@media only screen
and (max-device-width: 812px)
and (orientation: landscape) {
    .filter-buttons-section {
        margin-top: 0.75rem !important;
        margin-bottom: 1rem !important;
    }

    .filter-btn {
        min-height: 40px !important;
        padding: 8px 12px !important;
        font-size: 14px !important;
    }
}

/* iPhone SE and smaller devices */
@media only screen
and (max-device-width: 375px) {
    .filter-buttons-section {
        margin-top: 0.75rem !important;
        margin-bottom: 1rem !important;
    }

    .filter-btn {
        min-height: 44px !important;
        padding: 10px 12px !important;
        font-size: 15px !important;
    }
}

/* Ensure proper button layout on all iOS devices */
.filter-buttons .d-flex {
    gap: 12px !important;
}

.filter-btn.flex-fill {
    flex: 1 !important;
    min-width: 0 !important;
}

/* Fix for iOS Safari button text wrapping */
.filter-btn .btn-text {
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
}

/* iOS Safari specific button state fixes */
@supports (-webkit-touch-callout: none) {
    .filter-btn:focus {
        outline: none !important;
        box-shadow: 0 0 0 2px rgba(225, 35, 68, 0.5) !important;
    }

    .filter-btn:focus:not(:focus-visible) {
        box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1) !important;
    }
}

/* Modal-specific iOS fixes */
@supports (-webkit-touch-callout: none) {
    /* Ensure modal content is properly scrollable */
    .modal-body {
        -webkit-overflow-scrolling: touch !important;
        max-height: 80vh !important;
        overflow-y: auto !important;
    }

    /* Ensure filter content fits within modal */
    .filter-content {
        max-height: calc(80vh - 200px) !important;
        overflow-y: auto !important;
        -webkit-overflow-scrolling: touch !important;
    }

    /* Ensure buttons are always visible within modal */
    .filter-buttons-section {
        position: relative !important;
        bottom: auto !important;
        left: auto !important;
        right: auto !important;
        background: transparent !important;
        box-shadow: none !important;
        border-top: none !important;
        border-radius: 0 !important;
        margin-top: 1rem !important;
        margin-bottom: 1.5rem !important;
        padding: 0 !important;
    }
}