/* =========================================
   Auto Translate — Language Widget
   ========================================= */

:root {
  --at-bg:       #1a1a2e;
  --at-surface:  #16213e;
  --at-border:   rgba(255,255,255,0.08);
  --at-text:     #f0f0f0;
  --at-muted:    rgba(255,255,255,0.5);
  --at-accent:   #e2b96f;
  --at-hover:    rgba(226,185,111,0.1);
  --at-active:   rgba(226,185,111,0.18);
  --at-shadow:   0 8px 32px rgba(0,0,0,0.4), 0 2px 8px rgba(0,0,0,0.3);
  --at-radius:   14px;
  --at-btn-r:    10px;
  --at-z:        99999;
  --at-size:     46px;
  --at-font:     'Segoe UI', system-ui, -apple-system, sans-serif;
}

/* ── Wrapper ────────────────────────────── */
#at-widget {
  position: fixed;
  bottom: 28px;
  z-index: var(--at-z);
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
  font-family: var(--at-font);
  user-select: none;
}

#at-widget.at-bottom-right { right: 24px; align-items: flex-end; }
#at-widget.at-bottom-left  { left:  24px; align-items: flex-start; }

/* ── Toggle Button ──────────────────────── */
#at-toggle {
  display: flex;
  align-items: center;
  gap: 7px;
  height: var(--at-size);
  padding: 0 16px 0 12px;
  background: var(--at-bg);
  color: var(--at-text);
  border: 1px solid var(--at-border);
  border-radius: 100px;
  cursor: pointer;
  box-shadow: var(--at-shadow);
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.04em;
  transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.2s ease;
  outline: none;
  white-space: nowrap;
}

#at-toggle:hover {
  border-color: var(--at-accent);
  box-shadow: 0 10px 36px rgba(0,0,0,0.5), 0 0 0 1px var(--at-accent);
  transform: translateY(-1px);
}

#at-toggle:focus-visible {
  border-color: var(--at-accent);
  box-shadow: 0 0 0 3px rgba(226,185,111,0.35);
}

#at-toggle-flag {
  font-size: 18px;
  line-height: 1;
}

#at-toggle-label {
  color: var(--at-accent);
  font-size: 12px;
  letter-spacing: 0.08em;
}

.at-chevron {
  font-size: 9px;
  color: var(--at-muted);
  transition: transform 0.2s ease;
  margin-left: 2px;
}

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

/* ── Dropdown Menu ──────────────────────── */
#at-menu {
  display: flex;
  flex-direction: column;
  gap: 4px;
  background: var(--at-surface);
  border: 1px solid var(--at-border);
  border-radius: var(--at-radius);
  padding: 8px;
  box-shadow: var(--at-shadow);
  min-width: 130px;

  /* Hidden state */
  opacity: 0;
  transform: translateY(10px) scale(0.97);
  pointer-events: none;
  transition: opacity 0.18s ease, transform 0.18s cubic-bezier(0.34, 1.56, 0.64, 1);
  transform-origin: bottom center;
}

#at-widget.at-bottom-left #at-menu {
  transform-origin: bottom left;
}

#at-menu.at-open {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

/* ── Language Buttons ───────────────────── */
.at-lang-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 14px;
  border: 1px solid transparent;
  border-radius: var(--at-btn-r);
  background: transparent;
  color: var(--at-text);
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.03em;
  transition: background 0.12s ease, border-color 0.12s ease, color 0.12s ease;
  text-align: left;
  width: 100%;
  font-family: var(--at-font);
  outline: none;
}

.at-lang-btn:hover {
  background: var(--at-hover);
  border-color: var(--at-border);
}

.at-lang-btn.at-active {
  background: var(--at-active);
  border-color: rgba(226,185,111,0.3);
  color: var(--at-accent);
}

.at-lang-btn:focus-visible {
  border-color: var(--at-accent);
  box-shadow: 0 0 0 2px rgba(226,185,111,0.25);
}

.at-lang-btn span {
  font-size: 12px;
  letter-spacing: 0.06em;
  font-weight: 600;
}

/* Flag emoji size inside menu */
.at-lang-btn::before {
  font-size: 17px;
}

/* ── Loading Indicator ──────────────────── */
#at-loader {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  height: 28px;
  padding: 0 14px;
  background: var(--at-bg);
  border: 1px solid var(--at-border);
  border-radius: 100px;
  opacity: 0;
  transform: scale(0.9);
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
}

#at-loader.at-visible {
  opacity: 1;
  transform: scale(1);
}

#at-loader span {
  width: 5px;
  height: 5px;
  background: var(--at-accent);
  border-radius: 50%;
  animation: at-bounce 1.2s ease-in-out infinite;
}

#at-loader span:nth-child(2) { animation-delay: 0.2s; }
#at-loader span:nth-child(3) { animation-delay: 0.4s; }

@keyframes at-bounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
  30%            { transform: translateY(-5px); opacity: 1; }
}

/* ── Translating state (pulse toggle) ───── */
#at-widget.at-translating #at-toggle {
  border-color: rgba(226,185,111,0.4);
  animation: at-pulse 1.5s ease-in-out infinite;
}

@keyframes at-pulse {
  0%, 100% { box-shadow: var(--at-shadow); }
  50%       { box-shadow: 0 8px 32px rgba(0,0,0,0.4), 0 0 0 3px rgba(226,185,111,0.25); }
}

/* ── Mobile adjustments ─────────────────── */
@media (max-width: 480px) {
  #at-widget.at-bottom-right { right: 16px; bottom: 20px; }
  #at-widget.at-bottom-left  { left:  16px; bottom: 20px; }

  #at-toggle {
    height: 42px;
    padding: 0 14px 0 10px;
    font-size: 13px;
  }

  #at-menu {
    min-width: 120px;
  }
}

/* ── Accessibility: reduced motion ──────── */
@media (prefers-reduced-motion: reduce) {
  #at-loader span,
  #at-widget.at-translating #at-toggle {
    animation: none;
  }
  #at-menu,
  #at-toggle {
    transition: none;
  }
}
