/* =========================================================
   Al-Burhan RTL Overrides
   Applied when dir="rtl" (Arabic / Urdu)
   ========================================================= */

[dir="rtl"] body { font-family: 'Noto Naskh Arabic', 'Traditional Arabic', 'Arial', sans-serif; }
[dir="rtl"][lang="ur"] body {
  font-family: 'Noto Nastaliq Urdu', 'Urdu Typesetting', 'Arial', sans-serif;
  line-height: 2.2;  /* Nastaliq glyphs are much taller than Latin/Arabic — prevent clipping */
}
[dir="rtl"][lang="ur"] h1,
[dir="rtl"][lang="ur"] h2,
[dir="rtl"][lang="ur"] h3,
[dir="rtl"][lang="ur"] h4,
[dir="rtl"][lang="ur"] h5,
[dir="rtl"][lang="ur"] h6 { line-height: 2; }
[dir="rtl"][lang="ur"] .btn { line-height: 1.5; }
[dir="rtl"][lang="ur"] .badge { line-height: 1.5; }

/* Bootstrap overrides */
[dir="rtl"] .navbar { flex-direction: row-reverse; }
[dir="rtl"] .me-auto { margin-right: 0 !important; margin-left: auto !important; }
[dir="rtl"] .ms-auto { margin-left: 0 !important; margin-right: auto !important; }
[dir="rtl"] .me-1 { margin-right: 0 !important; margin-left: 0.25rem !important; }
[dir="rtl"] .me-2 { margin-right: 0 !important; margin-left: 0.5rem !important; }
[dir="rtl"] .me-3 { margin-right: 0 !important; margin-left: 1rem !important; }
[dir="rtl"] .me-4 { margin-right: 0 !important; margin-left: 1.5rem !important; }
[dir="rtl"] .ms-1 { margin-left: 0 !important; margin-right: 0.25rem !important; }
[dir="rtl"] .ms-2 { margin-left: 0 !important; margin-right: 0.5rem !important; }
[dir="rtl"] .ms-3 { margin-left: 0 !important; margin-right: 1rem !important; }
[dir="rtl"] .ms-4 { margin-left: 0 !important; margin-right: 1.5rem !important; }
[dir="rtl"] .ps-0 { padding-left: 0 !important; padding-right: 0 !important; }
[dir="rtl"] .pe-0 { padding-right: 0 !important; padding-left: 0 !important; }
[dir="rtl"] .ps-3 { padding-left: 0 !important; padding-right: 1rem !important; }
[dir="rtl"] .pe-3 { padding-right: 0 !important; padding-left: 1rem !important; }

/* Input alignment */
[dir="rtl"] input[type="text"],
[dir="rtl"] input[type="email"],
[dir="rtl"] input[type="tel"],
[dir="rtl"] input[type="number"],
[dir="rtl"] textarea,
[dir="rtl"] select {
  text-align: right;
}

/* Breadcrumb */
[dir="rtl"] .breadcrumb-item + .breadcrumb-item::before {
  float: right;
  padding-right: 0;
  padding-left: 0.5rem;
  content: "\\";
}

/* Lists */
[dir="rtl"] ul:not(.navbar-nav):not(.nav):not(.list-unstyled) { padding-right: 1.25rem; padding-left: 0; }

/* Card */
[dir="rtl"] .card-footer { text-align: right; }

/* Close button */
[dir="rtl"] .btn-close { margin: auto auto auto 0; }

/* Modal */
[dir="rtl"] .modal-header .btn-close { margin-right: auto; margin-left: 0; }

/* Form check */
[dir="rtl"] .form-check { padding-right: 1.5rem; padding-left: 0; }
[dir="rtl"] .form-check-input { float: right; margin-right: -1.5rem; margin-left: 0; }

/* Table */
[dir="rtl"] .table > thead > tr > th,
[dir="rtl"] .table > tbody > tr > td { text-align: right; }

/* Flex */
[dir="rtl"] .flex-row         { flex-direction: row-reverse !important; }
[dir="rtl"] .justify-content-start { justify-content: flex-end !important; }
[dir="rtl"] .justify-content-end   { justify-content: flex-start !important; }

/* Text */
[dir="rtl"] .text-start { text-align: right !important; }
[dir="rtl"] .text-end   { text-align: left !important; }

/* Dropdown */
[dir="rtl"] .dropdown-menu-end { right: 0 !important; left: auto !important; }
[dir="rtl"] .dropdown-menu     { text-align: right; }

/* Accordion */
[dir="rtl"] .accordion-button::after { margin-left: 0; margin-right: auto; }

/* Pagination */
[dir="rtl"] .page-item:first-child .page-link { border-radius: 0 0.375rem 0.375rem 0; }
[dir="rtl"] .page-item:last-child  .page-link { border-radius: 0.375rem 0 0 0.375rem; }

/* Al-Burhan specific RTL */
[dir="rtl"] .ab-dropdown-menu { left: auto; right: 0; }
[dir="rtl"] .footer-links a:hover { padding-left: 0; padding-right: 4px; }
[dir="rtl"] .course-card-track { left: auto; right: 1rem; }
[dir="rtl"] .course-card-free  { right: auto; left: 1rem; }
[dir="rtl"] .majalis-card { border-left: none; border-right: 4px solid var(--secondary); }
[dir="rtl"] .majalis-card:hover { transform: translateX(-4px); }
[dir="rtl"] .podcast-card:hover { transform: translateX(-4px); }
[dir="rtl"] .back-to-top { right: auto; left: 2rem; }
[dir="rtl"] .hero-controls { right: auto; left: 2rem; }
[dir="rtl"] .hero-prev { left: auto; right: 1.5rem; }
[dir="rtl"] .hero-next { right: auto; left: 1.5rem; }
[dir="rtl"] .news-ticker-label { border-radius: var(--radius-full) 0 0 var(--radius-full); }
[dir="rtl"] .sidebar-link.active::before { left: auto; right: 0; border-radius: 3px 0 0 3px; }
[dir="rtl"] .sidebar-badge { margin-left: unset; margin-right: auto; }
[dir="rtl"] .admin-main { margin-left: 0; margin-right: var(--admin-sidebar-width); }
[dir="rtl"] .admin-sidebar { left: auto; right: 0; transform: translateX(100%); }
[dir="rtl"] .admin-sidebar.open { transform: translateX(0); }
/* Buttons: make inline-flex so RTL flex direction puts icon on correct side of text */
[dir="rtl"] .btn {
  display: inline-flex;
  align-items: center;
  flex-direction: row;
}

/* Alerts: flip border side + make flex so icon gap is direction-correct */
[dir="rtl"] .alert {
  border-left: none;
  border-right: 4px solid;
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
}
[dir="rtl"] .alert > i.bi { flex-shrink: 0; margin-right: 0 !important; margin-left: 0 !important; }

/* Headings and spans with leading icons: keep gap between icon and RTL text */
[dir="rtl"] h1 > i.bi,
[dir="rtl"] h2 > i.bi,
[dir="rtl"] h3 > i.bi,
[dir="rtl"] h4 > i.bi,
[dir="rtl"] h5 > i.bi,
[dir="rtl"] h6 > i.bi,
[dir="rtl"] span > i.bi:first-child {
  margin-right: 0 !important;
  margin-left: 0.5rem !important;
}

/* Hardcoded directional margins not covered by me-*/ms-* flips */
[dir="rtl"] .news-card-meta i { margin-right: 0; margin-left: 0.2rem; }
[dir="rtl"] .price-usd { margin-left: 0; margin-right: 0.25rem; }

/* Icon vertical-align is handled globally in app.css via Latin font on <i> elements */

/* Directional icon flips */
[dir="rtl"] .bi-arrow-right::before   { content: "\f12f"; } /* bi-arrow-left glyph */
[dir="rtl"] .bi-arrow-left::before    { content: "\f138"; } /* bi-arrow-right glyph */
[dir="rtl"] .bi-chevron-right::before { content: "\f284"; } /* bi-chevron-left glyph */
[dir="rtl"] .bi-chevron-left::before  { content: "\f285"; } /* bi-chevron-right glyph */

/* Contact info card — flip border side */
[dir="rtl"] .contact-info-card { border-left: none; border-right: 4px solid var(--primary); }

/* Donation receipt — reset hardcoded text-align */
[dir="rtl"] .donation-receipt { text-align: right; }

/* News article blockquote — flip border + padding */
[dir="rtl"] .article-content blockquote { border-left: none; border-right: 4px solid var(--secondary); padding-left: 0; padding-right: 1.25rem; }

/* ── Input groups: mirror for RTL ───────────────────────── */
[dir="rtl"] .input-group { flex-direction: row-reverse; }
[dir="rtl"] .input-group > *:first-child {
  border-radius: 0 0.375rem 0.375rem 0 !important;
}
[dir="rtl"] .input-group > *:last-child {
  border-radius: 0.375rem 0 0 0.375rem !important;
}
/* Middle elements (three+ item groups) */
[dir="rtl"] .input-group > *:not(:first-child):not(:last-child) {
  border-radius: 0 !important;
}
/* Adjust negative margin direction so borders collapse correctly */
[dir="rtl"] .input-group > *:not(:first-child) {
  margin-left: 0;
  margin-right: -1px;
}

/* ── Zakat Calculator RTL label fixes ───────────────────── */
[dir="rtl"] .zakat-input-group label {
  text-align: right;
  letter-spacing: 0;
}

/* ── course-card-desc: Urdu Nastaliq clamp fix ──────────── */
[dir="rtl"][lang="ur"] .course-card-desc {
  line-height: 2 !important;
  -webkit-line-clamp: 4 !important;
}

/* ── majalis-city-select: Urdu text bottom-clip fix ─────── */
[dir="rtl"][lang="ur"] .majalis-city-select,
[dir="rtl"][lang="ur"] select.form-select,
[dir="rtl"][lang="ur"] select.form-control {
  height: auto !important;
  min-height: 44px !important;
  padding-top: 0.65rem !important;
  padding-bottom: 0.65rem !important;
  line-height: 2 !important;
}
