/* Mobile Responsiveness Fix for SchoolBundleSupply */
/* This file consolidates and fixes mobile responsiveness issues */

/* Ensure viewport meta tag effectiveness */
html {
    -webkit-text-size-adjust: 100%;
    -ms-text-size-adjust: 100%;
}

/* Fix body overflow on mobile */
body {
    overflow-x: hidden;
    position: relative;
    width: 100%;
}

/* Main content wrapper to prevent horizontal scroll */
main {
    overflow-x: hidden;
    width: 100%;
}

/* Mobile Menu Styles (768px and below) */
@media (max-width: 768px) {
    /* Ensure mobile menu toggle is visible */
    .mobile-menu-toggle {
        display: flex !important;
        position: relative;
        z-index: 1002;
    }
    
    /* Hide desktop navigation */
    .nav-wrapper,
    .nav-buttons {
        display: none !important;
    }
    
    /* Mobile header adjustments */
    .header {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        z-index: 1000;
        height: 60px;
    }
    
    .nav-container {
        padding: 0.75rem 1rem;
        height: 60px;
        display: flex;
        align-items: center;
        justify-content: space-between;
    }
    
    /* Adjust body padding for fixed header */
    body {
        padding-top: 6px !important;
    }
    
    /* Logo adjustments */
    .logo {
        font-size: 1.25rem !important;
        flex: 1;
    }
    
    /* Mobile menu styles */
    .mobile-menu {
        display: block !important;
        position: fixed;
        top: 0;
        right: -100%;
        width: 85vw;
        max-width: 320px;
        height: 100vh;
        background: white;
        z-index: 1001;
        transition: right 0.3s ease;
        overflow-y: auto;
        box-shadow: -4px 0 20px rgba(0, 0, 0, 0.1);
    }
    
    .mobile-menu.active {
        right: 0;
    }
    
    .mobile-menu-overlay {
        display: none;
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background: rgba(0, 0, 0, 0.5);
        z-index: 1000;
        opacity: 0;
        transition: opacity 0.3s ease;
    }
    
    .mobile-menu-overlay.active {
        display: block;
        opacity: 1;
    }
    
    /* Container and section adjustments */
    .container {
        padding: 0 1rem !important;
        max-width: 100% !important;
    }
    
    .section {
        padding: 2rem 0 !important;
    }
    
    /* Hero section mobile */
    .hero {
        padding: 2rem 0 !important;
    }
    
    .hero-container {
        grid-template-columns: 1fr !important;
        text-align: center;
        gap: 1.5rem;
        padding: 0 1rem;
    }
    
    .hero h1 {
        font-size: 2rem !important;
        line-height: 1.2;
        margin-bottom: 1rem;
    }
    
    .hero p {
        font-size: 1rem !important;
        margin-bottom: 1.5rem;
    }
    
    .hero-buttons {
        flex-direction: column;
        width: 100%;
        gap: 0.75rem;
    }
    
    .hero-buttons .btn {
        width: 100%;
        padding: 0.875rem 1.5rem;
        font-size: 1rem;
    }
    
    /* Grid layouts mobile */
    .categories-grid,
    .bundles-grid,
    .products-grid {
        grid-template-columns: 1fr !important;
        gap: 1rem !important;
        padding: 0 !important;
    }
    
    /* Card adjustments */
    .category-card,
    .bundle-card,
    .product-card {
        width: 100%;
        margin: 0;
        padding: 1.5rem !important;
    }
    
    /* Form elements */
    input,
    select,
    textarea {
        font-size: 16px !important; /* Prevents zoom on iOS */
        width: 100%;
        padding: 0.75rem !important;
    }
    
    /* Buttons */
    .btn,
    button {
        min-height: 44px; /* Touch-friendly size */
        padding: 0.75rem 1.5rem;
        font-size: 1rem;
        width: 100%;
        margin-bottom: 0.5rem;
    }
    
    /* Modal adjustments */
    .modal-content {
        width: 95% !important;
        max-width: 100% !important;
        margin: 1rem !important;
        max-height: 90vh;
        overflow-y: auto;
    }
    
    /* Table responsiveness */
    table {
        display: block;
        overflow-x: auto;
        width: 100%;
    }
    
    /* Footer mobile */
    .footer {
        padding: 2rem 0 !important;
    }
    
    .footer-content {
        grid-template-columns: 1fr !important;
        gap: 2rem;
        text-align: center;
    }
    
    .footer-section {
        margin-bottom: 1.5rem;
    }
    
    .footer-bottom {
        flex-direction: column;
        text-align: center;
        gap: 1rem;
    }
    
    /* Images */
    img {
        max-width: 100% !important;
        height: auto !important;
    }
    
    /* Prevent horizontal scroll from wide elements */
    * {
        max-width: 100vw !important;
        word-wrap: break-word;
    }
    
    /* Hide horizontal scrollbar but allow vertical scroll */
    html, body {
        overflow-x: hidden !important;
    }
}

/* Small mobile devices (480px and below) */
@media (max-width: 480px) {
    .hero h1 {
        font-size: 1.75rem !important;
    }
    
    .hero p {
        font-size: 0.875rem !important;
    }
    
    .container {
        padding: 0 0.75rem !important;
    }
    
    .btn {
        font-size: 0.875rem !important;
        padding: 0.625rem 1.25rem;
    }
    
    .category-card,
    .bundle-card {
        padding: 1rem !important;
    }
}

/* Landscape orientation adjustments */
@media (max-width: 768px) and (orientation: landscape) {
    .header {
        height: 50px;
    }
    
    .nav-container {
        height: 50px;
        padding: 0.5rem 1rem;
    }
    
    body {
        padding-top: 50px !important;
    }
    
    .hero {
        padding: 1.5rem 0 !important;
    }
    
    .hero h1 {
        font-size: 1.75rem !important;
    }
}

/* Touch-friendly hover states */
@media (hover: none) and (pointer: coarse) {
    .btn:hover,
    .card:hover,
    a:hover {
        transform: none !important;
        box-shadow: none !important;
    }
    
    /* Add active states for touch feedback */
    .btn:active,
    .card:active,
    a:active {
        transform: scale(0.98);
        opacity: 0.9;
    }
}

/* Fix for iOS Safari */
@supports (-webkit-touch-callout: none) {
    /* iOS specific fixes */
    .mobile-menu {
        -webkit-overflow-scrolling: touch;
    }
    
    input, textarea, select {
        -webkit-appearance: none;
        border-radius: 0;
    }
}

/* Ensure z-index hierarchy */
.header {
    z-index: 999;
}

.mobile-menu-overlay {
    z-index: 1000;
}

.mobile-menu {
    z-index: 1001;
}

.mobile-menu-toggle {
    z-index: 1002;
}

.modal {
    z-index: 1100;
}

.modal-content {
    z-index: 1101;
}

/* Loading spinner mobile adjustments */
@media (max-width: 768px) {
    .loading-overlay {
        padding: 1rem;
    }
    
    .loading-container {
        padding: 1.5rem;
        font-size: 0.875rem;
    }
    
    .loading-spinner {
        width: 40px;
        height: 40px;
    }
}

/* Accessibility improvements for mobile */
@media (max-width: 768px) {
    /* Ensure tap targets are at least 44x44 pixels */
    a, button, input, select, textarea, .clickable {
        min-height: 44px;
        min-width: 44px;
    }
    
    /* Increase spacing between interactive elements */
    .nav-menu li,
    .mobile-nav-list li {
        margin-bottom: 0.5rem;
    }
    
    /* Focus indicators */
    *:focus {
        outline: 3px solid #667eea;
        outline-offset: 2px;
    }
}

/* Print styles to prevent mobile print issues */
@media print {
    .mobile-menu-toggle,
    .mobile-menu,
    .mobile-menu-overlay {
        display: none !important;
    }
}