/* Components of the Termik design system, built from its component guidelines and previews.
   Colour, type size and radius always come from tokens; state is always colour plus words. */

/* Button */
.btn {
  font-size: var(--fs-label); font-weight: 500; min-height: var(--control-lg); padding: 0 24px;
  border-radius: var(--radius-pill); border: 0; cursor: pointer; display: inline-flex; align-items: center;
  justify-content: center; gap: var(--space-2); text-decoration: none; white-space: nowrap;
  transition: background-color var(--duration-fast) var(--ease-standard), box-shadow var(--duration-fast) var(--ease-standard), transform var(--duration-fast) var(--ease-standard);
}
.btn:active:not(:disabled) { transform: scale(var(--press-scale)); }
.btn-primary { background: var(--primary); color: var(--on-primary); box-shadow: var(--shadow-primary); }
.btn-secondary { background: var(--surface-card); color: var(--ink); box-shadow: var(--shadow-float); }
.btn-quiet { background: var(--surface-sunken); color: var(--ink); }
.btn-sm { min-height: var(--control-sm); font-size: var(--fs-caption); padding: 0 14px; box-shadow: none; }
.btn:disabled { background: var(--line); color: var(--ink-muted); box-shadow: none; cursor: not-allowed; }
.btn-why { font-size: var(--fs-micro); color: var(--ink-muted); }

/* Card */
.card { background: var(--surface-card); border-radius: var(--radius-2xl); box-shadow: var(--shadow-card); padding: var(--space-6); display: flex; flex-direction: column; gap: var(--space-4); min-width: 0; }
.card-flush { padding: 0; overflow: hidden; gap: 0; }
.card-problem { background: var(--tint-blush); }
.card-problem .listrow, .card-problem .rule { background: var(--surface-card); }
.card-title { font-size: var(--fs-heading); line-height: var(--lh-heading); font-weight: 500; }
.card-caption { font-size: var(--fs-caption); color: var(--ink-muted); }
.inset { background: var(--surface-sunken); border-radius: var(--radius-md); padding: 12px 14px; }

/* StatusPill: fill, edge and ink of one status always together */
.pill { display: inline-block; white-space: nowrap; padding: 4px 12px; border-radius: var(--radius-pill); font-size: var(--fs-micro); line-height: var(--lh-micro); font-weight: 500; color: var(--ink); background: var(--surface-track); border: 1px solid transparent; }
.pill-draft { background: var(--status-draft); border-color: var(--status-draft-edge); color: var(--status-draft-ink); }
.pill-final { background: var(--status-final); border-color: var(--status-final-edge); color: var(--status-final-ink); }
.pill-requested { background: var(--status-requested); border-color: var(--status-requested-edge); color: var(--status-requested-ink); }
.pill-rejected { background: var(--status-rejected); border-color: var(--status-rejected-edge); color: var(--status-rejected-ink); }
.pill-after { background: var(--status-after); border-color: var(--status-after-edge); color: var(--status-after-ink); }
.pill-merged { background: var(--tint-lilac); border-color: var(--status-merged-edge); color: var(--status-merged-ink); }
.pill-white { background: var(--surface-card); }

/* DataTable */
.table-scroll { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; min-width: 620px; }
.table th { text-align: right; font-size: var(--fs-micro); font-weight: 500; color: var(--ink-muted); padding: 12px 16px; border-bottom: 1px solid var(--surface-track); white-space: nowrap; }
.table td { padding: 12px 16px; border-bottom: 1px solid var(--surface-track); font-size: var(--fs-small); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table td:first-child { font-weight: 500; }
.table .actions { text-align: left; white-space: nowrap; }
.table-more { padding: 12px 16px; font-size: var(--fs-caption); color: var(--ink-muted); }

/* EmptyState */
.empty { display: flex; flex-direction: column; align-items: center; text-align: center; gap: var(--space-3); padding: 32px 24px; }
.empty-icon { width: 64px; height: 64px; border-radius: 50%; background: var(--tint-powder); display: grid; place-items: center; color: var(--ink); }
.empty-good .empty-icon { background: var(--tint-mint); color: var(--signal-success); font-size: var(--fs-heading); }
.empty-title { font-size: var(--fs-empty-title); font-weight: 500; }
.empty-text { font-size: var(--fs-small); color: var(--ink-muted); line-height: var(--lh-body); max-width: 420px; }

/* ErrorState: banner and field message */
.alert { display: flex; gap: var(--space-3); align-items: flex-start; padding: 14px 16px; border-radius: var(--radius-lg); background: var(--status-rejected); border: 1px solid var(--status-rejected-edge); color: var(--status-rejected-ink); }
.alert-body { display: flex; flex-direction: column; gap: var(--space-1); flex: 1; }
.alert-title { font-size: var(--fs-small); font-weight: 700; }
.alert-text { font-size: var(--fs-caption); line-height: var(--lh-body); }
.mark { flex: none; width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; font-size: var(--fs-caption); font-weight: 700; line-height: 1; }
.mark-danger { background: var(--signal-danger); color: var(--surface-card); }
.mark-ok { background: var(--tint-mint); color: var(--signal-success); }
.mark-fail { background: var(--status-rejected); color: var(--signal-danger); }
.mark-warn { background: var(--tint-butter); color: var(--signal-warning); }

/* TextField */
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field-label { font-size: var(--fs-caption); font-weight: 500; color: var(--ink-muted); }
.field-box { position: relative; display: flex; align-items: center; }
.field-input { width: 100%; min-height: var(--control-lg); padding: 0 16px; border-radius: var(--radius-lg); border: 1px solid var(--line); background: var(--surface-sunken); font-size: var(--fs-label); color: var(--ink); }
.field-input::placeholder { color: var(--ink-subtle); }
.field-input[aria-invalid="true"] { border: 2px solid var(--signal-danger); background: var(--status-rejected); }
.field-help { font-size: var(--fs-micro); color: var(--ink-subtle); }
.field-error { font-size: var(--fs-micro); color: var(--signal-danger); }
.field-reveal { position: absolute; left: 8px; min-height: var(--control-sm); padding: 0 12px; border: 0; border-radius: var(--radius-pill); background: var(--surface-track); font-size: var(--fs-micro); cursor: pointer; }
.field-box .field-input.ltr { padding-left: 88px; }

/* Switch: whole row is the button */
.switch { display: inline-flex; align-items: center; gap: var(--space-3); min-height: var(--control-md); padding: 0; border: 0; background: none; cursor: pointer; font-size: var(--fs-small); text-align: right; }
.switch-track { flex: none; position: relative; width: 44px; height: 26px; border-radius: var(--radius-pill); background: var(--line); transition: background-color var(--duration-fast) var(--ease-standard); }
.switch-track::after { content: ""; position: absolute; top: 3px; right: 3px; width: 20px; height: 20px; border-radius: 50%; background: var(--surface-card); box-shadow: var(--shadow-float); transition: right var(--duration-fast) var(--ease-standard); }
.switch[aria-checked="true"] .switch-track { background: var(--primary); }
.switch[aria-checked="true"] .switch-track::after { right: 21px; }

/* Segmented */
.seg { display: inline-flex; gap: var(--space-1); padding: 5px; border-radius: var(--radius-pill); background: var(--surface-track); width: max-content; max-width: 100%; overflow-x: auto; }
.seg button { min-height: 40px; padding: 0 16px; border: 0; border-radius: var(--radius-pill); background: transparent; font-size: var(--fs-small); font-weight: 500; color: var(--ink-muted); cursor: pointer; display: inline-flex; align-items: center; gap: 6px; transition: background-color var(--duration-fast) var(--ease-standard), color var(--duration-fast) var(--ease-standard); }
.seg button[aria-pressed="true"] { background: var(--surface-card); color: var(--ink); box-shadow: var(--shadow-float); }
.seg-strong { background: var(--surface-card); box-shadow: var(--shadow-float); }
.seg-strong button[aria-pressed="true"] { background: var(--primary); color: var(--on-primary); box-shadow: none; }
.count { display: inline-grid; place-items: center; min-width: 22px; height: 22px; padding: 0 6px; border-radius: var(--radius-pill); background: var(--surface-track); font-size: var(--fs-micro); color: var(--ink); }

/* Stepper */
.stepper { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); padding: 14px 16px; border-radius: var(--radius-item); background: var(--surface-sunken); }
.stepper-text { display: flex; flex-direction: column; gap: 2px; }
.stepper-control { display: flex; align-items: center; gap: var(--space-2); }
.stepper-btn { width: 44px; height: 44px; border-radius: 50%; border: 0; background: var(--surface-card); box-shadow: var(--shadow-float); font-size: var(--fs-heading); cursor: pointer; display: grid; place-items: center; }
.stepper-value { min-width: 72px; text-align: center; font-size: var(--fs-stepper); font-weight: 500; }

/* RuleCheck */
.rules { display: flex; flex-direction: column; gap: var(--space-2); }
.rule { display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-radius: var(--radius-md); background: var(--surface-sunken); font-size: var(--fs-small); }
.rule-name { flex: 1; }
.rule-value { font-size: var(--fs-caption); color: var(--ink-muted); }

/* ListRow */
.listrow { width: 100%; display: flex; align-items: center; gap: var(--space-3); min-height: var(--control-md); padding: 12px 14px; border: 0; border-radius: var(--radius-item); background: var(--surface-sunken); text-align: right; cursor: pointer; }
.listrow[aria-pressed="true"] { outline: 2px solid var(--ink); outline-offset: 1px; }
.listrow.is-inactive { opacity: 0.6; }
.avatar { flex: none; width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; font-size: var(--fs-label); font-weight: 500; background: var(--status-final); color: var(--status-final-ink); border: 1px solid var(--status-final-edge); }
.listrow-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: var(--space-1); }
.listrow-name { font-size: var(--fs-label); font-weight: 500; }
.listrow-meta { font-size: var(--fs-micro); color: var(--ink-muted); }
.bar { height: 6px; border-radius: var(--radius-pill); background: var(--surface-track); overflow: hidden; }
.bar > span { display: block; height: 100%; border-radius: var(--radius-pill); background: var(--accent); }

/* NavSidebar */
.nav { width: 250px; flex: none; background: var(--surface-card); border-radius: var(--radius-2xl); box-shadow: var(--shadow-card); padding: 26px 18px 18px; display: flex; flex-direction: column; gap: var(--space-6); }
.nav-brand { display: flex; align-items: center; gap: var(--space-3); padding: 0 6px; }
.nav-logo { width: 48px; height: 48px; border-radius: 50%; background: var(--primary); color: var(--on-primary); display: grid; place-items: center; font-weight: 700; flex: none; }
.nav-name { font-size: var(--fs-label); font-weight: 700; }
.nav-role { font-size: var(--fs-micro); color: var(--ink-muted); }
.nav-group { display: flex; flex-direction: column; gap: 2px; }
.nav-group-title { font-size: var(--fs-micro); color: var(--ink-subtle); padding: 0 14px 6px; }
.nav-item { display: flex; align-items: center; gap: 10px; min-height: var(--control-md); padding: 10px 14px; border-radius: var(--radius-item); font-size: var(--fs-label); text-decoration: none; color: var(--ink); }
.nav-item::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--line); flex: none; }
.nav-item[aria-current="page"] { background: var(--tint-powder); font-weight: 700; }
.nav-item[aria-current="page"]::before { background: var(--ink); }
.nav-item .count { margin-inline-start: auto; }
.focus-toggle { width: 44px; height: 44px; border-radius: 50%; border: 0; background: var(--surface-card); box-shadow: var(--shadow-float); cursor: pointer; display: grid; place-items: center; }
@media (max-width: 760px) { .nav { width: 100%; } }

/* SlotGrid */
.slots-scroll { overflow-x: auto; }
.slots { display: grid; grid-template-columns: 90px repeat(var(--slot-count, 4), minmax(96px, 1fr)); gap: 6px; min-width: 540px; }
.slots-head { font-size: var(--fs-micro); color: var(--ink-subtle); text-align: center; padding-bottom: var(--space-1); }
.slots-day { font-size: var(--fs-caption); font-weight: 500; display: flex; align-items: center; }
.slot { min-height: 52px; border-radius: var(--radius-cell); padding: 8px 10px; display: flex; flex-direction: column; gap: 2px; font-size: var(--fs-micro); position: relative; transition: transform var(--duration-base) var(--ease-standard), box-shadow var(--duration-fast) var(--ease-standard); }
.slot-empty { background: var(--surface-sunken); border: 1px dashed var(--line); }
.slot-title { font-weight: 500; }
.slot-meta { opacity: 0.85; }
.slot-draft { background: var(--status-draft); border: 1px solid var(--status-draft-edge); color: var(--status-draft-ink); }
.slot-final { background: var(--status-final); border: 1px solid var(--status-final-edge); color: var(--status-final-ink); }
.slot-requested { background: var(--status-requested); border: 1px solid var(--status-requested-edge); color: var(--status-requested-ink); }
.slot-rejected, .slot-clash { background: var(--status-rejected); border: 1px solid var(--status-rejected-edge); color: var(--status-rejected-ink); }
.slot-after { background: var(--status-after); border: 1px solid var(--status-after-edge); color: var(--status-after-ink); }
.slot-merged { background: var(--tint-lilac); border: 1px solid var(--status-merged-edge); color: var(--status-merged-ink); }
.slot-clash::after { content: "!"; position: absolute; top: -6px; left: -6px; width: 20px; height: 20px; border-radius: 50%; background: var(--signal-danger); color: var(--surface-card); display: grid; place-items: center; font-size: var(--fs-micro); font-weight: 700; }
.slot.is-selected { outline: 2px solid var(--ink); outline-offset: 1px; box-shadow: var(--shadow-float); }
button.slot { border: 0; text-align: right; cursor: pointer; }
.slot-blocked { background: var(--line); color: var(--ink-muted); cursor: not-allowed; }
.slot-chosen { background: var(--primary); color: var(--on-primary); }

/* StatCard */
.stat { border-radius: var(--radius-xl); padding: 20px 22px; display: flex; flex-direction: column; gap: 10px; background: var(--tint-powder); }
.stat-butter { background: var(--tint-butter); }
.stat-blush { background: var(--tint-blush); }
.stat-mint { background: var(--tint-mint); }
.stat-label { font-size: var(--fs-small); font-weight: 500; }
.stat-figure { font-size: var(--fs-figure); line-height: var(--lh-figure); font-weight: var(--fw-figure); }
.stat-note { font-size: var(--fs-caption); color: var(--ink-muted); }

/* ConfirmDialog: an inline panel where the action started, not a modal */
.confirm { display: flex; flex-direction: column; gap: 10px; padding: 16px; border-radius: var(--radius-lg); background: var(--tint-butter); }
.confirm-blocked { background: var(--status-rejected); color: var(--status-rejected-ink); }
.confirm-title { font-size: var(--fs-label); font-weight: 700; }
.confirm-text { font-size: var(--fs-caption); line-height: 1.8; }
.confirm[hidden] { display: none; }

/* Toast and the unsaved-changes bar */
.toast { display: flex; align-items: center; gap: var(--space-2); padding: 10px 10px 10px 16px; border-radius: var(--radius-toast); background: var(--tint-mint); font-size: var(--fs-small); animation: rise var(--duration-base) var(--ease-standard); }
.toast .btn { min-height: var(--control-sm); }
.unsaved { display: flex; align-items: center; gap: var(--space-3); padding: 12px 12px 12px 20px; border-radius: var(--radius-pill); background: var(--primary); color: var(--on-primary); font-size: var(--fs-small); box-shadow: var(--shadow-primary); }
.unsaved .btn-outline { background: transparent; color: var(--on-primary); border: 1px solid currentColor; }
.unsaved .btn-light { background: var(--surface-card); color: var(--ink); }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* Tooltip: shows on hover and keyboard focus */
.tip { position: relative; display: inline-block; text-decoration: underline dashed; text-underline-offset: 4px; cursor: help; }
.tip::after { content: attr(data-tip); position: absolute; bottom: calc(100% + 8px); right: 0; white-space: nowrap; background: var(--ink); color: var(--surface-card); font-size: var(--fs-micro); line-height: 1.5; padding: 6px 10px; border-radius: var(--radius-sm); opacity: 0; transform: translateY(4px); transition: opacity var(--duration-fast) var(--ease-standard), transform var(--duration-fast) var(--ease-standard); pointer-events: none; z-index: 10; }
.tip:hover::after, .tip:focus-visible::after, .tip.show::after { opacity: 1; transform: none; }

/* Skeleton: only after 300ms, slow pulse, none under reduced motion */
.sk { background: var(--surface-track); border-radius: var(--radius-pill); animation: sk 1.4s var(--ease-standard) infinite; }
.sk-line { height: 12px; }
.sk-circle { width: 44px; height: 44px; border-radius: 50%; }
@keyframes sk { 0%, 100% { opacity: 1; } 50% { opacity: 0.45; } }

/* Shell helpers for the Core screens */
.btn-reset { border: 0; background: none; width: 100%; text-align: right; cursor: pointer; font-family: inherit; font-size: var(--fs-label); }
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--space-4); }
.page-head .col { gap: var(--space-2); }
.page-head > .row { flex-shrink: 0; align-items: center; flex-wrap: nowrap; }
.page-head > .row .field-input { width: auto; }
@media (max-width: 760px) { .page-head { flex-wrap: wrap; } .page-head > .row { flex-shrink: 1; flex-wrap: wrap; } }
.secret { font-size: var(--fs-heading); font-weight: 700; letter-spacing: 1px; direction: ltr; unicode-bidi: plaintext; background: var(--surface-card); padding: 6px 14px; border-radius: var(--radius-md); }
.auth { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 460px); gap: var(--space-8); align-items: center; padding: var(--space-8); max-width: 1120px; margin: 0 auto; }
.auth-hero { display: flex; flex-direction: column; gap: var(--space-4); }
.auth-card { gap: var(--space-5); }
select.field-input { appearance: auto; }
@media (max-width: 860px) { .auth { grid-template-columns: 1fr; padding: var(--space-4); } }
.alert-note { background: var(--tint-butter); border-color: transparent; color: var(--ink); }
.alert-good { background: var(--tint-mint); border-color: transparent; color: var(--ink); }
img.nav-logo { object-fit: contain; background: var(--surface-card); }
.letterhead { display: flex; align-items: center; gap: var(--space-3); padding: 14px 16px; border: 1px solid var(--line); border-radius: var(--radius-md); background: var(--surface-card); }
.letterhead img { width: 48px; height: 48px; object-fit: contain; }
/* In-app help (T-093) */
.help-list { margin: 0; padding-inline-start: 22px; line-height: 2; }
ol.help-list { list-style-type: persian; }
