/* Mobile Responsiveness for Sirex E-commerce */

/* Mobile First Breakpoints */
/* xs: < 576px (default mobile) */
/* sm: >= 576px (landscape phones) */
/* md: >= 768px (tablets) */
/* lg: >= 992px (desktops) */
/* xl: >= 1200px (large desktops) */

/* Base Mobile Styles (< 576px) */
@media (max-width: 575.98px) {
    /* Global Page Layout */
    html, body {
        overflow-x: hidden;
        width: 100%;
        position: relative;
    }

    /* Typography */
    .hero-section h1 {
        font-size: 2rem !important;
    }
    
    .hero-section p {
        font-size: 1rem !important;
    }
    
    h3 {
        font-size: 1.5rem !important;
    }
    
    /* Navigation Layout - Mobile Specific */
    .navbar .container {
        flex-wrap: wrap; /* Allow wrapping */
        justify-content: space-between;
        align-items: center;
        padding-top: 5px;
        padding-bottom: 5px;
    }

    /* 1. Logo (Top Left) */
    .navbar-brand {
        font-size: 1.25rem !important;
        margin-right: 10px;
        order: 1;
        width: auto;
    }

    /* 2. Horizontal Nav (Top Right) */
    .mobile-horizontal-nav {
        display: block !important;
        order: 2;
        width: auto; /* Let it shrink/grow naturally */
        flex: 1; /* Take remaining space on line 1 */
        overflow-x: auto;
        white-space: nowrap;
        -webkit-overflow-scrolling: touch;
        margin-left: auto;
        text-align: right;
    }

    /* 3. Force Break */
    .mobile-break {
        order: 3;
        flex-basis: 100%;
        height: 0;
        margin: 0;
        padding: 0;
    }

    /* 4. Hamburger (Bottom Left) */
    .navbar > .container > button.btn { /* Target the offcanvas toggle button */
        display: inline-block !important;
        order: 4;
        margin-right: 2px;
        padding: 4px 2px !important;
        font-size: 1.2rem;
        margin-top: 5px;
        min-width: auto !important;
        width: auto !important;
        line-height: 1;
        border: 1px solid #dee2e6;
        vertical-align: middle;
    }

    /* 5. Search Box (Bottom Right) */
    .search-box {
        width: auto !important;
        margin: 5px 0 0 0;
        order: 5;
        flex: 1;
        min-width: 0;
    }
    
    .search-box input {
        border-top-right-radius: 0;
        border-bottom-right-radius: 0;
        height: 38px; /* Fixed height for consistency */
        font-size: 14px;
    }
    
    .search-box button {
        flex: 0 0 auto;
        width: auto;
        padding: 0 10px !important;
        border-top-left-radius: 0; 
        border-bottom-left-radius: 0;
        height: 38px;
    }
    
    /* Hide scrollbar for nav but keep functionality */
    .mobile-horizontal-nav::-webkit-scrollbar {
        height: 0px;
        background: transparent;
    }
    
    .mobile-horizontal-nav {
        width: 100%;
        display: flex;
        flex-direction: column;
    }

    .navbar-nav {
        flex-direction: row !important;
        overflow-x: auto;
        white-space: nowrap;
        padding-bottom: 5px;
        -webkit-overflow-scrolling: touch;
        gap: 10px;
    }

    .navbar-nav .nav-link {
        padding-right: .5rem;
        padding-left: .5rem;
    }
    
    /* Product Cards */
    .product-card img {
        height: 200px !important;
    }
    
    .product-card .card-body {
        padding: 1rem !important;
    }
    
    .product-card .card-title {
        font-size: 0.9rem !important;
    }
    
    /* Buttons */
    .btn {
        width: 100%;
        margin-bottom: 0.5rem;
    }
    
    .btn-sm {
        width: auto;
    }
    
    /* Forms */
    .form-control, .form-select {
        font-size: 16px; /* Prevents zoom on iOS */
    }
    
    /* Tables */
    .table-responsive {
        font-size: 0.875rem;
    }
    
    .table thead {
        display: none;
    }
    
    .table tbody tr {
        display: block;
        margin-bottom: 1rem;
        border: 1px solid var(--border-color);
        border-radius: var(--radius-md);
        padding: 1rem;
    }
    
    .table tbody td {
        display: block;
        text-align: right;
        padding: 0.5rem 0;
        border: none;
    }
    
    .table tbody td::before {
        content: attr(data-label);
        float: left;
        font-weight: 700;
        color: var(--text-secondary);
    }
    
    /* Cards */
    .card {
        margin-bottom: 1rem;
    }
    
    .card-header {
        padding: 1rem !important;
    }
    
    /* Hero Section */
    .hero-section {
        padding: 3rem 0 !important;
    }
    
    /* Spacing */
    .container {
        padding-left: 1rem;
        padding-right: 1rem;
    }
    
    section {
        padding: 2rem 0 !important;
    }
    
    /* Cart */
    .cart-item {
        flex-direction: column;
    }
    
    .cart-item img {
        width: 100% !important;
        margin-bottom: 1rem;
    }
}

/* Tablet Styles (576px - 767.98px) */
@media (min-width: 576px) and (max-width: 767.98px) {
    .hero-section h1 {
        font-size: 2.5rem !important;
    }
    
    .product-card img {
        height: 250px !important;
    }
    
    .search-box {
        width: 400px !important;
    }
}

/* Tablet Landscape / Small Desktop (768px - 991.98px) */
@media (min-width: 768px) and (max-width: 991.98px) {
    .hero-section h1 {
        font-size: 3rem !important;
    }
    
    .product-card img {
        height: 280px !important;
    }
    
    .search-box {
        width: 500px !important;
    }
}

/* Touch-Friendly Enhancements */
@media (hover: none) and (pointer: coarse) {
    /* Larger touch targets */
    .btn {
        min-height: 44px;
        padding: 0.75rem 1.5rem;
    }
    
    .nav-link {
        min-height: 44px;
        display: flex;
        align-items: center;
    }
    
    .form-control, .form-select {
        min-height: 44px;
    }
    
    /* Remove hover effects on touch devices */
    .product-card:hover {
        transform: none;
    }
    
    .btn:hover {
        transform: none;
    }
}

/* Landscape Orientation */
@media (max-width: 767.98px) and (orientation: landscape) {
    .hero-section {
        padding: 2rem 0 !important;
    }
    
    .hero-section h1 {
        font-size: 1.75rem !important;
    }
}

/* High DPI Displays */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    .product-card img {
        image-rendering: -webkit-optimize-contrast;
    }
}

/* Accessibility - Reduced Motion */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Print Styles */
@media print {
    .navbar, footer, .btn {
        display: none !important;
    }
    
    .container {
        max-width: 100%;
    }
    
    .card {
        box-shadow: none;
        border: 1px solid #000;
    }
}

/* Utility Classes for Responsive Design */
.mobile-only {
    display: block;
}

.desktop-only {
    display: none;
}

@media (min-width: 768px) {
    .mobile-only {
        display: none;
    }
    
    .desktop-only {
        display: block;
    }
}

/* Responsive Images */
img {
    max-width: 100%;
    height: auto;
}

/* Responsive Embeds */
.embed-responsive {
    position: relative;
    display: block;
    width: 100%;
    padding: 0;
    overflow: hidden;
}

.embed-responsive::before {
    display: block;
    content: "";
}

.embed-responsive-16by9::before {
    padding-top: 56.25%;
}

.embed-responsive-item {
    position: absolute;
    top: 0;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border: 0;
}

/* Mobile Navigation Improvements */
@media (max-width: 991.98px) {
    .navbar-collapse {
        background: rgba(102, 126, 234, 0.95);
        padding: 1rem;
        border-radius: var(--radius-md);
        margin-top: 1rem;
    }
    
    .navbar-nav {
        gap: 0.5rem;
    }
    
    .nav-link {
        padding: 0.75rem 1rem !important;
        border-radius: var(--radius-sm);
    }
    
    .nav-link:hover {
        background: rgba(255, 255, 255, 0.1);
    }
}

/* Offcanvas Mobile Optimization */
.offcanvas {
    max-width: 80vw;
}

@media (max-width: 575.98px) {
    .offcanvas {
        max-width: 90vw;
    }
}

/* Grid Improvements for Mobile */
@media (max-width: 767.98px) {
    .row > [class*='col-'] {
        margin-bottom: 1rem;
    }
    
    .row > [class*='col-']:last-child {
        margin-bottom: 0;
    }
}

/* Modal Responsiveness */
@media (max-width: 575.98px) {
    .modal-dialog {
        margin: 0.5rem;
    }
    
    .modal-content {
        border-radius: var(--radius-lg);
    }
}

/* Carousel Mobile Optimization */
@media (max-width: 767.98px) {
    .carousel-item img {
        height: 250px !important;
    }
    
    .carousel-caption {
        display: none !important;
    }
}
