/**
 * Style đi kèm i18n.js: font theo nhóm ngôn ngữ + dropdown chuyển ngôn ngữ.
 *
 * File này chưa được trang nào nhúng. Nó tồn tại vì i18n.js gắn class
 * `i18n-font-*` lên <html> và sinh markup `.lang-switcher-*`, nên hai bên phải
 * đi cùng nhau. Trang nào bật i18n thì nhúng thêm file này.
 */

/* ---------- Font theo nhóm ngôn ngữ ----------
 * Lexend (font của template) không có glyph CJK và Devanagari. Không khai báo
 * riêng thì trình duyệt rơi về font hệ thống, và chất lượng phụ thuộc máy người
 * dùng - trên Windows chưa cài gói ngôn ngữ sẽ ra ô vuông.
 */
html.i18n-font-cjk body,
html.i18n-font-cjk button,
html.i18n-font-cjk input,
html.i18n-font-cjk select,
html.i18n-font-cjk textarea {
  font-family: "Noto Sans SC", "Noto Sans JP", "Noto Sans KR", "Lexend",
    -apple-system, "Segoe UI", sans-serif;
}

/* Tiếng Trung, Nhật, Hàn không có khoảng trắng giữa từ. Mặc định trình duyệt
 * ngắt dòng ở bất kỳ ký tự nào, làm nhãn ngắn bị xé giữa cụm từ. */
html.i18n-font-cjk .card-header h3,
html.i18n-font-cjk .contact-label,
html.i18n-font-cjk .section-title-premium,
html.i18n-font-cjk .lang-switcher-native,
html.i18n-font-cjk .fab-item-label {
  word-break: keep-all;
  overflow-wrap: break-word;
}

html.i18n-font-devanagari body,
html.i18n-font-devanagari button,
html.i18n-font-devanagari input,
html.i18n-font-devanagari select,
html.i18n-font-devanagari textarea {
  font-family: "Noto Sans Devanagari", "Lexend", -apple-system, "Segoe UI",
    sans-serif;
}

/* Devanagari có dấu phụ phía trên và dưới đường chân chữ, line-height mặc định
 * làm chúng chạm nhau giữa hai dòng. */
html.i18n-font-devanagari body {
  line-height: 1.75;
}

/* ---------- Chống tràn khi chuỗi dài hơn tiếng Việt ----------
 * Tiếng Đức ghép từ dài hơn tiếng Anh 20-30%. Nút đặt chiều rộng cố định sẽ bị
 * tràn chữ; min-width giữ được kích thước tối thiểu mà vẫn giãn ra được.
 */
.lang-switcher-toggle,
.lang-switcher-option {
  min-width: max-content;
}

/* ---------- Dropdown chuyển ngôn ngữ ---------- */
.lang-switcher {
  position: relative;
  display: inline-flex;
  align-items: center;
}

.lang-switcher[hidden] {
  display: none;
}

.lang-switcher-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.42rem;
  min-height: 2.25rem;
  padding: 0.4rem 0.55rem 0.4rem 0.65rem;
  border: 1px solid rgba(0, 113, 227, 0.18);
  border-radius: 999px;
  background: var(--bg-card, #fff);
  color: var(--text-secondary, #475569);
  font-size: 0.85rem;
  font-weight: 600;
  line-height: 1;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(15, 61, 122, 0.07);
  transition: border-color 0.2s, color 0.2s, box-shadow 0.2s, transform 0.2s;
}

.lang-switcher-toggle:hover,
.lang-switcher-toggle:focus-visible {
  border-color: var(--primary-color, #2563eb);
  color: var(--primary-color, #2563eb);
  box-shadow: 0 7px 20px rgba(0, 113, 227, 0.12);
  transform: translateY(-1px);
}

/* Bàn phím phải thấy được focus: dropdown này là điều khiển chính của tính năng. */
.lang-switcher-toggle:focus-visible,
.lang-switcher-option:focus-visible {
  outline: 2px solid var(--primary-color, #2563eb);
  outline-offset: 2px;
}

.lang-switcher-toggle .material-symbols-outlined {
  font-size: 1.15rem;
}

.lang-switcher-flag {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  justify-content: center;
  width: 1.25rem;
  height: 0.875rem;
  border: 1px solid rgba(15, 23, 42, 0.12);
  border-radius: 0.18rem;
  background: #eef2f7 center / cover no-repeat;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.12);
}

.lang-switcher-flag.flag-vi {
  background-image: url('/assets/img/flags/vi.svg');
}

.lang-switcher-flag.flag-en {
  background-image: url('/assets/img/flags/gb.svg');
}

.lang-switcher-chevron {
  margin-left: -0.1rem;
  color: var(--text-muted, #64748b);
  font-size: 1rem !important;
  transition: transform 0.2s ease;
}

.lang-switcher-toggle[aria-expanded="true"] .lang-switcher-chevron {
  transform: rotate(180deg);
}

.lang-switcher-menu {
  position: absolute;
  top: calc(100% + 0.5rem);
  right: 0;
  z-index: 1080;
  min-width: 11rem;
  margin: 0;
  padding: 0.35rem;
  list-style: none;
  background: var(--bg-card, #fff);
  border: 1px solid var(--border-color, #e2e8f0);
  border-radius: 0.75rem;
  box-shadow: var(--shadow-md, 0 4px 6px -1px rgba(0, 0, 0, 0.1));
}

.lang-switcher-menu[hidden] {
  display: none;
}

.lang-switcher-option {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 0.75rem;
  width: 100%;
  padding: 0.5rem 0.65rem;
  border: 0;
  border-radius: 0.5rem;
  background: transparent;
  color: var(--text-primary, #0f172a);
  font-size: 0.875rem;
  text-align: left;
  cursor: pointer;
}

.lang-switcher-option .lang-switcher-native {
  flex: 1 1 auto;
}

.lang-switcher-option:hover {
  background: var(--bg-hover, #f8fafc);
}

.lang-switcher-option.active {
  background: var(--bg-blue-light, #eff6ff);
  color: var(--primary-color, #2563eb);
  font-weight: 600;
}

.lang-switcher-code {
  color: var(--text-muted, #64748b);
  font-size: 0.75rem;
  font-weight: 600;
}

.lang-switcher-option.active .lang-switcher-code {
  color: inherit;
}

/* Trên mobile header rất chật: bỏ nhãn chữ, chỉ giữ icon quả cầu. */
@media (max-width: 575.98px) {
  .lang-switcher-toggle {
    gap: 0.3rem;
    min-height: 2rem;
    padding: 0.32rem 0.45rem;
    font-size: 0.78rem;
  }

}
