/* EarthTeam LMS — Translate Widget (same base as styles/translate.css) */

/* Hide foundation elements (not shown to user) */
#google_translate_element,
.goog-te-gadget,
.goog-te-gadget-simple {
  display: none !important;
  visibility: hidden !important;
}

/* Hide Google Translate banner completely using pure CSS */
.skiptranslate,
.goog-te-banner-frame,
.goog-te-banner,
.VIpgJd-ZVi9od-ORHb-OEVmcd {
  display: none !important;
  visibility: hidden !important;
  height: 0 !important;
  width: 0 !important;
  position: absolute !important;
  top: -9999px !important;
  left: -9999px !important;
  opacity: 0 !important;
  overflow: hidden !important;
  transform: scale(0) !important;
  pointer-events: none !important;
}

/* Show dropdown menu when opened */
.goog-te-menu-frame {
  display: block !important;
  visibility: visible !important;
}

/* ── EarthTeam override: inline in navbar instead of fixed ── */
.translate-widget {
  position: relative;
  display: inline-block;
  z-index: 1000;
  align-self: center;
  margin-left: 15px;
  margin-right: 15px;
}

/* Prevent navbar from clipping the language menu */
#usernavigation {
  overflow: visible !important;
}

/* ── Translate Button ── */
.translate-button {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  border: none;
  padding: 12px 20px;
  border-radius: 50px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.3s ease;
  box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 160px;
  justify-content: center;
}

.translate-button:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 25px rgba(102, 126, 234, 0.5);
}

.translate-button:disabled {
  opacity: 0.7;
  cursor: not-allowed;
  transform: none;
}

.translate-spinner {
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-top: 2px solid white;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* ── Language Menu ── */
.language-menu {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  background: white;
  border-radius: 12px;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.15);
  border: 1px solid #e5e7eb;
  padding: 20px;
  min-width: 320px;
  max-width: 90vw;
  max-height: 70vh;
  overflow-y: auto;
  z-index: 1001;
}

.language-menu-header {
  font-size: 18px;
  font-weight: 600;
  color: #1f2937;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid #e5e7eb;
}

.language-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
  gap: 8px;
}

.language-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 12px 8px;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s ease;
  text-align: center;
  background: white;
}

.language-item:hover {
  background: #f0f9ff;
  border-color: #3b82f6;
  transform: translateY(-1px);
}

.language-flag {
  font-size: 24px;
  line-height: 1;
  transition: transform 0.2s ease;
}

.language-item:hover .language-flag {
  transform: scale(1.1);
}

.language-native-name {
  font-size: 11px;
  font-weight: 500;
  color: #1f2937;
  line-height: 1.2;
  margin-bottom: 2px;
  word-break: break-word;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.language-english-name {
  font-size: 10px;
  color: #6b7280;
  line-height: 1;
}

/* ── Click outside overlay ── */
.language-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 1000;
  background: transparent;
}

/* ── Dark mode ── */
@media (prefers-color-scheme: dark) {
  body.dark-mode .language-menu {
    background: #1f2937;
    border-color: #374151;
  }

  body.dark-mode .language-menu-header {
    color: #f9fafb;
    border-color: #374151;
  }

  body.dark-mode .language-item {
    background: #1f2937;
    border-color: #374151;
  }

  body.dark-mode .language-item:hover {
    background: #374151;
    border-color: #3b82f6;
  }

  body.dark-mode .language-native-name {
    color: #f9fafb;
  }

  body.dark-mode .language-english-name {
    color: #9ca3af;
  }
}

/* ── Responsive ── */
@media (max-width: 768px) {
  .translate-widget {
    margin-left: 8px;
    margin-right: 8px;
  }

  .translate-button {
    font-size: 12px;
    padding: 10px 16px;
    min-width: 140px;
  }

  .language-menu {
    min-width: 280px;
    max-width: 85vw;
    padding: 16px;
  }

  .language-grid {
    grid-template-columns: repeat(auto-fill, minmax(70px, 1fr));
    gap: 6px;
  }

  .language-item {
    padding: 10px 6px;
  }

  .language-flag {
    font-size: 20px;
  }

  .language-native-name {
    font-size: 10px;
  }

  .language-english-name {
    font-size: 9px;
  }
}

@media (max-width: 480px) {
  .translate-widget {
    margin-left: 4px;
    margin-right: 4px;
  }

  .language-menu {
    min-width: 260px;
    max-width: 80vw;
  }

  .language-grid {
    grid-template-columns: repeat(auto-fill, minmax(60px, 1fr));
  }
}

/* ── Animations ── */
.language-menu {
  animation: fadeInSlideDown 0.2s ease-out;
}

@keyframes fadeInSlideDown {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ── Scrollbar ── */
.language-menu::-webkit-scrollbar {
  width: 6px;
}

.language-menu::-webkit-scrollbar-track {
  background: #f1f5f9;
  border-radius: 3px;
}

.language-menu::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 3px;
}

.language-menu::-webkit-scrollbar-thumb:hover {
  background: #94a3b8;
}
