/**
 * Universal Responsive Stylesheet for B2B Platform
 * Ensures flawless layout on Mobile (320px - 767px), Tablet (768px - 1024px), and Desktop (> 1024px).
 * Eliminates all horizontal scroll / overflow issues.
 */

/* 1. Global Viewport & Box Resets */
html {
    width: 100%;
    max-width: 100vw;
    overflow-x: hidden;
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
    box-sizing: border-box;
}

body {
    width: 100%;
    max-width: 100vw;
    overflow-x: hidden;
    position: relative;
    margin: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
}

*, *::before, *::after {
    box-sizing: inherit;
}

/* 2. Responsive Table Wrappers */
.table-responsive,
[style*="overflow-x: auto"],
[style*="overflow-x:auto"] {
    width: 100% !important;
    max-width: 100% !important;
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch !important;
    display: block !important;
    box-sizing: border-box !important;
    margin-bottom: 15px;
    border-radius: 8px;
}

/* Allow table inside responsive container to size naturally without forcing page overflow */
.table-responsive table,
[style*="overflow-x: auto"] table,
[style*="overflow-x:auto"] table {
    width: 100% !important;
    max-width: none !important;
    min-width: 550px;
    border-collapse: collapse;
}

/* 3. Media Controls & Images */
img, svg, video, canvas {
    max-width: 100%;
    height: auto;
}

/* 4. Touch Targets & Form Controls (Prevent auto-zoom on mobile) */
@media (max-width: 768px) {
    input[type="text"],
    input[type="number"],
    input[type="password"],
    input[type="email"],
    input[type="tel"],
    input[type="search"],
    select,
    textarea {
        font-size: 16px !important; /* Critical: prevents iOS/Android zoom on focus */
        max-width: 100% !important;
        box-sizing: border-box !important;
    }
}

/* 5. Mobile Adjustments (< 768px) */
@media (max-width: 768px) {
    .container {
        width: 100% !important;
        max-width: 100% !important;
        padding-left: 12px !important;
        padding-right: 12px !important;
        box-sizing: border-box !important;
    }

    .content {
        padding: 12px 10px !important;
        width: 100% !important;
        max-width: 100% !important;
        overflow-x: hidden !important;
    }

    /* Grids to single column */
    .stats-grid,
    .grid-two-columns,
    .quick-actions,
    .form-grid,
    .layout-grid,
    .content-grid {
        grid-template-columns: 1fr !important;
        gap: 12px !important;
    }

    .card,
    .admin-card,
    .section-block,
    .panel {
        padding: 14px 12px !important;
        margin-bottom: 15px !important;
        border-radius: 10px !important;
    }

    /* Modals fit mobile */
    .modal-box,
    .modal-content {
        width: 95% !important;
        max-width: 95% !important;
        margin: 5% auto !important;
        padding: 16px !important;
    }
}

/* 6. Tablet Adjustments (769px to 1024px) */
@media (min-width: 769px) and (max-width: 1024px) {
    .container {
        max-width: 100% !important;
        padding-left: 20px !important;
        padding-right: 20px !important;
    }

    .stats-grid {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 15px !important;
    }

    .grid-two-columns,
    .content-grid {
        grid-template-columns: 1fr !important;
    }
}
