/* OmniCalcs - RTL / Arabic overrides. Loaded after styles.css on pages with <html dir="rtl">. */
html[dir="rtl"] body {
  font-family: "Segoe UI", Tahoma, "Noto Sans Arabic", "Noto Naskh Arabic", Arial, sans-serif;
  line-height: 1.8;
}

/* Header */
html[dir="rtl"] .nav-toggle { margin-left: 0; margin-right: auto; }
html[dir="rtl"] .search-form { margin-left: 0; margin-right: auto; }
html[dir="rtl"] .nav-item:first-child .dropdown { left: auto; right: 0; }
html[dir="rtl"] .nav-item:last-child .dropdown { left: 0; right: auto; }
html[dir="rtl"] .nav-link .caret { margin-right: 4px; margin-left: 0; }
html[dir="rtl"] .nav-link { text-decoration: none; }
html[dir="rtl"] .lang-switch { font-family: var(--font); direction: ltr; }

/* Text alignment inside components */
html[dir="rtl"] .result-row .v { text-align: left; }
html[dir="rtl"] table.data th, html[dir="rtl"] table.data td { text-align: right; }
html[dir="rtl"] .prose ul, html[dir="rtl"] .prose ol { padding-left: 0; padding-right: 1.2em; }
html[dir="rtl"] .tool-card .tc-badge { float: left; }
html[dir="rtl"] .fcount { text-align: left; }
html[dir="rtl"] .breadcrumb .sep { display: inline-block; }
html[dir="rtl"] .hero-actions { justify-content: flex-start; }

/* Numbers and formulas stay left-to-right inside RTL text */
html[dir="rtl"] .num, html[dir="rtl"] .result-value,
html[dir="rtl"] input[type="number"] { direction: ltr; unicode-bidi: plaintext; }
html[dir="rtl"] input[type="number"] { text-align: right; }
html[dir="rtl"] .formula-box { direction: rtl; text-align: right; font-family: "Segoe UI", Tahoma, Arial, sans-serif; line-height: 1.9; }

/* Footer and cookie bar */
html[dir="rtl"] .site-footer a { text-align: right; }
html[dir="rtl"] .footer-bottom { flex-direction: row; }

/* Arabic needs slightly more air for headings */
html[dir="rtl"] h1, html[dir="rtl"] h2, html[dir="rtl"] h3 { line-height: 1.45; letter-spacing: 0; }
html[dir="rtl"] .page-head h1 { letter-spacing: 0; }
html[dir="rtl"] .hero h1 { letter-spacing: 0; }

/* Bracket table helper */
html[dir="rtl"] .brk-table td:nth-child(n+2), html[dir="rtl"] .brk-table th:nth-child(n+2) { white-space: nowrap; }
.scroll-x { overflow-x: auto; }

/* Mobile: tool layout (inline 2-column grid) collapses to one column */
@media (max-width: 820px) {
  html[dir="rtl"] .grid[style*="grid-template-columns"] { grid-template-columns: minmax(0, 1fr) !important; }
  html[dir="rtl"] .grid > * { min-width: 0; }
}
