/* Mobile App Experience - iOS/Android Style */

/* ===== ROOT VARIABLES ===== */
:root {
    --safe-area-inset-top: env(safe-area-inset-top, 0px);
    --safe-area-inset-bottom: env(safe-area-inset-bottom, 0px);
    --bottom-nav-height: 70px;
}

/* ===== iOS-STYLE SMOOTH SCROLLING ===== */
html {
    scroll-behavior: smooth;
    -webkit-tap-highlight-color: transparent;
}

body {

    -webkit-overflow-scrolling: touch;
    touch-action: pan-y;
}

/* ===== MOBILE OPTIMIZATIONS ===== */
@media (max-width: 768px) {

    /* Add padding for bottom navigation */
    main {
        padding-bottom: calc(var(--bottom-nav-height) + var(--safe-area-inset-bottom) + 20px);
        min-height: 100vh;
    }

    /* Header adjustments */
    nav.sticky {
        padding-top: var(--safe-area-inset-top);
    }

    /* Hero section mobile optimization */
    .hero-section {
        min-height: calc(100vh - 60px);
        padding: 2rem 1rem;
    }

    /* Main View Background Fix for Mobile */
    .mainView {
        height: calc(100vh - 55px) !important;
        min-height: 500px !important;
        max-height: 100vh !important;
        overflow: hidden;
    }

    .mainViewCont {
        width: 100% !important;
        height: 100% !important;
        overflow: hidden;
    }

    .mainViewCont::after {
        background-position: center center !important;
        background-size: cover !important;
        background-attachment: scroll !important;
        width: 100% !important;
        height: 100% !important;
        object-fit: cover !important;
    }

    .hero-title {
        font-size: 2rem !important;
        letter-spacing: 3px !important;
        line-height: 1.2;
    }

    .hero-subtitle {
        font-size: 0.9rem !important;
        letter-spacing: 2px !important;
    }

    /* Card optimizations */
    .therapist-card,
    .concept-card,
    .service-box {
        border-radius: 12px;
        overflow: hidden;
        box-shadow: 0 2px 8px rgba(212, 175, 55, 0.15);
    }

    /* Touch-friendly buttons */
    .btn-gold,
    .btn-outline-gold,
    button,
    a.btn {
        min-height: 44px;
        border-radius: 12px;
        font-size: 0.95rem;
        padding: 14px 24px;
        cursor: pointer;
        -webkit-tap-highlight-color: transparent;
        touch-action: manipulation;
    }

    /* Touch feedback */
    .btn-gold:active,
    .btn-outline-gold:active {
        transform: scale(0.96);
        transition: transform 0.1s;
    }

    /* Input fields */
    input,
    textarea,
    select {
        font-size: 16px !important;
        /* Prevent zoom on iOS */
        min-height: 44px;
        border-radius: 12px;
        padding: 12px 16px;
    }

    /* Section padding */
    section {
        padding: 3rem 1rem;
    }

    .container {
        padding-left: 1rem;
        padding-right: 1rem;
    }
}

/* ===== BOTTOM NAVIGATION BAR ===== */
.bottom-nav {
    /* 最强的固定定位 */
    position: fixed !important;
    bottom: 0 !important;
    left: 0 !important;
    right: 0 !important;
    width: 100vw !important;
    height: var(--bottom-nav-height);
    background: linear-gradient(180deg, rgba(10, 10, 10, 0.95) 0%, rgba(0, 0, 0, 0.98) 100%);
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    border-top: 1px solid rgba(212, 175, 55, 0.4);
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.5), 0 -1px 0 rgba(212, 175, 55, 0.1);
    z-index: 999999 !important;
    padding-bottom: var(--safe-area-inset-bottom);
    display: none;
    /* 强制GPU加速和固定位置 */
    transform: translate3d(0, 0, 0) !important;
    -webkit-transform: translate3d(0, 0, 0) !important;
    will-change: auto !important;
    backface-visibility: hidden !important;
    -webkit-backface-visibility: hidden !important;
    /* 防止任何移动 */
    overscroll-behavior: none !important;
    /* 防止touch事件影响 */
    touch-action: none !important;
    pointer-events: auto !important;
    /* 确保不受父元素影响 */
    contain: layout style paint !important;
    isolation: isolate !important;
}

@media (max-width: 768px) {
    .bottom-nav {
        display: flex !important;
        align-items: center !important;
        justify-content: space-around !important;
        flex-direction: row !important;
        /* Additional fixes for mobile */
        position: fixed !important;
        bottom: 0 !important;
        margin: 0 !important;
        /* 防止滚动时移动 */
        -webkit-overflow-scrolling: auto !important;
    }
}

.bottom-nav-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    color: #888;
    padding: 8px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    -webkit-tap-highlight-color: transparent;
    position: relative;
    /* 确保子元素可以正常点击 */
    pointer-events: auto !important;
    touch-action: manipulation !important;
    -webkit-touch-action: manipulation !important;
}

.bottom-nav-item::before {
    content: '';
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%) scaleX(0);
    width: 40px;
    height: 3px;
    background: linear-gradient(90deg, transparent, #d4af37, transparent);
    border-radius: 0 0 3px 3px;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.bottom-nav-item:active {
    transform: scale(0.92);
}

.bottom-nav-item i {
    font-size: 1.3rem;
    margin-bottom: 4px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.bottom-nav-item span {
    font-size: 0.7rem;
    font-weight: 600;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    display: block;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.bottom-nav-item.active {
    color: #d4af37;
}

.bottom-nav-item.active::before {
    transform: translateX(-50%) scaleX(1);
}

.bottom-nav-item.active i {
    transform: translateY(-3px) scale(1.1);
    filter: drop-shadow(0 2px 4px rgba(212, 175, 55, 0.5));
}

.bottom-nav-item.active span {
    font-weight: 700;
}

/* Notification badge */
.bottom-nav-badge {
    position: absolute;
    top: 4px;
    right: calc(50% - 8px);
    background: #ef4444;
    color: white;
    border-radius: 10px;
    padding: 2px 6px;
    font-size: 0.65rem;
    font-weight: 700;
    min-width: 18px;
    text-align: center;
}

/* ===== MOBILE HEADER ENHANCEMENTS ===== */
@media (max-width: 768px) {
    nav {
        padding: 0.75rem 1rem;
        box-shadow: 0 2px 10px rgba(0, 0, 0, 0.5), 0 1px 0 rgba(212, 175, 55, 0.2);
    }

    .logo-text {
        font-size: 1.3rem !important;
        letter-spacing: 2px !important;
        text-shadow: 0 2px 8px rgba(212, 175, 55, 0.3);
    }

    .logo-text i {
        animation: pulse 2s infinite;
    }

    @keyframes pulse {

        0%,
        100% {
            transform: scale(1);
            opacity: 1;
        }

        50% {
            transform: scale(1.05);
            opacity: 0.8;
        }
    }

    /* Hide desktop menu on mobile */
    nav .hidden.md\:flex {
        display: none !important;
    }

    /* Mobile menu improvements */
    #mobile-menu {
        background: rgba(10, 10, 10, 0.98);
        backdrop-filter: blur(20px);
        padding: 1rem;
        border-top: 1px solid rgba(212, 175, 55, 0.3);
        margin-top: 0.5rem;
        border-radius: 12px 12px 0 0;
    }

    #mobile-menu a {
        padding: 12px 16px;
        margin: 4px 0;
        border-radius: 8px;
        color: #cccccc !important;
        transition: all 0.2s;
    }

    #mobile-menu a:hover,
    #mobile-menu a:active {
        background: rgba(212, 175, 55, 0.1);
        color: #d4af37 !important;
    }

    #mobile-menu-button {
        padding: 8px;
        border-radius: 8px;
        transition: all 0.2s;
    }

    #mobile-menu-button:active {
        transform: scale(0.9);
        background: rgba(212, 175, 55, 0.1);
    }
}

/* ===== PULL TO REFRESH INDICATOR ===== */
.pull-to-refresh {
    position: fixed;
    top: calc(var(--safe-area-inset-top) + 60px);
    left: 50%;
    transform: translateX(-50%) scale(0);
    background: rgba(212, 175, 55, 0.9);
    color: #0a0a0a;
    padding: 8px 20px;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 600;
    z-index: 1000;
    transition: transform 0.2s;
    box-shadow: 0 4px 12px rgba(212, 175, 55, 0.3);
}

.pull-to-refresh.active {
    transform: translateX(-50%) scale(1);
}

/* ===== SWIPE GESTURES ===== */
.swipe-item {
    position: relative;
    transition: transform 0.2s ease-out;
}

.swipe-actions {
    position: absolute;
    top: 0;
    right: 0;
    height: 100%;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 0 16px;
}

.swipe-action-btn {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    transition: all 0.2s;
}

.swipe-action-btn:active {
    transform: scale(0.9);
}

/* ===== LOADING STATES ===== */
.skeleton {
    background: linear-gradient(90deg,
            rgba(212, 175, 55, 0.1) 25%,
            rgba(212, 175, 55, 0.2) 50%,
            rgba(212, 175, 55, 0.1) 75%);
    background-size: 200% 100%;
    animation: skeleton-loading 1.5s infinite;
    border-radius: 8px;
}

@keyframes skeleton-loading {
    0% {
        background-position: 200% 0;
    }

    100% {
        background-position: -200% 0;
    }
}

/* ===== FLOATING ACTION BUTTON ===== */
.fab {
    position: fixed;
    bottom: calc(var(--bottom-nav-height) + var(--safe-area-inset-bottom) + 16px);
    right: 16px;
    width: 56px;
    height: 56px;
    background: linear-gradient(135deg, #d4af37 0%, #f4e5c3 100%);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #0a0a0a;
    font-size: 1.5rem;
    box-shadow: 0 4px 16px rgba(212, 175, 55, 0.4);
    z-index: 998;
    transition: all 0.3s ease;
    cursor: pointer;
}

.fab:active {
    transform: scale(0.9);
}

@media (min-width: 769px) {
    .fab {
        bottom: 24px;
    }
}

/* ===== MODAL/SHEET ANIMATIONS ===== */
@media (max-width: 768px) {
    .modal-mobile {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        background: #1a1a1a;
        border-radius: 20px 20px 0 0;
        padding: 20px;
        padding-bottom: calc(20px + var(--safe-area-inset-bottom));
        transform: translateY(100%);
        transition: transform 0.3s ease;
        z-index: 1001;
        max-height: 90vh;
        overflow-y: auto;
    }

    .modal-mobile.active {
        transform: translateY(0);
    }

    .modal-handle {
        width: 40px;
        height: 4px;
        background: rgba(212, 175, 55, 0.3);
        border-radius: 2px;
        margin: 0 auto 16px;
    }
}

/* ===== HAPTIC FEEDBACK VISUAL ===== */
@keyframes haptic-pulse {
    0% {
        transform: scale(1);
    }

    50% {
        transform: scale(0.95);
    }

    100% {
        transform: scale(1);
    }
}

.haptic-feedback {
    animation: haptic-pulse 0.1s ease;
}

/* ===== SMOOTH TRANSITIONS ===== */
* {
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ===== CARD STACK EFFECT ===== */
@media (max-width: 768px) {
    .card-stack {
        position: relative;
        padding: 16px;
    }

    .card-stack>* {
        margin-bottom: 12px;
        border-radius: 16px;
        box-shadow: 0 2px 12px rgba(0, 0, 0, 0.3);
    }
}

/* ===== TOUCH RIPPLE EFFECT ===== */
.ripple {
    position: relative;
    overflow: hidden;
}

.ripple::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(212, 175, 55, 0.3);
    transform: translate(-50%, -50%);
    transition: width 0.3s, height 0.3s;
}

.ripple:active::after {
    width: 300px;
    height: 300px;
}

/* ===== STATUS BAR OVERLAY ===== */
.status-bar-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--safe-area-inset-top);
    background: #0a0a0a;
    z-index: 1000;
}

/* ===== OPTIMIZED GRID FOR MOBILE ===== */
@media (max-width: 768px) {
    .grid {
        gap: 12px;
    }

    .therapist-card {
        margin-bottom: 16px;
    }
}

/* ===== STICKY FILTERS BAR ===== */
@media (max-width: 768px) {
    .filters-mobile {
        position: sticky;
        top: 60px;
        background: rgba(10, 10, 10, 0.95);
        backdrop-filter: blur(20px);
        padding: 12px 16px;
        z-index: 50;
        border-bottom: 1px solid rgba(212, 175, 55, 0.2);
        margin: 0 -1rem;
    }

    .filter-chips {
        display: flex;
        gap: 8px;
        overflow-x: auto;
        scrollbar-width: none;
        -ms-overflow-style: none;
    }

    .filter-chips::-webkit-scrollbar {
        display: none;
    }

    .filter-chip {
        flex-shrink: 0;
        padding: 8px 16px;
        background: rgba(212, 175, 55, 0.1);
        border: 1px solid rgba(212, 175, 55, 0.3);
        border-radius: 20px;
        color: #d4af37;
        font-size: 0.85rem;
        white-space: nowrap;
        transition: all 0.2s;
    }

    .filter-chip.active {
        background: #d4af37;
        color: #0a0a0a;
    }

    .filter-chip:active {
        transform: scale(0.95);
    }
}

/* ===== EMPTY STATE ===== */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: #888;
}

.empty-state i {
    font-size: 4rem;
    color: rgba(212, 175, 55, 0.3);
    margin-bottom: 16px;
}

.empty-state h3 {
    font-size: 1.2rem;
    color: #cccccc;
    margin-bottom: 8px;
}

.empty-state p {
    color: #888;
    font-size: 0.9rem;
}

/* ===== PERFORMANCE OPTIMIZATIONS ===== */
.will-change-transform {
    will-change: transform;
}

.gpu-accelerated {
    transform: translateZ(0);
    -webkit-transform: translateZ(0);
}

/* ===== DARK MODE OPTIMIZATIONS ===== */
@media (prefers-color-scheme: dark) {
    body {
        background: #0a0a0a;
    }
}

/* ===== REDUCE MOTION ===== */
@media (prefers-reduced-motion: reduce) {

    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* ===== HORIZONTAL SCROLL (iOS-style) ===== */
.scrollbar-hide {
    -ms-overflow-style: none;
    scrollbar-width: none;
}

.scrollbar-hide::-webkit-scrollbar {
    display: none;
}

/* Snap scrolling for cards */
@media (max-width: 1024px) {
    .snap-x {
        scroll-snap-type: x mandatory;
        -webkit-overflow-scrolling: touch;
    }

    .snap-center {
        scroll-snap-align: center;
        scroll-snap-stop: always;
    }

    /* Add padding to first and last items */
    .snap-x> :first-child {
        margin-left: 1rem;
    }

    .snap-x> :last-child {
        margin-right: 1rem;
    }
}

/* ===== MOBILE THERAPIST CARDS ===== */
@media (max-width: 768px) {
    .therapist-card {
        min-width: 160px;
        max-width: 160px;
    }

    .therapist-image {
        height: 200px;
    }

    .therapist-info {
        padding: 12px;
    }
}

/* ===== MODAL BOTTOM SHEET ===== */
.filter-modal {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: #1a1a1a;
    border-radius: 20px 20px 0 0;
    padding: 20px;
    padding-bottom: calc(20px + var(--safe-area-inset-bottom));
    transform: translateY(100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.3s ease;
    z-index: 1000;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.5);
    /* 默认隐藏 */
    visibility: hidden;
    opacity: 0;
    display: block;
}

.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: 999;
    pointer-events: none;
    /* 默认隐藏 */
    display: none;
}

.modal-backdrop.open {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    display: block;
    transition: opacity 0.3s ease;
}

/* ===== IMPROVED TOUCH TARGETS ===== */
@media (max-width: 768px) {

    a,
    button,
    input,
    select,
    textarea {
        -webkit-tap-highlight-color: rgba(212, 175, 55, 0.1);
    }

    /* Larger tap targets */
    .btn-gold,
    .btn-outline-gold {
        padding: 14px 28px;
        font-size: 0.95rem;
    }

    /* Card spacing */
    .space-y-4>* {
        margin-bottom: 12px;
    }
}

/* ===== SAFE AREA SUPPORT ===== */
@supports(padding: max(0px)) {
    body {
        padding-top: min(var(--safe-area-inset-top), 0px);
    }
}

/* ===== ENSURE TEXT IS VISIBLE IN PORTRAIT MODE ===== */
@media (max-width: 768px) and (orientation: portrait) {
    .bottom-nav-item span {
        display: block !important;
    }
}

/* ===== LANDSCAPE MODE ===== */
@media (max-width: 768px) and (orientation: landscape) {
    .hero-section {
        min-height: 100vh;
    }

    .bottom-nav {
        height: 56px;
    }

    .bottom-nav-item span {
        display: none;
    }

    .bottom-nav-item i {
        font-size: 1.1rem;
        margin-bottom: 0;
    }
}