/**
 * Mobile-Specific Styles
 * Optimizations for iPhone 13 and other mobile devices
 */

/* ============================================
   PREVENT HORIZONTAL SCROLL ON MOBILE
   ============================================ */

@media (max-width: 768px) {
    html,
    body {
        overflow-x: hidden;
        max-width: 100%;
    }
}

/* ============================================
   TAP TARGET SIZES (44x44px minimum for iOS)
   ============================================ */

@media (max-width: 768px) {
    /* Contact bar buttons - use same styling as desktop */

    /* Action buttons on flight cards */
    .action-btn {
        padding: 12px 16px;
        min-height: 44px;
        min-width: 44px;
    }

    .book-btn {
        padding: 12px 20px;
        min-height: 44px;
        font-size: 1rem;
    }

    /* Navigation tabs */
    .search-tab {
        min-height: 48px;
        padding: 12px 16px;
        font-size: 1rem;
    }

    /* Airport search options */
    .airport-option,
    .city-option {
        min-height: 52px;
        padding: 14px 16px;
    }

    .nested-airport {
        min-height: 48px;
        padding: 12px 16px 12px 32px;
    }

    /* Search button */
    .show-flights-btn {
        min-height: 48px;
        padding: 14px 24px;
        font-size: 1.0625rem;
    }

    /* Reset search button - tap target size */
    .reset-btn {
        min-height: 44px;
        min-width: 44px;
        padding: 10px;
    }

    /* Note: .reset-btn is hidden on mobile via styles.css */

    /* Navigation toggle button */
    .nav-toggle {
        min-height: 44px;
        min-width: 44px;
        padding: 8px;
    }

    /* Close buttons on modals */
    .cancel-booking-modal-close,
    .modal-close {
        min-height: 44px;
        min-width: 44px;
        font-size: 32px;
    }

    /* Form inputs */
    input[type="text"],
    input[type="email"],
    input[type="tel"],
    input[type="number"],
    textarea,
    select {
        min-height: 44px;
        padding: 12px 16px;
        font-size: 16px;
    }
}

/* ============================================
   MOBILE NAVIGATION
   ============================================ */

@media (max-width: 768px) {
    .nav-container {
        padding: 0.5rem 1rem;
        height: auto;
        min-height: 60px;
        display: flex;
        justify-content: space-between;
        align-items: center;
        gap: 0.5rem;
    }

    /* Hide tagline stats on mobile */
    .nav-tagline {
        display: none !important;
    }

    /* Show compact logo on mobile */
    .logo-full {
        display: none;
    }

    .logo-compact {
        display: block;
    }

    .nav-logo {
        flex: 0 0 auto;
    }

    /* Mobile navigation menu - positioned on the right */
    .nav-menu {
        position: static !important;
        display: flex !important;
        flex-direction: row !important;
        align-items: center;
        gap: 0.5rem;
        padding: 0;
        margin-left: auto;
        flex: 0 0 auto;
        background: transparent !important;
        transform: none !important;
        box-shadow: none;
        overflow-y: visible;
    }

    /* Hide regular nav items on mobile, show only currency and auth */
    .nav-item:not(.currency-selector-wrapper, .user-menu, .login-btn-wrapper) {
        display: none !important;
    }

    /* Ensure currency selector and auth items are visible and aligned right */
    .nav-item.currency-selector-wrapper,
    .nav-item.user-menu,
    .nav-item.login-btn-wrapper {
        display: flex !important;
        padding: 0;
        margin: 0;
        min-height: auto;
        border: none;
    }

    .nav-toggle {
        display: none !important;
    }

    /* Compact currency selector on mobile */
    .currency-selector-btn {
        padding: 0.4rem 0.6rem;
        font-size: 0.875rem;
        min-height: 36px;
    }

    /* Compact user menu on mobile */
    .user-avatar {
        width: 32px !important;
        height: 32px !important;
    }

    .user-name {
        display: none;
    }

    /* Compact login button on mobile */
    .login-btn {
        padding: 0.5rem 0.75rem;
        font-size: 0.875rem;
        min-height: 36px;
    }
}

/* ============================================
   MOBILE CONTACT BAR
   ============================================ */

@media (max-width: 768px) {
    .contact-container {
        padding: 0.5rem 1rem;
        gap: 0.5rem;
        flex-wrap: wrap;
    }

    .contact-label {
        width: 100%;
        text-align: center;
        font-size: 0.8125rem;
        padding-bottom: 0.25rem;
    }

    .contact-phone {
        font-size: 1rem;
        margin-right: 0;
    }
}

@media (max-width: 480px) {
    /* Buttons render exactly the same as desktop - no overrides */
}

/* ============================================
   MOBILE SEARCH FORM
   ============================================ */

@media (max-width: 768px) {
    .search-container {
        margin: 1rem;
    }

    .form-row-single {
        flex-direction: column;
        gap: 1rem;
    }

    .form-group {
        width: 100%;
    }

    .search-actions {
        flex-direction: column;
        width: 100%;
        gap: 0.75rem;
    }

    .show-flights-btn {
        width: 100%;
        order: 1;
    }
}

/* ============================================
   MOBILE MODALS (Bottom Sheet Style)
   ============================================ */

@media (max-width: 768px) {
    /* Flight details popup overlay */
    .flight-popup-overlay.active {
        padding: 0 !important;
        align-items: flex-end !important;
    }

    /* Flight details popup - fill horizontal space with no borders */
    .flight-popup {
        width: 100% !important;
        max-width: 100% !important;
        border-radius: 0 !important;
        margin: 0 !important;
        box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.15) !important;
    }

    /* Booking cancellation modal */
    .cancel-booking-modal-content {
        position: fixed;
        inset: auto 0 0;
        max-width: 100%;
        max-height: 85vh;
        border-radius: 20px 20px 0 0;
        animation: slide-up-mobile 0.3s ease;
        padding-bottom: max(1.5rem, calc(1.5rem + var(--safe-area-inset-bottom)));
    }

    @keyframes slide-up-mobile {
        from {
            transform: translateY(100%);
        }

        to {
            transform: translateY(0);
        }
    }

    .modal-actions {
        flex-direction: column;
        gap: 0.75rem;
    }

    .btn-keep,
    .btn-cancel-confirm {
        width: 100%;
        min-height: 48px;
    }
}

/* ============================================
   MOBILE TYPOGRAPHY IMPROVEMENTS
   ============================================ */

@media (max-width: 768px) {
    /* Increase font sizes for better readability */
    .city-info,
    .airport-location {
        font-size: 14px;
    }

    .airport-code {
        font-size: 15px;
    }

    .city-name,
    .airport-name {
        font-size: 15px;
    }

    .stat-text {
        font-size: 0.9375rem;
    }

    .date,
    .time,
    .flight-time,
    .distance {
        font-size: 0.9375rem;
    }
}

/* ============================================
   MOBILE SEARCH TABS
   ============================================ */

@media (max-width: 768px) {
    .search-tabs {
        display: flex;
        gap: 0;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
    }

    .search-tabs::-webkit-scrollbar {
        display: none;
    }

    .search-tab {
        flex-shrink: 0;
        white-space: nowrap;
    }

    /* Hide text labels on small screens, show only icons */
    .tab-text-desktop {
        display: none;
    }

    .tab-icon {
        display: inline-block;
    }

    .tab-text-mobile {
        display: inline-block;
        font-size: 0.875rem;
    }
}

@media (max-width: 480px) {
    .tab-text-mobile {
        display: none;
    }

    .search-tab {
        padding: 12px;
        min-width: 48px;
        justify-content: center;
    }

    .tab-icon {
        font-size: 1.125rem;
    }
}

/* ============================================
   MOBILE PERFORMANCE OPTIMIZATIONS
   ============================================ */

@media (max-width: 768px) {
    /* Reduce backdrop blur on mobile for better performance */
    .top-nav {
        backdrop-filter: blur(8px);
        -webkit-backdrop-filter: blur(8px);
    }

    /* Optimize animations for mobile */
    * {
        animation-duration: 0.2s !important;
        transition-duration: 0.2s !important;
    }

    /* Reduce shadows on mobile */
    .flight-card-compact {
        box-shadow: 0 2px 4px rgba(0, 0, 0, 0.08);
    }

    .flight-card-compact:hover {
        box-shadow: 0 4px 8px rgba(0, 0, 0, 0.12);
    }
}

/* ============================================
   PULL-TO-REFRESH INDICATOR
   ============================================ */

.pull-to-refresh-indicator {
    position: fixed;
    top: max(80px, calc(80px + var(--safe-area-inset-top)));
    left: 50%;
    transform: translateX(-50%) scale(0);
    background: white;
    padding: 12px 24px;
    border-radius: 24px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.875rem;
    color: var(--gray-700);
    z-index: 1001;
    transition: transform 0.3s ease;
}

.pull-to-refresh-indicator.active {
    transform: translateX(-50%) scale(1);
}

.pull-to-refresh-indicator i {
    animation: spin 1s linear infinite;
}

@keyframes spin {
    from {
        transform: rotate(0deg);
    }

    to {
        transform: rotate(360deg);
    }
}

/* ============================================
   MOBILE FLIGHT CARDS
   ============================================ */

@media (max-width: 768px) {
    .flight-card-compact {
        padding: 12px 10px;
        margin-bottom: 10px;
    }

    .flight-card-content {
        gap: 0.5rem;
        padding: 0 0.5rem;
    }

    .cell-actions {
        width: 100%;
        justify-content: space-between;
        margin-top: 0.75rem;
        padding-top: 0.75rem;
        border-top: 1px solid var(--gray-200);
    }

    .action-buttons {
        width: 100%;
        justify-content: space-between;
    }

    .book-btn {
        flex: 1;
    }
}

/* ============================================
   MOBILE LANDSCAPE MODE
   ============================================ */

@media (max-height: 500px) and (orientation: landscape) {
    /* Prevent horizontal scroll in landscape - critical fix for Android */
    html,
    body {
        overflow-x: hidden !important;
        max-width: 100%;
    }

    /* Use compact logo in landscape mode (screen height is limited) */
    .logo-full {
        display: none !important;
    }

    .logo-compact {
        display: block !important;
    }

    .nav-container {
        min-height: 48px;
        padding: 0.25rem 1rem;
    }

    .search-container {
        margin: 0.5rem;
    }

    .search-header {
        padding: 0.5rem;
    }

    /* Reduce modal heights in landscape */
    .cancel-booking-modal-content,
    .flight-popup,
    .auth-modal-content,
    .loading-overlay {
        max-height: 95vh;
    }

    /* Ensure loading spinner is visible in landscape */
    .loading-spinner {
        padding: 20px;
        max-width: 90%;
    }
}
