/*
 * Phone / tablet support for the dealer pages (included via partials/responsive.blade.php).
 * Every rule sits inside a max-width media query so the desktop layout is unchanged.
 */

/* Wide tables are wrapped in .table-scroll by js/responsive.js */
.table-scroll {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

/* ---------- Tablets and phones ---------- */
@media (max-width: 991.98px) {
    html,
    body {
        max-width: 100%;
        overflow-x: hidden;
    }

    img,
    video,
    canvas {
        max-width: 100%;
    }

    /* Tables scroll sideways inside their own box instead of pushing the page wider */
    .table-scroll > table {
        margin-bottom: 0;
    }

    .table-scroll th,
    .table-scroll td,
    .table-responsive th,
    .table-responsive td {
        white-space: nowrap;
    }

    /* Bootstrap modals that live inside a table cell (e.g. Edit Target) */
    .table-scroll td .modal,
    .table-responsive td .modal {
        white-space: normal;
    }

    /* Inputs inside table cells were squeezed to a few pixels wide */
    .table-scroll td input:not([type="checkbox"]):not([type="radio"]),
    .table-scroll td select,
    .table-scroll td textarea {
        min-width: 110px;
    }

    /* Modals opened from inside a scrolling table should still fit the screen */
    .modal-dialog {
        max-width: calc(100vw - 1rem);
        margin-left: auto;
        margin-right: auto;
    }

    /* Page header: shrink the logo and keep the title clear of it */
    img[src*="images/logo.webp"].position-absolute {
        height: 34px !important;
        margin-left: 3.25rem !important;
        margin-top: 0.85rem !important;
    }

    .bg-black h1 {
        font-size: 1.35rem !important;
        padding-left: 9.5rem;
        padding-right: 0.5rem;
        margin-bottom: 0;
    }

    /* Filter / search rows with fixed 200px inputs */
    .filter-form {
        justify-content: stretch !important;
        padding-left: 0.75rem;
        padding-right: 0.75rem;
    }

    .filter-form > *,
    .filter-form input[type="text"],
    .filter-form input[type="date"],
    .filter-form select {
        flex: 1 1 calc(50% - 10px);
        min-width: 0;
        width: auto !important;
        max-width: 100%;
    }

    .filter-form > a,
    .filter-form > button {
        flex: 0 0 auto;
    }

    /* Inputs wrapped in a div for autocomplete suggestions */
    .filter-form > div > input[type="text"],
    .filter-form > div > input[type="date"],
    .filter-form > div > select {
        width: 100% !important;
    }

    /* Keep row action buttons on one line so rows don't become very tall */
    .table-scroll td > .d-flex {
        flex-wrap: nowrap !important;
    }

    /* Fixed / centered overlay popups used instead of Bootstrap modals */
    #invoiceModal {
        top: 5% !important;
        left: 2.5% !important;
        width: 95% !important;
        height: 90% !important;
        padding: 10px !important;
    }
}

/* ---------- Card lists (GRN / Other GRN history) below Bootstrap's md breakpoint ---------- */
@media (max-width: 767.98px) {
    /* The column-title card makes no sense once columns stack; label each value instead */
    .grn-header-card {
        display: none;
    }

    .record-card [data-label] {
        display: flex;
        gap: 6px;
        padding-top: 2px;
        padding-bottom: 2px;
    }

    .record-card [data-label]::before {
        content: attr(data-label) ":";
        color: #ED1D26;
        font-weight: 600;
        min-width: 120px;
    }

    .record-card {
        margin-bottom: 0.5rem !important;
    }

    .bg-black .logo-img {
        height: 30px !important;
        top: 18px !important;
        left: 56px !important;
    }
}

/* ---------- Phones ---------- */
@media (max-width: 575.98px) {
    /* Stop iOS from zooming the page when a field is focused */
    input:not([type="checkbox"]):not([type="radio"]),
    select,
    textarea {
        font-size: 16px !important;
    }

    .bg-black h1 {
        font-size: 1.1rem !important;
        padding-left: 9rem;
        text-align: left !important;
    }

    .filter-form > *,
    .filter-form input[type="text"],
    .filter-form input[type="date"],
    .filter-form select {
        flex-basis: 100%;
    }

    .container,
    .container-fluid {
        padding-left: 0.75rem;
        padding-right: 0.75rem;
    }

    .btn {
        white-space: normal;
    }
}
