/*
 * BKG Work System — mobile tier (phones and tablets, below 1200px, screen only)
 * Loaded by bkg_preview_assets.php right after bkg-ui-system.css, so every portal module shares
 * one type scale and one control size on phones. Only font-family / font-size / height / padding /
 * line-height are forced; colors, layout and module logic stay with each page.
 *
 * Why these numbers: controls are 16px so iOS Safari does not auto-zoom on focus, and 44px tall so
 * they match the Portal mobile home and the platform touch-target size.
 *
 * Opt-outs
 *   [data-bkg-mobile="dense"] on a table or wrapper  → keeps that table/section compact (fields and buttons stay unified)
 *   [data-bkg-font="keep"]   on <html>               → keeps the module's own font family (numeric sheets)
 */
@import url("https://fonts.googleapis.com/css2?family=Kodchasan:wght@300;400;600;700&display=swap");
html body .bkg-legacy-search-clear { display:none !important; }

@media screen and (max-width:1199.98px) {
    html body .fc .fc-list-event-time { padding:12px 14px !important; vertical-align:middle !important; white-space:normal; }
    html body .fc .fc-list-event-graphic { vertical-align:middle !important; }
    html body .fc .fc-list-event-graphic .fc-list-event-dot { display:block; }
    html[data-bs-theme="dark"] body :is(.fc .fc-list-day-cushion,.bkg-calendar-list-day) { background:#233b4f !important; color:#f8fafc !important; border-block:1px solid #47647b !important; }
    html[data-bs-theme="dark"] body .bkg-calendar-list-day { padding:8px 14px !important; }
    html[data-bs-theme="dark"] body .fc .fc-list-day-cushion :is(.fc-list-day-text,.fc-list-day-side-text) { color:inherit !important; }
    html body #rentalQrAction { margin-left:auto !important; }
    html body :is(#rentDocumentReload,#unitListReload) { display:none !important; }
    html body :is(#holidayToolbarActions,#leaveCalendarToolbarActions) { width:100%; flex-wrap:wrap; }
    html body :is(#holidayPrintButton,#leaveCalendarPrintButton) { margin-left:auto !important; }
    html body.bkg-mobile-compact .bkg-mobile-page-heading { display:none !important; }
    html body.bkg-mobile-compact .bkg-mobile-heading-toolbar { padding-block:0 !important; margin-bottom:8px !important; min-height:0 !important; }
    html body.bkg-mobile-compact .bkg-mobile-page-toolbar { border:0 !important; background:none !important; box-shadow:none !important; }
    html body.bkg-mobile-compact > :is(.container,.container-fluid,.container-full,.custom-container,.page-shell,.page-wrapper) { padding-top:8px !important; }
    html body.bkg-mobile-compact .bkg-mobile-button-caption { display:none !important; }
    html body.bkg-mobile-compact .bkg-mobile-icon-command { min-width:40px; gap:0 !important; padding-inline:10px !important; }
    html body.bkg-mobile-compact .bkg-mobile-short-command { max-width:100%; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
    html body.bkg-mobile-compact .bkg-mobile-pad-y { padding-top:16px !important; padding-bottom:16px !important; }
    html body.bkg-mobile-compact .bkg-mobile-pad-x { padding-left:16px !important; padding-right:16px !important; }
    html body.bkg-mobile-compact :is(.glass-card,.glass-panel,.filters,.surface):not(.modal *):not(dialog *):not(.modal) { margin-bottom:12px; }
    html[data-bkg-page="bkg_hr/employment_settings"] #staffRows .action-cell { width:auto !important; background:transparent !important; box-shadow:none !important; }
}

@media screen and (max-width: 1199.98px) {
    :root {
        --bkg-m-font: 'Kodchasan', 'Noto Sans Thai', 'Leelawadee UI', Tahoma, system-ui, -apple-system, 'Segoe UI', sans-serif;
        --bkg-m-text: 16px;
        --bkg-m-control: 16px;
        --bkg-m-label: 14px;
        --bkg-m-caption: 13px;
        --bkg-m-table: 14px;
        --bkg-m-table-sm: 13px;
        --bkg-m-btn: 15px;
        --bkg-m-btn-sm: 14px;
        --bkg-m-h1: 21px;
        --bkg-m-h2: 19px;
        --bkg-m-h3: 18px;
        --bkg-m-h4: 17px;
        --bkg-m-h5: 16px;
        --bkg-m-h6: 15px;
        --bkg-m-control-h: 44px;
        --bkg-m-control-h-sm: 38px;
        --bkg-m-control-pad-x: .85rem;
        /* Raise the shared layer (40px desktop / 42px small) to the phone size; input-group parts follow it. */
        --bkg-ui-control-height: var(--bkg-m-control-h);
    }

    html {
        -webkit-text-size-adjust: 100%;
    }

    /* ---------- Font family & base text ---------- */
    html:not([data-bkg-font="keep"]) body,
    html:not([data-bkg-font="keep"]) body :is(input, select, textarea, button, .btn, table, .modal, .dropdown-menu, .form-control, .form-select) {
        font-family: var(--bkg-m-font) !important;
    }

    /* Base text: beats bare `body {}` rules but not a module's deliberate class-level sizing. */
    html body:not([data-bkg-mobile="dense"]) {
        font-size: var(--bkg-m-text);
        line-height: 1.45;
    }

    /* ---------- Fields ---------- */
    /* :where() keeps the exclusion chains at zero specificity, so the select / search follow-ups below can win. */
    html body :is(input, select, textarea, .form-control, .form-select):where(:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="file"]):not([type="hidden"]):not([type="color"]):not([type="button"]):not([type="submit"]):not([type="reset"]):not([type="image"])) {
        font-size: var(--bkg-m-control) !important;
        line-height: 1.35 !important;
    }

    /* Single-line fields: one height, one horizontal padding. Floating labels keep Bootstrap's own geometry. */
    html body :is(input, select, .form-control, .form-select):where(:not(textarea):not([multiple]):not(select[size]:not([size="0"]):not([size="1"])):not(.form-control-plaintext):not(.form-floating > *):not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="file"]):not([type="hidden"]):not([type="color"]):not([type="button"]):not([type="submit"]):not([type="reset"]):not([type="image"])) {
        box-sizing: border-box;
        height: var(--bkg-m-control-h) !important;
        min-height: var(--bkg-m-control-h) !important;
        padding-top: 0 !important;
        padding-bottom: 0 !important;
        padding-left: var(--bkg-m-control-pad-x) !important;
        padding-right: var(--bkg-m-control-pad-x) !important;
    }

    /* Native/Bootstrap selects keep room for the arrow. */
    html body :is(select, .form-select):where(:not([multiple])) {
        padding-right: 2.25rem !important;
    }

    html body :is(textarea, textarea.form-control) {
        min-height: 96px !important;
        padding: .6rem var(--bkg-m-control-pad-x) !important;
        line-height: 1.45 !important;
    }

    html body .input-group-text {
        font-size: var(--bkg-m-btn) !important;
        height: var(--bkg-m-control-h) !important;
        min-height: var(--bkg-m-control-h) !important;
        padding-top: 0 !important;
        padding-bottom: 0 !important;
    }

    /* Checkboxes and switches: finger-sized. */
    html body .form-check-input {
        width: 1.25rem;
        height: 1.25rem;
        margin-top: .15em;
    }

    html body .form-switch .form-check-input {
        width: 2.4rem;
    }

    html body .form-check-label {
        font-size: 15px !important;
        line-height: 1.4;
    }

    /* ---------- Search (anatomy comes from bkg-ui-system.js: no leading magnifier, × inside; the base layer's 2.65rem end padding already clears the 36px button) ---------- */
    html body .bkg-search-shell {
        width: 100%;
    }

    html body .bkg-search-clear {
        width: 36px !important;
        height: 36px !important;
        min-height: 36px !important;
        inset-inline-end: 4px !important;
    }

    html body .bkg-search-clear::before {
        font-size: 24px !important;
    }

    /* ---------- Labels & captions ---------- */
    html body :is(label, .form-label, .col-form-label):not(.form-check-label):not(.btn) {
        font-size: var(--bkg-m-label) !important;
        font-weight: 600;
        line-height: 1.35;
    }

    html body :is(.form-text, small, .small, .caption, .hint, .help-text, .text-caption):where(:not(.badge):not([data-bkg-mobile="dense"] *)) {
        font-size: var(--bkg-m-caption) !important;
    }

    /* ---------- Buttons ---------- */
    html body :is(.btn, .btn2, .action-btn, .filter-btn, .toolbar-btn):where(:not(.btn-close):not(.btn-sm):not(.btn-lg):not([data-bkg-mobile="dense"] *)) {
        font-size: var(--bkg-m-btn) !important;
        min-height: var(--bkg-m-control-h) !important;
        min-width: var(--bkg-m-control-h);
        padding: .45rem .95rem !important;
        line-height: 1.3 !important;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        gap: .4rem;
    }

    html body .btn-sm:where(:not(.btn-close):not([data-bkg-mobile="dense"] *)) {
        font-size: var(--bkg-m-btn-sm) !important;
        min-height: var(--bkg-m-control-h-sm) !important;
        min-width: var(--bkg-m-control-h-sm);
        padding: .3rem .7rem !important;
        line-height: 1.3 !important;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        gap: .35rem;
    }

    html body .btn-lg {
        font-size: 16px !important;
        min-height: 48px !important;
        padding: .55rem 1.1rem !important;
    }

    html body .btn-close {
        padding: .6rem;
    }

    /* ---------- Tabs, menus, pagination, badges ---------- */
    html body :is(.nav-tabs, .nav-pills) .nav-link {
        font-size: var(--bkg-m-btn) !important;
        min-height: var(--bkg-m-control-h);
        padding: .55rem .85rem !important;
        display: inline-flex;
        align-items: center;
        gap: .4rem;
    }

    html body .dropdown-item {
        font-size: var(--bkg-m-btn) !important;
        min-height: var(--bkg-m-control-h);
        padding: .6rem .9rem !important;
        display: flex;
        align-items: center;
        gap: .5rem;
    }

    html body .page-link {
        font-size: var(--bkg-m-btn) !important;
        min-width: 40px;
        min-height: 40px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }

    html body .badge {
        font-size: 12px !important;
    }

    /* ---------- Tables ---------- */
    html body table:where(:not(.table-sm):not([data-bkg-mobile="dense"]):not([data-bkg-mobile="dense"] *)) :is(th, td) {
        font-size: var(--bkg-m-table) !important;
        padding: .55rem .6rem !important;
        line-height: 1.35;
    }

    html body table.table-sm:where(:not([data-bkg-mobile="dense"]):not([data-bkg-mobile="dense"] *)) :is(th, td) {
        font-size: var(--bkg-m-table-sm) !important;
        padding: .35rem .45rem !important;
        line-height: 1.3;
    }

    /* ---------- Headings: normalize defaults, respect class-level sizing (stat tiles, hero numbers) ----------
       Element and class rules stay separate: a combined :is(h2, .h2) would take the class specificity and
       override a module's `.stat-number` sizing on an h2. */
    html body h1 { font-size: var(--bkg-m-h1); }
    html body h2 { font-size: var(--bkg-m-h2); }
    html body h3 { font-size: var(--bkg-m-h3); }
    html body h4 { font-size: var(--bkg-m-h4); }
    html body h5 { font-size: var(--bkg-m-h5); }
    html body h6 { font-size: var(--bkg-m-h6); }
    html body .h1 { font-size: var(--bkg-m-h1); }
    html body .h2 { font-size: var(--bkg-m-h2); }
    html body .h3 { font-size: var(--bkg-m-h3); }
    html body .h4 { font-size: var(--bkg-m-h4); }
    html body .h5 { font-size: var(--bkg-m-h5); }
    html body .h6 { font-size: var(--bkg-m-h6); }
    html body :is(.modal-title, .page-title, .section-title) { font-size: var(--bkg-m-h3) !important; }
    html body .card-title { font-size: var(--bkg-m-h4) !important; }
}
