/**
 * Mobile-First Optimizations
 * אופטימיזציה מלאה למובייל
 */

/* ==========================================
   Touch-Friendly Targets (44px minimum)
   ========================================== */

@media (max-width: 768px) {
    button,
    a,
    .btn,
    input[type="button"],
    input[type="submit"],
    .clickable {
        min-height: 44px;
        min-width: 44px;
    }
    
    /* Larger touch targets for mobile */
    .mobile-touch-large {
        padding: var(--space-4) !important;
    }
}

/* ==========================================
   Mobile Bottom Navigation
   ========================================== */

.mobile-bottom-nav {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: white;
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.1);
    z-index: var(--z-sticky);
    padding: var(--space-2) 0;
}

@media (max-width: 768px) {
    .mobile-bottom-nav {
        display: flex;
        justify-content: space-around;
        align-items: center;
    }
    
    /* Add padding to body to prevent content hiding behind nav */
    body {
        padding-bottom: 70px;
    }
}

.mobile-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-1);
    padding: var(--space-2) var(--space-3);
    color: var(--neutral-600);
    text-decoration: none;
    font-size: var(--text-xs);
    transition: var(--transition-fast);
    flex: 1;
    max-width: 80px;
}

.mobile-nav-item i {
    font-size: 20px;
}

.mobile-nav-item.active,
.mobile-nav-item:active {
    color: var(--primary-600);
    background: var(--primary-50);
    border-radius: var(--radius-lg);
}

/* ==========================================
   Swipe Gestures
   ========================================== */

.swipeable {
    touch-action: pan-y;
    -webkit-user-select: none;
    user-select: none;
}

/* ==========================================
   Mobile Filter Sheet (Bottom Sheet)
   ========================================== */

.mobile-filter-sheet {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: white;
    border-radius: var(--radius-2xl) var(--radius-2xl) 0 0;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.15);
    z-index: var(--z-modal);
    transform: translateY(100%);
    transition: transform var(--duration-300) var(--ease-smooth);
}

.mobile-filter-sheet.active {
    transform: translateY(0);
}

.mobile-filter-sheet-header {
    position: sticky;
    top: 0;
    background: white;
    padding: var(--space-4);
    border-bottom: 1px solid var(--neutral-200);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.mobile-filter-sheet-handle {
    width: 40px;
    height: 4px;
    background: var(--neutral-300);
    border-radius: var(--radius-full);
    margin: var(--space-2) auto;
}

/* ==========================================
   Pull to Refresh
   ========================================== */

.pull-to-refresh {
    position: relative;
}

.pull-to-refresh-indicator {
    position: absolute;
    top: -60px;
    left: 50%;
    transform: translateX(-50%);
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition-base);
}

.pull-to-refresh.pulling .pull-to-refresh-indicator {
    top: 20px;
}

/* ==========================================
   Mobile-Optimized Forms
   ========================================== */

@media (max-width: 768px) {
    input[type="text"],
    input[type="email"],
    input[type="tel"],
    input[type="number"],
    select,
    textarea {
        font-size: 16px; /* Prevents zoom on iOS */
        -webkit-appearance: none;
    }
    
    /* Full-width buttons on mobile */
    .btn-block-mobile {
        display: block;
        width: 100%;
    }
}

/* ==========================================
   Mobile Card Layout
   ========================================== */

@media (max-width: 768px) {
    .room-card {
        margin-bottom: var(--space-4);
    }
    
    /* Horizontal scroll for card rows */
    .mobile-scroll-x {
        display: flex;
        overflow-x: auto;
        scroll-snap-type: x mandatory;
        -webkit-overflow-scrolling: touch;
        gap: var(--space-4);
        padding: var(--space-4);
        margin: 0 calc(var(--space-4) * -1);
    }
    
    .mobile-scroll-x > * {
        flex: 0 0 80%;
        scroll-snap-align: start;
    }
    
    /* Hide scrollbar */
    .mobile-scroll-x::-webkit-scrollbar {
        display: none;
    }
}

/* ==========================================
   Mobile Menu (Hamburger)
   ========================================== */

.mobile-menu-toggle {
    display: none;
    background: none;
    border: none;
    padding: var(--space-2);
    cursor: pointer;
}

@media (max-width: 768px) {
    .mobile-menu-toggle {
        display: block;
    }
    
    .desktop-nav {
        display: none !important;
    }
}

.mobile-menu {
    position: fixed;
    top: 0;
    right: 0;
    width: 280px;
    height: 100vh;
    background: white;
    box-shadow: -2px 0 10px rgba(0, 0, 0, 0.1);
    transform: translateX(100%);
    transition: transform var(--duration-300) var(--ease-smooth);
    z-index: var(--z-modal);
    overflow-y: auto;
}

[dir="rtl"] .mobile-menu {
    right: auto;
    left: 0;
    transform: translateX(-100%);
}

.mobile-menu.active {
    transform: translateX(0);
}

.mobile-menu-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: calc(var(--z-modal) - 1);
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--duration-300);
}

.mobile-menu-overlay.active {
    opacity: 1;
    pointer-events: all;
}

/* ==========================================
   Mobile-Specific Utilities
   ========================================== */

/* Hide on mobile */
@media (max-width: 768px) {
    .hide-mobile {
        display: none !important;
    }
}

/* Show only on mobile */
.show-mobile {
    display: none !important;
}

@media (max-width: 768px) {
    .show-mobile {
        display: block !important;
    }
    
    .show-mobile-flex {
        display: flex !important;
    }
}

/* ==========================================
   Safe Area Insets (iOS notch support)
   ========================================== */

@supports (padding: env(safe-area-inset-bottom)) {
    .mobile-bottom-nav {
        padding-bottom: calc(var(--space-2) + env(safe-area-inset-bottom));
    }
    
    .mobile-cta-bar {
        padding-bottom: calc(var(--space-3) + env(safe-area-inset-bottom));
    }
}

/* ==========================================
   Viewport Height Fix for Mobile Browsers
   ========================================== */

.full-height-mobile {
    min-height: 100vh;
    min-height: -webkit-fill-available;
}

/* ==========================================
   Mobile Performance Optimizations
   ========================================== */

@media (max-width: 768px) {
    /* Reduce motion on mobile for better performance */
    * {
        animation-duration: 0.5s !important;
        transition-duration: 0.2s !important;
    }
    
    /* Optimize images */
    img {
        image-rendering: -webkit-optimize-contrast;
    }
    
    /* GPU acceleration for animations */
    .room-card,
    .floating-cta-btn,
    .mobile-nav-item {
        will-change: transform;
    }
}

