/* ─────────────────────────────────────────────────────────────────────
   HOMEi Contract screens — «بنود العقد» and «العقود» (CONTRACT-DS-1,
   design approved by Kamal 2026-11-10 on the house design system: the
   tenders / extracts / conversations references).

   The lists: the numbers strip, one card with a blue rule (the type pills
   and the search on the table's toolbar row) and — for the terms — the
   term read beside the list in a panel. The pages: the title with its
   tags, the form in a ruled card, the variables beside it, the save in a
   bar at the bottom.

   Colours: the design system's own tokens (--lm-d-* in tokens.css, with
   their dark mirror); no colour literal here — the ratchet holds this sheet
   at zero. Text never under 12px. RTL-safe: logical properties only.
   Scoped by `.ctr-page` (the page class) and `.ctr`.

   Registered as a Filament asset — a change here ships NOTHING until
   `php artisan filament:assets` is run and public/css/app/ is committed in
   the same change.
   ──────────────────────────────────────────────────────────────────── */

/* ── 1. the ground and the head ── */
body:has(.ctr-page) { background: var(--lm-d-page); }
body:has(.ctr-page) .fi-main-ctn { background: transparent; }
.ctr-page .fi-header-heading { font-size: 26px; font-weight: 700; line-height: 1.3; color: var(--lm-d-ink); }
.ctr-page .fi-header-subheading { margin-block-start: 4px; font-size: 13.5px; color: var(--lm-d-muted); }
.ctr { display: flex; flex-direction: column; gap: 12px; color: var(--lm-d-ink); }
.ctr :focus-visible, .ctr-page :focus-visible { outline: 2px solid var(--lm-d-info); outline-offset: 2px; }
.ctr-ico { inline-size: 16px; block-size: 16px; flex: none; }
.ctr-ico.is-info { color: var(--lm-d-info); }

/* the page's header actions: outline buttons, the main decision is the orange */
.ctr-page .fi-header-actions-ctn .fi-btn {
    min-block-size: 42px;
    border-radius: 12px;
    padding-inline: 16px;
    background: var(--lm-d-surface);
    color: var(--lm-d-ink);
    box-shadow: inset 0 0 0 1px var(--lm-d-control-edge);
    font-weight: 700;
}
.ctr-page .fi-header-actions-ctn .fi-btn .fi-icon { color: currentColor; }
.ctr-page .fi-header-actions-ctn .fi-btn:is(.fi-color-primary, .fi-color-success):not(.fi-outlined) { background: var(--lm-d-accent); color: var(--lm-d-on-accent); box-shadow: 0 4px 12px var(--lm-d-accent-soft); }
.ctr-page .fi-header-actions-ctn .fi-btn.fi-color-danger { color: var(--lm-d-danger); box-shadow: inset 0 0 0 1px var(--lm-d-gap-edge); }
.ctr-page .fi-header-actions-ctn .fi-btn.fi-disabled { opacity: 0.55; }

/* ── 2. the numbers strip ── */
.ctr-strip {
    display: grid;
    grid-template-columns: repeat(var(--ctr-cols, 5), minmax(0, 1fr));
    background: var(--lm-d-surface);
    border: 1px solid var(--lm-d-border);
    border-radius: 16px;
    box-shadow: 0 1px 2px var(--lm-d-shadow);
}
.ctr-strip-c { padding: 10px 18px; border-inline-start: 1px solid var(--lm-d-divider); min-inline-size: 0; }
.ctr-strip-c:first-child { border-inline-start: 0; }
.ctr-k-l { font-size: 13px; color: var(--lm-d-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ctr-k-v { font-size: 24px; font-weight: 700; line-height: 1.3; font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ctr-k-s { font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ctr-k-v.is-ink, .ctr-k-s.is-ink { color: var(--lm-d-ink); }
.ctr-k-v.is-muted, .ctr-k-s.is-muted { color: var(--lm-d-muted); }
.ctr-k-v.is-info { color: var(--lm-d-info); }
.ctr-k-v.is-ok, .ctr-k-s.is-ok { color: var(--lm-d-ok); }
.ctr-k-v.is-accent { color: var(--lm-d-accent-ink); }
.ctr-k-v.is-danger { color: var(--lm-d-danger); }

/* ── 3. the card with the blue rule, the table flattened into it ── */
.ctr-card {
    background: var(--lm-d-surface);
    border: 1px solid var(--lm-d-border);
    border-block-start: 3px solid var(--lm-d-info);
    border-radius: 16px;
    box-shadow: 0 1px 2px var(--lm-d-shadow);
    overflow: hidden;
    min-inline-size: 0;
}
.ctr-list .fi-ta-ctn { border: 0; border-radius: 0; box-shadow: none; background: transparent; }
.ctr-list .fi-ta-header-ctn { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding-inline: 14px; border-block-end: 1px solid var(--lm-d-divider); }
.ctr-list .fi-ta-header-ctn > * { border: 0; }
.ctr-list .fi-ta-header { padding: 10px 0; flex: 1 1 auto; min-inline-size: 0; }
.ctr-list .fi-ta-header-toolbar { padding: 8px 0; flex: 0 0 auto; border: 0; }
.ctr-list .fi-ta-search-field { min-inline-size: 260px; }
.ctr-list .fi-ta-header-cell { background: var(--lm-d-page); color: var(--lm-d-muted); font-size: 12.5px; font-weight: 700; padding-inline: 12px; white-space: nowrap; }
.ctr-list .fi-ta-cell { padding-inline: 12px; color: var(--lm-d-ink); }
.ctr-list .fi-ta-cell .fi-ta-text { padding-block: 10px; }
.ctr-list .fi-ta-row:hover > td { background: var(--lm-d-hover); }
.ctr-list .fi-ta-text-item-description, .ctr-list .fi-ta-text-description { font-size: 12.5px; color: var(--lm-d-muted); max-inline-size: 420px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ctr-list .fi-ta-actions .fi-icon-btn { inline-size: 34px; block-size: 34px; border-radius: 10px; box-shadow: inset 0 0 0 1px var(--lm-d-control-edge); color: var(--lm-d-muted); }
.ctr-list .fi-ta-actions .fi-icon-btn.fi-color-primary { color: var(--lm-d-accent-ink); box-shadow: inset 0 0 0 1px var(--lm-d-accent-line); }
.ctr-list .fi-pagination { padding-inline: 14px; }
.ctr-list-page .ctr-list .fi-ta-row { cursor: pointer; }
.ctr-list .fi-ta-row.ctr-row-open > td { background: var(--lm-d-row-hl); }
.ctr-list .fi-ta-row.ctr-row-open > td:first-child { box-shadow: inset -3px 0 0 var(--lm-d-accent); }
[dir='ltr'] .ctr-list .fi-ta-row.ctr-row-open > td:first-child { box-shadow: inset 3px 0 0 var(--lm-d-accent); }

/* the type pills on the toolbar row: navy when on, with the count */
.ctr-pills { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.ctr-pill {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-block-size: 36px;
    padding-inline: 14px;
    border-radius: 999px;
    border: 1px solid var(--lm-d-border);
    background: var(--lm-d-surface);
    color: var(--lm-d-ink);
    font-size: 13.5px;
    font-weight: 700;
    white-space: nowrap;
    cursor: pointer;
}
.ctr-pill:hover { border-color: var(--lm-d-control-edge); }
.ctr-pill-n { font-size: 12.5px; font-variant-numeric: tabular-nums; color: var(--lm-d-muted); }
.ctr-pill.is-danger .ctr-pill-n { color: var(--lm-d-danger); }
.ctr-pill.is-on { background: var(--lm-d-tab-on-bg); border-color: var(--lm-d-tab-on-bg); color: var(--lm-d-tab-on-ink); }
.ctr-pill.is-on .ctr-pill-n { color: var(--lm-d-tab-on-ink); }

/* the number badge, the tags, a variable chip */
.ctr-no { display: inline-grid; place-items: center; min-inline-size: 30px; block-size: 30px; padding-inline: 6px; border-radius: 9px; background: var(--lm-d-page); border: 1px solid var(--lm-d-border); color: var(--lm-d-ink); font-weight: 700; font-size: 13.5px; font-variant-numeric: tabular-nums; }
.ctr-no.is-lg { min-inline-size: 40px; block-size: 40px; font-size: 16px; }
.ctr-tags { display: inline-flex; flex-wrap: wrap; gap: 4px; vertical-align: middle; }
.ctr-tag { display: inline-flex; align-items: center; gap: 5px; min-block-size: 24px; padding-inline: 10px; border-radius: 999px; font-size: 12.5px; font-weight: 700; white-space: nowrap; }
.ctr-tag.is-info { background: var(--lm-d-info-soft); color: var(--lm-d-info); }
.ctr-tag.is-ok { background: var(--lm-d-ok-soft); color: var(--lm-d-ok); }
.ctr-tag.is-accent { background: var(--lm-d-accent-soft); color: var(--lm-d-accent-ink); }
.ctr-tag.is-danger { background: var(--lm-d-danger-soft); color: var(--lm-d-danger); }
.ctr-tag.is-danger::before { content: '⚠'; font-size: 12px; }
.ctr-tag.is-quiet { background: var(--lm-d-quiet-bg); color: var(--lm-d-muted); }
.ctr-var { display: inline-block; direction: ltr; unicode-bidi: isolate; font-family: ui-monospace, Menlo, monospace; font-size: 12px; font-weight: 700; color: var(--lm-d-info); background: var(--lm-d-info-soft); border-radius: 6px; padding-inline: 6px; line-height: 1.7; }

/* ── 4. the split: the list (start) and the term beside it (end) ── */
.ctr-split { display: grid; grid-template-columns: minmax(0, 1fr); gap: 12px; align-items: start; }
.ctr-split.has-open { grid-template-columns: minmax(0, 1fr) 360px; }
.ctr-split.has-open .ctr-list .fi-ta-text-item-description,
.ctr-split.has-open .ctr-list .fi-ta-text-description { max-inline-size: 260px; }
.ctr-panel { position: sticky; inset-block-start: 12px; background: var(--lm-d-surface); border: 1px solid var(--lm-d-border); border-radius: 16px; box-shadow: 0 1px 2px var(--lm-d-shadow); overflow: hidden; max-block-size: calc(100dvh - 110px); display: flex; flex-direction: column; }
.ctr-p { display: flex; flex-direction: column; min-block-size: 0; flex: 1 1 auto; }
.ctr-p-h { display: flex; align-items: flex-start; gap: 10px; padding: 12px 14px; border-block-end: 1px solid var(--lm-d-divider); }
.ctr-p-t { min-inline-size: 0; flex: 1 1 auto; }
.ctr-p-t b { display: block; font-size: 16px; }
.ctr-p-t small { font-size: 12.5px; color: var(--lm-d-muted); }
.ctr-p-x { display: grid; place-items: center; inline-size: 30px; block-size: 30px; border-radius: 8px; border: 1px solid var(--lm-d-border); background: var(--lm-d-surface); color: var(--lm-d-muted); cursor: pointer; }
.ctr-p-b { flex: 1 1 auto; min-block-size: 0; overflow-y: auto; overscroll-behavior: contain; padding: 12px 14px; display: flex; flex-direction: column; gap: 10px; }
.ctr-kv { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 8px 14px; margin: 0; font-size: 13.5px; align-items: center; }
.ctr-kv dt { color: var(--lm-d-muted); }
.ctr-kv dd { margin: 0; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.ctr-kv dd b { font-weight: 600; }
.ctr-p-txt { font-size: 13.5px; line-height: 2; color: var(--lm-d-ink); background: var(--lm-d-page); border-radius: 12px; padding: 10px 12px; }
.ctr-p-f { display: flex; gap: 8px; padding: 12px 14px; border-block-start: 1px solid var(--lm-d-divider); background: var(--lm-d-page); }
.ctr-p-f > .ctr-btn { flex: 1 1 0; justify-content: center; }
.ctr-note { display: flex; gap: 8px; align-items: flex-start; padding: 9px 12px; border-radius: 12px; font-size: 13px; line-height: 1.6; }
.ctr-note .ctr-ico { margin-block-start: 3px; }
.ctr-note.is-warn { background: var(--lm-d-warn-soft); color: var(--lm-d-warn); }
.ctr-note b { color: inherit; }
.ctr-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-block-size: 42px;
    padding-inline: 16px;
    border-radius: 12px;
    border: 1px solid var(--lm-d-control-edge);
    background: var(--lm-d-surface);
    color: var(--lm-d-ink);
    font-size: 14px;
    font-weight: 700;
    white-space: nowrap;
    text-decoration: none;
    cursor: pointer;
}
.ctr-btn.is-primary { background: var(--lm-d-accent); border-color: var(--lm-d-accent); color: var(--lm-d-on-accent); }

/* ── 5. the term's page and the contract's page ── */
.ctr-doc-h { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.ctr-doc-sub { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 6px 18px; font-size: 13.5px; color: var(--lm-d-muted); }
.ctr-doc-sub > span { display: inline-flex; align-items: center; gap: 6px; }
.ctr-doc-sub b { color: var(--lm-d-ink); }
.ctr-doc-sub a { color: var(--lm-d-info); font-weight: 700; text-decoration: none; }
.ctr-doc-page .fi-page-content { gap: 12px; }

/* the main card: one ruled card, the sections inside it divided by a line */
.ctr-doc-page .fi-section { border-radius: 16px; box-shadow: 0 1px 2px var(--lm-d-shadow); }
.ctr-doc-page .fi-section-header-heading { color: var(--lm-d-ink); font-weight: 700; font-size: 14.5px; }
.ctr-doc-page .fi-section-header > .fi-icon { color: var(--lm-d-info); }
.ctr-doc-page .ctr-form-card { border-block-start: 3px solid var(--lm-d-info); }
.ctr-doc-page .ctr-form-card .fi-section { box-shadow: none; }
.ctr-doc-page .fi-fo-field-label-content { color: var(--lm-d-muted); font-size: 13px; font-weight: 600; }
.ctr-doc-page :is(.fi-input-wrp) { border-radius: 10px; }

/* «بيتطبع في»: the contract types as toggle chips (info-soft when on) */
.ctr-toggles .fi-fo-checkbox-list-options { display: flex; flex-wrap: wrap; gap: 6px; }
.ctr-toggles .fi-fo-checkbox-list-option-ctn { margin: 0; }
.ctr-toggles .fi-fo-checkbox-list-option {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-block-size: 40px;
    padding-inline: 12px 14px;
    border: 1px solid var(--lm-d-control-edge);
    border-radius: 10px;
    background: var(--lm-d-surface);
    cursor: pointer;
}
.ctr-toggles .fi-fo-checkbox-list-option-label { font-size: 14px; font-weight: 700; color: var(--lm-d-muted); }
.ctr-toggles .fi-fo-checkbox-list-option:has(input:checked) { background: var(--lm-d-info-soft); border-color: var(--lm-d-info-soft); }
.ctr-toggles .fi-fo-checkbox-list-option:has(input:checked) .fi-fo-checkbox-list-option-label { color: var(--lm-d-info); }

/* the languages: a segmented pill pair, navy when on */
.ctr-sec-h { margin: 0; display: flex; align-items: center; gap: 8px; min-block-size: 36px; font-size: 14.5px; font-weight: 700; color: var(--lm-d-ink); }
.ctr-sec-h.is-split { padding-block-start: 14px; border-block-start: 1px solid var(--lm-d-divider); }
.ctr-lang-tabs.fi-sc-tabs { border: 0; box-shadow: none; background: transparent; margin-block-start: -50px; }
.ctr-doc-page .ctr-lang-tabs .fi-tabs { display: flex; inline-size: fit-content; margin-inline-start: auto; gap: 2px; padding: 3px; margin-block-end: 4px; border-radius: 999px; background: var(--lm-d-page); border: 1px solid var(--lm-d-border); box-shadow: none; }
.ctr-lang-tabs .fi-tabs .fi-tabs-item { min-block-size: 32px; padding-inline: 14px; border-radius: 999px; font-size: 13.5px; font-weight: 700; color: var(--lm-d-muted); background: transparent; }
.ctr-lang-tabs .fi-tabs .fi-tabs-item .fi-tabs-item-label { color: inherit; }
.ctr-lang-tabs .fi-tabs .fi-tabs-item.fi-active { background: var(--lm-d-tab-on-bg); color: var(--lm-d-tab-on-ink); }
.ctr-lang-tabs .fi-sc-tabs-tab { padding: 8px 0 0; }

/* the editor's frame */
.ctr-doc-page .tox-tinymce { border-radius: 12px; border-color: var(--lm-d-control-edge); }

/* «حقول إضافية للبند»: folded, a dashed row */
.ctr-doc-page .ctr-adv { border: 1px dashed var(--lm-d-control-edge); box-shadow: none; background: transparent; }
.ctr-doc-page .ctr-adv .fi-section-header-heading { color: var(--lm-d-muted); font-size: 13.5px; }
.ctr-doc-page .ctr-adv .fi-section-header-description { font-size: 12.5px; }

/* ── 6. the side column: the variables, the history ── */
.ctr-side { inline-size: 350px; display: flex; flex-direction: column; gap: 12px; position: sticky; inset-block-start: 12px; }
.ctr-box { background: var(--lm-d-surface); border: 1px solid var(--lm-d-border); border-radius: 16px; padding: 12px 14px; display: flex; flex-direction: column; gap: 8px; box-shadow: 0 1px 2px var(--lm-d-shadow); }
.ctr-box-h { margin: 0; display: flex; align-items: center; gap: 8px; font-size: 14.5px; font-weight: 700; color: var(--lm-d-ink); }
.ctr-box-h small { margin-inline-start: auto; font-size: 12.5px; font-weight: 500; color: var(--lm-d-muted); }
.ctr-search { display: flex; align-items: center; gap: 8px; min-block-size: 38px; padding-inline: 12px; border: 1px solid var(--lm-d-control-edge); border-radius: 10px; color: var(--lm-d-subtle); background: var(--lm-d-surface); }
.ctr-search input { flex: 1 1 auto; min-inline-size: 0; border: 0; padding: 0; background: transparent; font-size: 13.5px; color: var(--lm-d-ink); box-shadow: none; }
.ctr-search input:focus { outline: none; box-shadow: none; }
.ctr-vars { max-block-size: calc(100dvh - 160px); overflow-y: auto; overscroll-behavior: contain; }
.ctr-vars-g h5 { margin: 8px 0 2px; font-size: 12.5px; font-weight: 700; color: var(--lm-d-muted); }
.ctr-vr { display: flex; align-items: center; gap: 8px; inline-size: 100%; padding: 5px 8px; border: 0; border-radius: 8px; background: transparent; font-size: 13.5px; color: var(--lm-d-ink); text-align: start; cursor: pointer; }
.ctr-vr:hover { background: var(--lm-d-hover); }
.ctr-vr-l { flex: 0 1 auto; min-inline-size: 0; line-height: 1.4; }
.ctr-vr-u { flex: none; font-style: normal; font-size: 12px; font-weight: 700; color: var(--lm-d-ok); background: var(--lm-d-ok-soft); border-radius: 999px; padding-inline: 8px; }
.ctr-vr-i { margin-inline-start: auto; color: var(--lm-d-subtle); inline-size: 14px; block-size: 14px; }

/* ── 7. the save bar: always at the bottom of the page ── */
.ctr-doc-page .fi-form > .fi-sc-actions, .ctr-doc-page form .fi-sc-actions[id] {
    position: sticky;
    inset-block-end: 0;
    z-index: 5;
    padding: 10px 16px;
    background: var(--lm-d-surface);
    border: 1px solid var(--lm-d-border);
    border-radius: 16px;
    box-shadow: 0 -4px 16px var(--lm-d-shadow);
}
.ctr-doc-page .fi-sc-actions .fi-btn { min-block-size: 42px; border-radius: 12px; padding-inline: 16px; font-weight: 700; }
.ctr-doc-page .fi-sc-actions .fi-btn.fi-color-primary { background: var(--lm-d-accent); color: var(--lm-d-on-accent); box-shadow: 0 4px 12px var(--lm-d-accent-soft); }
.ctr-doc-page .fi-sc-actions .fi-btn.fi-color-gray { background: var(--lm-d-surface); color: var(--lm-d-ink); box-shadow: inset 0 0 0 1px var(--lm-d-control-edge); }

/* ── 8. the contract: the parties as cards, the terms as rows that open ── */
.ctr-parties .fi-fo-repeater-item { border-radius: 14px; border: 1px solid var(--lm-d-border); box-shadow: none; background: var(--lm-d-surface); }
.ctr-parties .fi-fo-repeater-item-header { padding-block: 10px; }
.ctr-parties .fi-fo-repeater-item-header-label { font-size: 15px; font-weight: 700; color: var(--lm-d-ink); }
.ctr-parties .fi-fo-repeater-add .fi-btn, .ctr-items .fi-fo-repeater-add .fi-btn { color: var(--lm-d-info); font-weight: 700; box-shadow: none; background: transparent; }
.ctr-items .fi-fo-repeater-items { gap: 0; border: 1px solid var(--lm-d-border); border-radius: 12px; overflow: hidden; }
.ctr-items .fi-fo-repeater-item { border-radius: 0; border: 0; border-block-end: 1px solid var(--lm-d-divider); box-shadow: none; }
.ctr-items .fi-fo-repeater-item:last-child { border-block-end: 0; }
.ctr-items .fi-fo-repeater-item-header { padding-block: 8px; }
.ctr-items .fi-fo-repeater-item-header-label { font-size: 14px; font-weight: 700; color: var(--lm-d-ink); }
.ctr-items .fi-fo-repeater-item:not(.fi-collapsed) { background: var(--lm-d-row-hl); }
.ctr-doc-page .ctr-entity { inline-size: fit-content; padding: 3px; gap: 2px; border-radius: 999px; background: var(--lm-d-page); box-shadow: inset 0 0 0 1px var(--lm-d-border); }
.ctr-doc-page .ctr-entity .fi-btn { min-block-size: 32px; border-radius: 999px; padding-inline: 14px; font-size: 13.5px; font-weight: 700; background: transparent; color: var(--lm-d-muted); box-shadow: none; }
.ctr-doc-page .ctr-entity .fi-fo-toggle-buttons-input:checked + .fi-btn { background: var(--lm-d-tab-on-bg); color: var(--lm-d-tab-on-ink); }

/* ── 9. narrow screens: the panel and the side column go under, the strip wraps ── */
@media (max-width: 1023px) {
    .ctr-split.has-open { grid-template-columns: minmax(0, 1fr); }
    .ctr-panel { position: static; max-block-size: none; }
    .ctr-side { inline-size: auto; position: static; }
    .ctr-strip { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .ctr-strip-c:nth-child(odd) { border-inline-start: 0; }
    .ctr-strip-c:nth-child(n + 3) { border-block-start: 1px solid var(--lm-d-divider); }
}
@media (max-width: 639px) {
    .ctr-pills { flex-wrap: nowrap; overflow-x: auto; padding-block-end: 2px; }
    .ctr-list .fi-ta-search-field { min-inline-size: 0; }
    .ctr-page .fi-header-heading { font-size: 22px; }
    .ctr-k-v { font-size: 20px; }
}
