/* Therapist Pages Mobile Optimization */

/* Desktop: Hide mobile modal completely */
@media (min-width: 769px) {
    .filter-modal,
    .modal-backdrop {
        display: none !important;
    }
}

/* Mobile Container Fixes */
@media (max-width: 768px) {
    /* Remove horizontal overflow */
    body {
        overflow-x: hidden !important;
    }
    
    .container {
        padding-left: 1rem !important;
        padding-right: 1rem !important;
        max-width: 100% !important;
    }
    
    /* Therapist Grid - Single Column on Mobile */
    #therapists-grid {
        grid-template-columns: 1fr !important;
        gap: 1rem !important;
    }
    
    /* Therapist Card Mobile Optimization */
    .therapist-card {
        margin-bottom: 1rem;
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3) !important;
    }
    
    /* Filter Chips - Horizontal Scroll */
    .filter-chips {
        display: flex;
        overflow-x: auto;
        overflow-y: hidden;
        gap: 0.5rem;
        padding: 0.5rem 0;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none; /* Firefox */
        -ms-overflow-style: none; /* IE/Edge */
    }
    
    .filter-chips::-webkit-scrollbar {
        display: none; /* Chrome/Safari */
    }
    
    .filter-chip {
        flex-shrink: 0;
        padding: 0.5rem 1rem;
        border-radius: 20px;
        font-size: 0.85rem;
        white-space: nowrap;
        background: rgba(212, 175, 55, 0.1);
        border: 1px solid rgba(212, 175, 55, 0.3);
        color: #d4af37;
        text-decoration: none;
        transition: all 0.3s;
    }
    
    .filter-chip.active {
        background: linear-gradient(135deg, #d4af37 0%, #f4e5c3 50%, #d4af37 100%);
        color: #0a0a0a;
        font-weight: 600;
    }
    
    /* Mobile Filter Modal */
    .filter-modal {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        background: #1a1a1a;
        border-top-left-radius: 20px;
        border-top-right-radius: 20px;
        padding: 1.5rem;
        transform: translateY(100%);
        transition: transform 0.3s cubic-bezier(0.25, 0.8, 0.25, 1), opacity 0.3s ease;
        z-index: 10000;
        max-height: 85vh;
        overflow-y: auto;
        box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.5);
        border-top: 2px solid #d4af37;
        visibility: hidden;
        opacity: 0;
        /* 平滑滚动 */
        -webkit-overflow-scrolling: touch;
    }

    .filter-modal.open {
        transform: translateY(0);
        visibility: visible;
        opacity: 1;
    }

    .modal-backdrop {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0, 0, 0, 0.7);
        backdrop-filter: blur(4px);
        -webkit-backdrop-filter: blur(4px);
        opacity: 0;
        visibility: hidden;
        transition: opacity 0.3s ease, visibility 0s linear 0.3s;
        z-index: 9999;
        pointer-events: none;
        display: none;
    }

    .modal-backdrop.open {
        opacity: 1;
        visibility: visible;
        pointer-events: auto;
        display: block;
        transition: opacity 0.3s ease;
    }
    
    .modal-handle {
        width: 40px;
        height: 4px;
        background: rgba(212, 175, 55, 0.5);
        border-radius: 2px;
        margin: 0 auto 1rem;
    }
    
    /* Therapist Detail Page Mobile */
    .lg\:col-span-2,
    .lg\:col-span-1 {
        grid-column: span 1 !important;
    }
    
    /* Photo Gallery Mobile */
    .therapist-image {
        border-radius: 12px !important;
    }
    
    /* Sticky Booking Card on Mobile */
    .sticky {
        position: relative !important;
        top: 0 !important;
    }
    
    /* Mobile Bottom Spacing for Bottom Nav */
    main {
        padding-bottom: 80px !important;
    }
    
    /* Service Cards Mobile */
    .space-y-4 > div {
        padding: 1rem !important;
        font-size: 0.9rem;
    }
    
    /* Stats Grid Mobile */
    .grid-cols-2 {
        gap: 0.5rem !important;
    }
    
    .grid-cols-4 {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 0.5rem !important;
    }
    
    /* Photo Gallery Mobile */
    .grid-cols-4.md\:grid-cols-6 {
        grid-template-columns: repeat(4, 1fr) !important;
    }
    
    /* Reviews Mobile */
    .space-y-4 {
        gap: 1rem !important;
    }
    
    /* Pagination Mobile */
    nav.inline-flex {
        flex-wrap: wrap;
        gap: 0.25rem;
    }
    
    nav.inline-flex a {
        padding: 0.5rem 0.75rem !important;
        font-size: 0.85rem;
    }
    
    /* Mobile Typography */
    h1 {
        font-size: 1.5rem !important;
        line-height: 1.3 !important;
    }
    
    h2 {
        font-size: 1.25rem !important;
        line-height: 1.4 !important;
    }
    
    h3 {
        font-size: 1.1rem !important;
    }
    
    /* Mobile Buttons */
    .btn-gold,
    .btn-outline-gold {
        padding: 0.75rem 1.5rem !important;
        font-size: 0.9rem !important;
    }
    
    /* Mobile Image Optimization */
    img {
        image-rendering: -webkit-optimize-contrast;
        image-rendering: crisp-edges;
    }
    
    /* Touch Feedback */
    .therapist-card,
    .filter-chip,
    a,
    button {
        -webkit-tap-highlight-color: rgba(212, 175, 55, 0.2);
    }
    
    /* Prevent Text Selection on Tap */
    .filter-chip,
    .therapist-card h3,
    button {
        -webkit-user-select: none;
        user-select: none;
    }
    
    /* Mobile Sidebar Hidden */
    aside.lg\:w-1\/4 {
        display: none !important;
    }
    
    /* Main Content Full Width on Mobile */
    main.lg\:w-3\/4 {
        width: 100% !important;
    }
    
    /* Mobile Filter Toggle */
    #mobile-filter-toggle {
        display: inline-flex !important;
        align-items: center;
        gap: 0.5rem;
    }
    
    /* Filters Mobile Container */
    .filters-mobile {
        background: rgba(212, 175, 55, 0.05);
        border: 1px solid rgba(212, 175, 55, 0.2);
        border-radius: 12px;
        padding: 1rem;
        margin-bottom: 1rem;
    }
}

/* Tablet Optimization (768px - 1024px) */
@media (min-width: 768px) and (max-width: 1024px) {
    #therapists-grid {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 1.5rem !important;
    }
    
    .container {
        padding-left: 2rem !important;
        padding-right: 2rem !important;
    }
}

/* Small Mobile (< 375px) */
@media (max-width: 374px) {
    .container {
        padding-left: 0.75rem !important;
        padding-right: 0.75rem !important;
    }
    
    .therapist-card {
        font-size: 0.85rem;
    }
    
    h1 {
        font-size: 1.25rem !important;
    }
    
    h2 {
        font-size: 1.1rem !important;
    }
    
    .grid-cols-2 {
        grid-template-columns: 1fr !important;
    }
}

/* Landscape Mobile */
@media (max-height: 500px) and (orientation: landscape) {
    .filter-modal {
        max-height: 90vh;
    }
    
    .sticky {
        position: relative !important;
    }
}

/* iOS Safari Specific Fixes */
@supports (-webkit-touch-callout: none) {
    /* Fix for iOS Safari bottom nav overlap */
    main {
        padding-bottom: calc(80px + env(safe-area-inset-bottom)) !important;
    }
    
    .filter-modal {
        padding-bottom: calc(1.5rem + env(safe-area-inset-bottom));
    }
    
    /* Prevent rubber band scrolling */

    
    /* Fix for iOS Safari viewport height */
    .filter-modal {
        max-height: -webkit-fill-available;
    }
}

/* Dark Mode Enhancements */
@media (prefers-color-scheme: dark) {
    /* Already dark, but ensure consistency */
    body {
        background: #0a0a0a !important;
        color: #ffffff !important;
    }
}

/* Reduce Motion for Accessibility */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* High Contrast Mode */
@media (prefers-contrast: high) {
    .therapist-card,
    .filter-modal,
    .filter-chip {
        border-width: 2px !important;
    }
}

/* Performance Optimizations */
.therapist-card,
.filter-modal,
.filter-chip {
    will-change: transform;
    transform: translateZ(0);
    backface-visibility: hidden;
}

/* Smooth Scrolling */
html {
    scroll-behavior: smooth;
}

.filter-chips {
    scroll-behavior: smooth;
}

/* Loading States (DISABLED - 直接显示所有图片) */
.lazy-load {
    opacity: 1 !important;
    transition: opacity 0.3s;
}

.lazy-load.loaded {
    opacity: 1 !important;
}

