/**
 * DACAIS Mobile-First Responsive Design System
 * Global mobile enhancements for all application pages
 * Version: 1.0.0
 * Last Updated: 2025-10-22
 */

/* ============================================
   MOBILE-FIRST BASE STYLES
   ============================================ */

/* Ensure proper touch targets (min 44x44px) */
* {
    -webkit-tap-highlight-color: rgba(0, 120, 212, 0.2);
    -webkit-touch-callout: none;
}

button,
a,
input,
select,
textarea,
[role="button"] {
    min-height: 44px;
    min-width: 44px;
}

/* Improve text readability on mobile */
body {
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
}

/* Prevent text size adjustment on orientation change */
html {
    -webkit-text-size-adjust: 100%;
    -moz-text-size-adjust: 100%;
    -ms-text-size-adjust: 100%;
    text-size-adjust: 100%;
}

/* ============================================
   RESPONSIVE BREAKPOINTS
   ============================================ */

/* Mobile-first: Base styles are for mobile */
/* Tablet: 768px and up */
/* Desktop: 1024px and up */
/* Wide: 1280px and up */

/* ============================================
   MOBILE NAVIGATION & HEADER
   ============================================ */

@media (max-width: 767px) {
    /* Hamburger menu styles */
    .mobile-menu-toggle {
        display: block !important;
        position: fixed;
        top: 20px;
        right: 20px;
        z-index: 1001;
        background: #0078d4;
        color: white;
        border: none;
        border-radius: 8px;
        padding: 12px;
        cursor: pointer;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    }

    .mobile-nav-overlay {
        display: none;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0, 0, 0, 0.5);
        z-index: 999;
    }

    .mobile-nav-overlay.active {
        display: block;
    }

    nav,
    .nav-menu,
    header nav {
        position: fixed;
        top: 0;
        right: -100%;
        width: 80%;
        max-width: 320px;
        height: 100vh;
        background: white;
        z-index: 1000;
        transition: right 0.3s ease;
        overflow-y: auto;
        box-shadow: -2px 0 8px rgba(0, 0, 0, 0.1);
    }

    nav.active,
    .nav-menu.active,
    header nav.active {
        right: 0;
    }

    nav a,
    .nav-menu a,
    header nav a {
        display: block !important;
        padding: 16px 24px !important;
        border-bottom: 1px solid #f0f0f0;
        color: #333 !important;
        text-decoration: none;
        font-size: 16px;
    }

    nav a:hover,
    .nav-menu a:hover {
        background: #f8f8f8;
    }

    /* Hide desktop nav elements */
    .desktop-nav {
        display: none !important;
    }
}

/* ============================================
   MOBILE TYPOGRAPHY
   ============================================ */

@media (max-width: 767px) {
    h1 {
        font-size: 28px !important;
        line-height: 1.3 !important;
        margin-bottom: 16px !important;
    }

    h2 {
        font-size: 24px !important;
        line-height: 1.4 !important;
        margin-bottom: 12px !important;
    }

    h3 {
        font-size: 20px !important;
        line-height: 1.4 !important;
    }

    h4 {
        font-size: 18px !important;
    }

    p,
    li {
        font-size: 16px !important;
        line-height: 1.6 !important;
    }

    small,
    .small-text {
        font-size: 14px !important;
    }
}

/* ============================================
   MOBILE FORMS & INPUTS
   ============================================ */

@media (max-width: 767px) {
    input[type="text"],
    input[type="email"],
    input[type="password"],
    input[type="tel"],
    input[type="date"],
    input[type="number"],
    select,
    textarea {
        width: 100% !important;
        padding: 14px 16px !important;
        font-size: 16px !important; /* Prevents iOS zoom */
        border-radius: 8px !important;
        border: 1px solid #ccc !important;
        box-sizing: border-box !important;
        margin-bottom: 12px !important;
    }

    input:focus,
    select:focus,
    textarea:focus {
        outline: 2px solid #0078d4 !important;
        outline-offset: 2px !important;
    }

    button:not(.icon-button),
    .btn,
    input[type="submit"],
    input[type="button"] {
        width: 100% !important;
        padding: 14px 24px !important;
        font-size: 16px !important;
        border-radius: 8px !important;
        min-height: 48px !important;
        margin-bottom: 12px !important;
    }

    .form-row,
    .form-group {
        flex-direction: column !important;
        width: 100% !important;
    }

    .form-row > *,
    .form-group > * {
        width: 100% !important;
        margin-right: 0 !important;
    }

    label {
        display: block !important;
        margin-bottom: 8px !important;
        font-weight: 500 !important;
    }
}

/* ============================================
   MOBILE CARDS & CONTAINERS
   ============================================ */

@media (max-width: 767px) {
    .card,
    .pricing-card,
    .booking-card,
    .result-card {
        width: 100% !important;
        margin: 0 0 16px 0 !important;
        padding: 16px !important;
        border-radius: 12px !important;
        box-sizing: border-box !important;
    }

    .container,
    .main-content,
    .content-wrapper {
        padding: 16px !important;
        max-width: 100% !important;
        box-sizing: border-box !important;
    }

    .grid,
    .pricing-grid,
    .results-grid {
        grid-template-columns: 1fr !important;
        gap: 16px !important;
    }

    .flex-row,
    .row {
        flex-direction: column !important;
    }
}

/* ============================================
   MOBILE TABLES
   ============================================ */

@media (max-width: 767px) {
    table {
        display: block !important;
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch !important;
        border: 1px solid #ddd !important;
        border-radius: 8px !important;
    }

    /* Card-style table layout for mobile */
    table.mobile-card-table {
        border: none !important;
    }

    table.mobile-card-table thead {
        display: none !important;
    }

    table.mobile-card-table tbody,
    table.mobile-card-table tr {
        display: block !important;
        margin-bottom: 16px !important;
        border: 1px solid #ddd !important;
        border-radius: 8px !important;
        padding: 12px !important;
    }

    table.mobile-card-table td {
        display: flex !important;
        justify-content: space-between !important;
        padding: 8px 0 !important;
        border: none !important;
        border-bottom: 1px solid #f0f0f0 !important;
    }

    table.mobile-card-table td:last-child {
        border-bottom: none !important;
    }

    table.mobile-card-table td::before {
        content: attr(data-label);
        font-weight: 600;
        color: #666;
    }
}

/* ============================================
   MOBILE MODALS & OVERLAYS
   ============================================ */

@media (max-width: 767px) {
    .modal,
    .dialog,
    .popup {
        width: 95% !important;
        max-width: none !important;
        margin: 20px auto !important;
        border-radius: 16px !important;
        max-height: 90vh !important;
        overflow-y: auto !important;
    }

    .modal-header,
    .modal-footer {
        padding: 16px !important;
    }

    .modal-body {
        padding: 16px !important;
    }
}

/* ============================================
   MOBILE UTILITY CLASSES
   ============================================ */

@media (max-width: 767px) {
    .hide-mobile {
        display: none !important;
    }

    .show-mobile {
        display: block !important;
    }

    .stack-mobile {
        flex-direction: column !important;
    }

    .full-width-mobile {
        width: 100% !important;
    }

    .center-mobile {
        text-align: center !important;
    }

    .no-padding-mobile {
        padding: 0 !important;
    }

    .small-padding-mobile {
        padding: 12px !important;
    }
}

@media (min-width: 768px) {
    .hide-desktop {
        display: none !important;
    }

    .show-desktop {
        display: block !important;
    }
}

/* ============================================
   MOBILE TOUCH IMPROVEMENTS
   ============================================ */

@media (max-width: 767px) {
    /* Larger touch targets for links */
    a {
        padding: 4px 8px !important;
        margin: 4px 0 !important;
        display: inline-block !important;
    }

    /* Better spacing for clickable elements */
    .clickable,
    [onclick],
    [role="button"] {
        padding: 12px !important;
        margin: 4px 0 !important;
    }

    /* Swipe indicators */
    .swipeable::after {
        content: "← Swipe →";
        display: block;
        text-align: center;
        color: #999;
        font-size: 12px;
        margin-top: 8px;
    }
}

/* ============================================
   MOBILE IMAGES & MEDIA
   ============================================ */

@media (max-width: 767px) {
    img,
    video,
    iframe {
        max-width: 100% !important;
        height: auto !important;
        border-radius: 8px !important;
    }

    .video-container,
    .iframe-container {
        position: relative;
        padding-bottom: 56.25%; /* 16:9 aspect ratio */
        height: 0;
        overflow: hidden;
    }

    .video-container iframe,
    .iframe-container iframe {
        position: absolute;
        top: 0;
        left: 0;
        width: 100% !important;
        height: 100% !important;
    }
}

/* ============================================
   MOBILE SPACING & LAYOUT
   ============================================ */

@media (max-width: 767px) {
    .section,
    section {
        padding: 32px 16px !important;
    }

    .hero,
    .hero-section {
        min-height: 50vh !important;
        padding: 48px 16px !important;
    }

    .footer,
    footer {
        padding: 32px 16px !important;
    }

    /* Reduce excessive whitespace on mobile */
    .spacer-large {
        height: 32px !important;
    }

    .spacer-medium {
        height: 16px !important;
    }

    .spacer-small {
        height: 8px !important;
    }
}

/* ============================================
   MOBILE ANIMATIONS & TRANSITIONS
   ============================================ */

@media (max-width: 767px) {
    /* Reduce motion for better performance on mobile */
    @media (prefers-reduced-motion: reduce) {
        *,
        *::before,
        *::after {
            animation-duration: 0.01ms !important;
            animation-iteration-count: 1 !important;
            transition-duration: 0.01ms !important;
            scroll-behavior: auto !important;
        }
    }

    /* Smooth scrolling on mobile */
    html {
        scroll-behavior: smooth;
    }

    /* Faster transitions for better perceived performance */
    * {
        transition-duration: 0.2s !important;
    }
}

/* ============================================
   MOBILE PRICING PAGE SPECIFIC
   ============================================ */

@media (max-width: 767px) {
    .pricing-tier {
        width: 100% !important;
        max-width: none !important;
        margin: 0 0 24px 0 !important;
    }

    .pricing-header {
        padding: 16px !important;
    }

    .price {
        font-size: 32px !important;
    }

    .feature-list {
        padding: 16px !important;
    }

    .feature-list li {
        padding: 10px 0 !important;
        font-size: 15px !important;
    }
}

/* ============================================
   MOBILE FLIGHT BOOKING SPECIFIC
   ============================================ */

@media (max-width: 767px) {
    .search-form,
    .booking-form {
        padding: 16px !important;
    }

    .flight-card,
    .result-item {
        padding: 16px !important;
        margin-bottom: 16px !important;
    }

    .flight-details {
        flex-direction: column !important;
        gap: 12px !important;
    }

    .passenger-form {
        padding: 16px !important;
    }

    .seat-selection {
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch !important;
    }
}

/* ============================================
   MOBILE RADAR & MAP SPECIFIC
   ============================================ */

@media (max-width: 767px) {
    #map,
    .map-container,
    .radar-map {
        height: 60vh !important;
        min-height: 400px !important;
    }

    .map-controls {
        position: fixed !important;
        bottom: 80px !important;
        right: 16px !important;
        z-index: 500 !important;
    }

    .map-sidebar {
        position: fixed !important;
        bottom: 0 !important;
        left: 0 !important;
        right: 0 !important;
        height: 40% !important;
        max-height: none !important;
        border-radius: 16px 16px 0 0 !important;
        transform: translateY(calc(100% - 60px)) !important;
        transition: transform 0.3s ease !important;
    }

    .map-sidebar.expanded {
        transform: translateY(0) !important;
    }

    .map-sidebar-handle {
        display: block !important;
        width: 40px !important;
        height: 4px !important;
        background: #ccc !important;
        border-radius: 2px !important;
        margin: 12px auto !important;
        cursor: pointer !important;
    }
}

/* ============================================
   MOBILE CHAT INTERFACE SPECIFIC
   ============================================ */

@media (max-width: 767px) {
    .chat-container {
        height: calc(100vh - 120px) !important;
        padding: 8px !important;
    }

    .chat-messages {
        padding: 12px !important;
        gap: 12px !important;
    }

    .message {
        max-width: 85% !important;
        padding: 12px 14px !important;
        font-size: 15px !important;
    }

    .chat-input-container {
        padding: 12px !important;
        gap: 8px !important;
    }

    .chat-input {
        font-size: 16px !important;
        padding: 12px 14px !important;
    }

    .send-button {
        min-width: 50px !important;
        padding: 12px !important;
    }
}

/* ============================================
   MOBILE PERFORMANCE OPTIMIZATIONS
   ============================================ */

@media (max-width: 767px) {
    /* GPU acceleration for smoother animations */
    .animated,
    .slide-in,
    .fade-in {
        transform: translateZ(0);
        -webkit-transform: translateZ(0);
        will-change: transform, opacity;
    }

    /* Optimize font loading on mobile */
    @font-face {
        font-display: swap;
    }
}

/* ============================================
   MOBILE ACCESSIBILITY
   ============================================ */

@media (max-width: 767px) {
    /* Larger focus indicators on mobile */
    *:focus,
    *:focus-visible {
        outline: 3px solid #0078d4 !important;
        outline-offset: 2px !important;
    }

    /* Skip to content link for screen readers */
    .skip-link {
        position: fixed;
        top: -100px;
        left: 0;
        background: #0078d4;
        color: white;
        padding: 12px 16px;
        z-index: 9999;
        border-radius: 0 0 8px 0;
    }

    .skip-link:focus {
        top: 0;
    }
}

/* ============================================
   MOBILE SAFE AREAS (iPhone notch, etc.)
   ============================================ */

@supports (padding: max(0px)) {
    body {
        padding-left: max(16px, env(safe-area-inset-left));
        padding-right: max(16px, env(safe-area-inset-right));
        padding-top: max(0px, env(safe-area-inset-top));
        padding-bottom: max(0px, env(safe-area-inset-bottom));
    }

    .mobile-fixed-header {
        padding-top: max(16px, env(safe-area-inset-top));
    }

    .mobile-fixed-footer {
        padding-bottom: max(16px, env(safe-area-inset-bottom));
    }
}
