/* Mobile-specific optimizations for PackIt */

/* =================================
   General Mobile Improvements
   ================================= */

/* Smooth scrolling on iOS */
html {
    -webkit-overflow-scrolling: touch;
}

/* Better text rendering 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%;
    -ms-text-size-adjust: 100%;
}

/* =================================
   Touch Target Improvements
   ================================= */

/* Minimum touch target size (44x44px recommended by Apple) */
@media (max-width: 768px) {
    a, button, input[type="button"], input[type="submit"], .btn {
        min-height: 44px;
        min-width: 44px;
    }

    /* Checkbox and radio buttons */
    input[type="checkbox"],
    input[type="radio"] {
        min-width: 24px;
        min-height: 24px;
    }

    /* Links in text should still be normal size */
    p a, li a, .card-text a {
        min-height: auto;
        min-width: auto;
    }
}

/* =================================
   Responsive Typography
   ================================= */

@media (max-width: 576px) {
    /* Fluid typography for better readability */
    body {
        font-size: 0.95rem;
        line-height: 1.6;
    }

    h1 {
        font-size: 1.75rem;
        line-height: 1.2;
    }

    h2 {
        font-size: 1.5rem;
    }

    h3 {
        font-size: 1.3rem;
    }

    h4, h5 {
        font-size: 1.1rem;
    }

    h6 {
        font-size: 1rem;
    }

    /* Better spacing for headings */
    h1, h2, h3, h4, h5, h6 {
        margin-bottom: 0.75rem;
    }
}

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

@media (max-width: 991.98px) {
    /* Better collapsed navigation */
    .navbar {
        transition: transform 0.3s ease-in-out;
    }

    .navbar-hidden {
        transform: translateY(-100%);
    }

    .navbar-collapse {
        margin-top: 1rem;
        padding: 1rem 0;
        border-top: 1px solid rgba(255, 255, 255, 0.1);
    }

    .navbar-nav .nav-item {
        margin: 0.25rem 0;
    }

    .navbar-nav .nav-link {
        padding: 0.75rem 1rem;
        border-radius: 0.25rem;
    }

    /* Dropdown improvements */
    .dropdown-menu {
        border: none;
        box-shadow: none;
        background-color: transparent;
        padding-left: 1rem;
    }

    .dropdown-item {
        padding: 0.5rem 1rem;
        border-radius: 0.25rem;
    }
}

/* =================================
   Mobile Forms
   ================================= */

@media (max-width: 768px) {
    /* Better form controls */
    .form-control,
    .form-select {
        font-size: 16px; /* Prevents zoom on iOS */
        padding: 0.75rem;
    }

    .form-label {
        font-size: 0.9rem;
        margin-bottom: 0.5rem;
    }

    /* Stack form buttons vertically */
    .modal-footer .btn {
        width: 100%;
        margin: 0.25rem 0 !important;
    }

    /* Better input groups */
    .input-group > * {
        font-size: 16px; /* Prevents zoom on iOS */
    }
}

/* =================================
   Mobile Tables
   ================================= */

@media (max-width: 768px) {
    .table-responsive {
        border: none;
        -webkit-overflow-scrolling: touch;
    }

    .table {
        font-size: 0.85rem;
    }

    .table th,
    .table td {
        padding: 0.75rem 0.5rem;
        vertical-align: middle;
    }

    /* Compact table headers */
    .table thead th {
        font-size: 0.8rem;
        white-space: nowrap;
    }
}

/* Hide table columns on very small screens */
@media (max-width: 576px) {
    .table th,
    .table td {
        padding: 0.5rem 0.25rem;
    }

    /* Use icons for column headers where possible */
    .table thead th {
        font-size: 0.75rem;
    }
}

/* =================================
   Mobile Cards
   ================================= */

@media (max-width: 768px) {
    .card {
        margin-bottom: 1rem;
        border-radius: 0.5rem;
    }

    .card-body {
        padding: 1rem;
    }

    .card-header,
    .card-footer {
        padding: 0.75rem 1rem;
    }

    /* Stack card content vertically */
    .card .row {
        margin-left: 0;
        margin-right: 0;
    }

    .card .row > [class*='col-'] {
        padding-left: 0;
        padding-right: 0;
    }
}

/* =================================
   Mobile Modals
   ================================= */

@media (max-width: 576px) {
    .modal {
        padding: 0 !important;
    }

    .modal-dialog {
        margin: 0.5rem;
        max-width: calc(100% - 1rem);
    }

    .modal-content {
        border-radius: 0.5rem;
    }

    .modal-header {
        padding: 1rem;
    }

    .modal-body {
        padding: 1rem;
        max-height: calc(100vh - 200px);
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }

    .modal-footer {
        padding: 1rem;
        flex-direction: column-reverse;
        gap: 0.5rem;
    }

    .modal-footer .btn {
        width: 100%;
        margin: 0 !important;
    }

    .modal-title {
        font-size: 1.25rem;
    }
}

/* =================================
   Mobile Spacing
   ================================= */

@media (max-width: 576px) {
    /* Reduce overall spacing */
    .container {
        padding-left: 0.75rem;
        padding-right: 0.75rem;
    }

    main.container {
        padding-top: 1rem;
        padding-bottom: 1rem;
    }

    /* Compact spacing utilities */
    .mb-4 {
        margin-bottom: 1rem !important;
    }

    .mt-4 {
        margin-top: 1rem !important;
    }

    .py-4 {
        padding-top: 1rem !important;
        padding-bottom: 1rem !important;
    }
}

/* =================================
   Mobile Images
   ================================= */

@media (max-width: 768px) {
    img {
        max-width: 100%;
        height: auto;
    }

    .card-img-top {
        border-top-left-radius: calc(0.5rem - 1px);
        border-top-right-radius: calc(0.5rem - 1px);
    }
}

/* =================================
   Mobile Utilities
   ================================= */

/* Hide on mobile */
.mobile-hide {
    display: none !important;
}

/* Show only on mobile */
@media (min-width: 769px) {
    .mobile-only {
        display: none !important;
    }
}

/* Center content on mobile */
@media (max-width: 576px) {
    .mobile-center {
        text-align: center;
    }

    .mobile-stack {
        flex-direction: column !important;
    }

    .mobile-full-width {
        width: 100% !important;
    }
}

/* =================================
   Landscape Orientation
   ================================= */

@media (max-width: 896px) and (orientation: landscape) {
    /* Reduce vertical spacing in landscape */
    .navbar {
        padding-top: 0.25rem;
        padding-bottom: 0.25rem;
    }

    .navbar-brand {
        font-size: 1.1rem;
    }

    .nav-link {
        padding: 0.25rem 0.5rem;
    }

    main.container {
        padding-top: 0.5rem;
        padding-bottom: 0.5rem;
    }

    .card-body {
        padding: 0.75rem;
    }

    footer {
        padding: 0.5rem 0 !important;
    }
}

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

/* Optimize animations for mobile */
@media (max-width: 768px) {
    * {
        transition-duration: 0.15s !important;
    }

    /* Disable hover effects on touch devices */
    @media (hover: none) {
        .card:hover,
        .btn:hover,
        a:hover {
            transform: none;
        }
    }
}

/* Reduce motion for users who prefer it */
@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;
    }
}

