/*
 * ALMOMANI — system layer ("Obsidian")
 * --------------------------------------------------------------------------
 * Loaded AFTER components.css / pages.css. It re-skins every Bootstrap component and every legacy component class
 * with the Obsidian language (hairlines, mono micro-labels, signal red, ink buttons) so that no page — migrated or
 * not — keeps the old look. New compositions live in patterns.css.
 * Tokens only; logical properties only (English LTR + Arabic RTL share one rule set).
 *
 *  1. Bootstrap bridge      2. Typography & links    3. Buttons          4. Cards & panels
 *  5. Forms                 6. Tables                7. Badges & status  8. Alerts, toasts
 *  9. Menus, modals         10. Tabs, breadcrumb, pagination             11. Progress, empty, avatar, misc
 *  12. Legacy components re-skinned (kpi, stat-card, person, feed, filter-bar …)
 */

/* ===================================================================== 1. Bootstrap bridge */
:root,
[data-bs-theme="light"],
[data-bs-theme="dark"] {
  --bs-body-font-family: var(--font-sans);
  --bs-body-font-size: var(--fs-md);
  --bs-body-bg: var(--bg);
  --bs-body-color: var(--text);
  --bs-border-radius: var(--radius-md);
  --bs-border-radius-sm: var(--radius-sm);
  --bs-border-radius-lg: var(--radius-lg);
  --bs-border-radius-xl: var(--radius-xl);
  --bs-link-color-rgb: 163, 0, 0;
  --bs-primary-rgb: 186, 0, 0;
}
[data-bs-theme="dark"] {
  --bs-link-color-rgb: 255, 87, 87;
  --btn-primary-hover: var(--brand-red-bright);
  --ink-bg: #f3f3f5; --ink-fg: #0a0a0c; --ink-hover: #ffffff;
}
[data-bs-theme="light"], :root:not([data-bs-theme]) {
  --btn-primary-hover: var(--brand-red-strong);
  --ink-bg: #121215; --ink-fg: #ffffff; --ink-hover: #2a2a31;
}
:root:not([data-bs-theme]) { --ink-bg: #f3f3f5; --ink-fg: #0a0a0c; --ink-hover: #ffffff; --btn-primary-hover: var(--brand-red-bright); }

.card, .panel {
  --bs-card-bg: var(--surface);
  --bs-card-border-color: var(--border);
  --bs-card-border-radius: var(--radius-lg);
  --bs-card-inner-border-radius: calc(var(--radius-lg) - 1px);
  --bs-card-cap-bg: transparent;
}
.dropdown-menu {
  --bs-dropdown-bg: var(--surface);
  --bs-dropdown-border-radius: var(--radius-lg);
  --bs-dropdown-link-hover-bg: var(--surface-3);
  --bs-dropdown-link-active-bg: var(--brand-tint-strong);
  --bs-dropdown-link-active-color: var(--brand-text);
  --bs-dropdown-box-shadow: var(--shadow-lg);
}
[data-bs-theme="dark"] .dropdown-menu { --bs-dropdown-border-color: var(--border-strong); }
.modal { --bs-modal-border-radius: var(--radius-xl); --bs-modal-inner-border-radius: calc(var(--radius-xl) - 1px); --bs-modal-box-shadow: var(--shadow-lg); }
[data-bs-theme="dark"] .modal { --bs-modal-border-color: var(--border-strong); }
.modal-backdrop { --bs-backdrop-bg: #000; --bs-backdrop-opacity: 0.62; }
.progress { --bs-progress-height: 6px; --bs-progress-bg: var(--surface-3); --bs-progress-bar-bg: var(--brand-red); }
.table { --bs-table-hover-bg: var(--surface-2); --bs-table-active-bg: var(--brand-tint); --bs-table-striped-bg: var(--surface-2); }
.pagination { --bs-pagination-border-radius: var(--radius-md); }

/* ===================================================================== 2. Typography & links */
.eyebrow, .mono-label {
  font-family: var(--font-label);
  font-size: var(--fs-2xs);
  font-weight: var(--fw-medium);
  letter-spacing: var(--tracking-label);
  text-transform: uppercase;
  color: var(--text-muted);
}
.mono { font-family: var(--font-mono); }
.num, .tnum { font-variant-numeric: tabular-nums; }
.display-num { font-family: var(--font-mono); font-weight: var(--fw-medium); font-variant-numeric: tabular-nums; letter-spacing: -0.04em; }
.lead-text { font-size: var(--fs-lg); color: var(--text-muted); line-height: 1.6; max-width: 62ch; }
.kbd, kbd {
  display: inline-flex; align-items: center; justify-content: center; min-width: 22px; height: 22px; padding: 0 6px;
  font-family: var(--font-sans); font-size: var(--fs-xs); font-weight: var(--fw-medium); line-height: 1;
  color: var(--text-muted); background: var(--surface-2); border: 1px solid var(--border-strong); border-block-end-width: 2px; border-radius: var(--radius-sm);
}

/* Arabic: no mono tracking / uppercase (breaks letter joining) — the Plex Arabic fallback in --font-mono is used as-is */
:lang(ar) .eyebrow, :lang(ar) .mono-label, [dir="rtl"] .eyebrow { letter-spacing: normal; text-transform: none; font-size: var(--fs-xs); }

/* ===================================================================== 3. Buttons */
.btn {
  --bs-btn-padding-x: 0.95rem;
  --bs-btn-padding-y: 0.38rem;
  --bs-btn-font-size: var(--fs-sm);
  --bs-btn-font-weight: var(--fw-medium);
  --bs-btn-border-radius: var(--radius-md);
  min-height: 38px;
  letter-spacing: -0.003em;
  transition: background-color var(--dur-fast) var(--ease), border-color var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease),
              box-shadow var(--dur) var(--ease), transform var(--dur-fast) var(--ease);
}
.btn-sm { --bs-btn-padding-x: 0.7rem; --bs-btn-padding-y: 0.2rem; --bs-btn-border-radius: var(--radius-sm); min-height: 30px; }
.btn-lg, .btn-large { --bs-btn-padding-x: 1.4rem; --bs-btn-padding-y: 0.55rem; --bs-btn-font-size: var(--fs-md); --bs-btn-border-radius: var(--radius-md); min-height: 46px; }
.btn:active:not(:disabled):not(.disabled) { transform: translateY(1px); }

/* Primary: the signal. Red fill, soft top highlight, brighter on hover in dark, deeper in light. */
.btn-primary {
  --bs-btn-bg: var(--brand-red); --bs-btn-border-color: var(--brand-red);
  --bs-btn-hover-bg: var(--btn-primary-hover); --bs-btn-hover-border-color: var(--btn-primary-hover);
  --bs-btn-active-bg: var(--brand-red-deep); --bs-btn-active-border-color: var(--brand-red-deep);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.16), 0 1px 2px rgba(0, 0, 0, 0.18);
}

/* Secondary family: quiet, hairline */
.btn-secondary, .btn-light, .btn-outline-secondary, .btn-outline-dark, .btn-outline-white {
  --bs-btn-bg: var(--surface); --bs-btn-border-color: var(--border-strong);
  --bs-btn-hover-bg: var(--surface-3); --bs-btn-hover-border-color: var(--border-input);
  --bs-btn-active-bg: var(--surface-4);
}
[data-bs-theme="dark"] .btn-secondary, [data-bs-theme="dark"] .btn-light,
[data-bs-theme="dark"] .btn-outline-secondary, [data-bs-theme="dark"] .btn-outline-dark { --bs-btn-bg: var(--surface-2); }
.btn-secondary:hover:not(:disabled):not(.disabled) { border-color: var(--border-input); }

/* Ink: high-contrast neutral action (dark fill on light, white fill on dark) */
.btn-dark, .btn-success, .btn-ink {
  --bs-btn-color: var(--ink-fg); --bs-btn-bg: var(--ink-bg); --bs-btn-border-color: var(--ink-bg);
  --bs-btn-hover-color: var(--ink-fg); --bs-btn-hover-bg: var(--ink-hover); --bs-btn-hover-border-color: var(--ink-hover);
  --bs-btn-active-color: var(--ink-fg); --bs-btn-active-bg: var(--ink-hover); --bs-btn-active-border-color: var(--ink-hover);
  --bs-btn-disabled-color: var(--ink-fg); --bs-btn-disabled-bg: var(--ink-bg); --bs-btn-disabled-border-color: var(--ink-bg);
}
/* Destructive / attention: red outline that fills on hover */
.btn-danger, .btn-outline-danger, .btn-warning {
  --bs-btn-color: var(--danger-text); --bs-btn-bg: transparent; --bs-btn-border-color: var(--danger-border);
  --bs-btn-hover-color: var(--danger-text); --bs-btn-hover-bg: var(--danger-bg); --bs-btn-hover-border-color: var(--danger-solid);
  --bs-btn-active-color: var(--danger-text); --bs-btn-active-bg: var(--danger-bg); --bs-btn-active-border-color: var(--danger-solid);
}
.btn-info, .btn-outline-info { --bs-btn-color: var(--text); --bs-btn-bg: var(--surface-3); --bs-btn-border-color: var(--border-strong); --bs-btn-hover-bg: var(--surface-4); --bs-btn-hover-color: var(--text); --bs-btn-hover-border-color: var(--border-input); }
.btn-outline-primary {
  --bs-btn-color: var(--text); --bs-btn-border-color: var(--border-strong); --bs-btn-bg: transparent;
  --bs-btn-hover-color: var(--text); --bs-btn-hover-bg: var(--surface-3); --bs-btn-hover-border-color: var(--border-input);
}
.btn-ghost, .btn-link {
  --bs-btn-color: var(--text-muted); --bs-btn-bg: transparent; --bs-btn-border-color: transparent;
  --bs-btn-hover-color: var(--text); --bs-btn-hover-bg: var(--surface-3); --bs-btn-hover-border-color: transparent;
}
.btn-link { --bs-btn-color: var(--link); text-decoration: none; }
.btn-link:hover { text-decoration: underline; }
.btn.is-busy { position: relative; }

.icon-btn { border-radius: var(--radius-md); }
.icon-btn:hover { background: var(--surface-3); color: var(--text); }
.icon-btn--sm { border-radius: var(--radius-sm); }

/* ===================================================================== 4. Cards & panels */
.card { border-radius: var(--radius-lg); box-shadow: var(--surface-shadow); }
.card-header, .card > .card-head, .card > .form-title {
  background: transparent; border-block-end: 1px solid var(--border);
  padding: var(--space-3) var(--card-pad);
  font-size: var(--fs-sm); font-weight: var(--fw-semibold); letter-spacing: -0.003em;
  border-radius: 0;
}
.card .card-head { background: transparent; }
.card-footer { background: transparent; border-block-start: 1px solid var(--border); }
.card.card-hover:hover { border-color: var(--border-strong); box-shadow: var(--shadow-md); transform: translateY(-1px); }
.form-title { background: transparent; border-radius: var(--radius-lg) var(--radius-lg) 0 0; }
.form-title > i, .card-head__title > i, .section-title > i, .profile-section__title > i, .form-section__title > i { color: var(--text-faint); }
.card-head__title { font-size: var(--fs-sm); }
.card-title { letter-spacing: var(--tracking-tight); }
.well { border-radius: var(--radius-md); }

/* ===================================================================== 5. Forms */
.form-label, label { font-size: var(--fs-sm); font-weight: var(--fw-medium); letter-spacing: -0.003em; }
.form-control, .form-select, .au-input {
  min-height: 40px;
  padding: 0.45rem 0.8rem;
  border-radius: var(--radius-md);
  background-color: var(--surface);
  border-color: var(--border-input);
  transition: border-color var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease), background-color var(--dur-fast) var(--ease);
}
[data-bs-theme="dark"] .form-control, [data-bs-theme="dark"] .form-select, [data-bs-theme="dark"] .au-input { background-color: var(--surface-2); border-color: var(--border-input); }
.form-control:hover:not(:disabled):not(:focus), .form-select:hover:not(:disabled):not(:focus) { border-color: var(--text-faint); }
.form-control:focus, .form-select:focus, .au-input:focus { border-color: var(--brand-red); box-shadow: var(--focus-ring); }
[data-bs-theme="dark"] .form-control:focus, [data-bs-theme="dark"] .form-select:focus { background-color: var(--surface-2); border-color: var(--focus); }
.form-control::placeholder { color: var(--text-muted); opacity: 1; }  /* Phase E: faint was < 4.5:1 */
textarea.form-control { min-height: 104px; }
.input-group > .form-control, .input-group > .form-select { min-height: 40px; }
.input-group > .btn { min-height: 40px; }
.input-group-text { border-radius: var(--radius-md); border-color: var(--border-strong); }
.form-check-input { width: 1.1rem; height: 1.1rem; margin-block-start: 0.18rem; border-color: var(--border-input); background-color: var(--surface); }
.form-check-input[type="checkbox"] { border-radius: var(--radius-xs); }
.form-check-input:checked { background-color: var(--brand-red); border-color: var(--brand-red); }
.form-switch .form-check-input { width: 2.1rem; height: 1.15rem; border-radius: var(--radius-pill); }
.form-text { font-size: var(--fs-xs); }
.form-select { padding-inline-end: 2.4rem; }
input[type="file"].form-control { padding: 0.35rem 0.5rem; }
.was-validated .form-control:valid, .form-control.is-valid { border-color: var(--border-strong); background-image: none; }

/* ===================================================================== 6. Tables — editorial: mono heads, hairline rows, no zebra */
.table { font-size: var(--fs-sm); --bs-table-hover-bg: var(--surface-2); }
.table > :not(caption) > * > * { padding: 0.8rem var(--space-4); border-bottom-color: var(--border); }
.table > thead > tr > th {
  background: transparent;
  padding-block: 0.7rem;
  font-family: var(--font-label);
  font-size: var(--fs-2xs);
  font-weight: var(--fw-medium);
  letter-spacing: var(--tracking-label);
  text-transform: uppercase;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border-strong);
}
:lang(ar) .table > thead > tr > th, [dir="rtl"] .table > thead > tr > th { letter-spacing: normal; text-transform: none; font-size: var(--fs-xs); }
.table > tbody > tr:hover > * { background-color: var(--surface-2); }
.table-responsive, .table-shadow {
  background: var(--surface); border-radius: var(--radius-lg); box-shadow: var(--surface-shadow);
}
.table-responsive > .table, .table-shadow > .table { --bs-table-bg: transparent; }
.table-striped > tbody > tr:nth-of-type(odd) > * { --bs-table-bg-type: transparent; }
.table-sm > :not(caption) > * > * { padding-block: 0.5rem; }
.table-title { font-size: var(--fs-md); }
.table tr.row-accent > * { background: var(--brand-red); }

/* ===================================================================== 7. Badges & status */
.badge {
  display: inline-flex; align-items: center; gap: 0.4em;
  padding: 0.28em 0.6em;
  font-family: var(--font-label); font-size: var(--fs-2xs); font-weight: var(--fw-medium);
  letter-spacing: 0.04em; text-transform: uppercase; line-height: 1.25;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
}
:lang(ar) .badge, [dir="rtl"] .badge { letter-spacing: normal; text-transform: none; font-size: var(--fs-xs); font-family: var(--font-sans); }
.badge.bg-primary, .badge.text-bg-primary { background: var(--surface-3) !important; color: var(--text) !important; border-color: var(--border-strong); }   /* quiet "Primary" marker, not a red block */
.sidebar .badge.text-bg-primary, .tabbar .badge.text-bg-primary, .subnav .badge.text-bg-primary { background: var(--brand-red) !important; color: var(--on-brand) !important; border-color: var(--brand-red); }   /* the only red count: items waiting on the admin */
.badge.bg-secondary, .badge.text-bg-secondary { background: var(--surface-3) !important; color: var(--text-muted) !important; border-color: var(--border); }
.badge.bg-success, .badge.text-bg-success { background: var(--success-bg) !important; color: var(--success-text) !important; border-color: var(--success-border); }
.badge.bg-warning, .badge.text-bg-warning { background: var(--warning-bg) !important; color: var(--warning-text) !important; border-color: var(--warning-border); }
.badge.bg-danger, .badge.text-bg-danger { background: var(--danger-bg) !important; color: var(--danger-text) !important; border-color: var(--danger-border); }
.badge.bg-info, .badge.text-bg-info { background: var(--info-bg) !important; color: var(--info-text) !important; border-color: var(--info-border); }
.badge.bg-light, .badge.text-bg-light, .badge.bg-dark, .badge.text-bg-dark { background: var(--surface-3) !important; color: var(--text) !important; border-color: var(--border); }
.badge.rounded-pill { border-radius: var(--radius-pill); }

/* Status: dot + word. The default reading of "state" everywhere (replaces coloured blocks). */
.status {
  display: inline-flex; align-items: center; gap: 0.5em;
  font-size: var(--fs-sm); font-weight: var(--fw-medium); color: var(--text); white-space: nowrap;
}
.status::before { content: ""; flex: none; inline-size: 7px; block-size: 7px; border-radius: 50%; background: var(--text-faint); }
/* Semantic status dots (always paired with a word, so meaning never rests on colour): ok = green, warn = amber (pending / needs attention),
   bad = red (failed / rejected / overdue), live = blue (in progress), draft = hollow neutral, mute = faded (archived / closed). */
.status--ok::before { background: var(--success-solid); box-shadow: 0 0 0 3px var(--success-bg); }
.status--warn::before { background: var(--warning-solid); box-shadow: 0 0 0 3px var(--warning-bg); }
.status--bad::before { background: var(--danger-solid); box-shadow: 0 0 0 3px var(--danger-bg); }
.status--live::before { background: var(--info-solid); animation: status-pulse 1.8s ease-out infinite; }
.status--draft { color: var(--text-muted); }
.status--draft::before { background: transparent; border: 2px solid var(--text-faint); inline-size: 9px; block-size: 9px; }
.status--mute { color: var(--text-muted); }
.status--mute::before { background: var(--border-strong); }
@keyframes status-pulse { 0% { box-shadow: 0 0 0 0 var(--info-border); } 100% { box-shadow: 0 0 0 8px transparent; } }
@media (prefers-reduced-motion: reduce) { .status--live::before { animation: none; } }

.status-pill { border-radius: var(--radius-sm); background: transparent; font-family: var(--font-label); font-size: var(--fs-2xs); text-transform: uppercase; letter-spacing: 0.04em; }
.status-pill--success { background: var(--success-bg); color: var(--success-text); border-color: var(--success-border); }
.status-pill--warning { background: var(--warning-bg); color: var(--warning-text); border-color: var(--warning-border); }
.status-pill--danger { background: var(--danger-bg); color: var(--danger-text); border-color: var(--danger-border); }
:lang(ar) .status-pill, [dir="rtl"] .status-pill { text-transform: none; letter-spacing: normal; font-family: var(--font-sans); font-size: var(--fs-xs); }
.count-pill { border-radius: var(--radius-sm); background: var(--surface-3); font-family: var(--font-mono); font-size: var(--fs-2xs); font-weight: var(--fw-medium); color: var(--text-muted); min-height: 22px; }
.chip { border-radius: var(--radius-sm); background: var(--surface-3); border-color: var(--border); font-weight: var(--fw-medium); }
.info-text { border-radius: var(--radius-sm); }

/* ===================================================================== 8. Alerts & toasts */
.alert {
  --bs-alert-border-radius: var(--radius-md);
}
.alert-success { background: var(--surface-2); color: var(--text); border-color: var(--border-strong); }
.alert-info { background: var(--surface-2); color: var(--text); border-color: var(--border-strong); }
.alert .btn-close { margin-inline-start: auto; }
.alert > i { color: var(--text-muted); }
.alert-warning > i, .alert-danger > i { color: var(--brand-text); }

.toast-region { inset-block-start: auto; inset-block-end: var(--space-5); inset-inline-end: var(--space-5); z-index: var(--z-toast); flex-direction: column-reverse; }
.toast-item {
  border-radius: var(--radius-lg); padding: var(--space-3) var(--space-4);
  box-shadow: var(--shadow-lg); backdrop-filter: blur(10px);
  animation: toast-in var(--dur-slow) var(--ease-out);
}
.toast-item { border-color: var(--border-strong); overflow: hidden; }
.toast-item--warning { border-color: var(--warning-border); }
.toast-item--error { border-color: var(--danger-border); }
@keyframes toast-in { from { opacity: 0; transform: translateY(12px) scale(0.98); } to { opacity: 1; transform: none; } }

/* ===================================================================== 9. Menus, modals, tooltips */
.dropdown-menu { padding: var(--space-2); border-radius: var(--radius-lg); min-width: 12rem; }
.dropdown-item { margin-inline: 0; padding: 0.5rem var(--space-3); border-radius: var(--radius-md); gap: var(--space-3); font-weight: var(--fw-medium); }
.dropdown-item:hover { background: var(--surface-3); }
.dropdown-item.text-danger:hover { background: var(--danger-bg); }
.dropdown-divider { margin-block: var(--space-2); }
.dropdown-header { font-family: var(--font-label); font-size: var(--fs-2xs); letter-spacing: var(--tracking-label); }
.modal-content { background: var(--surface); }
.modal-header { border-block-end: 1px solid var(--border); }
.modal-footer { border-block-start: 1px solid var(--border); background: transparent; }
.modal.fade .modal-dialog { transform: translateY(16px) scale(0.985); transition: transform var(--dur-slow) var(--ease-out), opacity var(--dur) var(--ease); }
.modal.show .modal-dialog { transform: none; }
.tooltip { --bs-tooltip-bg: var(--ink-bg); --bs-tooltip-color: var(--ink-fg); --bs-tooltip-border-radius: var(--radius-sm); --bs-tooltip-font-size: var(--fs-xs); }
.popover { --bs-popover-bg: var(--surface); --bs-popover-border-color: var(--border-strong); --bs-popover-border-radius: var(--radius-lg); }

/* ===================================================================== 10. Tabs, breadcrumb, pagination */
/* Underline tabs, red on the active one */
.nav-tabs { gap: var(--space-5); border-block-end: 1px solid var(--border); }
.nav-tabs .nav-link {
  position: relative; padding: var(--space-3) 0; border: 0; background: transparent !important; color: var(--text-muted);
  font-weight: var(--fw-medium); font-size: var(--fs-sm); text-decoration: none; margin-block-end: -1px;
}
.nav-tabs .nav-link::after { content: ""; position: absolute; inset-inline: 0; inset-block-end: 0; height: 2px; background: var(--brand-red); transform: scaleX(0); transform-origin: left; transition: transform var(--dur) var(--ease-out); }
[dir="rtl"] .nav-tabs .nav-link::after { transform-origin: right; }
.nav-tabs .nav-link:hover { color: var(--text); border: 0; }
.nav-tabs .nav-link.active { color: var(--text); border: 0; }
.nav-tabs .nav-link.active::after { transform: scaleX(1); }
.nav-tabs .nav-link .badge, .nav-tabs .nav-link .count-pill { margin-inline-start: var(--space-2); }

/* Segmented control (pills) */
.nav-pills { gap: 2px; padding: 3px; background: var(--surface-3); border: 1px solid var(--border); border-radius: var(--radius-md); display: inline-flex; flex-wrap: wrap; }
.nav-pills .nav-link { padding: 0.3rem 0.85rem; border-radius: var(--radius-sm); font-size: var(--fs-sm); color: var(--text-muted); }
.nav-pills .nav-link.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm), 0 0 0 1px var(--border-strong); }
[data-bs-theme="dark"] .nav-pills .nav-link.active { background: var(--surface-4); box-shadow: none; }
.nav-pills .nav-link:not(.active):hover { background: transparent; color: var(--text); }

/* Breadcrumb = mono eyebrow */
.breadcrumb { margin-block-end: var(--space-3); font-family: var(--font-sans); font-size: var(--fs-xs); letter-spacing: normal; text-transform: none; }
:lang(ar) .breadcrumb, [dir="rtl"] .breadcrumb { font-family: var(--font-sans); letter-spacing: normal; text-transform: none; font-size: var(--fs-xs); }
.breadcrumb-item a { color: var(--text-muted); }
.breadcrumb-item a:hover { color: var(--brand-text); text-decoration: none; }
.breadcrumb-item.active { color: var(--text); font-weight: var(--fw-medium); }
.breadcrumb-item + .breadcrumb-item { padding-inline-start: 0.5rem; }
.breadcrumb-item + .breadcrumb-item::before { content: "/"; color: var(--border-strong); padding-inline-end: 0.5rem; }
nav[aria-label="breadcrumb"] { --bs-breadcrumb-divider: "/" !important; }
[dir="rtl"] nav[aria-label="breadcrumb"] { --bs-breadcrumb-divider: "/" !important; }
[dir="rtl"] .breadcrumb { --bs-breadcrumb-divider: "/"; }

.pagination { gap: var(--space-1); }
.page-link, .pagination > a { border-radius: var(--radius-md) !important; min-width: 36px; min-height: 36px; display: inline-flex; align-items: center; justify-content: center; background: transparent; border-color: var(--border); font-family: var(--font-mono); font-size: var(--fs-xs); font-weight: var(--fw-medium); color: var(--text-muted); }
.page-link:hover { background: var(--surface-3); color: var(--text); border-color: var(--border-strong); }
.page-item.active .page-link, .pagination-active, .pagination > a.pagination-active { background: var(--ink-bg); border-color: var(--ink-bg); color: var(--ink-fg); }
.page-item.disabled .page-link { background: transparent; opacity: 0.45; }

.list-group-item { background: transparent; border-color: var(--border); }
.accordion { --bs-accordion-border-radius: var(--radius-lg); --bs-accordion-inner-border-radius: calc(var(--radius-lg) - 1px); }

/* ===================================================================== 11. Progress, empty states, avatars, skeletons */
.progress { border-radius: var(--radius-pill); height: 6px; }
.progress--lg { height: 10px; }
.progress-bar { border-radius: var(--radius-pill); transition: width var(--dur-slow) var(--ease-out); }
.progress--brand { height: 6px; border-radius: var(--radius-pill); }
.progress--brand .progress-bar { background: var(--brand-red); }
.spinner-border { color: var(--brand-red); }

.empty-state {
  position: relative;
  display: flex; flex-direction: column; align-items: center;
  padding: var(--space-10) var(--space-5);
  text-align: center; color: var(--text-muted);
  border: 1px dashed var(--border-strong); border-radius: var(--radius-lg);
  background:
    radial-gradient(var(--grid-dot) 1px, transparent 1.4px) 0 0 / 20px 20px,
    transparent;
}
.empty-state__icon {
  display: inline-grid; place-items: center; inline-size: 52px; block-size: 52px; margin-block-end: var(--space-4);
  border-radius: var(--radius-lg); background: var(--surface); border: 1px solid var(--border-strong);
  color: var(--text-muted); font-size: var(--fs-xl);
  box-shadow: var(--edge), var(--shadow-sm);
}
.empty-state__title { font-size: var(--fs-lg); letter-spacing: var(--tracking-tight); }
.empty-state__text { color: var(--text-muted); }
.empty-state--sm { padding: var(--space-6) var(--space-4); }
.empty-state--sm .empty-state__icon { inline-size: 40px; block-size: 40px; font-size: var(--fs-md); }
.card > .empty-state, .panel > .empty-state, .table-responsive > .empty-state { border: 0; border-radius: 0; }

.avatar { border-radius: var(--radius-md); border: 1px solid var(--border-strong); background: var(--surface-3); }
.avatar img { border-radius: inherit; }
.avatar-md { width: 44px; height: 44px; }
.avatar-lg { width: 88px; height: 88px; border-radius: var(--radius-lg); }
.user-chip .avatar, .avatar.avatar--round { border-radius: 50%; }
.user-chip { border-radius: var(--radius-pill); background: transparent; border-color: var(--border); padding-inline-end: var(--space-3); }
.user-chip:hover { background: var(--surface-3); border-color: var(--border-strong); }
.user-menu { min-width: 17rem; padding: 0; overflow: hidden; }
.user-menu__head { padding: var(--space-4); background: var(--surface-2); border-block-end: 1px solid var(--border); }
.user-menu .dropdown-item { margin: 0; }
.user-menu > .dropdown-item:first-of-type, .user-menu > a.dropdown-item { margin-inline: var(--space-2); }
.user-menu > hr.dropdown-divider { margin: var(--space-2) 0; }

.skeleton { border-radius: var(--radius-md); }
hr { opacity: 1; }
.title-line { display: none; }

/* ===================================================================== 12. Legacy components, re-skinned */
/* Neutral icon tiles instead of tinted chips */
.icon-chip, .stat-card__icon, .kpi__icon, .feed__icon, .person__avatar, .account-chip__avatar {
  background: var(--surface-3); color: var(--text-muted); border: 1px solid var(--border);
}
.stat-card--info .stat-card__icon, .stat-card--success .stat-card__icon, .stat-card--warning .stat-card__icon,
.kpi--success .kpi__icon, .kpi--warning .kpi__icon, .kpi--info .kpi__icon { background: var(--surface-3); color: var(--text-muted); }
.person__avatar { border-radius: var(--radius-md); inline-size: 34px; block-size: 34px; font-family: var(--font-mono); font-weight: var(--fw-medium); color: var(--text); }
.person__name { letter-spacing: -0.005em; }

/* KPI grid → one hairline-divided strip (no separate boxes) */
.kpi-grid {
  gap: 1px; background: var(--border); border: 1px solid var(--border); border-radius: var(--radius-lg); overflow: hidden;
  box-shadow: var(--surface-shadow);
}
.kpi {
  border: 0; border-radius: 0; box-shadow: none; background: var(--surface);
  padding: var(--space-4) var(--space-5);
}
a.kpi:hover { background: var(--surface-2); transform: none; box-shadow: none; }
.kpi__label { font-family: var(--font-label); font-size: var(--fs-2xs); font-weight: var(--fw-medium); letter-spacing: var(--tracking-label); text-transform: uppercase; }
:lang(ar) .kpi__label, [dir="rtl"] .kpi__label { font-family: var(--font-sans); letter-spacing: normal; text-transform: none; font-size: var(--fs-xs); }
.kpi__value { font-size: var(--fs-3xl); font-weight: var(--fw-semibold); letter-spacing: -0.04em; }
.kpi__icon { inline-size: 24px; block-size: 24px; border-radius: var(--radius-sm); }
.kpi--attention { border-inline-start: 0; }
.stat-card { background: transparent; }
.stat-card__value { font-weight: var(--fw-semibold); letter-spacing: -0.04em; }

.summary-card { border-radius: var(--radius-lg); }
.summary-card__figure { font-family: var(--font-mono); font-weight: var(--fw-medium); letter-spacing: -0.03em; }

.feed__item:hover { background: var(--surface-2); }
.feed__icon { border-radius: var(--radius-sm); }

.filter-bar { background: transparent; border: 0; box-shadow: none; padding: 0; margin-block-end: var(--space-4); }
.filter-bar input, .filter-bar select { min-height: 40px; border-radius: var(--radius-md); background: var(--surface); border-color: var(--border-strong); }
[data-bs-theme="dark"] .filter-bar input, [data-bs-theme="dark"] .filter-bar select { background: var(--surface-2); }
.filter-bar > .btn { min-height: 40px; }
.filter-tabs { gap: var(--space-1); }

.post-card { border-block-start-width: 0; border-inline-start: 0; position: relative; }
.post-card--news::before { background: var(--brand-red); }
.post-card--event::before { background: var(--text); }
.program-card { border-block-start-width: 1px; }
.program-card__cover { background: var(--surface-3); color: var(--text-faint); }
.content-row, .mentor-card { border-inline-start-width: 1px; border-inline-start-color: var(--border); border-radius: var(--radius-lg); }
.content-row { position: relative; }
.content-row--archived::before { background: var(--border-strong); }

.alert-body { min-width: 0; }
.section-title, .profile-section__title { letter-spacing: var(--tracking-tight); }
.profile-card__avatar { border-radius: var(--radius-xl); }
.profile-card__head { background: transparent; }

.update-delete a, .update-delete button, .download-btn, .edit-btn { border-radius: var(--radius-md); }
code { background: var(--surface-3); padding: 0.1em 0.4em; border-radius: var(--radius-sm); font-size: 0.9em; }

/* Selection / focus clarity */
.table tr.is-selected > *, .rows__item.is-selected { background: var(--brand-tint) !important; }

/* Links inside data surfaces read as text until hovered (no underline noise) */
.table a:not(.btn):not(.dropdown-item):not(.page-link),
.rows a:not(.btn), .outline a, .person a, a.person__name, .panel a.rows__item, .card a.stretched-link,
li > a.sidebar__link, .tabbar a, .palette a, .filters a { text-decoration: none !important; }
.table a:not(.btn):not(.dropdown-item):hover, a.person__name:hover { color: var(--brand-text); text-decoration: none !important; }
.person__meta { font-family: var(--font-mono); font-size: var(--fs-2xs); letter-spacing: 0.02em; }

/* Phase E: comfortable touch targets and no iOS focus-zoom on phones */
@media (max-width: 767.98px) {
  .form-control, .form-select, .au-input { min-height: var(--touch-target); font-size: max(1rem, 16px); }
  .btn:not(.btn-sm):not(.btn-lg) { min-height: var(--touch-target); }
  .btn-sm { min-height: 36px; }
  .form-check-input { inline-size: 1.25rem; block-size: 1.25rem; }
}
