/* KeyPointS mobile foundation — 2026-11-10
   Compatible approach for Telerik UI for Blazor 15.x.
   Load ONCE after the Telerik theme and the existing application CSS.

   IMPORTANT: this is an opt-in layout layer, NOT a grid/table/window reset.
   Telerik owns its own table, colgroup, sticky columns, dialogs and scrolling.

   Usage:
     .kps-fluid             On an outer flex/grid page/content container
     .kps-form-grid         On semantic forms laid out with div + label
     .kps-form-field        On each field container
     .kps-action-row        On a toolbar/action group
     .kps-data-scroll       On the wrapper of a wide *HTML* table only
     .kps-mobile-card-list  For custom, purpose-built mobile cards
     .kps-mobile-card       For each card
     .kps-mobile-card-row   For labelled facts in a card

   Telerik Grid mobile cards: use DataLayoutMode="Stacked" + MediaQuery in Razor.
   Telerik TabStrip: use OverflowMode="Menu" or "Scroll" in Razor.
   Telerik Window: set Width/MaxHeight in Razor; never force all .k-window.
*/

:root {
    --kps-m-gap: 12px;
    --kps-m-radius: 10px;
    --kps-m-border: #dce4ed;
    --kps-m-muted: #667789;
    --kps-m-ink: #26354c;
    --kps-m-card: #fff;
}

/* Allow nested flex/grid contents to shrink without creating page overflow. */
.kps-fluid,
.kps-fluid > *,
.kps-form-field,
.kps-mobile-card,
.kps-mobile-card-row,
.kps-mobile-card-row > * {
    min-width: 0;
    max-width: 100%;
    box-sizing: border-box;
}

/* Semantically structured forms. This does NOT rewrite existing tables. */
.kps-form-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px 18px;
    min-width: 0;
}
.kps-form-field {
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.kps-form-field > label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--kps-m-ink);
}
.kps-form-field > :is(.k-input, .k-picker, .k-dropdownlist,
                      .k-combobox, .k-numerictextbox, .k-textbox,
                      .k-textarea, input, select, textarea) {
    width: 100%;
    min-width: 0;
    max-width: 100%;
    box-sizing: border-box;
}
.kps-form-field--full { grid-column: 1 / -1; }

/* Toolbars: controls remain usable without pushing the entire page wide. */
.kps-action-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    min-width: 0;
}
.kps-action-row > * { min-width: 0; }

/* Explicit horizontal scrolling only for true HTML tables with many columns. */
.kps-data-scroll {
    display: block;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    overflow-x: auto;
    overscroll-behavior-x: contain;
    -webkit-overflow-scrolling: touch;
}
.kps-data-scroll > table {
    min-width: 760px;
    width: max-content;
}

/* Purpose-built cards for interactive purchase/quote flows. */
.kps-mobile-card-list { display: grid; gap: var(--kps-m-gap); min-width: 0; }
.kps-mobile-card {
    padding: 14px;
    border: 1px solid var(--kps-m-border);
    border-radius: var(--kps-m-radius);
    background: var(--kps-m-card);
    box-shadow: 0 2px 8px rgb(24 39 70 / 5%);
}
.kps-mobile-card-title {
    font-weight: 750;
    color: var(--kps-m-ink);
    overflow-wrap: anywhere;
}
.kps-mobile-card-row {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
    padding: 8px 0;
    border-bottom: 1px solid #eff2f5;
}
.kps-mobile-card-row:last-child { border-bottom: 0; }
.kps-mobile-card-label { color: var(--kps-m-muted); font-size: 12px; flex: 0 0 37%; }
.kps-mobile-card-value { color: var(--kps-m-ink); text-align: right; overflow-wrap: anywhere; }

/* Mobile-only composition rules. Telerik's native Grid remains untouched. */
@media screen and (max-width: 767.98px) {
    .kps-form-grid { grid-template-columns: minmax(0, 1fr); gap: 12px; }
    .kps-action-row > .k-button { min-height: 44px; }
    .kps-mobile-card-row { align-items: flex-start; }
    .kps-mobile-card-row .kps-mobile-card-value { flex: 1 1 auto; }
}

/* Existing separate quote print layout must remain unchanged. */
@media print {
    .kps-mobile-card-list[data-screen-only='true'] { display: none !important; }
}
