/*
 * Direction-safe shared UI rules.
 *
 * Components keep their normal LTR presentation by default.  When the root
 * document has dir="rtl", logical properties mirror chrome and content
 * without changing record values or identifiers.
 */

html[dir="rtl"] body { direction: rtl; }

/* Navigation and common shell details that pre-date the contextual rail. */
html[dir] .nav-item { text-align: start; }
html[dir] .nav-item .count {
  margin-left: 0;
  margin-right: 0;
  margin-inline-start: auto;
}
html[dir] .online-dot {
  margin-left: 0;
  margin-right: 0;
  margin-inline-end: 7px;
}

.notification-dot {
  left: auto;
  right: auto;
  inset-inline-end: 7px;
}
.avatar {
  border-left: 0;
  border-right: 0;
  padding-left: 0;
  padding-right: 0;
  border-inline-start: 1px solid var(--line);
  padding-inline-start: 14px;
}
.role-select {
  padding: 9px 11px;
  padding-inline-end: 28px;
}

/* Direction-aware data tables and form framing. */
html[dir] .table { direction: inherit; }
html[dir] .table th,
html[dir] .formulator-table th { text-align: start; }
html[dir] .field,
html[dir] .modal-head,
html[dir] .modal-body,
html[dir] .modal-footer,
html[dir] .management-directory-head,
html[dir] .inventory-directory-head,
html[dir] .finance-workflow-note,
html[dir] .purchase-receipt-note,
html[dir] .formulator-component-head { text-align: start; }

/* Numeric, date, and contact entry remains stable in mixed Arabic/English UI. */
html[dir="rtl"] input[type="number"],
html[dir="rtl"] input[type="date"],
html[dir="rtl"] input[type="email"],
html[dir="rtl"] input[type="tel"],
html[dir="rtl"] .global-launcher kbd {
  direction: ltr;
  text-align: start;
  unicode-bidi: isolate;
}

/* Existing physical separators and markers, expressed in inline direction. */
.finance-summary > div {
  border-right: 0;
  padding-right: 0;
  border-inline-end: 1px solid var(--line);
  padding-inline-end: 12px;
}
.finance-summary > div:last-child { border-inline-end: 0; }
.timeline {
  margin-left: 0;
  margin-right: 0;
  margin-inline-start: 6px;
}
.timeline::before {
  left: auto;
  right: auto;
  inset-inline-start: 4px;
}
.timeline-row {
  padding-left: 0;
  padding-right: 0;
  padding-inline-start: 21px;
}
.timeline-row::before {
  left: auto;
  right: auto;
  inset-inline-start: 0;
}
.toast {
  left: auto;
  right: auto;
  inset-inline-end: 22px;
}

.switch input::before {
  left: auto;
  right: auto;
  inset-inline-start: 3px;
}
html[dir="rtl"] .switch input:checked::before { transform: translateX(-16px); }

/* Progress fills originate at the logical start of an RTL row. */
html[dir="rtl"] .progress i,
html[dir="rtl"] .capacity-meter i { margin-inline-end: auto; }

/* Component-specific layout corrections not covered by the base stylesheet. */
html[dir] .user-section-heading p,
html[dir] .analysis-record .analysis-values { text-align: end; }
html[dir] .context-link,
html[dir] .page-finder-card { text-align: start; }
html[dir] .context-link small { margin-inline-start: auto; }

@media (max-width: 800px) {
  /* The generic legacy drawer must hide and reveal from the correct edge. */
  html[dir="rtl"] .sidebar {
    left: auto;
    right: 0;
    transform: translateX(100%);
    box-shadow: -10px 0 30px #0003;
  }
  html[dir="rtl"] .sidebar.open { transform: none; }

  .finance-summary > div {
    border-inline-end: 0;
    padding-inline-end: 0;
  }
  html[dir] .user-section-heading p { text-align: start; }
}

@media (max-width: 560px) {
  html[dir] .modal-head,
  html[dir] .modal-body,
  html[dir] .modal-footer { text-align: start; }
}

@media (max-width: 600px) {
  html[dir] .analysis-record .analysis-values { text-align: start; }
}
