/**
 * Mobile Optimization CSS
 * Fixes responsive issues across all pages
 */

/* Base Mobile Optimizations */
* {
    -webkit-box-sizing: border-box;
    -moz-box-sizing: border-box;
    box-sizing: border-box;
}

html {
    -webkit-text-size-adjust: 100%;
    -ms-text-size-adjust: 100%;
}

body {
    overflow-x: hidden;
    width: 100%;
}

/* Prevent horizontal scroll */
img, video, iframe, embed {
    max-width: 100%;
    height: auto;
}

/* Responsive containers */
.container, .container-fluid {
    max-width: 100%;
    overflow-x: hidden;
}

/* Mobile Typography */
@media (max-width: 768px) {
    /* Reduce font sizes on mobile */
    h1 {
        font-size: 1.75rem !important;
        line-height: 1.2;
    }

    h2 {
        font-size: 1.5rem !important;
        line-height: 1.3;
    }

    h3 {
        font-size: 1.25rem !important;
        line-height: 1.3;
    }

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

    p, li, span {
        font-size: 0.95rem !important;
        line-height: 1.6;
    }

    /* Mobile padding adjustments */
    .px-4 {
        padding-left: 1rem !important;
        padding-right: 1rem !important;
    }

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

    /* Mobile margins */
    .my-4, .my-5 {
        margin-top: 1.5rem !important;
        margin-bottom: 1.5rem !important;
    }

    /* Touch-friendly buttons */
    button, a.btn, .btn {
        min-height: 44px !important;
        min-width: 44px !important;
        padding: 12px 20px !important;
        font-size: 1rem !important;
    }

    /* Forms on mobile */
    input, textarea, select {
        font-size: 16px !important; /* Prevents zoom on iOS */
        padding: 12px !important;
        max-width: 100%;
    }

    /* Tables - make them scrollable */
    table {
        display: block;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        white-space: nowrap;
    }

    /* Cards and content boxes */
    .card, .box, .content-box {
        margin-bottom: 1rem !important;
        padding: 1rem !important;
    }

    /* Grid adjustments */
    .row {
        margin-left: -0.5rem !important;
        margin-right: -0.5rem !important;
    }

    [class*="col-"] {
        padding-left: 0.5rem !important;
        padding-right: 0.5rem !important;
    }
}

/* Extra small devices */
@media (max-width: 480px) {
    /* Even smaller text for very small screens */
    h1 {
        font-size: 1.5rem !important;
    }

    h2 {
        font-size: 1.3rem !important;
    }

    /* Reduce padding on small screens */
    .container, .container-fluid {
        padding-left: 0.75rem !important;
        padding-right: 0.75rem !important;
    }

    /* Stack elements vertically */
    

    /* Full width buttons on small screens */
    button, a.btn, .btn {
        width: 100% !important;
    }
}

/* Fix common layout issues */
@media (max-width: 768px) {
    /* Hero sections */
    section[id*="hero"], .hero {
        min-height: auto !important;
        padding: 2rem 1rem !important;
    }

    /* Images in hero */
    .hero img, section[id*="hero"] img {
        max-width: 100% !important;
        height: auto !important;
        object-fit: cover;
    }

    /* Fix overflow in specific containers */
    .image_container, .mbl_image_container1 {
        position: relative !important;
        width: 100% !important;
        overflow: hidden !important;
    }

    /* Gallery items */
    .gallery-item, .portfolio-item {
        width: 100% !important;
        margin-bottom: 1rem !important;
    }

    /* Navigation dropdowns on mobile */
    .dropdown-menu {
        position: static !important;
        width: 100% !important;
        box-shadow: none !important;
        border: none !important;
        transform: none !important;
    }

    /* Footer adjustments */
    footer {
        text-align: center !important;
    }

    footer .row > div {
        margin-bottom: 1.5rem !important;
    }

    /* Social media icons */
    .social-icons a {
        font-size: 1.5rem !important;
        margin: 0 0.5rem !important;
    }
}

/* Landscape mobile devices */
@media (max-width: 768px) and (orientation: landscape) {
    /* Reduce vertical padding in landscape */
    section {
        padding-top: 1.5rem !important;
        padding-bottom: 1.5rem !important;
    }
}

/* Tablet optimizations */
@media (min-width: 769px) and (max-width: 1024px) {
    .container {
        max-width: 95% !important;
    }

    h1 {
        font-size: 2rem !important;
    }

    h2 {
        font-size: 1.75rem !important;
    }
}

/* Touch device optimizations */
@media (hover: none) and (pointer: coarse) {
    /* Larger tap targets */
    a, button, input[type="submit"], input[type="button"] {
        min-height: 48px !important;
        padding: 14px 24px !important;
    }

    /* Remove hover effects on touch devices */
    *:hover {
        -webkit-tap-highlight-color: transparent;
    }
}

/* Performance optimizations */
@media (max-width: 768px) {
    /* Reduce animation complexity on mobile */
    *, *::before, *::after {
        animation-duration: 0.3s !important;
        transition-duration: 0.2s !important;
    }

    /* Simplify shadows on mobile */
    .shadow, .card, .box {
        box-shadow: 0 2px 4px rgba(0,0,0,0.1) !important;
    }
}

/* Fix specific Tailwind classes on mobile */
@media (max-width: 768px) {
    .lg\:text-3xl, .lg\:text-4xl, .lg\:text-5xl {
        font-size: 1.5rem !important;
    }

    .lg\:px-8, .lg\:px-12 {
        padding-left: 1rem !important;
        padding-right: 1rem !important;
    }

    .lg\:py-8, .lg\:py-12 {
        padding-top: 1.5rem !important;
        padding-bottom: 1.5rem !important;
    }
}

/* Accessibility - minimum text size */
@media (max-width: 768px) {
    .text-xs, .text-sm {
        font-size: 0.875rem !important;
    }
}

/* Mobile Header Fix - Keep logo and menu on same line */
@media (max-width: 768px) {
    .header-nav .flex.justify-between {
        flex-wrap: nowrap !important;
        display: flex !important;
        align-items: center !important;
        flex-direction: row !important;
    }

    .header-nav .flex-shrink-0 {
        flex: 1 1 auto !important;
        min-width: 0 !important;
        max-width: calc(100% - 60px) !important;
        display: block !important;
    }

    .header-nav .logo-text {
        display: block !important;
        overflow: visible !important;
    }

    .header-nav .logo-text > div {
        display: flex !important;
        flex-wrap: wrap !important;
    }

    /* Ensure hamburger menu stays on right */
    .mobile-toggle {
        flex: 0 0 auto !important;
        flex-shrink: 0 !important;
        margin-left: 0.5rem !important;
        display: block !important;
    }

    .mobile-toggle button {
        padding: 0.5rem !important;
        min-width: 40px !important;
        min-height: 40px !important;
    }

    /* Simplify logo on mobile */
    .header-nav .logo-text .text-lg,
    .header-nav .logo-text .text-xl,
    .header-nav .logo-text .font-bold {
        font-size: 1.1rem !important;
        display: inline-block !important;
    }

    .header-nav .logo-text .text-xs {
        font-size: 0.75rem !important;
        display: inline-block !important;
        margin-left: 0.5rem !important;
    }

    /* Compact logo text on very small screens */
    @media (max-width: 380px) {
        .header-nav .logo-text .text-lg {
            font-size: 0.9rem !important;
        }

        .header-nav .logo-text .text-xs {
            font-size: 0.65rem !important;
        }
    }
}
