/*
 * Hamrah Studio: tokens and Persian typography on top of Tabler 1.7.5 (RTL build).
 * Load order: vendor/tabler/css/tabler.rtl.min.css, then this file.
 * Source of truth: design/DESIGN.md (tokens) and design/ui-patterns.md (patterns).
 * Rules: light theme only; logical properties only (never left/right); no external URL;
 * no !important (none is needed: Tabler's variables are overridden on :root, which wins
 * over Tabler's own :root/[data-bs-theme=light] by source order).
 */

/* 1. Font ---------------------------------------------------------------------------------- */
/* One variable file covers every weight; only 400 and 600 are used. */
@font-face {
  font-family: "Vazirmatn";
  src: url("../fonts/vazirmatn/Vazirmatn-variable.f6d31671339d.woff2") format("woff2");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

/* Persian letters inside code blocks (a Persian value in a JSON <pre>): the system monospace
   fonts draw Arabic script as isolated, wide glyphs. This face maps only the Arabic-script
   ranges (and ZWNJ) to the bundled Vazirmatn and is listed first in the monospace stack, so
   Latin code keeps the monospace font and Persian text stays joined. */
@font-face {
  font-family: "Hamrah Mono FA";
  src: url("../fonts/vazirmatn/Vazirmatn-variable.f6d31671339d.woff2") format("woff2");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
  unicode-range: U+0600-06FF, U+0750-077F, U+08A0-08FF, U+FB50-FDFF, U+FE70-FEFF, U+200C-200D;
}

/* 2. Tokens -> Tabler variables ------------------------------------------------------------- */
:root {
  /* Neutral scale (slate) replaces Tabler's grays everywhere */
  --tblr-gray-50: #f8fafc;
  --tblr-gray-100: #f1f5f9;
  --tblr-gray-200: #e2e8f0;
  --tblr-gray-300: #cbd5e1;
  --tblr-gray-400: #94a3b8;
  --tblr-gray-500: #64748b;
  --tblr-gray-600: #475569;
  --tblr-gray-700: #334155;
  --tblr-gray-800: #1e293b;
  --tblr-gray-900: #0f172a;

  /* Accent: teal-700 is the one primary colour (buttons, links, focus, active nav) */
  --tblr-primary: #0f766e;
  --tblr-primary-rgb: 15, 118, 110;
  --tblr-primary-darken: #115e59;
  --tblr-primary-lt: #f0fdfa;
  --tblr-primary-fg: #ffffff;
  --tblr-link-color: #0f766e;
  --tblr-link-hover-color: #115e59;
  --tblr-active-bg: #f0fdfa;

  /* Semantic colours: status only. "-lt" is the tint behind badge text. */
  --tblr-success: #15803d;
  --tblr-success-rgb: 21, 128, 61;
  --tblr-success-lt: #dcfce7;
  --tblr-warning: #b45309;
  --tblr-warning-rgb: 180, 83, 9;
  --tblr-warning-lt: #fef3c7;
  --tblr-danger: #b91c1c;
  --tblr-danger-rgb: 185, 28, 28;
  --tblr-danger-lt: #fee2e2;
  --tblr-info: #1d4ed8;
  --tblr-info-rgb: 29, 78, 216;
  --tblr-info-lt: #dbeafe;
  /* Neutral status tone = Tabler "secondary": neutral-600 on neutral-100 */
  --tblr-secondary: #475569;
  --tblr-secondary-rgb: 71, 85, 105;
  --tblr-secondary-lt: #f1f5f9;
  --tblr-form-invalid-color: #b91c1c;
  --tblr-form-invalid-border-color: #b91c1c;
  --tblr-form-valid-color: #15803d;
  --tblr-form-valid-border-color: #15803d;

  /* Surfaces and text */
  --tblr-body-bg: #f8fafc;
  --tblr-bg-surface: #ffffff;
  --tblr-bg-surface-secondary: #f8fafc;
  --tblr-bg-forms: #ffffff;
  --tblr-body-color: #0f172a;
  --tblr-emphasis-color: #0f172a;
  --tblr-secondary-color: #475569;
  --tblr-muted: #475569;
  --tblr-tertiary: #64748b; /* placeholders; never lighter than neutral-500 for text */
  --tblr-hover-bg: #f8fafc;
  --tblr-border-color: #e2e8f0;
  --tblr-border-color-translucent: #e2e8f0;

  /* Typography: 15px body, 1.75 line height, weights 400/600 only */
  --tblr-font-sans-serif: "Vazirmatn", system-ui, sans-serif;
  --tblr-body-font-family: var(--tblr-font-sans-serif);
  --tblr-font-monospace: "Hamrah Mono FA", ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas,
    "Liberation Mono", "Courier New", monospace;
  --tblr-body-font-size: 0.9375rem;
  --tblr-body-line-height: 1.75;
  --tblr-line-height-base: 1.75;
  --tblr-font-weight-light: 400;
  --tblr-font-weight-normal: 400;
  --tblr-font-weight-medium: 600;
  --tblr-font-weight-semibold: 600;
  --tblr-font-weight-bold: 600;
  --tblr-font-weight-headings: 600;
  --tblr-font-size-h1: 1.5rem;     /* 24px */
  --tblr-font-size-h2: 1.25rem;    /* 20px */
  --tblr-font-size-h3: 1.0625rem;  /* 17px */
  --tblr-font-size-h4: 0.9375rem;  /* 15px */
  --tblr-font-size-h5: 0.8125rem;  /* 13px, the minimum */
  --tblr-line-height-h1: 1.45;
  --tblr-line-height-h2: 1.45;
  --tblr-line-height-h3: 1.45;

  /* Controls and buttons share one height: 24px line + 2 x 8px padding + 2px border = 42px */
  --tblr-btn-input-font-size: 0.9375rem;
  --tblr-btn-input-line-height: 1.5rem;
  --tblr-btn-input-padding-y: 0.5rem;

  /* Shape and depth: 8px radius, one shadow level */
  --tblr-border-radius: 8px;
  --tblr-border-radius-sm: 8px;
  --tblr-border-radius-lg: 8px;
  --tblr-border-radius-xl: 8px;
  --tblr-border-radius-pill: 999px;
  --tblr-shadow-card: 0 1px 2px rgba(15, 23, 42, 0.06);
  --tblr-shadow-input: 0 1px 2px rgba(15, 23, 42, 0.06);
  --tblr-shadow-dropdown: 0 1px 2px rgba(15, 23, 42, 0.06);
  --tblr-box-shadow: 0 1px 2px rgba(15, 23, 42, 0.06);
  --tblr-box-shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.06);
  --tblr-box-shadow-lg: 0 1px 2px rgba(15, 23, 42, 0.06);

  /* Layout: page padding 24px at every width */
  --tblr-page-padding: 1.5rem;
  --tblr-sidebar-width: 16rem;
}

/* 3. Persian typography ----------------------------------------------------------------------- */
body {
  letter-spacing: normal;
  font-feature-settings: normal;
}

h1, h2, h3, h4, h5, h6, .h1, .h2, .h3, .h4, .h5, .h6, .page-title {
  line-height: 1.45;
}

/* No italics anywhere: Persian has no italic form */
em, i, cite, dfn, address, .fst-italic {
  font-style: normal;
}

/* Nothing under 13px; Tabler's 12px labels lose their uppercase and tracking */
small, .small, .form-hint, .text-secondary.small, .invalid-feedback, .dropdown-header {
  font-size: 0.8125rem;
}

.page-pretitle, .subheader, .datagrid-title, .nav-section-title {
  font-size: 0.8125rem;
  font-weight: 600;
  line-height: 1.6;
  letter-spacing: 0;
  text-transform: none;
}

.page-subtitle, .card-subtitle {
  color: var(--tblr-secondary-color);
}

/* 4. Mixed direction text ---------------------------------------------------------------------- */
/* URLs, English keywords and codes are isolated so they never reorder the RTL line. */
bdi, [dir="auto"], [dir="ltr"] {
  unicode-bidi: isolate;
}

/* An LTR value inside an RTL cell keeps the cell's alignment */
.text-ltr {
  direction: ltr;
  unicode-bidi: isolate;
  text-align: end;
}

/* Long URLs wrap at the end of a line instead of widening the table. "break-word" (not
   "anywhere") keeps the column's min-content width, so a narrow screen scrolls the table
   (table-responsive) instead of crushing every column to a few letters. */
.text-url {
  overflow-wrap: break-word;
}

/* Identifiers and codes (kind "ltr"): one line, cut with an ellipsis, full value in title */
.hamrah-ltr {
  display: inline-block;
  max-inline-size: 11rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  vertical-align: bottom;
}

/* 5. Tables ------------------------------------------------------------------------------------ */
.table {
  --tblr-table-striped-bg: transparent; /* no zebra, even if table-striped slips in */
  --tblr-table-hover-bg: #f8fafc;
  --tblr-table-border-color: #e2e8f0;
}

/* ~44px rows: 15px x 1.6 line height + 2 x 10px padding */
.table > :not(caption) > * > * {
  padding-block: 0.625rem;
  line-height: 1.6;
}

.table thead th {
  background: #f1f5f9;
  color: #475569;
  font-size: 0.8125rem;
  font-weight: 600;
  line-height: 1.6;
  letter-spacing: 0;
  text-transform: none;
}

/* Numeric columns: tabular digits, aligned to the start side (visual right in RTL), which
   lines up the units digit because numbers are written LTR. Header uses the same class. */
.col-num {
  font-variant-numeric: tabular-nums;
  text-align: start;
  white-space: nowrap;
}

/* Sortable headers (phase 10 round 2): Tabler draws the sort icon as the link's ::after, an
   atomic inline the line may break before, so at 1024 «تاریخ عضویت» left the icon alone on a
   second line. The kit's `sort_label` filter glues the label's last word and the vendored
   icon (selector / chevron-up / chevron-down, 16px like Tabler's) in one span.text-nowrap:
   the label may wrap between its words, the icon never leaves the last one. */
.table-sort::after {
  content: none;
}

.table-sort .hamrah-sort-icon {
  inline-size: var(--tblr-table-sort-icon-size);
  block-size: var(--tblr-table-sort-icon-size);
  margin-inline-start: var(--tblr-table-sort-icon-margin-start);
  vertical-align: -0.1875rem;
  stroke-width: 1.5;
}

/* Missing value marker "—" */
.text-empty {
  color: var(--tblr-tertiary);
}

/* Row checkbox column for bulk actions */
.col-check {
  inline-size: 2.75rem;
}

/* 6. Badges ------------------------------------------------------------------------------------ */
/* Statuses use .badge + one of bg-success-lt / bg-warning-lt / bg-danger-lt / bg-info-lt /
   bg-secondary-lt (see the mapping in design/ui-patterns.md). */
.badge {
  --tblr-badge-font-size: 0.8125rem;
  --tblr-badge-font-weight: 600;
  --tblr-badge-line-height: 1.6;
  --tblr-badge-padding-y: 0.125rem;
  --tblr-badge-padding-x: 0.625rem;
  --tblr-badge-border-radius: var(--tblr-border-radius-pill);
}

/* 7. Buttons ----------------------------------------------------------------------------------- */
/* Three kinds only: .btn.btn-primary, .btn (secondary: white + border), .btn.btn-danger. */
.btn {
  --tblr-btn-font-size: var(--tblr-btn-input-font-size);
  --tblr-btn-line-height: var(--tblr-btn-input-line-height);
  --tblr-btn-padding-y: var(--tblr-btn-input-padding-y);
  /* Tabler 1.7 paints solid buttons with a white-to-transparent gradient and an inset
     highlight; flat colour and the one shadow level only (no gradients). Same specificity as
     .btn-primary/.btn-danger, later in source, so this wins. */
  --tblr-btn-gradient: none;
  --tblr-btn-box-shadow: var(--tblr-shadow-input);
}

.btn .icon {
  inline-size: 1.125rem;
  block-size: 1.125rem;
}

/* 8. Forms ------------------------------------------------------------------------------------- */
.form-narrow {
  max-inline-size: 960px;
}

.form-label {
  font-size: 0.9375rem;
  font-weight: 600;
}

/* Fieldsets on long forms (ui-patterns §5): no box of their own inside the form card (Tabler's
   .form-fieldset is a grey bordered box, a card inside the card); groups are separated by one
   rule and 24px of air, the legend is a 17px/600 group title (card-title size). Tabler's own
   `legend` rules (an inline-flex nowrap legend with line-height 1) are undone so it wraps.
   The legend keeps the reboot's float (on the logical start side, full width, the next element
   clears it): a non-floated legend is drawn inside the fieldset's top border, which hid the
   separator rule and put the 24px top padding between the legend and its first field (round 3
   shots of /drafts/settings/). */
.hamrah-fieldset {
  min-inline-size: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

.hamrah-fieldset + .hamrah-fieldset,
.hamrah-fieldset + .hamrah-fieldset-rest {
  margin-block-start: 1.5rem;
  padding-block-start: 1.5rem;
  border-block-start: 1px solid var(--tblr-border-color);
}

.hamrah-legend {
  display: block;
  float: inline-start;
  inline-size: 100%;
  white-space: normal;
  margin-block-end: 1rem;
  padding: 0;
  font-size: var(--tblr-font-size-h3);
  font-weight: 600;
  line-height: 1.45;
}

.hamrah-legend + * {
  clear: both;
}

/* Field widths (ui-patterns §5, fix round 1): one rule by what a field holds. A chosen or
   numeric value (number, date, single select) is 24rem; free text (text, URL, textarea,
   multi-select) takes the form's full width. Was: numbers 12rem, selects full width. */
.form-narrow input[type="number"].form-control,
.form-narrow input[type="date"].form-control,
.form-narrow select.form-select:not([multiple]) {
  max-inline-size: 24rem;
}

/* A one-line LTR code or short list (country code «CA», «[3, 7, 14]»): the width of a number
   input. The class comes from field_widget (dir="ltr" text input with maxlength <= 64, or with
   spellcheck off and no maxlength); ui-critic round 3, /reports/settings/. */
.form-narrow .form-control.hamrah-input-short {
  max-inline-size: 24rem;
}

/* Exception to the 8px radius: a 16px checkbox with 8px corners reads as a radio button. */
.form-check-input[type="checkbox"] {
  border-radius: 4px;
}

/* Select indicator. Tabler's RTL build keeps "right <padding> center" for the arrow while the
   reserved padding moves to the inline end, so the arrow is drawn under the option text on the
   start side and disappears. The panel is RTL only (DESIGN.md): an x offset with no keyword is
   measured from the visual left = the inline end, inside the padding Tabler reserves there. */
[dir="rtl"] .form-select {
  --tblr-control-select-bg-position: var(--tblr-control-padding-x) center;
}

/* dir="auto" inputs (search, URLs): an empty input has no strong character and resolves to
   LTR, which pushes the Persian placeholder to the wrong edge. While the placeholder shows,
   the input follows the page. */
.form-control[dir="auto"]:placeholder-shown {
  direction: rtl;
}

/* LTR text typed into the search box («CTR», a path) keeps its own direction but stays on the
   start edge next to the search icon; the icon padding follows it (the input is LTR, so its
   logical sides are mirrored). */
.input-icon .form-control[dir="auto"]:not(:placeholder-shown):dir(ltr) {
  text-align: end;
  padding-inline-start: var(--tblr-control-padding-x);
  padding-inline-end: var(--tblr-input-icon-padding-start);
}

/* Error summary above a form: danger text on its tint, one Persian sentence per error */
.form-errors {
  padding: 0.75rem 1rem;
  border: 1px solid var(--tblr-danger-lt);
  border-radius: var(--tblr-border-radius);
  background: var(--tblr-danger-lt);
  color: var(--tblr-danger);
}

/* 9. Cards, datagrid, empty state ---------------------------------------------------------------- */
.card {
  --tblr-card-box-shadow: var(--tblr-shadow-card);
}

.card-title {
  font-size: var(--tblr-font-size-h3);
  font-weight: 600;
}

.datagrid {
  --tblr-datagrid-padding: 1rem;
  --tblr-datagrid-item-width: 13rem;
}

.datagrid-title {
  color: var(--tblr-secondary-color);
}

/* Detail side card (ui-patterns §4): status, times and who-did-what in one column */
/* A section of only numbers (counts of a crawl, a fetch): short values, so narrower items
   (8rem: two columns at 1024, four at 1440) instead of one tall column (fix round 1). */
.hamrah-datagrid-numbers {
  --tblr-datagrid-item-width: 8rem;
}

.hamrah-datagrid-stack {
  grid-template-columns: minmax(0, 1fr);
}

/* Side-card actions are full width; at 1024 the card is ~220px, so a long Persian label wraps
   inside the button instead of being cut (Tabler's .btn is nowrap). */
.hamrah-side-actions .btn,
.hamrah-side-actions .dropdown-item {
  white-space: normal;
}

.empty {
  --tblr-empty-icon-size: 2.5rem;
  --tblr-empty-padding-md: 2rem;
  /* Error code «۴۰۴»: proportional digits (the Persian zero is narrow), calmer size */
  --tblr-empty-header-font-size: 3rem;
}

.empty-title {
  font-size: var(--tblr-font-size-h3);
  line-height: 1.45;
}

.empty-subtitle {
  max-inline-size: 36rem;
  color: var(--tblr-secondary-color);
}

/* Confirm modal: the accept button names the action and the count («رد — ۳ مورد»); a long
   label wraps inside the button instead of pushing it out of the small dialog. */
#confirm-modal [data-confirm-accept] {
  white-space: normal;
}

/* Stat card label (dashboard, ui-critic fix round 2): two lines high, so the numbers of a
   row-deck row sit on one line when one label wraps («بریف‌های تأییدشده بدون پیش‌نویس» at
   1024). Pushing the value down instead (mt-auto) misaligned it in cards with a caption or a
   bar under it (cost and report cards, measured 39px apart). */
.hamrah-stat-label {
  min-block-size: 3.2em;
}

/* Stat card number (dashboard) */
.stat-value {
  font-size: var(--tblr-font-size-h1);
  font-weight: 600;
  line-height: 1.45;
  font-variant-numeric: tabular-nums;
}

/* 10. App shell: vertical floating sidebar (Tabler's navbar-vertical navbar-floating) ----------- */
.navbar-vertical {
  --tblr-navbar-active-bg: #f0fdfa;
  --tblr-navbar-active-color: #115e59;
  --tblr-navbar-color: #334155;
}

.navbar-vertical[class*="navbar-expand"] .navbar-nav {
  --tblr-sidebar-section-title-font-size: 0.8125rem;
  --tblr-sidebar-section-title-margin-top: 1rem;
}

/* A group: the heading plus its own list of items (sidebar.html). The inner list is a bare
   list; Tabler's item rules match through the outer .navbar-nav. */
.hamrah-nav-group-items {
  display: flex;
  flex-direction: column;
  margin: 0;
  padding: 0;
  list-style: none;
}

/* Below 992px (Tabler's top-bar menu) every heading is the first child of its group, which
   Tabler's :first-child rule would leave without the gap between groups. */
@media (max-width: 991.98px) {
  .navbar-vertical[class*="navbar-expand"] .navbar-nav .hamrah-nav-group + .hamrah-nav-group > .nav-section-title {
    margin-block-start: var(--tblr-sidebar-section-title-margin-top);
  }
}

/* Same selector weight as Tabler's rule, which sets uppercase + tracking */
.navbar-vertical[class*="navbar-expand"] .navbar-nav .nav-section-title {
  color: #64748b;
  letter-spacing: 0;
  text-transform: none;
}

/* Long sidebar (ui-patterns §1, phase 9: «سوابق سیستم» brought the editor to ~40 items). From
   992px Tabler's sidebar is fixed and its menu (.navbar-collapse) scrolls between the wordmark
   and the user block; nothing is hidden or folded. Items are 8px + line + 8px (about 42px, was
   50px) so more fit above the fold. Group headings scroll with their own items (not sticky:
   at 1024px a stuck heading was left alone at the top over the next group's items, cleanup
   after phase 10). hamrah-panel.js scrolls the active item into view on load. */
@media (min-width: 992px) {
  .navbar-vertical.navbar-expand-lg .navbar-nav {
    --tblr-sidebar-nav-padding-y: 0.5rem;
  }

  /* Each group is its own <li>; the 16px gap above a group is the heading's own padding, so
     the spacing is the same as when the headings were sticky. */
  .navbar-vertical.navbar-expand-lg .navbar-collapse .nav-section-title {
    margin-block-start: 0;
    padding-block: 1rem 0.5rem;
  }

  .navbar-vertical.navbar-expand-lg .navbar-collapse .hamrah-nav-group:first-child .nav-section-title {
    padding-block-start: 0.25rem;
  }

  .navbar-vertical.navbar-expand-lg .navbar-collapse {
    overscroll-behavior: contain;
    scrollbar-width: thin;
  }
}

/* Active item: tint + accent colour + 600 weight, plus a bar on the inline-start edge so the
   state does not rely on colour alone. */
.navbar-vertical .nav-item.active > .nav-link {
  color: var(--tblr-navbar-active-color);
}

.navbar-vertical .nav-item.active > .nav-link::before {
  content: "";
  position: absolute;
  inset-block: 0.5rem;
  inset-inline-start: 0;
  inline-size: 3px;
  border-radius: var(--tblr-border-radius-pill);
  background: var(--tblr-primary);
}

.navbar-brand .hamrah-wordmark {
  font-size: var(--tblr-font-size-h3);
  font-weight: 600;
  color: var(--tblr-body-color);
}

/* 11. HTMX states -------------------------------------------------------------------------------- */
/* Tabler/Bootstrap spinner inside .htmx-indicator is shown only while a request runs. */
.htmx-indicator {
  display: none;
}

.htmx-request .htmx-indicator,
.htmx-request.htmx-indicator {
  display: inline-flex;
}

/* While a list request runs (hamrah-panel.js sets aria-busy on #table), the rows dim so stale
   rows are not read as fresh. */
.hamrah-list[aria-busy="true"] .table-responsive,
.hamrah-list[aria-busy="true"] .empty {
  opacity: 0.6;
  transition: opacity 0.15s;
}

/* 12. Focus ------------------------------------------------------------------------------------- */
:focus-visible {
  outline: 2px solid var(--tblr-primary);
  outline-offset: 2px;
}

/* 13. Shell details (step 3b) ------------------------------------------------------------------ */
/* Wordmark + caption: text only, no invented logo. */
.hamrah-brand {
  display: inline-flex;
  align-items: baseline;
  gap: 0.5rem;
  color: var(--tblr-body-color);
  text-decoration: none;
}

.hamrah-brand:hover {
  text-decoration: none;
}

.hamrah-wordmark {
  font-size: var(--tblr-font-size-h3);
  font-weight: 600;
  line-height: 1.45;
  color: var(--tblr-body-color);
}

.hamrah-caption {
  font-size: 0.8125rem;
  font-weight: 400;
  color: var(--tblr-secondary-color);
}

/* Skip link: first focusable element, visible only on focus. */
.hamrah-skip:focus {
  position: fixed;
  inset-block-start: 0.5rem;
  inset-inline-start: 0.5rem;
  z-index: 1100;
  padding: 0.5rem 1rem;
  border-radius: var(--tblr-border-radius);
  background: var(--tblr-bg-surface);
  color: var(--tblr-primary);
  box-shadow: var(--tblr-box-shadow);
}

/* User block in the sidebar footer: name over role, both truncated in the 16rem column. */
.hamrah-user {
  display: flex;
  flex-direction: column;
  min-inline-size: 0;
  line-height: 1.5;
}

.hamrah-user-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.navbar-footer .dropdown-item {
  gap: 0.5rem;
}

/* Messages under the page header */
#messages .alert {
  margin-block-end: 1rem;
}

/* 14. List details ------------------------------------------------------------------------------ */
/* Clickable rows (data-href, see hamrah-panel.js); the first cell also holds a real link. */
tr[data-href] {
  cursor: pointer;
}

tr[data-href]:hover > td {
  background: var(--tblr-gray-50);
}

/* The record's name column never shrinks below a readable width. 16rem from xl (1440: a
   70-character Persian title takes at most three lines); 12.5rem below xl, where the card is
   ~700px wide and low-priority columns are hidden (d-none d-xl-table-cell). Measured on the
   alerts list (fix round 1): checkbox 52 + severity 81 + kind 158 + status 65 + date 135 px
   leave 211px of the 702px card at 1024; at 1440 the 8 columns fill the 1118px card exactly
   with two 9rem identifiers. More columns than that scroll inside table-responsive. */
.col-main {
  min-inline-size: 12.5rem;
}

@media (min-width: 1200px) {
  .col-main {
    min-inline-size: 16rem;
  }
}

/* Row rhythm: only LTR/link/date cells stay on one line (text-nowrap / hamrah-ltr); text
   wraps. Badges never break inside. */
.table td .badge {
  white-space: nowrap;
}

/* A long free text (more than 24 characters, cell_class.html) never collapses to one word per
   line when a wide table squeezes its column (phase 8 shots: the per-country volume column of
   the clusters list was 8 lines high). Short texts («فارسی») keep their natural width. */
.table td.col-text {
  min-inline-size: 7.5rem;
}

/* The record's column keeps its own minimum when its text is long too (a long link gets
   col-text, cell_class.html): same specificity as the rule above, so it comes after it
   (round 2 shots: the title column of /drafts/ fell to ~130px under col-text's 7.5rem). */
.table td.col-main {
  min-inline-size: 12.5rem;
}

@media (min-width: 1200px) {
  .table td.col-main {
    min-inline-size: 16rem;
  }
}

/* A long link in a secondary column (a brief's title in the drafts list, more than 24
   characters, cell_class.html) keeps a readable width (9.5rem: at 11rem the nine columns of
   /drafts/ overflowed the 1440 card by ~20px) and stops at two lines; the full text is
   in the link's title and on the detail page. Phase 9 shots: the brief column of /drafts/ was
   five to ten lines high at 1440 (one or two words per line). The clamp sits on the link's
   <bdi>, whose direction follows its text, so an English title gets its ellipsis at its own
   end (on the <a> of an RTL cell it cut the start of «symptoms»). The record's own column
   (col-main) is not clamped and keeps its own minimum: col-text never overrides col-main
   (round 2 shots: the title column of /drafts/ fell to ~130px). */
.table td.text-url.col-text:not(.col-main) {
  min-inline-size: 9.5rem;
}

.table td.text-url.col-text:not(.col-main) > a > bdi:not(.hamrah-path),
.table td.text-url.col-text:not(.col-main) > bdi:not(.hamrah-path) {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  overflow: hidden;
}

/* Codes (kind "code": an id, a location code, a hash): LTR, the monospace stack, Latin digits
   exactly as stored (never grouped or converted), one line. 14px: the monospace face runs larger
   than Vazirmatn at the same size. */
.hamrah-code {
  font-family: var(--tblr-font-monospace);
  font-size: 0.875rem;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0;
  white-space: nowrap;
}

/* In a table a code is cut at its END (phase 10 fix 1: /jobs/ task names): the bdi is
   dir="ltr", so the start of «competitors.check_coverage» stays visible and the ellipsis eats
   its tail; 14rem shows about 26 monospace characters (every task name), a 64-character hash is
   cut. The full value is in the title (cell.html) and on the detail page. "clip", not "hidden":
   an inline-block with overflow hidden sits on its bottom edge, 2-3px below the row's text
   (fix 1 shots, /jobs/ and /groups/); a clipped one keeps its text baseline. */
.table bdi.hamrah-code {
  display: inline-block;
  max-inline-size: 14rem;
  overflow: hidden;
  overflow: clip;
  text-overflow: ellipsis;
  vertical-align: baseline;
}

/* A code cell that holds a list of identifiers (group detail: the codenames of one app) is one
   <code> chip per item, wrapping between chips and never inside one (phase 10 fix 1: the
   comma-joined list ran 900px wide on one line). */
.hamrah-code-list {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  white-space: normal;
}

.hamrah-code-list .hamrah-code {
  padding-inline: 0.25rem;
  border-radius: var(--tblr-border-radius-sm);
  background: var(--tblr-code-bg);
  color: inherit;
  white-space: nowrap;
}

/* Money (kind "usd"): «$» and the amount stay one LTR unit; the digits keep col-num's
   tabular figures. */
.hamrah-usd {
  white-space: nowrap;
}

/* In a table an identifier is a hint (full value in title and on the detail page) */
.table .hamrah-ltr {
  max-inline-size: 9rem;
}

/* A path inside the record's title (isolate_ltr) stays on one line and is cut with an
   ellipsis instead of breaking at its hyphens; the full title is in the link's title.
   "contain: inline-size" keeps the unbroken path out of the column's minimum width (with a
   plain max-inline-size: 100% the table grew wider than the card); as a block it takes the
   cell's width on its own line, its LTR text kept on the cell's start edge. */
.table .col-main bdi[dir="ltr"] {
  display: block;
  contain: inline-size;
  max-inline-size: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-align: end;
}

/* On a detail page an identifier has room: show it whole, wrapping if it must */
.datagrid-content .hamrah-ltr {
  max-inline-size: 100%;
  white-space: normal;
  overflow-wrap: anywhere;
}

/* A path or URL on a detail page (url_breaks, ui-patterns §11) wraps only after its slashes:
   each piece is a nowrap span joined with <wbr>, so «online-therapy» never splits («…/on»
   «line-…», phase 8 critic). Inline, not clipped; a URL over 40 characters takes the whole
   datagrid row (.hamrah-datagrid-wide), so a single piece fits its line. The same holds for a
   path inside a multi-line block (isolate_ltr_block): «…/mental-» «health-…» at 1024 was the
   ui-critic r2 bug, from the block's inherited overflow-wrap. */
.datagrid-content .hamrah-url {
  display: inline;
  overflow: visible;
  overflow-wrap: normal;
  word-break: normal;
}

.hamrah-multiline .hamrah-url {
  overflow-wrap: normal;
  word-break: normal;
  white-space: normal;
}

/* Breadcrumb: Tabler's RTL build mirrors the divider with scaleX(-1), so its default "/" reads
   as a backslash and its padding lands on the wrong side. The divider is "›" (mirrored: «‹»,
   pointing forward in RTL, like Tabler's breadcrumb-arrows) and the spacing moves to the
   margin, outside the transform, so the divider sits between the items with equal air. */
.breadcrumb {
  --tblr-breadcrumb-divider: "›";
}

.breadcrumb-item + .breadcrumb-item::before {
  padding-inline-end: 0;
  margin-inline-end: var(--tblr-breadcrumb-item-padding-x);
}

/* Page title: a plain block, not Tabler's flex row. In a flex container the text and an
   isolated path (<bdi>, isolate_ltr) become separate flex items and the spaces between them
   vanish («نشده:/fa/blog/…»). Our titles never hold icons; a status badge sits beside the h1
   in .hamrah-title-row. */
.page-title {
  display: block;
  /* Tabler sizes .page-title with the h2 variable (20px); the page's one h1 is 24px/600. */
  font-size: var(--tblr-font-size-h1);
  line-height: var(--tblr-line-height-h1);
}

/* Page header: the title and description keep at least 20rem; when the header buttons need
   more than the rest, they wrap under the title instead of squeezing the description to one
   word per line (phase 8 shots: the clusters list with three header buttons at 1024). */
.hamrah-header-main {
  min-inline-size: min(20rem, 100%);
}

/* Detail header: title + status badge on one line */
.hamrah-title-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
}

/* Multi-line LTR values (JSON, logs) on a detail page: a light code block across the whole
   datagrid row; 13px monospace, lines kept exactly as written (no wrapping: a JSON value
   broken at its hyphen reads as two values), scrolls when too wide or too tall. The grid item
   may shrink below the longest line ("min-inline-size: 0"), so the block scrolls inside the
   card instead of widening the datagrid. */
.hamrah-datagrid-wide {
  grid-column: 1 / -1;
  min-inline-size: 0;
}

.hamrah-pre {
  margin: 0;
  padding: 0.75rem 1rem;
  max-block-size: 24rem;
  overflow: auto;
  direction: ltr;
  text-align: start;
  white-space: pre;
  font-family: var(--tblr-font-monospace);
  font-size: 0.8125rem;
  line-height: 1.6;
  color: var(--tblr-body-color);
  background: var(--tblr-gray-100);
  border-radius: var(--tblr-border-radius);
}

/* Multi-line Persian text (kind "text" with line breaks: a SERP summary, page headings) on a
   detail page: across the whole datagrid row, the line breaks kept and long lines wrapped
   (pre-line), each line in its own direction (dir="auto" on the block), body type, no code
   styling. The LTR <pre> above is only for kind "ltr". */
.hamrah-multiline {
  white-space: pre-line;
  text-align: start;
  overflow-wrap: break-word;
  max-inline-size: 48rem;
}

/* The same text in a table cell stays one line, cut with an ellipsis; the full text is in the
   title attribute and on the detail page. */
.table .hamrah-oneline {
  display: inline-block;
  max-inline-size: 18rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  vertical-align: bottom;
}

/* A bare path or URL in a link cell (link_text.html): one LTR line; in a table it is cut with
   an ellipsis (full value in title and on the detail page) instead of breaking at its hyphens. */
.table .hamrah-path {
  display: inline-block;
  max-inline-size: 11rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  vertical-align: bottom;
}

/* Table headers may wrap at their spaces («ایمپرشن ۲۸ روز» on two lines): a number column is
   then as wide as its numbers, not as its label, which gives the text columns room. Only at
   spaces: the card's inherited "word-wrap: break-word" let a scrolling table break «CTR» into
   one letter per line, so words are kept whole here. */
.table thead th,
.table thead th.col-num {
  white-space: normal;
  overflow-wrap: normal;
  word-break: keep-all;
}

/* Phase 11: a list with at most seven columns, the bulk checkbox not counted (`hamrah-th-nowrap`,
   set by table.html: `columns|length <= 7`), keeps every header label on one line from xl, where
   it has room: on /users/ «دسترسی کامل» and «تاریخ عضویت» wrapped and the header row was 58px
   instead of 37px. Not below xl (columns are hidden there and nowrap could force a scroll at
   1024), and not on wider tables (measured on all 35 lists at 1440: with eight columns nowrap
   overflowed /api-usage/, /drafts/, /inventory/ and /keywords/clusters/). Number headers
   (col-num) keep wrapping at their spaces (rule above): on /keywords/ one-line «ایمپرشن ۲۸ روز»,
   «کلیک ۲۸ روز», «جایگاه ۲۸ روز» took 53px from the cluster column and four cluster names
   wrapped, so the page got taller, not shorter. */
@media (min-width: 1200px) {
  .table.hamrah-th-nowrap thead th:not(.col-num) {
    white-space: nowrap;
  }
}

/* Dashboard lists: a path inside an alert title stays on one line, cut with an ellipsis. */
.list-group-item-title bdi[dir="ltr"] {
  display: inline-block;
  max-inline-size: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  vertical-align: bottom;
}

/* First-column link (ui-patterns §3 «link (first column)»): the link colour (accent-700) and the
   body weight, the same as a `link` cell, whatever the cell's kind. Was bold neutral text, so a
   date or plain-text first column did not read as a link (ui-critic round 3). */
.hamrah-row-link {
  color: var(--tblr-link-color);
}

.hamrah-row-link:hover {
  color: var(--tblr-link-hover-color);
}

/* Boolean cell: icon + word, never an icon alone */
.hamrah-bool {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
}

/* Filter labels are captions (13px) to keep the filter bar to one dense row */
.hamrah-filters .form-label.small {
  font-size: 0.8125rem;
  font-weight: 600;
  line-height: 1.45;
  color: var(--tblr-secondary-color);
}

/* Filter bar density (ui-patterns §3/§13): one row at 1440, two rows at 1024. A select is
   as wide as its longest option up to 11rem (longer labels are cut by the browser); a date
   input's "mm/dd/yyyy" and picker button measure 111px, so 8.5rem with 0.5rem side padding
   (was 9rem with 0.75rem: round 3, the fifth filter of /reports/index-checks/ wrapped). */
.hamrah-filters .form-select {
  max-inline-size: 11rem;
}

.hamrah-date-range .form-control {
  max-inline-size: 8.5rem;
  padding-inline: 0.5rem;
}

/* With a date range or >= 4 filters the search column is col-xl-3 (ui-patterns §3). Phase 9 ui-critic round 3:
   at 1440 four selects + a date range + col-xl-3 search needed ~1170px of a 1088px row, so the
   last filter wrapped. From xl col-xl-3 is the search column's MAXIMUM: it starts at 13rem (its
   placeholder and icon) and grows into whatever the filters leave, so up to five filters stay
   on one row and the search never pushes one down. (Only the search column carries col-xl-3.) */
@media (min-width: 1200px) {
  .hamrah-filters .row > .col-xl-3 {
    flex: 1 1 13rem;
    inline-size: auto;
    max-inline-size: 25%;
  }

  /* Phase 10 fix 1: a placeholder of at most 16 characters («جست‌وجو در کارها») fits 11rem, so
     /jobs/ (four selects, a date range and the search) stays on one row at 1440. */
  .hamrah-filters .row > .col-xl-3:has(> .hamrah-search-short) {
    flex-basis: 11rem;
  }
}

/* Below xl (1024) the same column was col-lg-4, a third of the row (215px): every placeholder
   longer than «جست‌وجو در کوئری‌ها» was cut («جست‌وجو در کیوردهای پا…» on /keywords/seeds/, also
   /drafts/; phase 11). Now it starts at the width its placeholder needs beside the icon and
   grows into whatever row 1 leaves; the filters that fit share row 1, the rest wrap to row 2
   (ui-patterns §3/§13). 13.5rem by default (up to 18 visible characters, «جست‌وجو در هشدارها»),
   11rem with hamrah-search-short, 16rem with hamrah-search-long (19+ characters without
   half-spaces: «جست‌وجو در کیوردهای پایه»). One 16rem basis for all pushed a select of /briefs/
   to a third row and /searchdata/queries/ to a second. */
@media (min-width: 992px) and (max-width: 1199.98px) {
  .hamrah-filters .row > .col-xl-3 {
    flex: 1 1 13.5rem;
    inline-size: auto;
    max-inline-size: 100%;
  }

  .hamrah-filters .row > .col-xl-3:has(> .hamrah-search-short) {
    flex-basis: 11rem;
  }

  .hamrah-filters .row > .col-xl-3:has(> .hamrah-search-long) {
    flex-basis: 16rem;
  }
}

/* The list's loading spinner sits in the filter bar's top inline-end corner, inside the card
   padding, instead of a column of its own (that column cost the row 24px; round 3). */
.hamrah-filters {
  position: relative;
}

.hamrah-filter-loading {
  position: absolute;
  inset-block-start: 0.25rem;
  inset-inline-end: 0.25rem;
  line-height: 0;
}

/* An empty date input shows no English «mm/dd/yyyy» (phase 10 round 2). The browser draws
   the format in its own UI locale; neither lang="fa" on the input nor a Persian page locale
   changes it (tested in Chromium), and a placeholder is ignored. While the input is empty
   (the server renders value="" or no value: every change re-renders the list), unfocused
   and not holding a half-typed date (:invalid), its segments are transparent: the box shows
   only the picker button under the Persian label «… (میلادی)». Focus brings the segments
   back for typing. WebKit/Blink only; Firefox keeps its locale's format. */
.hamrah-filter-date:is([value=""], :not([value])):not(:focus):not(:invalid)::-webkit-datetime-edit {
  color: transparent;
}

/* The «تا» between the two dates: 6px side padding (Tabler: 12px). */
.hamrah-date-range .input-group-text {
  padding-inline: 0.375rem;
}

/* The empty search's free side (the icon side keeps Tabler's 2.5rem): 8px, so at its 13rem
   minimum «جست‌وجو در آدرس صفحه» is not cut (round 3, /reports/index-checks/ at 1440). Typed
   LTR text keeps the mirrored padding of the rule above. */
.hamrah-filters .input-icon .form-control:placeholder-shown {
  padding-inline-end: 0.5rem;
}

/* Filter chips: Tabler's .tag with its own .btn-close. Tabler draws the close glyph at 6px
   (0.5rem font, 0.75 of it) and opacity 0.4, which is barely visible. Here: a 24px box (the
   hit target) in a 28px chip, a 10.5px glyph, and opacity 0.75 so the glyph (body colour over
   white) keeps a contrast of about 7:1 (>= 3:1 for a graphic). */
.hamrah-chips .tag {
  --tblr-tag-height: 1.75rem;
  --tblr-tag-close-size: 1.5rem;
  --tblr-tag-close-font-size: 0.875rem;
  --tblr-tag-close-margin-end: -0.375rem;
  gap: 0.25rem;
}

.hamrah-chips .tag .btn-close {
  --tblr-btn-close-opacity: 0.75;
  --tblr-btn-close-hover-opacity: 1;
}

/* Error pages inside the shell: one centred card of readable width */
.hamrah-error {
  max-inline-size: 36rem;
  margin-inline: auto;
  margin-block-start: 2rem;
}


/* 15. Draft editor, review page, version diff (phase 9, ui-patterns §15) ----------------------- */
/* One line of facts under the page header (language, keyword, brief, safety flags). */
.hamrah-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 1rem;
}

.hamrah-meta-item {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
}

/* Editor layout: one column below 1200px in the order status -> editor -> panels (the state
   buttons stay near the top at 1024); from 1200px the editor takes the start column and the
   status card and the tabbed panels share the end column. */
.hamrah-editor {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-areas: "status" "form" "panels";
  gap: 1rem;
  align-items: start;
}

.hamrah-editor-status {
  grid-area: status;
}

.hamrah-editor-form {
  grid-area: form;
}

.hamrah-editor-panels {
  grid-area: panels;
}

@media (min-width: 1200px) {
  .hamrah-editor {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    grid-template-areas: "form status" "form panels";
    grid-template-rows: auto 1fr;
    column-gap: 1.5rem;
  }
}

/* The Markdown textarea: the monospace stack, whose first face ("Hamrah Mono FA") draws the
   Persian letters with the bundled Vazirmatn, so "#", "*" and "-" line up while Persian stays
   joined. Body size, a calm line height, resizable in height only. */
.hamrah-markdown-input {
  font-family: var(--tblr-font-monospace);
  font-size: var(--tblr-body-font-size);
  line-height: 1.8;
  resize: vertical;
}

/* Preview: Tabler's .prose with the panel's sizes. The article's h1 is smaller than the
   page's own h1 (24px), so the page keeps one focal point. No attribute is added to the
   sanitized content; links are underlined so they read as links in running text. The outer
   .hamrah-preview carries dir/lang; Tabler sets its markdown variables on .prose itself, so the
   overrides sit on the inner .prose. */
.hamrah-preview > .prose {
  --tblr-markdown-heading-margin-top: 1.5rem;
  --tblr-markdown-blockquote-margin-y: 1rem;
  --tblr-markdown-blockquote-padding-x: 1rem;
  max-inline-size: 48rem;
  font-size: var(--tblr-body-font-size);
  line-height: 1.8;
  overflow-wrap: break-word;
}

.hamrah-preview > .prose > h1 {
  font-size: var(--tblr-font-size-h2);
}

.hamrah-preview > .prose > h2 {
  font-size: var(--tblr-font-size-h3);
}

.hamrah-preview > .prose > h3 {
  font-size: var(--tblr-font-size-h4);
}

.hamrah-preview > .prose > h1,
.hamrah-preview > .prose > h2,
.hamrah-preview > .prose > h3 {
  line-height: 1.45;
}

.hamrah-preview ul,
.hamrah-preview ol {
  padding-inline-start: 1.5rem;
}

.hamrah-preview a {
  text-decoration: underline;
  text-underline-offset: 0.2em;
}

.hamrah-preview blockquote {
  color: var(--tblr-gray-700);
  border-inline-start-color: var(--tblr-gray-300);
}

/* FAQ and image suggestions under the preview: separated by one rule, 24px of air. */
.hamrah-editor-extra {
  margin-block-start: 1.5rem;
  padding-block-start: 1.5rem;
  border-block-start: 1px solid var(--tblr-border-color);
}

/* Image suggestions: one block per suggestion (alt, description, placement tag), 12px apart. */
.hamrah-image-list > li + li {
  margin-block-start: 0.75rem;
}

/* QA panel: one section per run, 24px apart; folded details (technical data, passed checks)
   open with a muted 13px summary line. */
.hamrah-qa-run {
  margin-block-start: 1.5rem;
}

.hamrah-fold > summary {
  margin-block-start: 0.25rem;
  font-size: 0.8125rem;
  color: var(--tblr-secondary-color);
  cursor: pointer;
}

.hamrah-fold > .hamrah-pre {
  margin-block-start: 0.5rem;
  max-block-size: 12rem;
}

/* A claim's four decisions (review page): an even 2 x 2 grid of Tabler selectgroup items. In
   the ~410px claims column at 1440 they wrapped 3 + 1 («حذف شود» alone on the second row). */
.hamrah-choice-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.5rem;
}

.hamrah-choice-grid .form-selectgroup-item {
  margin: 0;
}

.hamrah-choice-grid .form-selectgroup-label {
  inline-size: 100%;
}

/* A flex child that holds long text or a code block may shrink below its content. */
.hamrah-min-0 {
  min-inline-size: 0;
}

/* Claim and brief sources: an external URL wraps only after its slashes (url_breaks), never
   inside a word, like the datagrid rule above. */
.hamrah-source .hamrah-url {
  display: inline;
  overflow-wrap: normal;
  word-break: normal;
}

/* Version diff: one stacked column of lines; added lines on the success tint, removed lines
   on the danger tint, each with a +/- mark (and a visually hidden word) so the change is not
   told by colour alone. Lines wrap (pre-wrap) and keep their own direction (dir="auto"). */
.hamrah-diff {
  padding-block: 0.5rem;
  font-family: var(--tblr-font-monospace);
  font-size: var(--tblr-body-font-size);
  line-height: 1.8;
}

.hamrah-diff-line {
  display: flex;
  gap: 0.5rem;
  min-block-size: 1.8em;
  padding-inline: 1rem;
}

.hamrah-diff-mark {
  flex: 0 0 1ch;
  color: var(--tblr-secondary-color);
  text-align: center;
}

.hamrah-diff-text {
  flex: 1 1 auto;
  min-inline-size: 0;
  white-space: pre-wrap;
  overflow-wrap: break-word;
  text-align: start;
  text-decoration: none;
}

.hamrah-diff-ins {
  background: var(--tblr-success-lt);
}

.hamrah-diff-del {
  background: var(--tblr-danger-lt);
}

.hamrah-diff-fold > summary {
  padding-block: 0.25rem;
  padding-inline: 1rem;
  font-family: var(--tblr-body-font-family);
  font-size: 0.8125rem;
  color: var(--tblr-secondary-color);
  background: var(--tblr-gray-50);
  cursor: pointer;
}

/* Draft editor «ابزار و خروجی» (fix round 1): equal cells, so the tool and export buttons
   wrap in even rows (2 + 2 at 1024 and 1440) instead of leaving one button alone. A label
   that is longer than its cell wraps inside the button. */
.hamrah-tool-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr));
  gap: 0.5rem;
}

.hamrah-tool-grid .btn {
  white-space: normal;
}
