/* AliLife / xxooxx Global Console i18n Switcher Styles v1.2
 * - Single host outside React #root (mounted on document.body, zero React reconciliation conflict)
 * - No flex gap dependency (100% compatible with Chrome 53+ / legacy Android WebView)
 * - Dark & Light theme adaptive
 */

.fc-lang-host {
  position: fixed;
  top: 18px;
  right: 20px;
  z-index: 99990;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "PingFang SC", "Microsoft YaHei", sans-serif;
}

.fc-lang-host.mode-topbar {
  top: 9px;
  right: 20px;
}

.fc-lang-host.mode-ctrl {
  top: 7px;
  right: 12px;
}

.fc-lang-trigger {
  display: inline-flex;
  align-items: center;
  height: 34px;
  padding: 0 12px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: rgba(28, 14, 34, 0.84);
  color: #f3e8ff;
  font-size: 12.5px;
  font-weight: 500;
  line-height: 1;
  cursor: pointer;
  outline: none;
  white-space: nowrap;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.28);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  transition: background 0.18s ease, border-color 0.18s ease, transform 0.12s ease;
  box-sizing: border-box;
}

.fc-lang-trigger:hover {
  background: rgba(48, 22, 58, 0.94);
  border-color: rgba(249, 115, 22, 0.5);
}

.fc-lang-trigger:active {
  transform: scale(0.98);
}

.fc-lang-host.mode-topbar .fc-lang-trigger {
  height: 34px;
  padding: 0 10px;
  border-radius: 8px;
  background: var(--fc-input-bg, rgba(22, 27, 34, 0.92));
  border: 1px solid var(--fc-border-soft, rgba(255, 255, 255, 0.14));
  color: var(--fc-text-secondary, #e2e8f0);
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.22);
  font-size: 12px;
}

.fc-lang-host.mode-topbar .fc-lang-trigger:hover {
  border-color: rgba(249, 115, 22, 0.55);
  color: var(--fc-text-topbar, #ffffff);
}

.fc-lang-host.mode-ctrl .fc-lang-trigger {
  height: 26px;
  padding: 0 9px;
  border-radius: 7px;
  font-size: 11px;
  background: rgba(22, 27, 34, 0.92);
  border: 1px solid #30363d;
  color: #cbd5e1;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.35);
}

.fc-lang-host.mode-ctrl .fc-lang-trigger:hover {
  background: #21262d;
  border-color: #58a6ff;
  color: #ffffff;
}

[data-theme="light"] .fc-lang-host.mode-topbar .fc-lang-trigger,
[data-theme="light"] .fc-lang-host.mode-ctrl .fc-lang-trigger {
  background: #ffffff;
  border-color: #d1d5db;
  color: #1f2937;
  box-shadow: 0 1px 4px rgba(15, 23, 42, 0.08);
}

[data-theme="light"] .fc-lang-host.mode-topbar .fc-lang-trigger:hover,
[data-theme="light"] .fc-lang-host.mode-ctrl .fc-lang-trigger:hover {
  background: #f8fafc;
  border-color: #f97316;
  color: #111827;
}

.fc-lang-flag {
  font-size: 14px;
  line-height: 1;
  margin-right: 6px;
}

.fc-lang-caret {
  font-size: 10px;
  opacity: 0.75;
  margin-left: 6px;
}

.fc-lang-spinner {
  display: inline-block;
  width: 11px;
  height: 11px;
  margin-left: 6px;
  border: 2px solid rgba(255, 255, 255, 0.25);
  border-top-color: #f97316;
  border-radius: 50%;
  animation: fcLangSpin 0.7s linear infinite;
}

@keyframes fcLangSpin {
  to { transform: rotate(360deg); }
}

/* Popover panel mounted on document.body with explicit class */
.fc-lang-popover {
  position: fixed;
  z-index: 2147483640;
  width: 460px;
  max-width: calc(100vw - 24px);
  max-height: calc(100vh - 76px);
  max-height: min(560px, calc(100vh - 76px));
  display: none;
  flex-direction: column;
  background: rgba(18, 14, 28, 0.97);
  border: 1px solid rgba(249, 115, 22, 0.28);
  border-radius: 14px;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.65), 0 0 0 1px rgba(255, 255, 255, 0.04) inset;
  color: #f1f5f9;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "PingFang SC", "Microsoft YaHei", sans-serif;
  overflow: hidden;
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
}

.fc-lang-popover.open {
  display: flex;
}

[data-theme="light"] .fc-lang-popover {
  background: rgba(255, 255, 255, 0.98);
  border-color: #e2e8f0;
  box-shadow: 0 16px 42px rgba(15, 23, 42, 0.16);
  color: #0f172a;
}

.fc-lang-pop-head {
  padding: 12px 14px 10px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  display: block;
  flex: 0 0 auto;
}

[data-theme="light"] .fc-lang-pop-head {
  border-bottom-color: #e5e7eb;
}

.fc-lang-pop-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.fc-lang-pop-title {
  font-size: 13.5px;
  font-weight: 600;
  color: #f8fafc;
  display: flex;
  align-items: center;
}

.fc-lang-pop-title-ico {
  margin-right: 6px;
}

[data-theme="light"] .fc-lang-pop-title {
  color: #0f172a;
}

.fc-lang-pop-close {
  width: 24px;
  height: 24px;
  margin-left: 8px;
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.05);
  color: #cbd5e1;
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  flex: 0 0 auto;
}

.fc-lang-pop-close:hover {
  background: rgba(255, 255, 255, 0.14);
  color: #ffffff;
}

[data-theme="light"] .fc-lang-pop-close {
  border-color: #d1d5db;
  background: #f8fafc;
  color: #475569;
}

[data-theme="light"] .fc-lang-pop-close:hover {
  background: #e2e8f0;
  color: #0f172a;
}

.fc-lang-search {
  width: 100%;
  height: 34px;
  padding: 0 11px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.06);
  color: #f8fafc;
  font-size: 12.5px;
  outline: none;
  box-sizing: border-box;
}

.fc-lang-search:focus {
  border-color: rgba(249, 115, 22, 0.7);
  background: rgba(255, 255, 255, 0.09);
}

[data-theme="light"] .fc-lang-search {
  border-color: #cbd5e1;
  background: #f8fafc;
  color: #0f172a;
}

[data-theme="light"] .fc-lang-search:focus {
  border-color: #f97316;
  background: #ffffff;
}

.fc-lang-pop-body {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 10px 14px 12px;
}

.fc-lang-section {
  margin-bottom: 12px;
}

.fc-lang-section:last-child {
  margin-bottom: 0;
}

.fc-lang-section-title {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #94a3b8;
  margin-bottom: 7px;
  padding-left: 2px;
}

[data-theme="light"] .fc-lang-section-title {
  color: #64748b;
}

.fc-lang-grid {
  display: flex;
  flex-wrap: wrap;
  margin: -3px;
}

.fc-lang-cell {
  width: 50%;
  padding: 3px;
  box-sizing: border-box;
}

.fc-lang-item {
  display: flex;
  align-items: center;
  padding: 7px 9px;
  border-radius: 9px;
  border: 1px solid rgba(255, 255, 255, 0.07);
  background: rgba(255, 255, 255, 0.03);
  color: #e2e8f0;
  cursor: pointer;
  text-align: left;
  transition: background 0.14s ease, border-color 0.14s ease;
  box-sizing: border-box;
  width: 100%;
  min-width: 0;
}

.fc-lang-item:hover {
  background: rgba(249, 115, 22, 0.12);
  border-color: rgba(249, 115, 22, 0.42);
}

.fc-lang-item.active {
  background: rgba(249, 115, 22, 0.2);
  border-color: rgba(249, 115, 22, 0.85);
  color: #ffffff;
}

[data-theme="light"] .fc-lang-item {
  border-color: #e2e8f0;
  background: #f8fafc;
  color: #1e293b;
}

[data-theme="light"] .fc-lang-item:hover {
  background: #fff7ed;
  border-color: #fb923c;
}

[data-theme="light"] .fc-lang-item.active {
  background: #ffedd5;
  border-color: #f97316;
  color: #9a3412;
}

.fc-lang-item-flag {
  font-size: 16px;
  line-height: 1;
  flex: 0 0 auto;
  margin-right: 8px;
}

.fc-lang-item-meta {
  display: flex;
  flex-direction: column;
  min-width: 0;
  flex: 1 1 auto;
}

.fc-lang-item-native {
  font-size: 12.5px;
  font-weight: 600;
  line-height: 1.25;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.fc-lang-item-sub {
  font-size: 10.5px;
  color: #94a3b8;
  line-height: 1.2;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

[data-theme="light"] .fc-lang-item-sub {
  color: #64748b;
}

.fc-lang-item-check {
  font-size: 12px;
  color: #fb923c;
  font-weight: 700;
  flex: 0 0 auto;
  margin-left: 6px;
}

.fc-lang-empty {
  text-align: center;
  padding: 22px 10px;
  font-size: 12.5px;
  color: #94a3b8;
}

.fc-lang-pop-foot {
  padding: 8px 14px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  font-size: 11px;
  color: #94a3b8;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex: 0 0 auto;
}

[data-theme="light"] .fc-lang-pop-foot {
  border-top-color: #e5e7eb;
  color: #64748b;
}

.fc-lang-toast {
  position: fixed;
  left: 50%;
  bottom: 36px;
  transform: translateX(-50%);
  z-index: 2147483645;
  padding: 8px 16px;
  border-radius: 10px;
  font-size: 12.5px;
  color: #ffffff;
  background: rgba(18, 22, 32, 0.95);
  border: 1px solid rgba(249, 115, 22, 0.65);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s ease;
}

.fc-lang-toast.show {
  opacity: 1;
}

@media (max-width: 560px) {
  .fc-lang-cell {
    width: 100%;
  }
  .fc-lang-host {
    top: 12px;
    right: 12px;
  }
}
