/* =====================================================
   GILBATECH RTL OVERRIDES v1.2
   Purpose:
   - Enable Right-to-Left layout (Arabic)
   - Preserve institutional design integrity
   - No color, spacing, or branding changes
   - Long-term safe & predictable
===================================================== */

/* =====================================================
   1. GLOBAL DIRECTION
===================================================== */
html[dir="rtl"] {
  direction: rtl;
}

html[dir="rtl"] body {
  text-align: right;
}

/* =====================================================
   2. TEXT & TYPOGRAPHY
===================================================== */
html[dir="rtl"] h1,
html[dir="rtl"] h2,
html[dir="rtl"] h3,
html[dir="rtl"] h4,
html[dir="rtl"] h5,
html[dir="rtl"] h6,
html[dir="rtl"] p,
html[dir="rtl"] li,
html[dir="rtl"] label,
html[dir="rtl"] legend {
  text-align: right;
}

/* Preserve LTR readability for technical content */
html[dir="rtl"] code,
html[dir="rtl"] pre,
html[dir="rtl"] kbd,
html[dir="rtl"] samp,
html[dir="rtl"] input[type="email"],
html[dir="rtl"] input[type="text"],
html[dir="rtl"] input[type="number"],
html[dir="rtl"] .ltr,
html[dir="rtl"] .force-ltr {
  direction: ltr;
  unicode-bidi: isolate;
  text-align: left;
}

/* =====================================================
   3. NAVIGATION
===================================================== */
html[dir="rtl"] .site-header,
html[dir="rtl"] nav,
html[dir="rtl"] .nav-container {
  direction: rtl;
}

/* Horizontal nav spacing mirroring */
html[dir="rtl"] nav a {
  margin-left: 0;
  margin-right: 1.5rem;
}

html[dir="rtl"] nav a:first-child {
  margin-right: 0;
}

/* =====================================================
   4. FLEX & GRID MIRRORING
===================================================== */
/* Explicit containers only — no global flex override */
html[dir="rtl"] .row,
html[dir="rtl"] .flex-row,
html[dir="rtl"] .card-row {
  flex-direction: row-reverse;
}

/* Allow opt-out when logical order matters */
html[dir="rtl"] .no-rtl {
  direction: ltr;
}

html[dir="rtl"] .no-rtl.flex-row {
  flex-direction: row;
}

/* =====================================================
   5. ICONS & DIRECTIONAL ELEMENTS
===================================================== */
/* Spacing correction for inline icons */
html[dir="rtl"] .icon {
  margin-left: 0.5rem;
  margin-right: 0;
}

/* Directional icon mirroring */
html[dir="rtl"] .icon-arrow,
html[dir="rtl"] .icon-chevron,
html[dir="rtl"] .icon-directional,
html[dir="rtl"] svg.icon-directional {
  transform: scaleX(-1);
}

/* Prevent mirroring when not desired */
html[dir="rtl"] .no-mirror {
  transform: none !important;
}

/* =====================================================
   6. FORMS
===================================================== */
html[dir="rtl"] input,
html[dir="rtl"] textarea,
html[dir="rtl"] select {
  text-align: right;
}

html[dir="rtl"] input::placeholder,
html[dir="rtl"] textarea::placeholder {
  text-align: right;
}

/* Buttons remain centered */
html[dir="rtl"] button {
  text-align: center;
}

/* =====================================================
   7. LISTS
===================================================== */
html[dir="rtl"] ul,
html[dir="rtl"] ol {
  padding-right: 1.25rem;
  padding-left: 0;
}

/* =====================================================
   8. TABLES
===================================================== */
html[dir="rtl"] table {
  direction: rtl;
}

html[dir="rtl"] th,
html[dir="rtl"] td {
  text-align: right;
}

/* =====================================================
   9. FOOTER
===================================================== */
html[dir="rtl"] footer {
  direction: rtl;
  text-align: right;
}

/* =====================================================
   10. ACCESSIBILITY & UTILITIES
===================================================== */
/* Skip-link positioning */
html[dir="rtl"] .skip-link {
  left: auto;
  right: 1rem;
}

/* Ensure focus outline is not clipped */
html[dir="rtl"] *:focus-visible {
  outline-offset: 3px;
}
