/* Custom CSS for Aircraft Tracking Dashboard - Mobile Optimizations */

/* ============================================================================
   Mobile Navigation Fixes
   ============================================================================ */

/* Ensure navbar toggler is visible on mobile */
.navbar-toggler {
    display: block !important;
    border: 1px solid rgba(255, 255, 255, 0.5);
    padding: 0.5rem;
}

.navbar-toggler:focus {
    box-shadow: 0 0 0 0.2rem rgba(255, 255, 255, 0.25);
}

/* Navbar brand responsive sizing */
@media (max-width: 575.98px) {
    .navbar-brand {
        font-size: 0.95rem !important;
    }
    
    .navbar-brand img {
        height: 24px !important;
    }
    
    .fa-plane-departure {
        font-size: 1.2rem !important;
    }
}

/* Mobile navbar collapse styling */
@media (max-width: 991.98px) {
    .navbar-collapse {
        background-color: #2c3034;
        padding: 1rem;
        margin-top: 0.5rem;
        border-radius: 0.25rem;
        box-shadow: 0 2px 4px rgba(0,0,0,0.2);
    }
    
    .navbar-collapse .nav-link {
        padding: 0.75rem 1rem !important;
        border-bottom: 1px solid rgba(255, 255, 255, 0.1);
        font-size: 1.05rem;
    }
    
    .navbar-collapse .nav-link:last-child {
        border-bottom: none;
    }
    
    .navbar-collapse .btn {
        width: 100%;
        margin-top: 0.5rem;
    }
}

/* ============================================================================
   Filter Bar Optimization
   ============================================================================ */

/* Make filter bar sticky on mobile for easy access */
@media (max-width: 991.98px) {
    .filter-bar-sticky {
        position: sticky;
        top: 56px; /* Height of navbar */
        z-index: 1020;
        background-color: #f8f9fa;
        padding: 0.5rem 0;
    }
}

/* ============================================================================
   Dropdown Mobile Optimizations
   ============================================================================ */

/* Make all dropdowns responsive */
.Select-control,
.Select-menu-outer,
.dash-dropdown {
    max-width: 100% !important;
}

/* Ensure dropdown menus don't overflow on mobile */
@media (max-width: 767.98px) {
    .dash-dropdown,
    .Select-control {
        width: 100% !important;
        min-width: unset !important;
    }
    
    /* Fix dropdown positioning on small screens */
    .dash-dropdown .Select-menu-outer {
        max-height: 250px;
        overflow-y: auto;
        z-index: 9999;
    }
    
    /* Multi-select dropdown tags - make them smaller on mobile */
    .Select-multi-value-wrapper {
        max-width: 100%;
    }
    
    .Select-value {
        font-size: 0.875rem;
        padding: 0.25rem 0.5rem;
    }
}

/* ============================================================================
   Card Header Responsive Fixes
   ============================================================================ */

/* Make card headers stack on mobile */
@media (max-width: 767.98px) {
    .card-header .row {
        flex-direction: column !important;
    }
    
    .card-header .col,
    .card-header [class*="col-"] {
        width: 100% !important;
        max-width: 100% !important;
        margin-left: 0 !important;
        margin-top: 0.5rem;
    }
    
    .card-header .col:first-child,
    .card-header [class*="col-"]:first-child {
        margin-top: 0;
    }
    
    /* Make labels and dropdowns stack vertically */
    .card-header label {
        display: block;
        margin-bottom: 0.5rem;
    }
    
    /* Card header font sizes */
    .card-header {
        font-size: 0.95rem;
        padding: 0.75rem;
    }
}

/* ============================================================================
   Table Responsive Improvements
   ============================================================================ */

/* Make tables scrollable on mobile */
@media (max-width: 767.98px) {
    .table-responsive {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    table {
        font-size: 0.8rem;
    }
    
    table th,
    table td {
        padding: 0.4rem !important;
        white-space: nowrap;
    }
    
    /* Smaller table headers on mobile */
    table thead th {
        font-size: 0.75rem;
        font-weight: 600;
    }
}

/* ============================================================================
   Button Improvements
   ============================================================================ */

/* Make buttons full width on mobile for better touch targets */
@media (max-width: 575.98px) {
    .btn:not(.navbar .btn) {
        width: 100%;
        margin-bottom: 0.5rem;
    }
    
    .btn-group {
        flex-direction: column;
        width: 100%;
    }
    
    .btn-group .btn {
        width: 100%;
    }
}

/* ============================================================================
   Chart Responsive Fixes
   ============================================================================ */

/* Ensure charts are responsive */
.js-plotly-plot,
.plotly,
.plot-container {
    width: 100% !important;
    height: auto !important;
}

@media (max-width: 767.98px) {
    .js-plotly-plot .plotly .main-svg {
        max-width: 100%;
    }
    
    /* Reduce chart height on mobile for better scrolling */
    .js-plotly-plot {
        min-height: 300px;
    }
}

/* ============================================================================
   Modal Improvements for Mobile
   ============================================================================ */

@media (max-width: 767.98px) {
    .modal-dialog {
        margin: 0.5rem;
        max-width: calc(100% - 1rem);
    }
    
    .modal-body {
        padding: 1rem;
    }
    
    .modal-header {
        padding: 0.75rem;
    }
    
    .modal-title {
        font-size: 1.1rem;
    }
}

/* ============================================================================
   Form Controls Mobile Optimization
   ============================================================================ */

/* Improve form controls on mobile */
@media (max-width: 767.98px) {
    .form-control,
    .form-select,
    input[type="text"],
    input[type="number"],
    input[type="password"],
    .dash-dropdown .Select-control {
        font-size: 16px !important; /* Prevents zoom on iOS */
        min-height: 44px; /* Better touch target */
    }
    
    label {
        font-size: 0.95rem;
    }
}

/* ============================================================================
   Slider Improvements for Touch Devices
   ============================================================================ */

/* Make sliders easier to use on touch devices */
.rc-slider-handle {
    width: 20px !important;
    height: 20px !important;
    margin-top: -8px !important;
    border-width: 2px !important;
}

@media (max-width: 767.98px) {
    .rc-slider-handle {
        width: 32px !important;
        height: 32px !important;
        margin-top: -14px !important;
        border-width: 3px !important;
    }
    
    .rc-slider-mark-text {
        font-size: 0.7rem;
    }
    
    .rc-slider-track {
        height: 6px !important;
    }
    
    .rc-slider-rail {
        height: 6px !important;
    }
}

/* ============================================================================
   Metric Cards Mobile Layout
   ============================================================================ */

@media (max-width: 991.98px) {
    /* Stack metric cards on tablets and mobile */
    [class*="col-lg-3"] {
        margin-bottom: 1rem;
    }
}

@media (max-width: 575.98px) {
    /* Compact metric cards on mobile */
    .card-body h3 {
        font-size: 1.5rem;
    }
    
    .card-body h6 {
        font-size: 0.85rem;
    }
}

/* ============================================================================
   DatePickerRange Mobile Optimization
   ============================================================================ */

@media (max-width: 767.98px) {
    .DateRangePickerInput {
        width: 100%;
    }
    
    .DateInput {
        width: 100%;
    }
    
    .DateInput_input {
        font-size: 14px;
        padding: 0.5rem;
    }
}

/* ============================================================================
   Accessibility and Touch Target Improvements
   ============================================================================ */

/* Ensure touch targets are at least 44x44 pixels (WCAG guideline) */
@media (max-width: 767.98px) {
    a:not(.navbar-brand), 
    button, 
    .btn, 
    .nav-link {
        min-height: 44px;
        display: flex;
        align-items: center;
        justify-content: center;
    }
    
    .nav-link {
        padding: 0.75rem 1rem !important;
    }
}

/* ============================================================================
   Container Padding for Mobile
   ============================================================================ */

@media (max-width: 575.98px) {
    .container,
    .container-fluid {
        padding-left: 0.75rem;
        padding-right: 0.75rem;
    }
    
    .card {
        margin-bottom: 1rem;
    }
    
    .card-body {
        padding: 0.75rem;
    }
}

/* ============================================================================
   Typography Mobile Adjustments
   ============================================================================ */

@media (max-width: 575.98px) {
    h1 {
        font-size: 1.75rem;
    }
    
    h2 {
        font-size: 1.5rem;
    }
    
    h3 {
        font-size: 1.25rem;
    }
    
    h4 {
        font-size: 1.1rem;
    }
}

/* ============================================================================
   Hide/Show Elements Based on Screen Size
   ============================================================================ */

/* Utility classes for responsive visibility */
.mobile-only {
    display: none;
}

@media (max-width: 991.98px) {
    .mobile-only {
        display: block;
    }
    
    .desktop-only {
        display: none !important;
    }
}

/* ============================================================================
   Spacing Utilities for Mobile
   ============================================================================ */

@media (max-width: 767.98px) {
    .mb-4, .my-4 {
        margin-bottom: 1.5rem !important;
    }
    
    .mt-4, .my-4 {
        margin-top: 1.5rem !important;
    }
}

/* ============================================================================
   Smooth Scrolling and Performance
   ============================================================================ */

html {
    scroll-behavior: smooth;
}

/* Improve scrolling performance on mobile */
.overflow-auto {
    -webkit-overflow-scrolling: touch;
}

/* ============================================================================
   Focus Styles for Accessibility
   ============================================================================ */

@media (max-width: 767.98px) {
    *:focus {
        outline: 2px solid #0d6efd;
        outline-offset: 2px;
    }
    
    .btn:focus,
    .nav-link:focus {
        box-shadow: 0 0 0 0.2rem rgba(13, 110, 253, 0.25);
    }
}
