/* =====================================================================
   NexFit / Fit Urban: responsive safety net (design-only)
   ---------------------------------------------------------------------
   Loaded LAST in every layout so it refines the page stylesheets above.
   Presentation only: no markup, routes, redirects, validation or
   JavaScript behaviour is touched.

   Goals
   1. Nothing is cut off, overlaps a neighbour, or leaves its container.
   2. Short labels ("Cancellations", "No-shows", "Needs marking") wrap
      only between words, never in the middle of a word.
   3. Long unbroken strings (emails, URLs, names) wrap inside their box.
   4. Cards, buttons, modals and form controls never exceed the viewport.
   ===================================================================== */

/* ---------- 1. Foundations ---------- */
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body { max-width: 100%; overflow-x: clip; }          /* clip (not hidden) keeps sticky headers working */
img, video, canvas, iframe, embed, object { max-width: 100%; }
pre { max-width: 100%; overflow-x: auto; }
code, kbd, samp { overflow-wrap: anywhere; }

/* ---------- 2. Long text wraps inside its container ---------- */
h1, h2, h3, h4, h5, h6, p, li, dt, dd, label, legend, figcaption,
td, th, .modal-title, .modal-body, .card-title, .alert, .toast-body,
.dropdown-item, .list-group-item, .badge, .form-text, .invalid-feedback {
    overflow-wrap: break-word;
}
a { overflow-wrap: break-word; }

/* Text blocks inside flex rows must be allowed to shrink, otherwise they
   push past the card edge instead of wrapping. Buttons/icons are excluded. */
.d-flex > :is(div, span, p, h1, h2, h3, h4, h5, h6, a, small, strong):not(.btn):not([class*="icon"]):not([class*="ico"]):not(.badge) {
    min-width: 0;
}
.card, .card-body, .modal-content, .modal-body, .tab-pane, .list-group-item,
.row > [class*="col"] {
    min-width: 0;
}

/* ---------- 3. Short labels: break between words only ---------- */
/* Several page stylesheets set overflow-wrap:anywhere on label-like
   elements. That makes the label's min-content width ~1 character, so
   flex/grid parents squeeze it until "CANCELLATIONS" splits as
   "CANCELLA / TIONS". Restore word-level wrapping for these. */
.bk-kpi .bk-kpi-label,
.bk-kpi .bk-kpi-sub,
.ps-stat .ps-stat-label,
.ev-stat span, .ev-stat em,
.ev-kpi-body > *,
.tp-stat span,
.ts-kpi-body small,
.ts-stat small,
.bk-stat-body b,
.rx-kpi-label,
.metric-label,
.nf-chip .e,
.badge, .status-pill, .pill, [class*="-pill"], [class*="-chip"] {
    overflow-wrap: normal;
    word-break: normal;
    hyphens: none;
}
/* Only if one unbroken word is still wider than the whole card is it
   allowed to break, as a last resort. */
@supports (overflow-wrap: break-word) {
    .bk-kpi .bk-kpi-label,
    .bk-kpi .bk-kpi-sub { overflow-wrap: break-word; }
}

/* ---------- 4. Stat / KPI cards ---------- */
/* Manage Bookings strip: let the label use the full card width on
   narrow screens by stacking the number above it. */
.bk-kpis { grid-template-columns: repeat(auto-fit, minmax(min(100%, 170px), 1fr)); }
.bk-kpi { min-width: 0; }
.bk-kpi > span:last-child { min-width: 0; flex: 1 1 0; }
.bk-kpi .bk-kpi-label { flex-wrap: wrap; row-gap: 2px; line-height: 1.25; }
.bk-kpi .bk-dot { flex: none; }

@media (max-width: 575.98px) {
    .bk-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
    .bk-kpi { flex-direction: column; align-items: flex-start; gap: 6px; padding: 10px 12px; }
    .bk-kpi > span:last-child { width: 100%; flex: none; }
    .bk-kpi .bk-kpi-label { font-size: .68rem; letter-spacing: .2px; gap: 5px; }
    .bk-kpi .bk-kpi-sub { font-size: .72rem; line-height: 1.3; margin-top: 2px; }
}
@media (max-width: 359.98px) {
    .bk-kpis { grid-template-columns: minmax(0, 1fr); }
    .bk-kpi:last-child:nth-child(odd) { grid-column: auto; }
}

/* Same treatment for the other stat strips used across portals. */
.ts-kpi, .ev-kpi, .ps-stat, .rx-kpi, .metric-card, .ev-stat, .tp-stat { min-width: 0; max-width: 100%; }
.ts-kpi-body, .ev-kpi-body, .ps-stat > div, .ps-stat > span { min-width: 0; }
@media (max-width: 420px) {
    .ts-kpi, .ps-stat { flex-wrap: wrap; row-gap: 6px; }
    .ts-kpi-body, .ps-stat > div { flex: 1 1 100%; }
}

/* Big numbers/amounts scale with the screen instead of overflowing. */
.metric-value, .rx-kpi-value, .ps-stat-value, .rc-amount-val {
    max-width: 100%;
    overflow-wrap: anywhere;   /* digits only: safe to break as a last resort */
}
.rc-amount-val { font-size: clamp(1.9rem, 1.2rem + 3.4vw, 2.5rem); }

/* ---------- 5. Buttons, badges, chips ---------- */
.btn, .badge, .status-pill, .pill { max-width: 100%; }
@media (max-width: 575.98px) {
    .btn:not(.btn-icon):not(.btn-close):not([class*="-ico"]) {
        white-space: normal;
        line-height: 1.25;
        min-width: 0;
    }
    .badge, .status-pill, .pill { white-space: normal; text-align: left; line-height: 1.3; }
}

/* ---------- 6. Forms ---------- */
input, select, textarea { max-width: 100%; }
.form-control, .form-select, .input-group { min-width: 0; }
.input-group { flex-wrap: nowrap; }
.input-group > .form-control, .input-group > .form-select { min-width: 0; flex: 1 1 auto; width: 1%; }
@media (max-width: 575.98px) {
    .form-label, label { overflow-wrap: break-word; }
    .btn-group { flex-wrap: wrap; }
}

/* ---------- 7. Modals ---------- */
@media (max-width: 575.98px) {
    .modal-dialog:not(.modal-fullscreen) {
        max-width: calc(100vw - 1rem);
        margin-left: auto; margin-right: auto;
    }
    .modal-header { gap: 8px; align-items: flex-start; }
    .modal-title { min-width: 0; flex: 1 1 auto; line-height: 1.3; }
    .modal-footer { flex-wrap: wrap; gap: 8px; }
    .modal-footer > .btn { flex: 1 1 auto; margin: 0; }
}

/* ---------- 8. Page headings and top bars ---------- */
@media (max-width: 575.98px) {
    .page-title, .page-header h1, .content-area h1 { overflow-wrap: break-word; line-height: 1.2; }
    .page-subtitle, .page-header p { overflow-wrap: break-word; }
    .page-header, .page-head, .section-head, .card-header {
        flex-wrap: wrap;
        row-gap: 8px;
    }
}

/* ---------- 9. Tables and wide content scroll inside their box ---------- */
.table-responsive, .dataTables_wrapper, .dt-container { max-width: 100%; }
.table-responsive { -webkit-overflow-scrolling: touch; }
.dataTables_wrapper .dataTables_filter input { max-width: 100%; }
@media (max-width: 575.98px) {
    .dataTables_wrapper .dataTables_length,
    .dataTables_wrapper .dataTables_filter,
    .dataTables_wrapper .dataTables_info,
    .dataTables_wrapper .dataTables_paginate { float: none; text-align: left; white-space: normal; }
    .dataTables_wrapper .dataTables_filter input { width: 100%; margin-left: 0; }
    .dataTables_wrapper .dataTables_paginate { display: flex; flex-wrap: wrap; gap: 4px; }
}

/* ---------- 10. Respect user motion preference ---------- */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { scroll-behavior: auto !important; }
}
