/*
 * Supreme Master System — shared phone/tablet rules for every front-end shortcode.
 * Loaded only on pages that contain one of the plugin's shortcodes.
 * Everything here sits inside a max-width media query, so desktop layouts are untouched.
 * Component-specific fixes live in each component's own CSS.
 */

/* ---------- No sideways scrolling on phones (v2.50.2) ----------
 * This stylesheet only loads on pages that contain one of the plugin's shortcodes.
 * On those pages, nothing on the page (the shortcode itself, or a theme/page-builder
 * element around it such as an over-sized heading) may make the page wider than the
 * screen, so visitors can never drag it sideways into empty white space.
 * "clip" (unlike "hidden") doesn't create a scroll container, so sticky headers
 * keep working; older browsers without "clip" fall back to "hidden" on body only.
 */
@media (max-width: 782px) {
    html, body {
        overflow-x: clip !important;
        max-width: 100% !important;
    }
}
@supports not (overflow: clip) {
    @media (max-width: 782px) {
        body {
            overflow-x: hidden !important;
            position: relative;
        }
    }
}

@media (max-width: 782px) {

    /* ---------- Form fields: 16px stops iPhone/iPad from zooming the page on focus ---------- */
    .smsp-wrap input:not([type=checkbox]):not([type=radio]):not([type=button]):not([type=submit]),
    .smsp-wrap select, .smsp-wrap textarea,
    .cit-payment-page input, .cit-payment-page select,
    .fdm-shortcode-display input, .fdm-shortcode-display select,
    .sms-scan-wrap input,
    .org-profile input, .org-profile select, .org-directory input,
    .custom-query-report-wrapper input, .custom-query-report-wrapper select,
    .sqb-docs input, .sqb-docs select, .ta-docs input, .ta-docs select,
    .paypal-event-button input:not([type=checkbox]):not([type=radio]), .paypal-event-button select, .paypal-event-button textarea,
    .paypal-event-calendar-container select, .paypal-event-calendar-container input,
    .cpeb-checkin-container input, .cpeb-checkin-container select,
    .cpeb-event-lookup-wrap input,
    .cpeb-gl-container input, .cpeb-gl-container select {
        font-size: 16px !important;
        max-width: 100%;
        box-sizing: border-box;
    }

    /* ---------- Long words / URLs / emails never push the page sideways ----------
     * break-word (not "anywhere"): it only breaks a word that can't fit on its line,
     * and it does NOT shrink table columns' minimum widths — "anywhere" let tables
     * squeeze buttons down to a few letters ("Vie / w"). */
    .smsp-wrap, .cit-payment-page, .fdm-shortcode-display, .news-teocalli-container,
    .org-profile, .org-directory, .custom-query-report-wrapper, .sqb-profile, .sqb-docs,
    .ta-docs, .paypal-event-button, .paypal-event-calendar-container, .cpeb-checkin-container,
    .cpeb-event-lookup-wrap, .cpeb-gl-container {
        overflow-wrap: break-word;
        max-width: 100%;
    }
    .smsp-wrap img, .smsp-wrap canvas, .org-profile img, .org-profile canvas,
    .news-teocalli-container img, .paypal-event-button img, .sqb-profile img {
        max-width: 100% !important;
        height: auto;
    }
}

/* ---------- Data tables become labelled cards on phones ----------
 * sms-mobile.js adds .sms-rt to the plugin's data tables and copies each column
 * header into the cell's data-label, so every value keeps its label once the
 * header row is hidden.
 */
@media (max-width: 640px) {
    table.sms-rt,
    table.sms-rt > tbody,
    table.sms-rt > tbody > tr,
    table.sms-rt > tbody > tr > td {
        display: block !important;
        width: 100% !important;
        box-sizing: border-box;
    }
    table.sms-rt { border: 0 !important; background: transparent !important; }
    table.sms-rt > thead { display: none !important; }
    table.sms-rt > tbody > tr {
        background: #fff !important;
        border: 1px solid #e3e3e3 !important;
        border-radius: 8px;
        padding: 10px 14px !important;
        margin: 0 0 12px !important;
        box-shadow: 0 1px 2px rgba(0, 0, 0, .04);
    }
    table.sms-rt > tbody > tr > td {
        display: flex !important;
        justify-content: space-between;
        align-items: center;
        gap: 14px;
        padding: 9px 0 !important;
        border: 0 !important;
        border-bottom: 1px solid #f0f0f0 !important;
        text-align: right !important;
        min-height: 0;
        word-break: normal;
        overflow-wrap: anywhere;
    }
    table.sms-rt > tbody > tr > td:last-child { border-bottom: 0 !important; }
    table.sms-rt > tbody > tr > td[data-label]::before {
        content: attr(data-label);
        flex: 0 0 auto;
        max-width: 45%;
        text-align: left;
        font-weight: 600;
        color: #555;
        font-size: 13px;
        text-transform: none;
        letter-spacing: 0;
        overflow-wrap: normal;
        word-break: normal;
    }
    /* A cell with no header (or a full-width message row) spans the card. */
    table.sms-rt > tbody > tr > td:not([data-label]),
    table.sms-rt > tbody > tr > td[colspan] {
        display: block !important;
        text-align: left !important;
    }
    /* Action cells: buttons wrap and sit to the right of their label. */
    table.sms-rt > tbody > tr > td.sms-rt-actions {
        flex-wrap: wrap;
        justify-content: flex-end;
    }
    table.sms-rt > tbody > tr > td.sms-rt-actions::before { margin-right: auto; }
    table.sms-rt > tbody > tr > td.sms-rt-actions > * { margin: 0 !important; }
    table.sms-rt > tbody > tr > td.sms-rt-actions > a,
    table.sms-rt > tbody > tr > td.sms-rt-actions > button {
        display: inline-flex !important;
        align-items: center;
        justify-content: center;
        min-height: 40px;
        text-decoration: none;
        line-height: 1.2;
        box-sizing: border-box;
    }
    table.sms-rt > tbody > tr > td.sms-rt-actions > br { display: none; }
}
