/* ==========================================================================
   Engineers Academy — Internationalization & RTL Stylesheet (i18n & RTL)
   Supports seamless English (LTR) and Arabic (RTL) localization.
   ========================================================================== */

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

/* --- Language Switcher Component --- */
.lang-switch-wrap {
  display: inline-flex;
  align-items: center;
  background: rgba(23, 25, 27, 0.88);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 999px;
  padding: 3px 4px;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.3);
  gap: 2px;
  user-select: none;
  vertical-align: middle;
}

.lang-switch-wrap .lang-opt-btn {
  background: transparent;
  border: none;
  color: var(--muted, #a4a8ab);
  font-family: inherit;
  font-size: 0.78rem;
  font-weight: 500;
  padding: 5px 12px;
  border-radius: 999px;
  cursor: pointer;
  transition: all 0.22s cubic-bezier(0.2, 0.7, 0.2, 1);
  line-height: 1.25;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  outline: none;
}

.lang-switch-wrap .lang-opt-btn:hover {
  color: var(--teal, #7dded0);
}

.lang-switch-wrap .lang-opt-btn.active {
  background: var(--teal, #7dded0);
  color: var(--teal-ink, #0f2622);
  font-weight: 600;
  box-shadow: 0 2px 10px rgba(125, 222, 208, 0.35);
}

.lang-switch-wrap .lang-divider {
  color: rgba(255, 255, 255, 0.2);
  font-size: 0.72rem;
  line-height: 1;
  pointer-events: none;
}

/* Fixed Top Controls Bar (Desktop) */
.site-top-controls {
  position: fixed;
  top: 24px;
  right: 34px;
  z-index: 85;
  display: flex;
  align-items: center;
  gap: 16px;
  transition: right 0.25s ease, left 0.25s ease;
}

.site-top-controls .site-account {
  position: static !important;
  top: auto !important;
  right: auto !important;
  left: auto !important;
  z-index: auto !important;
  display: flex;
  align-items: center;
}

html[dir="rtl"] .site-top-controls {
  right: auto;
  left: 34px;
}

/* Sidebar language switcher box */
.sidebar-lang-box {
  margin-top: auto;
  padding-top: 14px;
  padding-bottom: 12px;
  border-top: 1px solid var(--line, rgba(255,255,255,.09));
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.sidebar-lang-box .lang-title {
  font-size: 0.76rem;
  color: var(--muted, #a4a8ab);
  display: flex;
  align-items: center;
  gap: 6px;
  letter-spacing: 0.03em;
}

.sidebar-lang-box .lang-title svg {
  width: 14px;
  height: 14px;
  stroke: var(--teal, #7dded0);
  fill: none;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.sidebar-lang-box .lang-switch-wrap {
  transform: scale(0.92);
  transform-origin: right center;
}

/* Mobile header language switcher */
.mobile-header-lang {
  display: flex;
  align-items: center;
  margin-inline-start: auto;
  margin-inline-end: 8px;
  z-index: 92;
  flex-shrink: 0;
}

.mobile-header-lang .lang-switch-wrap {
  transform: scale(0.82);
  transform-origin: center center;
}

/* Mobile menu language switcher */
.mobile-menu-lang {
  margin-top: 20px;
  padding-top: 18px;
  border-top: 1px solid var(--line, rgba(255,255,255,.09));
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.mobile-menu-lang span {
  color: var(--muted, #a4a8ab);
  font-size: 0.95rem;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Auth pages floating switcher */
.auth-lang-corner {
  position: fixed;
  top: 24px;
  right: 28px;
  z-index: 99;
}

html[dir="rtl"] .auth-lang-corner {
  right: auto;
  left: 28px;
}

/* ==========================================================================
   RTL Styles for Arabic (html[dir="rtl"] and html.lang-ar)
   ========================================================================== */

html[dir="rtl"] {
  direction: rtl;
  --font: "Cairo", "Poppins", system-ui, -apple-system, sans-serif;
}

html[dir="rtl"] body {
  direction: rtl;
  text-align: right;
  font-family: var(--font);
}

/* --- Layout & Sidebar --- */
html[dir="rtl"] .sidebar {
  inset: 0 0 0 auto;
  border-right: none;
  border-left: 1px solid var(--line, rgba(255,255,255,.09));
}

html[dir="rtl"] .page-main {
  margin-left: 0;
  margin-right: var(--sidebar, 230px);
}

html[dir="rtl"] .footer {
  margin-left: 0;
  margin-right: var(--sidebar, 230px);
}

html[dir="rtl"] .side-nav {
  padding-right: 0;
  padding-left: 3px;
}

html[dir="rtl"] .side-nav a {
  text-align: right;
}

html[dir="rtl"] .side-nav a::before {
  left: auto;
  right: -22px;
}

html[dir="rtl"] .sidebar-contact-link,
html[dir="rtl"] .sidebar-account-link {
  text-align: right;
}

html[dir="rtl"] .sidebar-lang-box .lang-switch-wrap {
  transform-origin: left center;
}

/* --- Typography & Headings in Arabic --- */
html[dir="rtl"] h1,
html[dir="rtl"] h2,
html[dir="rtl"] h3,
html[dir="rtl"] h4 {
  font-family: "Cairo", system-ui, -apple-system, sans-serif;
  letter-spacing: normal;
}

html[dir="rtl"] .eyebrow {
  letter-spacing: 0.08em;
}

/* --- Hero Section in Arabic --- */
html[dir="rtl"] .hero svg {
  right: auto;
  left: max(3vw, 0px);
  transform: scaleX(-1);
}

html[dir="rtl"] .hero::after {
  background: linear-gradient(270deg, rgba(28,29,31,.90) 0%, rgba(28,29,31,.50) 55%, rgba(28,29,31,.12) 100%),
              linear-gradient(0deg, var(--bg) 0%, transparent 30%);
}

html[dir="rtl"] .hero-content {
  text-align: right;
}

html[dir="rtl"] .hero h1 {
  max-width: 17ch;
}

/* --- About Strip (3 columns) --- */
html[dir="rtl"] .about-strip>div {
  border-right: 0;
  border-left: 1px solid var(--line);
  padding: 28px 0 32px 30px;
}

html[dir="rtl"] .about-strip>div+div {
  padding-left: 0;
  padding-right: 30px;
}

html[dir="rtl"] .about-strip>div:last-child {
  border-left: 0;
}

/* --- Section Links (Explore grid) --- */
html[dir="rtl"] .section-links a {
  border-right: 0;
  border-left: 1px solid var(--line);
  padding: 24px 0 20px 18px;
  text-align: right;
}

html[dir="rtl"] .section-links a:first-child {
  padding-right: 0;
}

html[dir="rtl"] .section-links a:last-child {
  border-left: 0;
}

html[dir="rtl"] .section-links a:hover {
  padding-left: 0;
  padding-right: 10px;
}

/* --- Plain list --- */
html[dir="rtl"] .plain-list>div {
  border-right: 0;
  border-left: 1px solid var(--line);
  padding: 25px 0 20px 25px;
}

html[dir="rtl"] .plain-list>div:last-child {
  border-left: 0;
}

/* --- Contact & Footer --- */
html[dir="rtl"] .contact-grid .contact-item {
  border-right: 0;
  border-left: 1px solid var(--line);
  padding: 26px 0 28px 28px;
}

html[dir="rtl"] .contact-grid .contact-item:last-child {
  border-left: 0;
  padding-left: 0;
  padding-right: 28px;
}

html[dir="rtl"] .contact-details a {
  border-right: 0;
  border-left: 1px solid var(--line);
  padding: 34px 0 34px 30px;
}

html[dir="rtl"] .contact-details a:last-child {
  border-left: 0;
  padding-left: 0;
  padding-right: 30px;
}

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

html[dir="rtl"] .footer-brand-name {
  margin-right: 0;
  margin-left: auto;
}

/* --- Academic Zone Clean --- */
html[dir="rtl"] .academic-zone-clean .lead,
html[dir="rtl"] .academic-zone-description {
  text-align: right !important;
  margin-left: 0 !important;
  margin-right: 0 !important;
}

/* --- Certifications Page --- */
html[dir="rtl"] .cert-lookup-clean {
  text-align: right;
}

html[dir="rtl"] .cert-lookup-form input {
  text-align: right;
}

html[dir="rtl"] .certificate-result-grid > div {
  text-align: right;
}

/* --- Our Team & Academic Trainers --- */
html[dir="rtl"] .team-heading,
html[dir="rtl"] .trainers-heading {
  text-align: right;
}

html[dir="rtl"] .team-card-body,
html[dir="rtl"] .trainer-body {
  text-align: right;
}

html[dir="rtl"] .trainers-admin-toolbar,
html[dir="rtl"] .team-admin-toolbar {
  justify-content: flex-start;
}

/* --- Courses & Workshops Page --- */
html[dir="rtl"] .program-card-body {
  text-align: right;
}

html[dir="rtl"] .program-card-meta {
  justify-content: flex-start;
}

html[dir="rtl"] .program-card-badges {
  left: auto;
  right: 14px;
}

html[dir="rtl"] .program-empty-state {
  text-align: right;
}

html[dir="rtl"] .course-back-btn {
  text-align: right;
}

html[dir="rtl"] .course-back-btn svg {
  transform: rotate(180deg);
}

html[dir="rtl"] .detail-price-wrap {
  text-align: right;
}

html[dir="rtl"] .detail-instructor-card {
  text-align: right;
}

/* --- Engineering Library (Knowledge) --- */
html[dir="rtl"] .knowledge-head {
  text-align: right;
}

html[dir="rtl"] .knowledge-category {
  text-align: right;
}

html[dir="rtl"] .knowledge-back-btn span {
  display: inline-block;
  transform: rotate(180deg);
}

/* --- Modals and Form Dialogs --- */
html[dir="rtl"] .team-modal-card,
html[dir="rtl"] .trainer-modal-card,
html[dir="rtl"] .program-modal-card,
html[dir="rtl"] .knowledge-modal-card {
  text-align: right;
}

html[dir="rtl"] .team-modal-close,
html[dir="rtl"] .trainer-modal-close,
html[dir="rtl"] .program-modal-close,
html[dir="rtl"] .knowledge-modal-close {
  right: auto;
  left: 20px;
}

html[dir="rtl"] .team-modal-card label,
html[dir="rtl"] .trainer-modal-card label,
html[dir="rtl"] .program-modal-card label,
html[dir="rtl"] .knowledge-modal-card label {
  text-align: right;
}

html[dir="rtl"] .team-modal-card input,
html[dir="rtl"] .team-modal-card textarea,
html[dir="rtl"] .trainer-modal-card input,
html[dir="rtl"] .trainer-modal-card textarea,
html[dir="rtl"] .program-modal-card input,
html[dir="rtl"] .program-modal-card textarea,
html[dir="rtl"] .program-modal-card select,
html[dir="rtl"] .knowledge-modal-card input,
html[dir="rtl"] .knowledge-modal-card textarea {
  text-align: right;
}

html[dir="rtl"] .team-form-actions,
html[dir="rtl"] .trainer-form-actions,
html[dir="rtl"] .program-form-actions,
html[dir="rtl"] .knowledge-form-actions {
  flex-direction: row-reverse;
}

/* --- Authentication Pages --- */
html[dir="rtl"] .auth-card,
html[dir="rtl"] .account-card {
  text-align: right;
}

html[dir="rtl"] .auth-form label {
  text-align: right;
}

html[dir="rtl"] .auth-form input {
  text-align: right;
}

html[dir="rtl"] .auth-form .password-field > input,
html[dir="rtl"] .password-field input {
  padding-right: 16px !important;
  padding-left: 58px !important;
}

html[dir="rtl"] .auth-form .password-field > .password-toggle,
html[dir="rtl"] .password-toggle {
  right: auto !important;
  left: 10px !important;
}

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

html[dir="rtl"] .account-top .auth-brand {
  margin: 0;
  justify-content: flex-end;
}

html[dir="rtl"] .profile-details {
  text-align: right;
}

html[dir="rtl"] .profile-detail:nth-child(odd) {
  padding-right: 0;
  padding-left: 28px;
}

html[dir="rtl"] .profile-detail:nth-child(even) {
  padding-left: 0;
  padding-right: 28px;
  border-left: 0;
  border-right: 1px solid var(--line);
}

/* --- Admin Page --- */
html[dir="rtl"] .admin-shell {
  text-align: right;
}

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

html[dir="rtl"] .admin-stats>div {
  border-right: 0;
  border-left: 1px solid var(--line);
  padding: 24px 0 28px 20px;
}

html[dir="rtl"] .admin-stats>div+div {
  padding-left: 0;
  padding-right: 20px;
}

html[dir="rtl"] .admin-stats>div:last-child {
  border-left: 0;
}

/* ==========================================================================
   Mobile RTL Tweaks (<= 820px)
   ========================================================================== */
@media (max-width: 820px) {
  .site-top-controls {
    display: none !important;
  }
  html[dir="rtl"] .page-main {
    margin-right: 0;
  }
  html[dir="rtl"] .footer {
    margin-right: 0;
  }
  /* RTL mobile header: keep same flex-direction (logo left, hamburger right)
     The mobile-brand has direction:ltr forced in styles.css so logo stays correct.
     Only adjust menu text alignment. */
  html[dir="rtl"] .mobile-header {
    flex-direction: row;
  }
  html[dir="rtl"] .mobile-menu nav a {
    text-align: right;
  }
  html[dir="rtl"] .section-links a:hover {
    padding-right: 8px;
    padding-left: 0;
  }
  html[dir="rtl"] .about-strip>div,
  html[dir="rtl"] .about-strip>div+div {
    padding: 22px 0;
    border-left: 0;
  }
  html[dir="rtl"] .hero svg {
    right: auto;
    left: -18%;
  }
  html[dir="rtl"] .profile-detail:nth-child(odd) {
    padding-left: 0;
  }
  html[dir="rtl"] .profile-detail:nth-child(even) {
    padding-right: 0;
    border-right: 0;
  }
}

/* V8.8.1 — sidebar language switcher removed; keep top/mobile language controls. */
@media (min-width: 1101px){ .sidebar-lang-box{display:none !important;} }
