/**
 * Revomart I18n — RTL / direction-safe presentation helpers.
 * Additive only. Prefer logical properties. Does not alter business layout CSS
 * unless html/body carries .i18n-rtl.
 */

html.i18n-rtl,
html[dir="rtl"] {
  direction: rtl;
}

/* ------------------------------------------------------------------ */
/* Language selector — high-contrast, discoverable chrome               */
/* ------------------------------------------------------------------ */

.i18n-lang-selector {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  flex: 0 0 auto;
  margin-inline-start: 0;
  z-index: 40;
}

.i18n-lang-label {
  font-size: 0.75rem;
  letter-spacing: 0.02em;
  opacity: 0.85;
  white-space: nowrap;
  color: inherit;
}

.i18n-lang-select {
  font: inherit;
  font-size: 0.875rem;
  font-weight: 600;
  line-height: 1.2;
  min-height: 40px;
  min-width: 7.5rem;
  padding: 0.4rem 0.75rem;
  border-radius: 0.45rem;
  border: 1.5px solid #9aa8b8;
  background: #ffffff;
  color: #142033;
  max-width: 12rem;
  cursor: pointer;
  box-shadow: 0 1px 3px rgba(20, 32, 51, 0.12);
}

.i18n-lang-select:hover,
.i18n-lang-select:focus-visible {
  border-color: #8fa0b5;
  outline: 2px solid rgba(37, 99, 235, 0.35);
  outline-offset: 1px;
}

/*
 * Body-first .i18n-lang-bar (not yet in a header slot): fixed top-right so the
 * control is discoverable even before lang-slot.js relocates it.
 */
.i18n-lang-bar:not(.i18n-lang-in-header) {
  position: fixed;
  top: 12px;
  right: 12px;
  left: auto;
  margin: 0;
  padding: 6px 8px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.96);
  border: 1px solid #d0d7e2;
  box-shadow: 0 4px 16px rgba(20, 32, 51, 0.12);
  z-index: 10050;
}

html[dir="rtl"] .i18n-lang-bar:not(.i18n-lang-in-header) {
  right: auto;
  left: 12px;
}

/* Once placed in a header slot, cancel floating chrome */
.i18n-lang-in-header.i18n-lang-bar,
.i18n-lang-selector.i18n-lang-in-header {
  position: static;
  padding: 0;
  border: 0;
  background: transparent;
  box-shadow: none;
}

/* Root home: language + account cluster outside the mobile drawer */
.rh-end {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 0 0 auto;
}

.rh-end > .i18n-lang-selector {
  flex: 0 0 auto;
}

@media (max-width: 900px) {
  .rh-end {
    margin-inline-start: auto;
    margin-inline-end: 6px;
    gap: 6px;
  }

  /* root-home.css sets toggle margin-left:auto; keep cluster before toggle */
  .root-home .rh-nav-toggle {
    margin-left: 0;
  }

  .rh-end .rh-actions {
    gap: 6px;
  }

  .rh-end .rh-btn {
    min-height: 36px;
    padding: 0 10px;
    font-size: 13px;
  }
}

@media (max-width: 520px) {
  /* Prefer language + menu; keep one account CTA */
  .rh-end .rh-btn-ghost {
    display: none;
  }
}

/* Root home header: high-contrast language control on dark navy */
.root-home .i18n-lang-select {
  border-color: rgba(212, 175, 55, 0.85);
  background: #0e1a2b;
  color: #f4f6f8;
  box-shadow: 0 0 0 1px rgba(212, 175, 55, 0.25);
}

.root-home .i18n-lang-label {
  color: #d4af37;
  font-weight: 600;
  opacity: 1;
}

.root-home .i18n-lang-bar:not(.i18n-lang-in-header) {
  background: rgba(14, 26, 43, 0.92);
  border-color: rgba(212, 175, 55, 0.55);
}

/* Light public headers */
.home-page .i18n-lang-select,
.about-page .i18n-lang-select,
.cases-page .i18n-lang-select,
.contact-page .i18n-lang-select,
.notice-page .i18n-lang-select,
.trust-page .i18n-lang-select,
.trust-index-page .i18n-lang-select,
.account-page .i18n-lang-select,
.rg-page .i18n-lang-select {
  border-color: #c5ced9;
  background: #ffffff;
  color: #142033;
}

.home-page .i18n-lang-label,
.about-page .i18n-lang-label,
.cases-page .i18n-lang-label,
.contact-page .i18n-lang-label,
.notice-page .i18n-lang-label,
.trust-page .i18n-lang-label,
.trust-index-page .i18n-lang-label,
.account-page .i18n-lang-label,
.rg-page .i18n-lang-label {
  color: #5c6b7a;
}

/* Demand / Executor: selector sits beside the account slot. Row gap supplies the space. */
.rv-header .header-inner > .i18n-lang-selector {
  flex: 0 0 auto;
  margin-inline: 0;
  min-width: 0;
}

.rv-user-area > .i18n-lang-selector {
  margin-inline-end: 8px;
}

/* Trust / Vault .th-user */
.th-user > .i18n-lang-selector {
  margin-inline-end: 10px;
}

/* Admin header */
.admin-account > .i18n-lang-selector,
.admin-header > .i18n-lang-selector {
  margin-inline-end: 12px;
}

/* Login identity meta */
.ri-header-meta > .i18n-lang-selector {
  margin-inline-end: 12px;
}

/* Register form shell: keep selector out of form fields */
.rg-form-shell > .i18n-lang-selector {
  display: flex;
  justify-content: flex-end;
  width: 100%;
  margin: 0 0 12px;
}

/* Admin login brand block */
.login-wrapper .brand > .i18n-lang-selector {
  display: flex;
  justify-content: flex-end;
  width: 100%;
  margin: 0 0 16px;
}

/* Hide footer duplicate mount hosts (marketplace) */
[data-i18n-lang-root][hidden],
.home-footer-langs [data-i18n-lang-root] {
  display: none !important;
}

/* Isolate emails, account IDs, UUIDs, REVO amounts in RTL contexts */
[dir="rtl"] [data-ltr-isolate],
[dir="rtl"] .i18n-ltr-isolate,
.i18n-rtl [data-ltr-isolate],
.i18n-rtl .i18n-ltr-isolate {
  direction: ltr;
  unicode-bidi: isolate;
  text-align: start;
}

@media (max-width: 900px) {
  .i18n-lang-selector {
    margin-inline: 0;
  }

  .i18n-lang-label {
    /* Keep label on mobile when space allows; shrink if needed */
    font-size: 0.7rem;
  }

  .i18n-lang-select {
    max-width: 9.5rem;
    min-height: 34px;
  }

  .i18n-lang-bar:not(.i18n-lang-in-header) {
    top: 8px;
    right: 8px;
    max-width: calc(100vw - 16px);
  }

  .rh-actions .i18n-lang-selector,
  .home-header-actions .i18n-lang-selector,
  .rv-user-area .i18n-lang-selector {
    order: -1;
  }
}

@media (max-width: 520px) {
  .i18n-lang-label {
    /* Prefer select alone on very narrow headers */
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
  }

  .i18n-lang-selector {
    position: relative;
  }
}
