/* nextxch shared 3-column language picker modal (Admin Cockpit & Webmail)
   Light mode default, sleek dark slate under html.dark, full RTL support. */

select.nx-lang-select-native {
  display: none !important;
}

/* Trigger pill button */
.nx-lang-trigger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 28px;
  padding: 0 9px;
  border-radius: 7px;
  border: 1px solid #e2e8f0;
  background: #ffffff;
  color: #334155;
  font-family: inherit;
  font-size: 12px;
  font-weight: 600;
  line-height: 1;
  letter-spacing: 0.02em;
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
  flex-shrink: 0;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.05);
  transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.nx-lang-trigger:hover {
  background: #f8fafc;
  border-color: #cbd5e1;
  color: #0f172a;
}

.nx-lang-trigger:focus-visible {
  outline: 2px solid #2563eb;
  outline-offset: 2px;
}

html.dark .nx-lang-trigger {
  background: #2d2d30;
  border-color: #3c3c3c;
  color: #cccccc;
  box-shadow: none;
}

html.dark .nx-lang-trigger:hover {
  background: #38383d;
  border-color: #52525b;
  color: #ffffff;
}

.nx-lang-trigger .nx-lang-flag {
  width: 18px;
  height: 13px;
  border-radius: 2px;
  object-fit: cover;
  display: block;
  flex-shrink: 0;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.12);
}

html.dark .nx-lang-trigger .nx-lang-flag {
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.18);
}

.nx-lang-trigger .nx-lang-code {
  display: inline-block;
  line-height: 1;
}

.nx-lang-trigger .nx-lang-chev {
  width: 13px;
  height: 13px;
  flex-shrink: 0;
  opacity: 0.65;
  transition: transform 0.15s ease;
}

.nx-lang-trigger[aria-expanded="true"] .nx-lang-chev {
  transform: rotate(180deg);
}

/* Modal backdrop */
html.nx-lang-modal-open {
  overflow: hidden;
}

.nx-lang-backdrop {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  background: rgba(15, 23, 42, 0.48);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  opacity: 0;
  transition: opacity 0.16s ease;
}

.nx-lang-backdrop[hidden] {
  display: none !important;
}

.nx-lang-backdrop.is-open {
  opacity: 1;
}

html.dark .nx-lang-backdrop {
  background: rgba(0, 0, 0, 0.62);
}

/* Modal card */
.nx-lang-dialog {
  width: calc(100% - 32px);
  max-width: 720px;
  max-height: calc(100dvh - 32px);
  overflow-y: auto;
  background: #ffffff;
  color: #0f172a;
  border: 1px solid rgba(15, 23, 42, 0.08);
  border-radius: 20px;
  padding: 28px 32px;
  box-shadow: 0 24px 60px rgba(15, 23, 42, 0.22);
  transform: translateY(6px) scale(0.985);
  transition: transform 0.18s cubic-bezier(0.16, 1, 0.3, 1);
}

.nx-lang-backdrop.is-open .nx-lang-dialog {
  transform: translateY(0) scale(1);
}

html.dark .nx-lang-dialog {
  background: #18181b;
  color: #f8fafc;
  border-color: rgba(255, 255, 255, 0.1);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.62);
}

/* Modal header */
.nx-lang-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
}

.nx-lang-title {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 700;
  line-height: 1.3;
  letter-spacing: -0.015em;
  color: #0f172a;
}

html.dark .nx-lang-title {
  color: #f8fafc;
}

.nx-lang-close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: #64748b;
  cursor: pointer;
  flex-shrink: 0;
  transition: background-color 0.15s ease, color 0.15s ease;
}

.nx-lang-close:hover {
  background: #f1f5f9;
  color: #0f172a;
}

.nx-lang-close:focus-visible {
  outline: 2px solid #2563eb;
  outline-offset: 2px;
}

html.dark .nx-lang-close {
  color: #9ca3af;
}

html.dark .nx-lang-close:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #ffffff;
}

/* 3-column language grid */
.nx-lang-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px 14px;
}

.nx-lang-opt {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-width: 0;
  padding: 9px 14px;
  border: 0;
  border-radius: 12px;
  background: transparent;
  color: #1e293b;
  font-family: inherit;
  font-size: 0.9375rem;
  font-weight: 500;
  line-height: 1.35;
  text-align: start;
  text-decoration: none;
  cursor: pointer;
  transition: background-color 0.15s ease, color 0.15s ease;
}

.nx-lang-opt:hover {
  background: #f8fafc;
  color: #0f172a;
}

.nx-lang-opt:focus-visible {
  outline: 2px solid #2563eb;
  outline-offset: 1px;
}

.nx-lang-opt.is-active {
  background: #eff6ff;
  color: #0f172a;
  font-weight: 600;
}

.nx-lang-opt.is-active:hover {
  background: #e0edff;
}

html.dark .nx-lang-opt {
  color: #e2e8f0;
}

html.dark .nx-lang-opt:hover {
  background: rgba(255, 255, 255, 0.06);
  color: #ffffff;
}

html.dark .nx-lang-opt.is-active {
  background: rgba(59, 130, 246, 0.18);
  color: #f8fafc;
  font-weight: 600;
}

html.dark .nx-lang-opt.is-active:hover {
  background: rgba(59, 130, 246, 0.25);
}

.nx-lang-opt .nx-lang-flag {
  width: 22px;
  height: 16px;
  border-radius: 3px;
  object-fit: cover;
  display: block;
  flex-shrink: 0;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.12);
}

html.dark .nx-lang-opt .nx-lang-flag {
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.18);
}

.nx-lang-opt .nx-lang-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.nx-lang-opt .nx-lang-check {
  width: 17px;
  height: 17px;
  flex-shrink: 0;
  color: #2563eb;
  display: block;
}

html.dark .nx-lang-opt .nx-lang-check {
  color: #60a5fa;
}

@media (max-width: 640px) {
  .nx-lang-dialog {
    padding: 22px 20px;
    border-radius: 16px;
  }

  .nx-lang-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px 12px;
  }
}

@media (max-width: 400px) {
  .nx-lang-dialog {
    width: calc(100% - 20px);
    padding: 20px 16px;
  }

  .nx-lang-grid {
    grid-template-columns: 1fr;
    gap: 6px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .nx-lang-backdrop,
  .nx-lang-dialog,
  .nx-lang-trigger,
  .nx-lang-trigger .nx-lang-chev,
  .nx-lang-close,
  .nx-lang-opt {
    transition: none;
  }
}
