/* ═══════════════════════════════════════════════════════════════════
   Bilingual & RTL/LTR Alignment Stylesheet (Arabic & English)
   Complete bidirectional layout mirroring, sidebar positioning,
   typography, alignment, and component overrides.
   ═══════════════════════════════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=Cairo:wght@400;500;600;700;800&display=swap');

/* ─── Base Direction & Typography ─── */
html[dir="rtl"],
html[dir="rtl"] body,
body.lang-ar {
  font-family: 'Cairo', 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, sans-serif !important;
  direction: rtl !important;
  text-align: right;
}

html[dir="ltr"],
html[dir="ltr"] body,
body.lang-en {
  direction: ltr !important;
  text-align: left;
}

/* Override any hardcoded direction: rtl in style.css or staff.css when English is selected */
html[dir="ltr"] .servers-section,
html[dir="ltr"] .user-hub-sidebar,
html[dir="ltr"] .staff-page-wrapper,
html[dir="ltr"] .staff-header,
html[dir="ltr"] .staff-stats-grid,
html[dir="ltr"] .staff-tabs-bar,
html[dir="ltr"] .staff-table-card,
html[dir="ltr"] .staff-modal-card {
  direction: ltr !important;
  text-align: left !important;
}

/* ─── Language Switcher UI Pill Component ─── */
.lang-switch-pill {
  display: inline-flex;
  align-items: center;
  background: #0A0A0A;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 9999px;
  padding: 2px;
  gap: 2px;
  user-select: none;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.5);
  vertical-align: middle;
  flex-shrink: 0;
}

.lang-pill-opt {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  color: rgba(255, 255, 255, 0.65);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.4px;
  padding: 4px 10px;
  border-radius: 9999px;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  font-family: 'Cairo', 'Plus Jakarta Sans', sans-serif;
  line-height: 1.2;
}

.lang-pill-opt:hover {
  color: #FFFFFF;
  background: rgba(255, 255, 255, 0.1);
}

.lang-pill-opt.active {
  background: #FFFFFF;
  color: #000000;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.45);
}

/* Compact version inside narrow rail */
.far-left-rail .lang-switch-pill {
  flex-direction: column;
  border-radius: 12px;
  padding: 3px;
  width: 48px;
}

.far-left-rail .lang-pill-opt {
  width: 100%;
  padding: 4px 0;
  font-size: 10px;
  border-radius: 8px;
}

/* Floating Language Pill for standalone pages & login */
.lang-switch-floating {
  position: fixed;
  top: 22px;
  right: 90px;
  z-index: 999;
}

html[dir="rtl"] .lang-switch-floating {
  right: auto;
  left: 90px;
}

/* ─── 1. SELECT-SERVER-AND-WELCOME.HTML RTL / LTR MIRRORING ─── */
html[dir="rtl"] .far-left-rail {
  left: auto !important;
  right: 0 !important;
  border-right: none !important;
  border-left: 1px solid var(--border-subtle, rgba(255, 255, 255, 0.08)) !important;
  box-shadow: -4px 0 24px rgba(0, 0, 0, 0.4) !important;
}

html[dir="rtl"] .rail-server-pill {
  left: auto !important;
  right: -12px !important;
  border-radius: 4px 0 0 4px !important;
}

html[dir="rtl"] [data-tooltip]::after {
  left: auto !important;
  right: 68px !important;
}

html[dir="rtl"] .user-profile-sidebar {
  left: auto !important;
  right: var(--rail-width, 72px) !important;
  border-right: none !important;
  border-left: 1px solid var(--border-subtle, rgba(255, 255, 255, 0.08)) !important;
  transform: translateX(100%);
  box-shadow: -14px 0 40px rgba(0, 0, 0, 0.5) !important;
}

html[dir="rtl"] .user-profile-sidebar.open {
  transform: translateX(0) !important;
}

html[dir="rtl"] .far-left-rail ~ .main-viewport {
  margin-left: 0 !important;
  margin-right: var(--rail-width, 72px) !important;
}

html[dir="rtl"] body.sidebar-open-shift .far-left-rail ~ .main-viewport {
  margin-left: 0 !important;
  margin-right: calc(var(--rail-width, 72px) + var(--sidebar-width, 290px)) !important;
}

html[dir="rtl"] .sidebar-tab-btn .tab-arrow {
  transform: rotate(180deg) !important;
}

html[dir="rtl"] .sidebar-tab-btn:hover {
  transform: translateX(-2px) !important;
}

html[dir="rtl"] .sidebar-tab-btn:hover .tab-arrow {
  transform: rotate(180deg) translateX(3px) !important;
}

/* ─── 2. SERVER.HTML SIDEBAR & MAIN VIEWPORT MIRRORING ─── */
html[dir="rtl"] .server-sidebar {
  left: auto !important;
  right: 0 !important;
  border-right: none !important;
  border-left: 1px solid var(--border-dark, rgba(255, 255, 255, 0.08)) !important;
  box-shadow: -4px 0 24px rgba(0, 0, 0, 0.35) !important;
}

html[dir="rtl"] .server-sidebar ~ .main-viewport {
  margin-left: 0 !important;
  margin-right: var(--sidebar-width, 280px) !important;
}

html[dir="rtl"] .nav-item-link.active {
  background: linear-gradient(270deg, rgba(255, 255, 255, 0.14), rgba(255, 255, 255, 0.03)) !important;
  box-shadow: inset -3px 0 0 #FFFFFF !important;
}

html[dir="rtl"] .btn-back-home i.fa-arrow-left {
  transform: rotate(180deg);
}

/* ─── 3. INDEX.HTML SPA DASHBOARD MIRRORING ─── */
html[dir="rtl"] .server-list-container {
  border-right: none !important;
  border-left: 1px solid var(--border, rgba(255, 255, 255, 0.08)) !important;
}

html[dir="rtl"] .server-icon-wrap::before {
  left: auto !important;
  right: -10px !important;
  border-radius: 4px 0 0 4px !important;
}

html[dir="rtl"] .server-icon-tooltip {
  left: auto !important;
  right: 80px !important;
}

html[dir="rtl"] .user-dropdown {
  left: auto !important;
  right: 84px !important;
}

html[dir="rtl"] .nav-sidebar {
  border-right: none !important;
  border-left: 1px solid var(--border, rgba(255, 255, 255, 0.08)) !important;
}

html[dir="rtl"] .nav-section-title,
html[dir="rtl"] .nav-section-label {
  padding-left: 0 !important;
  padding-right: 12px !important;
  text-align: right !important;
}

html[dir="rtl"] .module-status,
html[dir="rtl"] .sidebar-coming-soon-badge {
  margin-left: 0 !important;
  margin-right: auto !important;
}

/* ─── 4. SUBPAGE HEADERS, CARDS, FORMS & TABLES ─── */
html[dir="rtl"] .view-header,
html[dir="rtl"] .view-header-title-group,
html[dir="rtl"] .botprofile-panel-head,
html[dir="rtl"] .settings-panel-head,
html[dir="rtl"] .overview-welcome-hero,
html[dir="rtl"] .hero-left-content {
  text-align: right;
}

html[dir="ltr"] .view-header,
html[dir="ltr"] .view-header-title-group,
html[dir="ltr"] .botprofile-panel-head,
html[dir="ltr"] .settings-panel-head,
html[dir="ltr"] .overview-welcome-hero,
html[dir="ltr"] .hero-left-content {
  text-align: left;
}

html[dir="rtl"] input:not([type="url"]):not([id="settings-bot-prefix"]),
html[dir="rtl"] textarea,
html[dir="rtl"] select {
  text-align: right;
  direction: rtl;
}

html[dir="ltr"] input:not([id="settings-bot-prefix"]),
html[dir="ltr"] textarea,
html[dir="ltr"] select {
  text-align: left;
  direction: ltr;
}

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

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

/* Directional arrows inside buttons */
html[dir="rtl"] .fa-arrow-left,
html[dir="rtl"] .fa-chevron-left,
html[dir="rtl"] .fa-angle-left {
  transform: scaleX(-1);
}

html[dir="rtl"] .fa-arrow-right,
html[dir="rtl"] .fa-chevron-right,
html[dir="rtl"] .fa-angle-right {
  transform: scaleX(-1);
}

/* Mobile responsive adjustments for RTL */
@media (max-width: 900px) {
  html[dir="rtl"] .server-sidebar {
    transform: translateX(100%) !important;
  }

  html[dir="rtl"] .server-sidebar.mobile-open {
    transform: translateX(0) !important;
  }

  html[dir="rtl"] .server-sidebar ~ .main-viewport,
  html[dir="rtl"] .far-left-rail ~ .main-viewport,
  html[dir="rtl"] body.sidebar-open-shift .far-left-rail ~ .main-viewport {
    margin-right: 0 !important;
  }

  html[dir="rtl"] .nav-sidebar {
    left: auto !important;
    right: 0 !important;
    transform: translateX(100%);
  }

  html[dir="rtl"] .nav-sidebar.mobile-open {
    transform: translateX(0);
  }
}
