/* Language controls are independent of application/authentication form state. */
.language-picker {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-inline-size: 0;
  max-inline-size: 100%;
  color: var(--ink-600, #50617b);
  font-size: 12px;
}

.language-picker__label { overflow-wrap: anywhere; }

.language-picker select {
  min-inline-size: 0;
  inline-size: 138px;
  max-inline-size: 100%;
  min-block-size: 36px;
  padding-block: 6px;
  padding-inline: 8px;
  border: 1px solid var(--border, #dfe6ef);
  border-radius: 8px;
  background: var(--surface, #fff);
  color: var(--ink-800, #1d2a40);
  font: inherit;
  cursor: pointer;
}

.language-picker select:focus-visible {
  outline: 2px solid var(--primary-500, #3d7fe3);
  outline-offset: 2px;
}

.language-picker select:disabled { opacity: 0.65; cursor: progress; }
.auth-header { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 16px; }
.auth-header .auth-brand { margin: 0; }

/* Direction follows the language, while identifiers and code remain LTR. */
html[dir="rtl"] body { text-align: start; }
html[dir="rtl"] :is(input, textarea, select) { text-align: start; }
html[dir="rtl"] :is(pre, code, .mono, .source-ip, .endpoint-box, .key-prefix, .integration-code, [data-ltr], input[type="email"], input[type="url"], input[autocomplete="username"]) {
  direction: ltr;
  unicode-bidi: isolate;
  text-align: left;
}

html[dir="rtl"] .sidebar {
  inset-inline-start: 0;
  inset-inline-end: auto;
  border-inline-start: 0;
  border-inline-end: 1px solid var(--border, #dfe6ef);
}

html[dir="rtl"] .topbar { inset-inline-start: var(--sidebar-width, 252px); inset-inline-end: 0; }
html[dir="rtl"] .portal-main { margin-inline-start: var(--sidebar-width, 252px); margin-inline-end: 0; }
html[dir="rtl"] :is(.data-table th, .data-table td) { text-align: start; }
html[dir="rtl"] .text-right { text-align: end; }
html[dir="rtl"] :is(.check-list, .admin-evidence-list) { padding-inline-start: 18px; padding-inline-end: 0; }
html[dir="rtl"] :is(.user-dropdown, .model-select-menu) { inset-inline-start: auto; inset-inline-end: 0; }
html[dir="rtl"] .input-wrap .input { padding-inline-start: 13px; padding-inline-end: 44px; }
/* LTR identifiers still reserve space for the icon positioned by their RTL wrapper. */
html[dir="rtl"] .input-wrap :is(input[type="email"], input[type="url"], input[autocomplete="username"]) { padding-inline-start: 44px; padding-inline-end: 13px; }
html[dir="rtl"] .input-action { inset-inline-start: auto; inset-inline-end: 6px; }
html[dir="rtl"] .search-box .input { padding-inline-start: 38px; padding-inline-end: 13px; }
html[dir="rtl"] .search-box > .icon { inset-inline-start: 12px; inset-inline-end: auto; }
html[dir="rtl"] .admin-reconciliation-table .admin-evidence-list { text-align: start; }

/* Translations expand; allow flex/grid children and labels to wrap naturally. */
html[lang] :is(.public-nav__actions, .page-header__actions, .modal__foot, .auth-card__foot) { flex-wrap: wrap; }
html[lang] :is(.page-header, .card__head-copy, .modal__head > div, .auth-card-wrap, .topbar__left, .topbar__right) { min-inline-size: 0; }
html[lang] :is(.page-header h1, .card__head h2, .modal__head h2, .form-field > label, .auth-card h1) { overflow-wrap: anywhere; }

@media (max-width: 760px) {
  html[dir="rtl"] .sidebar { transform: translateX(100%); }
  html[dir="rtl"] body.nav-open .sidebar { transform: translateX(0); }
  html[dir="rtl"] .topbar { inset-inline-start: 0; }
  html[dir="rtl"] .portal-main { margin-inline-start: 0; }
  .language-picker select { inline-size: 126px; }
}

@media (max-width: 520px) {
  .language-picker { gap: 5px; flex-shrink: 1; }
  .language-picker__label {
    position: absolute;
    inline-size: 1px;
    block-size: 1px;
    padding: 0;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
  }
  .language-picker select { inline-size: 120px; min-block-size: 40px; }
  html[lang] :is(.public-nav__inner, .topbar__right) { gap: 8px; }
  html[lang] .public-nav__inner { height: auto; min-height: 67px; padding-block: 10px; flex-wrap: wrap; }
  html[lang] .public-nav__inner > .brand { flex-shrink: 0; }
  html[lang] .public-nav__actions { flex: 1 0 100%; justify-content: flex-end; }
  html[lang] .public-nav__actions .language-picker { flex-shrink: 0; }
  html[lang] .public-nav__actions .btn { flex: 1 1 0; min-inline-size: 0; }
  html[lang] .public-nav__actions { min-inline-size: 0; gap: 6px; }
  html[lang] :is(.public-nav__actions, .page-header__actions, .modal__foot) .btn { white-space: normal; overflow-wrap: anywhere; }
  html[dir="rtl"] .data-table--stack td { text-align: end; }
  html[dir="rtl"] .data-table--stack td::before { text-align: start; }
  html[dir="rtl"] .data-table--stack td:first-child { text-align: start; }
}


/* One searchable selector for public pages, account screens and authorization. The
   native select remains the compatibility bridge to existing protected form handlers. */
.language-picker { position: relative; }
.language-picker.is-enhanced > .language-picker__label,
.language-picker.is-enhanced > select[data-language-select] { position: absolute; inline-size: 1px; block-size: 1px; min-block-size: 0; padding: 0; margin: -1px; border: 0; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.language-picker .language-picker__button { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-block-size: 38px; max-inline-size: 170px; padding: 7px 10px; border: 1px solid #dfe6f2; border-radius: 10px; background: linear-gradient(145deg,#fff,#f4f7fe); color: #29364b; font: inherit; font-size: 13px; font-weight: 500; line-height: 1.4; cursor: pointer; box-shadow: inset 0 1px 0 #fff,0 2px 8px #1c47d807; }
.language-picker .language-picker__button[hidden] { display: none; }
.language-picker .language-picker__button:hover { border-color: #a8bce8; background: #f4f7ff; color: #1c47d8; }
.language-picker .language-picker__button:disabled { opacity: .5; cursor: progress; }
.language-picker .language-picker__button:focus-visible,
.language-dialog :is(button,input):focus-visible { outline: 2px solid #1c47d8; outline-offset: 3px; }
.language-picker [data-language-current] { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.language-picker__icon { flex: 0 0 16px; inline-size: 16px; block-size: 16px; background: currentColor; -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cg fill='none' stroke='black' stroke-width='1.6'%3E%3Ccircle cx='12' cy='12' r='9'/%3E%3Cellipse cx='12' cy='12' rx='4' ry='9'/%3E%3Cpath d='M3 12h18'/%3E%3C/g%3E%3C/svg%3E") center/contain no-repeat; mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cg fill='none' stroke='black' stroke-width='1.6'%3E%3Ccircle cx='12' cy='12' r='9'/%3E%3Cellipse cx='12' cy='12' rx='4' ry='9'/%3E%3Cpath d='M3 12h18'/%3E%3C/g%3E%3C/svg%3E") center/contain no-repeat; }
.language-picker__chevron { flex: 0 0 5px; inline-size: 5px; block-size: 5px; border-inline-end: 1.5px solid currentColor; border-block-end: 1.5px solid currentColor; transform: rotate(45deg) translateY(-2px); }
.language-picker__status:empty { display: none; }
.language-picker__status { position: absolute; inset-block-start: 100%; inset-inline-end: 0; z-index: 5; inline-size: 230px; margin-block-start: 6px; padding: 10px; background: #fff; border: 1px solid #e4e7ec; border-radius: 8px; color: #9a2727; font-size: 12px; }
.language-dialog { box-sizing: border-box; inline-size: min(520px,calc(100vw - 32px)); max-block-size: calc(100dvh - 40px); margin: auto; padding: 24px; border: 1px solid #d8e2f5; border-radius: 20px; color: #202b3e; background: radial-gradient(ellipse at 100% 0,#eaf1ff 0,#fff0 46%),#fff; box-shadow: 0 24px 90px #122c6630, inset 0 1px 0 #fff; font: 14px/1.5 var(--agent-font,system-ui,sans-serif); overflow: auto; }
.language-dialog::backdrop { background: #101e3c66; backdrop-filter: blur(4px); }
.language-dialog__head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-block-end: 18px; }
.language-dialog__head h2 { margin: 0; color: #202b3e; font-size: 21px; font-weight: 600; letter-spacing: -.02em; }
.language-dialog__close { display: grid; place-items: center; flex: 0 0 36px; inline-size: 36px; block-size: 36px; padding: 0; border: 0; border-radius: 9px; background: #f0f4fb; color: #52617b; font: 25px/1 system-ui; cursor: pointer; }
.language-dialog__search { box-sizing: border-box; inline-size: 100%; min-block-size: 44px; padding: 10px 13px; border: 1px solid #dce4f0; border-radius: 10px; background: #ffffffdb; color: #202b3e; font: inherit; }
.language-dialog__list { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 5px; max-block-size: min(55vh,420px); overflow: auto; margin-block-start: 16px; padding: 3px; overscroll-behavior: contain; }
.language-dialog__option { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-block-size: 44px; padding: 11px 12px; border: 1px solid transparent; border-radius: 10px; background: transparent; color: #344159; text-align: start; font: inherit; cursor: pointer; }
.language-dialog__option span { min-inline-size: 0; overflow-wrap: anywhere; }
.language-dialog__option small { color: #7a879d; font: 11px/1.4 var(--agent-font,system-ui,sans-serif); }
.language-dialog__option:hover { background: #f2f6fe; }
.language-dialog__option[aria-selected="true"] { border-color: #d1def9; color: #1c47d8; background: #eaf1ff; font-weight: 600; }
.language-dialog__option[hidden], .language-dialog__empty[hidden] { display: none; }
.language-dialog__empty { margin: 20px 0 4px; color: #6b778c; text-align: center; }
@media (max-width: 520px) {
  .language-picker .language-picker__button { max-inline-size: 128px; min-block-size: 40px; gap: 6px; padding-inline: 8px; }
  .language-dialog { padding: 18px; border-radius: 16px; }
  .language-dialog__option { padding: 10px 8px; font-size: 13px; }
}
@media (forced-colors: active) {
  .language-picker .language-picker__button, .language-dialog, .language-dialog__option[aria-selected="true"] { border: 1px solid ButtonText; }
  .language-picker__icon { background: ButtonText; }
}

/* Native controls stay in the DOM for the application's form-state checks. */
.language-picker.is-enhanced > select[data-language-select] { inline-size: 1px !important; block-size: 1px !important; min-block-size: 0 !important; padding: 0 !important; }
/* The customer shell uses a narrower rail than the legacy admin shell. */
html[dir="rtl"] #app .agent-portal .ap-sidebar { inset: 60px 0 0 auto; border-right: 0; border-left: 1px solid var(--ap-line); }
html[dir="rtl"] #app .agent-portal .portal-main { margin: 0 208px 0 0; }
html[dir="rtl"] #app .agent-portal :is(.ap-table,.au-table,.ad-table) :is(th,td) { text-align: start; }
html[dir="rtl"] #app .agent-portal .user-dropdown { left: 0; right: auto; }
@media (max-width: 760px) {
  html[dir="rtl"] #app .agent-portal .ap-sidebar { inset: auto; border-left: 0; }
  html[dir="rtl"] #app .agent-portal .portal-main { margin: 0; }
}
