/**
 * Mobile Specific Styles
 * Restaurant Online Food Ordering System
 */

/* =====================================================
   Touch Optimizations
   ===================================================== */

/* Increase tap target sizes */
@media (max-width: 767px) {

    /* Ensure minimum touch target */
    button,
    a,
    input[type="button"],
    input[type="submit"],
    .btn,
    .bottom-nav__item,
    .product-card__add-btn,
    .product-card__wishlist {
        min-height: 44px;
        min-width: 44px;
    }

    /* Remove tap highlight on mobile */
    * {
        -webkit-tap-highlight-color: transparent;
    }

    /* Prevent text selection on interactive elements */
    button,
    a,
    .btn,
    .product-card,
    .category-pill,
    .bottom-nav__item {
        -webkit-user-select: none;
        user-select: none;
    }
}

/* =====================================================
   Mobile Header
   ===================================================== */
@media (max-width: 767px) {
    .header {
        padding: 0;
    }

    .header__inner {
        min-height: 50px;
        padding: 5px 25px;
        /* Increased horizontal padding */
    }

    .header__logo-img {
        height: 40px;
        /* Increased from 32px */
    }

    .header__site-name {
        display: block;
        /* Visible on mobile */
        font-size: 16px;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        max-width: 150px;
        /* Prevent overlap */
    }

    /* Hide Desktop Elements */
    .header__location--desktop,
    .header__nav,
    .header__search {
        display: none;
    }

    /* Show Mobile Elements */
    .header__mobile-actions {
        display: flex;
        align-items: center;
    }

    .mobile-header-elements {
        display: block;
    }

    .header__greeting {
        display: none;
        /* Hide old greeting if present */
    }

    .mobile-location-bar {
        background: var(--bg-tertiary);
        padding: var(--spacing-xs) var(--spacing-md);
        color: var(--text-secondary);
        font-size: var(--font-size-sm);
        display: flex;
        align-items: center;
        gap: var(--spacing-sm);
        border-bottom: 1px solid var(--border-color);
    }

    .mobile-header-elements .search-bar {
        margin: var(--spacing-sm) var(--spacing-md);
        box-shadow: none;
        border: 1px solid var(--border-color);
    }

    .search-bar__input {
        height: 40px;
        /* Slightly smaller on mobile */
        font-size: 16px;
    }
}

/* =====================================================
   Mobile Product Cards
   ===================================================== */
@media (max-width: 767px) {
    .product-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: var(--spacing-sm);
    }

    .product-card__content {
        padding: var(--spacing-sm);
    }

    .product-card__name {
        font-size: var(--font-size-sm);
    }

    .product-card__price {
        font-size: var(--font-size-base);
    }

    .product-card__add-btn {
        width: 32px;
        height: 32px;
    }
}

/* =====================================================
   Mobile Forms
   ===================================================== */
@media (max-width: 767px) {

    .form-control,
    select,
    textarea {
        font-size: 16px;
        /* Prevents zoom on iOS */
    }

    .form-group {
        margin-bottom: var(--spacing-md);
    }

    .btn-block {
        padding: 14px 24px;
    }
}

/* =====================================================
   Mobile Banner Carousel
   ===================================================== */
@media (max-width: 767px) {

    .banner-carousel,
    .banner-carousel__track,
    .banner-carousel__slide {
        width: 100% !important;
        margin: 0 !important;
        padding: 0 !important;
        border-radius: 0 !important;
        max-width: 100vw !important;
    }

    .banner-carousel__slide {
        flex: 0 0 100%;
    }
}

/* =====================================================
   Mobile Product Carousel
   ===================================================== */
@media (max-width: 767px) {
    .product-carousel .product-card {
        flex: 0 0 calc((100% - var(--spacing-md)) / 2);
        min-width: 0;
    }
}

/* =====================================================
   Mobile Cart
   ===================================================== */
@media (max-width: 767px) {
    .cart-item {
        padding: var(--spacing-sm);
    }

    .cart-item__image {
        width: 60px;
        height: 60px;
    }

    .cart-bar {
        padding: var(--spacing-sm) var(--spacing-md);
    }
}

/* =====================================================
   Mobile Checkout
   ===================================================== */
@media (max-width: 767px) {
    .checkout-section {
        padding: var(--spacing-md);
        margin-bottom: var(--spacing-sm);
    }

    .address-card {
        padding: var(--spacing-md);
    }
}

/* =====================================================
   Pull to Refresh Indicator (if implemented)
   ===================================================== */
.pull-indicator {
    display: none;
    position: fixed;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    padding: var(--spacing-sm) var(--spacing-md);
    background: var(--bg-primary);
    border-radius: 0 0 var(--radius-lg) var(--radius-lg);
    box-shadow: var(--shadow-md);
    z-index: var(--z-sticky);
}

.pull-indicator.active {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
}

/* =====================================================
   Swipe Actions (for cart items, etc.)
   ===================================================== */
.swipe-container {
    position: relative;
    overflow: hidden;
}

.swipe-content {
    transition: transform 0.3s ease;
}

.swipe-actions {
    position: absolute;
    right: 0;
    top: 0;
    bottom: 0;
    display: flex;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.swipe-action {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 70px;
    color: white;
}

.swipe-action--delete {
    background: var(--error-color);
}

/* =====================================================
   Mobile Modal
   ===================================================== */
@media (max-width: 767px) {
    .modal {
        padding: var(--spacing-md);
    }

    .modal-content {
        max-height: 90vh;
        width: 100%;
        margin: auto var(--spacing-md);
    }

    /* Bottom sheet style modals */
    .modal--bottom-sheet .modal-content {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        margin: 0;
        max-height: 85vh;
        border-radius: var(--radius-xl) var(--radius-xl) 0 0;
        animation: slideUpModal 0.3s ease;
    }

    @keyframes slideUpModal {
        from {
            transform: translateY(100%);
        }

        to {
            transform: translateY(0);
        }
    }
}

/* =====================================================
   Mobile Navigation
   ===================================================== */
@media (max-width: 767px) {
    .bottom-nav {
        padding: 16px 20px;
        padding-bottom: calc(16px + env(safe-area-inset-bottom, 10px));
    }

    /* Adjust page padding for safe area */
    body.has-bottom-nav {
        padding-bottom: calc(var(--bottom-nav-height) + 20px + env(safe-area-inset-bottom, 20px));
    }
}

/* =====================================================
   Mobile Landscape Adjustments
   ===================================================== */
@media (max-width: 767px) and (orientation: landscape) {
    .bottom-nav {
        height: 48px;
    }

    .bottom-nav__icon {
        font-size: 20px;
    }

    .bottom-nav__label {
        font-size: 10px;
    }
}

/* =====================================================
   iOS Specific Fixes
   ===================================================== */
@supports (-webkit-touch-callout: none) {

    /* Safe area insets for notch devices */
    .header {
        padding-top: max(var(--spacing-sm), env(safe-area-inset-top));
    }

    .bottom-nav {
        padding-bottom: max(var(--spacing-xs), env(safe-area-inset-bottom));
    }

    /* Fix for iOS momentum scrolling */
    .scroll-container {
        -webkit-overflow-scrolling: touch;
    }
}

/* =====================================================
   Hide scrollbars on mobile but keep functionality
   ===================================================== */
@media (max-width: 767px) {
    .hide-scrollbar {
        -ms-overflow-style: none;
        scrollbar-width: none;
    }

    .hide-scrollbar::-webkit-scrollbar {
        display: none;
    }
}

/* =====================================================
   Mobile Skeleton Loading
   ===================================================== */
.skeleton {
    background: linear-gradient(90deg,
            var(--bg-tertiary) 25%,
            var(--bg-secondary) 50%,
            var(--bg-tertiary) 75%);
    background-size: 200% 100%;
    animation: skeleton-loading 1.5s infinite;
    border-radius: var(--radius-sm);
}

@keyframes skeleton-loading {
    0% {
        background-position: 200% 0;
    }

    100% {
        background-position: -200% 0;
    }
}

.skeleton-text {
    height: 16px;
    margin-bottom: var(--spacing-sm);
}

.skeleton-text--sm {
    height: 12px;
    width: 60%;
}

.skeleton-image {
    aspect-ratio: 1;
}

/* =====================================================
   Mobile Accessibility
   ===================================================== */
@media (max-width: 767px) {

    /* Larger focus indicators for touch */
    a:focus,
    button:focus,
    input:focus,
    select:focus,
    textarea:focus {
        outline: 3px solid var(--primary-color);
        outline-offset: 2px;
    }

    /* Skip navigation for screen readers */
    .skip-link {
        position: absolute;
        top: -999px;
        left: 0;
        background: var(--primary-color);
        color: white;
        padding: var(--spacing-md);
        z-index: 9999;
    }

    .skip-link:focus {
        top: 0;
    }
}