/* ============================================================
   AIVORYS Translate Widget — translate.css
   Version 1.0.0 | https://www.aivorys.com
   All styles are SCOPED to #aivtr-root — zero risk of
   affecting any existing website styles.
   ============================================================ */

/* ---- Variables ---- */
#aivtr-root {
  --aivtr-purple:     #7c3aed;
  --aivtr-pink:       #ec4899;
  --aivtr-gradient:   linear-gradient(135deg, #7c3aed 0%, #a855f7 50%, #ec4899 100%);
  --aivtr-bg:         #0d0d14;
  --aivtr-surface:    #16161f;
  --aivtr-surface2:   #1e1e2a;
  --aivtr-border:     rgba(255, 255, 255, 0.1);
  --aivtr-text:       #f0efff;
  --aivtr-muted:      #9b9ab8;
  --aivtr-faint:      #5a5970;
  --aivtr-success:    #4ade80;
  --aivtr-radius:     14px;
  --aivtr-shadow:     0 16px 48px rgba(0, 0, 0, 0.6), 0 0 0 1px rgba(255, 255, 255, 0.06);
  --aivtr-transition: 0.22s cubic-bezier(0.16, 1, 0.3, 1);

  /* Position — JS overrides these for bottom-right */
  --aivtr-bottom: 24px;
  --aivtr-left:   24px;
  --aivtr-right:  auto;

  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Inter', Roboto, sans-serif;
  font-size: 14px;
  line-height: 1.5;
}

/* ---- Scoped Reset ---- */
#aivtr-root *,
#aivtr-root *::before,
#aivtr-root *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}
#aivtr-root button    { cursor: pointer; background: none; border: none; font: inherit; color: inherit; }
#aivtr-root svg       { display: block; }

/* ============================================================
   TRIGGER BUTTON
   ============================================================ */
.aivtr-trigger {
  position: fixed;
  bottom: var(--aivtr-bottom);
  left: var(--aivtr-left);
  right: var(--aivtr-right);
  z-index: 99996; /* Below chatbot (99998) so they don't overlap */
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: var(--aivtr-gradient);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 18px rgba(124, 58, 237, 0.4), 0 2px 6px rgba(0, 0, 0, 0.3);
  transition: transform var(--aivtr-transition), box-shadow var(--aivtr-transition);
  will-change: transform;
}
.aivtr-trigger:hover {
  transform: scale(1.08) translateY(-2px);
  box-shadow: 0 8px 28px rgba(124, 58, 237, 0.6), 0 2px 6px rgba(0, 0, 0, 0.3);
}
.aivtr-trigger:active { transform: scale(0.95); }

/* Active language code label */
.aivtr-active-lang {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: white;
  line-height: 1;
}

/* ============================================================
   PANEL
   ============================================================ */
.aivtr-panel {
  position: fixed;
  bottom: calc(var(--aivtr-bottom) + 64px);
  left: var(--aivtr-left);
  right: var(--aivtr-right);
  z-index: 99997;
  width: 240px;
  border-radius: var(--aivtr-radius);
  background: var(--aivtr-bg);
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: var(--aivtr-shadow);
  overflow: hidden;

  /* Hidden state */
  opacity: 0;
  transform: translateY(10px) scale(0.97);
  pointer-events: none;
  transition: opacity var(--aivtr-transition), transform var(--aivtr-transition);
  transform-origin: bottom left;
}
.aivtr-panel.open {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: all;
}
/* Right-side variant */
.aivtr-panel.aivtr-right {
  transform-origin: bottom right;
}

/* ---- Panel Header ---- */
.aivtr-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px 10px;
  border-bottom: 1px solid var(--aivtr-border);
  background: var(--aivtr-gradient);
}
.aivtr-panel-title {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 700;
  color: white;
  letter-spacing: -0.01em;
}
.aivtr-close-btn {
  width: 24px;
  height: 24px;
  border-radius: 5px;
  color: rgba(255, 255, 255, 0.8);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background var(--aivtr-transition);
}
.aivtr-close-btn:hover {
  background: rgba(255, 255, 255, 0.2);
  color: white;
}

/* ---- Language list ---- */
.aivtr-lang-list {
  padding: 6px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.aivtr-lang-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 10px;
  border-radius: 9px;
  color: var(--aivtr-muted);
  transition: background var(--aivtr-transition), color var(--aivtr-transition);
  width: 100%;
  text-align: left;
  position: relative;
}
.aivtr-lang-btn:hover {
  background: var(--aivtr-surface2);
  color: var(--aivtr-text);
}
.aivtr-lang-btn.aivtr-lang-active {
  background: rgba(124, 58, 237, 0.15);
  color: var(--aivtr-text);
}
.aivtr-lang-btn:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}
.aivtr-flag {
  font-size: 18px;
  line-height: 1;
  flex-shrink: 0;
}
.aivtr-lang-name {
  flex: 1;
  font-size: 14px;
  font-weight: 500;
}
.aivtr-check {
  color: var(--aivtr-purple);
  transition: opacity var(--aivtr-transition);
  flex-shrink: 0;
}
.aivtr-lang-active .aivtr-check { opacity: 1 !important; }

/* Translating spinner inside button */
.aivtr-spinner {
  width: 14px;
  height: 14px;
  border: 2px solid rgba(124, 58, 237, 0.3);
  border-top-color: var(--aivtr-purple);
  border-radius: 50%;
  animation: aivtr-spin 0.7s linear infinite;
  flex-shrink: 0;
}
@keyframes aivtr-spin { to { transform: rotate(360deg); } }

/* ---- Progress bar ---- */
.aivtr-progress {
  height: 3px;
  background: var(--aivtr-surface2);
  display: none;
}
.aivtr-progress.visible { display: block; }
.aivtr-progress-bar {
  height: 100%;
  width: 0%;
  background: var(--aivtr-gradient);
  transition: width 0.4s ease;
  border-radius: 0 2px 2px 0;
}

/* ---- Footer status ---- */
.aivtr-panel-footer {
  padding: 8px 14px 10px;
  border-top: 1px solid var(--aivtr-border);
}
.aivtr-status {
  font-size: 11px;
  color: var(--aivtr-faint);
  display: block;
}
.aivtr-status.success { color: var(--aivtr-success); }
.aivtr-status.error   { color: #f87171; }

/* ============================================================
   PAGE TRANSLATION OVERLAY (shown while translating)
   ============================================================ */
.aivtr-translating-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.0);
  z-index: 99995;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.3s ease;
}
.aivtr-translating-overlay.active {
  pointer-events: all;
  opacity: 1;
}

/* Language indicator banner at top of page */
.aivtr-lang-banner {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 99994;
  background: var(--aivtr-gradient);
  color: white;
  font-size: 13px;
  font-weight: 500;
  padding: 8px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  box-shadow: 0 2px 12px rgba(0,0,0,0.3);
  transform: translateY(-100%);
  transition: transform var(--aivtr-transition);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}
.aivtr-lang-banner.visible {
  transform: translateY(0);
}
.aivtr-lang-banner-text { flex: 1; }
.aivtr-lang-banner-btn {
  padding: 4px 12px;
  border-radius: 20px;
  background: rgba(255,255,255,0.25);
  color: white;
  font-size: 12px;
  font-weight: 600;
  border: 1px solid rgba(255,255,255,0.35);
  cursor: pointer;
  transition: background 0.2s;
  white-space: nowrap;
  font-family: inherit;
}
.aivtr-lang-banner-btn:hover { background: rgba(255,255,255,0.4); }

/* ============================================================
   MOBILE
   ============================================================ */
@media (max-width: 480px) {
  .aivtr-trigger {
    width: 46px;
    height: 46px;
    bottom: 88px; /* Clear mobile nav bars */
  }
  .aivtr-panel {
    width: calc(100vw - 32px);
    left: 16px;
    right: 16px;
  }
}

/* ============================================================
   REDUCED MOTION
   ============================================================ */
@media (prefers-reduced-motion: reduce) {
  .aivtr-trigger, .aivtr-panel, .aivtr-lang-banner { transition: none; }
  .aivtr-spinner { animation: none; }
}
