/* Mobile Optimization & Aspect Ratio Fixes */

/* Prevent horizontal scroll on mobile */
html, body {
    width: 100%;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
}

/* Image aspect ratio preservation */
img {
    max-width: 100%;
    height: auto;
    display: block;
}

/* Aspect ratio boxes for images without explicit dimensions */
.img-1-1 { aspect-ratio: 1/1; }
.img-16-9 { aspect-ratio: 16/9; }
.img-4-3 { aspect-ratio: 4/3; }
.img-3-2 { aspect-ratio: 3/2; }

/* Lazy load images */
img[loading="lazy"] {
    content-visibility: auto;
}

/* Mobile menu fix */
@media (max-width: 768px) {
    body {
        position: relative;
    }

    .navbar {
        padding: 0 10px;
    }

    .nav-container {
        padding: 0 10px !important;
    }

    /* Prevent overflow on mobile navigation */
    .navbar * {
        overflow-x: hidden;
    }

    /* Fix horizontal scroll on tables */
    table {
        overflow-x: auto;
        display: block;
    }

    /* Ensure form inputs don't overflow */
    input, textarea, select {
        max-width: 100%;
        width: 100%;
    }

    /* Fix video embed aspect ratio */
    iframe {
        max-width: 100%;
        height: auto;
    }
}

/* Touch-friendly buttons */
@media (hover: none) and (pointer: coarse) {
    button, a, .btn {
        min-height: 44px;
        min-width: 44px;
    }
}

/* Print optimization */
@media print {
    html, body {
        height: 100%;
        margin: 0;
        padding: 0;
    }

    .navbar, footer, .sidebar {
        display: none !important;
    }
}

/* WebP image support */
picture {
    display: block;
}

/* Fix CSS @media rules for proper mobile detection */
@media (max-width: 480px) {
    html {
        font-size: 14px;
    }
}

@media (min-width: 481px) and (max-width: 768px) {
    html {
        font-size: 15px;
    }
}

@media (min-width: 769px) {
    html {
        font-size: 16px;
    }
}

/* Ensure proper spacing on mobile */
@media (max-width: 768px) {
    .container, .page-container {
        padding: 15px !important;
    }

    /* Fix margins that cause overflow */
    * {
        margin-left: 0 !important;
        margin-right: 0 !important;
    }

    main, section, article {
        margin: 0 !important;
        padding: 15px !important;
    }
}
