/* ══════════════════════════════════════════════════════════════
   Farab UI: the app's own page components (fb-*). Colours, radius, shadow and motion come from the
   shared tokens (ui-tokens.css / dcc-tokens.css), so these pages look like home, climate and heater.
   Pages built from fb-* need nothing from Bootstrap's component classes.
   ══════════════════════════════════════════════════════════════ */

/* ── page ── */
.fb-page { display: flex; flex-direction: column; gap: var(--dcc-s-4, 16px); padding-block: var(--dcc-s-2, 8px); }
.fb-page-head { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 12px; }
.fb-page-head h1, .fb-page-head h2 { margin: 0; font-size: 1.35rem; font-weight: 700; color: var(--txt); }
.fb-page-head p { margin: 2px 0 0; color: var(--muted); font-size: .92rem; }

/* ── card ── */
.fb-card {
    border: 1px solid var(--frost-line);
    border-radius: 22px;
    background: linear-gradient(160deg, var(--frost-hi), transparent 55%), var(--frost);
    box-shadow: var(--frost-shadow);
    -webkit-backdrop-filter: blur(22px) saturate(1.35);
    backdrop-filter: blur(22px) saturate(1.35);
    color: var(--txt);
}
.fb-card-head { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 12px; padding: 16px 20px 0; }
.fb-card-body { padding: 16px 20px 20px; }
.fb-card-title { margin: 0; font-size: 1.05rem; font-weight: 600; }
@media (max-width: 767.98px) {
    .fb-card { -webkit-backdrop-filter: none; backdrop-filter: none; background: linear-gradient(160deg, var(--frost-hi), transparent 55%), color-mix(in srgb, var(--s-1) 92%, transparent); }
    .fb-card-head { padding: 14px 14px 0; }
    .fb-card-body { padding: 12px 14px 16px; }
}

/* ── toolbar (search + actions) ── */
.fb-toolbar { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 10px; }
.fb-toolbar-end { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

/* ── fields ── */
.fb-label { display: block; margin-bottom: 6px; font-size: .88rem; font-weight: 600; color: var(--txt); }
.fb-label.is-required::after { content: "*"; color: var(--err); margin-inline-start: 4px; }
.fb-input, .fb-select, .fb-textarea {
    width: 100%;
    min-height: 44px;
    padding: 9px 14px;
    border: 1px solid var(--line-2);
    border-radius: 14px;
    background: var(--s-2);
    color: var(--txt);
    font: inherit;
    transition: border-color var(--dcc-t-base, .2s) var(--ease-soft), box-shadow var(--dcc-t-base, .2s) var(--ease-soft), background var(--dcc-t-base, .2s) var(--ease-soft);
}
.fb-textarea { min-height: 120px; resize: vertical; line-height: 1.7; }
.fb-input::placeholder, .fb-textarea::placeholder { color: var(--faint); }
.fb-input:focus, .fb-select:focus, .fb-textarea:focus { outline: 0; border-color: var(--acc); background: var(--s-1); box-shadow: 0 0 0 4px var(--tint-acc); }
.fb-field { margin-bottom: 16px; }
.fb-field .validation-message { margin-top: 6px; color: var(--err-t); font-size: .82rem; }
.fb-search { position: relative; flex: 1 1 240px; max-width: 360px; }
.fb-search > i { position: absolute; inset-inline-start: 14px; top: 50%; transform: translateY(-50%); color: var(--faint); pointer-events: none; }
.fb-search .fb-input { padding-inline-start: 40px; }

/* ── buttons ── */
.fb-btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    min-height: 44px; padding: 0 18px;
    border: 1px solid transparent; border-radius: 14px;
    font: inherit; font-weight: 600; font-size: .92rem; text-decoration: none; cursor: pointer;
    transition: background var(--dcc-t-base, .2s) var(--ease-soft), color var(--dcc-t-base, .2s) var(--ease-soft), box-shadow var(--dcc-t-base, .2s) var(--ease-soft), transform .12s;
}
.fb-btn:active { transform: scale(.97); }
.fb-btn:disabled, .fb-btn.is-disabled { opacity: .55; pointer-events: none; }
.fb-btn-primary { background: var(--acc); color: #04261c; box-shadow: 0 8px 20px -10px var(--acc); }
.fb-btn-primary:hover { background: color-mix(in srgb, var(--acc) 88%, #000); color: #fff; }
.fb-btn-soft { background: var(--tint-acc); color: var(--acc-t); }
.fb-btn-soft:hover { background: var(--tint-acc-2); }
.fb-btn-ghost { background: var(--s-2); border-color: var(--line-2); color: var(--txt); }
.fb-btn-ghost:hover { background: var(--s-3); }
.fb-btn-danger { background: var(--tint-err); color: var(--err-t); }
.fb-btn-danger:hover { background: var(--err); color: #fff; }
.fb-btn-sm { min-height: 36px; padding: 0 12px; border-radius: 12px; font-size: .85rem; }
.fb-btn:focus-visible, .fb-input:focus-visible { outline: 2px solid var(--acc-t); outline-offset: 2px; }

/* ── badges ── */
.fb-badge { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px; font-size: .78rem; font-weight: 600; white-space: nowrap; background: var(--ink-soft); color: var(--muted); }
.fb-badge.is-ok { background: var(--tint-acc); color: var(--ok-t); }
.fb-badge.is-info { background: var(--tint-cool); color: var(--cool-t); }
.fb-badge.is-warn { background: var(--tint-pend); color: var(--pend-t); }
.fb-badge.is-danger { background: var(--tint-err); color: var(--err-t); }
.fb-badge.is-dark { background: color-mix(in srgb, var(--txt) 12%, transparent); color: var(--txt); }

/* ── table: a real table on wide screens, a stack of cards on phones (each cell labelled by data-label) ── */
.fb-table-wrap { overflow-x: auto; }
.fb-table { width: 100%; border-collapse: collapse; color: var(--txt); }
.fb-table th { padding: 10px 12px; text-align: start; font-size: .78rem; font-weight: 600; color: var(--muted); border-bottom: 1px solid var(--line-2); white-space: nowrap; }
.fb-table td { padding: 14px 12px; border-bottom: 1px dashed var(--line); vertical-align: middle; }
.fb-table tbody tr:last-child td { border-bottom: 0; }
.fb-table tbody tr { transition: background var(--dcc-t-base, .2s); }
.fb-table tbody tr:hover { background: var(--glass-2); }
@media (max-width: 767.98px) {
    .fb-table thead { display: none; }
    .fb-table, .fb-table tbody, .fb-table tr, .fb-table td { display: block; width: 100%; }
    .fb-table tr { margin-bottom: 10px; padding: 8px 12px; border: 1px solid var(--line); border-radius: 18px; background: var(--s-1); }
    .fb-table td { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 8px 0; border-bottom: 1px dashed var(--line); }
    .fb-table td:last-child { border-bottom: 0; }
    .fb-table td::before { content: attr(data-label); color: var(--muted); font-size: .8rem; font-weight: 600; flex: none; }
    .fb-table td[data-label=""]::before { content: none; }
}

/* ── empty and loading ── */
.fb-empty { display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 48px 16px; text-align: center; }
.fb-empty-ico { display: grid; place-items: center; width: 64px; height: 64px; border-radius: 20px; background: var(--tint-acc); color: var(--acc-t); font-size: 1.6rem; }
.fb-empty h2 { margin: 6px 0 0; font-size: 1.25rem; font-weight: 700; }
.fb-empty p { margin: 0 0 8px; max-width: 420px; color: var(--muted); }
.fb-loading { display: grid; place-items: center; padding: 48px; }
.fb-spinner { width: 28px; height: 28px; border: 3px solid var(--tint-acc-2); border-top-color: var(--acc); border-radius: 50%; animation: fb-spin .8s linear infinite; }
@keyframes fb-spin { to { transform: rotate(360deg); } }
:root[data-motion="off"] .fb-spinner { animation-duration: 2.4s; }

/* ══════════════════════════════════════════════════════════════
   Motion: cards and table rows rise in one after another, buttons glow, rows light up under the pointer.
   Everything stops when <html data-motion="off"> (the in-app animations switch / reduced motion).
   ══════════════════════════════════════════════════════════════ */
@keyframes fb-rise { from { opacity: 0; transform: translateY(14px) scale(.985); } to { opacity: 1; transform: none; } }
@keyframes fb-sheen { from { background-position: 160% 0; } to { background-position: -60% 0; } }

:root:not([data-motion="off"]) .fb-card { animation: fb-rise .55s var(--ease-soft) both; }
:root:not([data-motion="off"]) .fb-empty > * { animation: fb-rise .6s var(--ease-soft) both; }
:root:not([data-motion="off"]) .fb-empty > :nth-child(2) { animation-delay: .07s; }
:root:not([data-motion="off"]) .fb-empty > :nth-child(3) { animation-delay: .14s; }
:root:not([data-motion="off"]) .fb-empty > :nth-child(4) { animation-delay: .21s; }
:root:not([data-motion="off"]) .fb-table tbody tr { animation: fb-rise .5s var(--ease-soft) both; }
:root:not([data-motion="off"]) .fb-table tbody tr:nth-child(1) { animation-delay: .05s; }
:root:not([data-motion="off"]) .fb-table tbody tr:nth-child(2) { animation-delay: .10s; }
:root:not([data-motion="off"]) .fb-table tbody tr:nth-child(3) { animation-delay: .15s; }
:root:not([data-motion="off"]) .fb-table tbody tr:nth-child(4) { animation-delay: .20s; }
:root:not([data-motion="off"]) .fb-table tbody tr:nth-child(5) { animation-delay: .25s; }
:root:not([data-motion="off"]) .fb-table tbody tr:nth-child(n+6) { animation-delay: .30s; }

/* a soft light sweeps across the primary button on hover */
.fb-btn-primary { position: relative; overflow: hidden; }
.fb-btn-primary::after {
    content: ""; position: absolute; inset: 0; pointer-events: none;
    background: linear-gradient(110deg, transparent 35%, rgba(255, 255, 255, .45) 50%, transparent 65%) 160% 0 / 250% 100% no-repeat;
}
:root:not([data-motion="off"]) .fb-btn-primary:hover::after { animation: fb-sheen .9s var(--ease-soft); }
.fb-btn-primary:hover { transform: translateY(-1px); box-shadow: 0 12px 26px -10px var(--acc); }

/* the card under the pointer lifts a little; rows get an accent edge */
.fb-card { transition: box-shadow var(--dcc-t-base, .2s) var(--ease-soft), border-color var(--dcc-t-base, .2s) var(--ease-soft); }
.fb-card:hover { box-shadow: var(--sh-2); border-color: color-mix(in srgb, var(--acc) 22%, var(--frost-line)); }
.fb-table tbody tr td:first-child { box-shadow: inset 3px 0 0 transparent; transition: box-shadow var(--dcc-t-base, .2s) var(--ease-soft); }
[dir="rtl"] .fb-table tbody tr td:first-child { box-shadow: inset -3px 0 0 transparent; }
@media (min-width: 768px) {
    .fb-table tbody tr:hover td:first-child { box-shadow: inset 3px 0 0 var(--acc); }
    [dir="rtl"] .fb-table tbody tr:hover td:first-child { box-shadow: inset -3px 0 0 var(--acc); }
}
.fb-empty-ico { box-shadow: 0 0 0 8px color-mix(in srgb, var(--acc) 8%, transparent), 0 0 0 18px color-mix(in srgb, var(--acc) 4%, transparent); }

/* ══════════════════════════════════════════════════════════════
   More building blocks: icon tile and buttons, switch, modal skin (Bootstrap's modal script stays as the open/close
   engine; the markup inside is fb-*), two-column form rows, cell title/sub, code chip.
   ══════════════════════════════════════════════════════════════ */
.fb-ico { display: inline-grid; place-items: center; width: 38px; height: 38px; flex: none; border-radius: 12px; background: var(--tint-cool); color: var(--cool-t); }
.fb-ico.is-ok { background: var(--tint-acc); color: var(--ok-t); }
.fb-ico.is-warn { background: var(--tint-pend); color: var(--pend-t); }
.fb-ico.is-danger { background: var(--tint-err); color: var(--err-t); }
.fb-btn-icon { width: 38px; min-height: 38px; padding: 0; border-radius: 12px; }
.fb-btn-icon.fb-btn-sm { width: 34px; min-height: 34px; }
.fb-cell { display: flex; align-items: center; gap: 12px; min-width: 0; }
.fb-cell-title { display: block; font-weight: 600; color: var(--txt); }
.fb-cell-sub { display: block; margin-top: 2px; color: var(--muted); font-size: .8rem; line-height: 1.6; }
.fb-actions { display: flex; align-items: center; justify-content: flex-end; gap: 8px; }
.fb-code { display: inline-block; padding: 3px 10px; border-radius: 10px; background: var(--ink-soft); color: var(--txt); font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: .82rem; direction: ltr; }
.fb-muted { color: var(--muted); }

/* two columns on wide screens, one on phones */
.fb-form-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 16px; }
@media (max-width: 575.98px) { .fb-form-row { grid-template-columns: minmax(0, 1fr); } }

/* switch: a native checkbox restyled; the text beside it is its label */
.fb-switch { display: inline-flex; align-items: center; gap: 12px; cursor: pointer; font-weight: 600; }
.fb-switch input { appearance: none; -webkit-appearance: none; position: relative; width: 46px; height: 26px; margin: 0; flex: none; border-radius: 999px; background: var(--s-3); box-shadow: inset 0 1px 3px rgba(0, 0, 0, .2); cursor: pointer; transition: background var(--dcc-t-base, .2s) var(--ease-soft); }
.fb-switch input::after { content: ""; position: absolute; top: 3px; inset-inline-start: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; box-shadow: 0 2px 5px rgba(0, 0, 0, .3); transition: inset-inline-start var(--dcc-t-base, .2s) var(--ease-soft); }
.fb-switch input:checked { background: var(--acc); }
.fb-switch input:checked::after { inset-inline-start: 23px; }
.fb-switch input:focus-visible { outline: 2px solid var(--acc-t); outline-offset: 2px; }

/* modal skin */
.modal.fb-modal .modal-content { border: 1px solid var(--frost-line); border-radius: 24px; background: var(--s-1); color: var(--txt); box-shadow: var(--sh-2); overflow: hidden; }
.modal.fb-modal .modal-dialog { max-width: 620px; }
.fb-modal-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 18px 22px 0; }
.fb-modal-head h2 { margin: 0; font-size: 1.15rem; font-weight: 700; }
.fb-modal-body { padding: 18px 22px 22px; }
.fb-modal-body .fb-scroll { max-height: 55vh; overflow-y: auto; padding-inline-end: 4px; }
.fb-modal-foot { display: flex; justify-content: flex-end; gap: 10px; padding-top: 18px; }
.modal-backdrop.show { --bs-backdrop-opacity: .45; }

/* Blazor-controlled dialog (shown with an @if, no Bootstrap script), tinted panels, wrapping control rows */
.fb-overlay { position: fixed; inset: 0; z-index: 1060; display: grid; place-items: center; padding: 16px; background: rgba(8, 12, 24, .5); overflow-y: auto; animation: fb-fade .2s ease both; }
.fb-dialog { width: 100%; max-width: 880px; margin: auto; border: 1px solid var(--frost-line); border-radius: 24px; background: var(--s-1); color: var(--txt); box-shadow: var(--sh-2); }
.fb-dialog .fb-modal-body { max-height: calc(100vh - 150px); overflow-y: auto; }
@keyframes fb-fade { from { opacity: 0; } to { opacity: 1; } }
.fb-panel { padding: 16px; border-radius: 18px; background: var(--ink-soft); margin-bottom: 16px; }
.fb-panel.is-primary { background: var(--tint-acc); }
.fb-panel.is-ok { background: var(--tint-cool); }
.fb-panel.is-warn { background: var(--tint-pend); border: 1px dashed color-mix(in srgb, var(--pend) 45%, transparent); }
.fb-panel-title { margin: 20px 0 10px; font-size: .95rem; font-weight: 700; }
.fb-panel-title.is-primary { color: var(--acc-t); }
.fb-panel-title.is-ok { color: var(--cool-t); }
.fb-row { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-bottom: 10px; }
.fb-row > .fb-grow { flex: 1 1 180px; min-width: 0; }
.fb-row > .fb-narrow { flex: 0 1 130px; min-width: 100px; }
.fb-hint { display: block; margin-bottom: 4px; font-size: .78rem; font-weight: 700; color: var(--pend-t); }
.fb-suffix { display: flex; align-items: center; gap: 8px; }
.fb-suffix span { color: var(--muted); font-size: .85rem; white-space: nowrap; }
.fb-select { appearance: auto; }

/* notes / alerts, a key shown for copying, an input joined to a button */
.fb-alert { display: flex; align-items: flex-start; gap: 14px; padding: 14px 16px; margin-bottom: 16px; border-radius: 16px; background: var(--tint-acc); color: var(--txt); }
.fb-alert > i { font-size: 1.4rem; margin-top: 2px; color: var(--acc-t); }
.fb-alert h4 { margin: 0 0 2px; font-size: .95rem; font-weight: 700; }
.fb-alert span, .fb-alert p { margin: 0; font-size: .88rem; color: var(--muted); }
.fb-alert.is-ok { background: var(--tint-acc); }
.fb-alert.is-warn { background: var(--tint-pend); }
.fb-alert.is-warn > i { color: var(--pend-t); }
.fb-alert.is-danger { background: var(--tint-err); }
.fb-alert.is-danger > i { color: var(--err-t); }
.fb-keybox { padding: 18px; margin-bottom: 14px; border: 1px dashed color-mix(in srgb, var(--acc) 55%, transparent); border-radius: 18px; background: var(--tint-acc); }
.fb-join { display: flex; gap: 8px; }
.fb-join .fb-input { flex: 1; min-width: 0; font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; direction: ltr; }
.fb-center { text-align: center; }
.fb-truncate { max-width: 300px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@media (max-width: 767.98px) { .fb-truncate { max-width: none; white-space: normal; text-align: end; } }
.fa-spin { animation: fb-spin 1s linear infinite; }

/* a table that stays a table on phones (matrices), and a plain checkbox */
@media (max-width: 767.98px) {
    .fb-table.is-plain { display: table; }
    .fb-table.is-plain thead { display: table-header-group; }
    .fb-table.is-plain tbody { display: table-row-group; }
    .fb-table.is-plain tr { display: table-row; margin: 0; padding: 0; border: 0; border-radius: 0; background: transparent; }
    .fb-table.is-plain th, .fb-table.is-plain td { display: table-cell; width: auto; padding: 10px 8px; border-bottom: 1px dashed var(--line); }
    .fb-table.is-plain td::before { content: none; }
}
.fb-table.is-plain td.is-center, .fb-table.is-plain th.is-center { text-align: center; }
.fb-check { width: 20px; height: 20px; accent-color: var(--acc); cursor: pointer; }
.fb-dialog.is-sm { max-width: 520px; }
.fb-checklist { max-height: 220px; overflow-y: auto; padding: 8px 12px; border: 1px solid var(--line-2); border-radius: 14px; background: var(--s-2); }
.fb-checklist label { display: flex; align-items: center; gap: 10px; padding: 8px 0; cursor: pointer; }
.fb-error { margin-top: 6px; color: var(--err-t); font-size: .82rem; }

/* segmented control (radio group) and initials avatar */
.fb-seg { position: relative; display: inline-flex; gap: 2px; padding: 3px; border: 1px solid var(--line-2); border-radius: 14px; background: var(--s-2); }
.fb-seg input { position: absolute; opacity: 0; pointer-events: none; }
.fb-seg label { padding: 8px 14px; border-radius: 11px; font-size: .85rem; font-weight: 600; color: var(--muted); cursor: pointer; transition: background var(--dcc-t-base, .2s) var(--ease-soft), color var(--dcc-t-base, .2s) var(--ease-soft); }
.fb-seg input:checked + label { background: var(--acc); color: #04261c; box-shadow: 0 4px 12px -6px var(--acc); }
.fb-seg input:focus-visible + label { outline: 2px solid var(--acc-t); outline-offset: 2px; }
.fb-avatar { display: inline-grid; place-items: center; width: 42px; height: 42px; flex: none; border-radius: 50%; background: var(--tint-acc); color: var(--acc-t); font-weight: 700; }
.fb-avatar.is-info { background: var(--tint-cool); color: var(--cool-t); }
.fb-grid-4 { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 0 16px; align-items: end; }
@media (max-width: 991.98px) { .fb-grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 575.98px) { .fb-grid-4 { grid-template-columns: minmax(0, 1fr); } }
.fb-empty-ico.is-warn { background: var(--tint-pend); color: var(--pend-t); }

/* side column + main column (profile), label / value rows, a larger avatar */
.fb-split { display: grid; grid-template-columns: 320px minmax(0, 1fr); gap: 16px; align-items: start; }
@media (max-width: 991.98px) { .fb-split { grid-template-columns: minmax(0, 1fr); } }
.fb-stack { display: flex; flex-direction: column; gap: 16px; }
.fb-kv { display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: 6px 16px; align-items: center; padding: 12px 0; border-bottom: 1px dashed var(--line); }
.fb-kv:last-child { border-bottom: 0; }
.fb-kv > dt { margin: 0; color: var(--muted); font-weight: 600; font-size: .88rem; }
.fb-kv > dd { margin: 0; font-weight: 600; min-width: 0; }
@media (max-width: 767.98px) { .fb-kv { grid-template-columns: minmax(0, 1fr); } }
.fb-avatar.is-lg { width: 96px; height: 96px; font-size: 2.2rem; }
.fb-profile-card { display: flex; flex-direction: column; align-items: center; gap: 10px; text-align: center; padding-bottom: 14px; border-bottom: 1px dashed var(--line); margin-bottom: 14px; }
.fb-profile-card h2 { margin: 6px 0 0; font-size: 1.15rem; font-weight: 700; }
.fb-contact { display: flex; align-items: center; gap: 10px; padding: 6px 0; color: var(--muted); }
.fb-contact i { width: 18px; text-align: center; color: var(--faint); }
.fb-ico.is-lg { width: 72px; height: 72px; border-radius: 22px; font-size: 1.8rem; }
