/* ==========================================
   Google Translate Widget Styles - Fixed
   ========================================== */

/*
  1) Hide default Google widget visually but keep it in DOM for functionality
  2) Provide custom floating button and modal (scrollable) UI
  3) Suppress Google's default dropdown/iframe UI
*/

/* Hide default widget but keep accessible for our script */
#google_translate_element {
  position: fixed !important;
  bottom: 0 !important;
  right: 0 !important;
  width: 1px !important;
  height: 1px !important;
  opacity: 0 !important;
  pointer-events: none !important;
  z-index: -1 !important;
}

/* Do not let Google's own dropdown render on top */
.VIpgJd-ZVi9od-xl07Ob-OEVmcd.skiptranslate,
iframe.goog-te-menu-frame {
  display: none !important;
}

/* Floating button */
.pe-gt-btn {
  position: fixed !important;
  bottom: 16px !important;
  right: 16px !important;
  z-index: 10000 !important;
  display: inline-flex !important;
  align-items: center !important;
  gap: 8px !important;
  padding: 8px 12px !important;
  border: none !important;
  border-radius: 9999px !important;
  background: #ffffff !important;
  color: #111827 !important;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12) !important;
  cursor: pointer !important;
  font-family: 'Charlie', -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', sans-serif !important;
  overflow: visible !important;
}

.pe-gt-btn:hover {
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.16) !important;
}

.pe-gt-btn:active .pe-gt-label,
.pe-gt-btn.active .pe-gt-label {
  font-weight: 700 !important;
}

.pe-gt-label {
  font-size: 13px !important;
  font-weight: 600 !important;
}

.pe-gt-icon {
  width: 18px !important;
  height: 18px !important;
  display: inline-block !important;
}

/* Loading state for the button */
.pe-gt-btn.loading { opacity: 0.95; pointer-events: none; }
.pe-gt-btn .pe-gt-spinner { display: none; width: 14px; height: 14px; border: 2px solid #D1D5DB; border-top-color: #5A8902; border-radius: 50%; animation: pe-spin 0.8s linear infinite; }
.pe-gt-btn.loading .pe-gt-spinner { display: inline-block; }
.pe-gt-btn.loading .pe-gt-icon { display: none; }
.pe-gt-btn.loading .pe-gt-label { font-weight: 700 !important; }

@keyframes pe-spin { to { transform: rotate(360deg); } }

/* Translating pulsing ring */
.pe-gt-btn.translating { position: fixed !important; }
.pe-gt-btn.translating::after {
  content: "";
  position: absolute;
  inset: -6px;
  border-radius: 9999px;
  border: 2px solid rgba(90,137,2,0.35);
  animation: pe-pulse 1.2s ease-out infinite;
  pointer-events: none;
}

@keyframes pe-pulse {
  0% { transform: scale(1); opacity: 0.75; }
  100% { transform: scale(1.25); opacity: 0; }
}

/* Top progress bar */
#pe-gt-progress {
  position: fixed;
  top: 0;
  left: 0;
  width: 0%;
  height: 3px;
  background: linear-gradient(90deg, #5A8902, #7FB50A);
  z-index: 20000;
  transition: width 0.2s ease, opacity 0.3s ease;
  box-shadow: 0 1px 4px rgba(0,0,0,0.2);
  opacity: 0;
}

#pe-gt-progress.active { opacity: 1; }

/* Modal */
.pe-gt-overlay {
  position: fixed !important;
  inset: 0 !important;
  background: rgba(0, 0, 0, 0.45) !important;
  z-index: 10001 !important;
  display: none !important;
  align-items: center !important;
  justify-content: center !important;
}

.pe-gt-overlay.open { display: flex !important; }

.pe-gt-modal {
  width: min(92vw, 680px) !important;
  max-height: min(86vh, 860px) !important;
  background: #ffffff !important;
  border-radius: 14px !important;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.28) !important;
  display: flex !important;
  flex-direction: column !important;
  overflow: hidden !important;
}

.pe-gt-header {
  display: flex !important;
  align-items: center !important;
  justify-content: space-between !important;
  padding: 12px 16px !important;
  border-bottom: 1px solid #F3F4F6 !important;
}

.pe-gt-title { display: inline-flex !important; align-items: center !important; gap: 8px !important; }

.pe-gt-close {
  background: transparent !important;
  border: none !important;
  font-size: 20px !important;
  line-height: 1 !important;
  cursor: pointer !important;
  color: #111827 !important;
}

.pe-gt-content { padding: 10px 12px 12px !important; overflow: hidden !important; }

/* Search bar */
.pe-gt-search-wrap {
  position: sticky;
  top: 0;
  background: #ffffff;
  z-index: 2;
  padding: 8px 0 10px;
  border-bottom: 1px solid #F3F4F6;
  display: grid;
  grid-template-columns: 1fr;
  align-items: center;
  position: relative;
}

.pe-gt-search {
  width: 100%;
  border: 1px solid #E5E7EB;
  border-radius: 10px;
  padding: 10px 40px 10px 12px; /* extra right padding for clear button */
  font-size: 14px;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.pe-gt-search:focus {
  border-color: #5A8902;
  box-shadow: 0 0 0 3px rgba(90, 137, 2, 0.15);
}

.pe-gt-clear {
  display: none;
  position: absolute;
  right: 14px;
  top: 50%;
  transform: translateY(-50%);
  width: 24px;
  height: 24px;
  border-radius: 9999px;
  border: none;
  background: #E5E7EB;
  color: #111827;
  cursor: pointer;
}

.pe-gt-clear:hover {
  background: #d6dae1;
}

.pe-gt-list {
  display: grid !important;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)) !important;
  gap: 8px !important;
  max-height: 70vh !important;
  overflow-y: auto !important;
  padding-right: 6px !important;
}

.pe-gt-empty {
  grid-column: 1 / -1;
  color: #6B7280;
  padding: 12px;
  text-align: center;
}

.pe-gt-item {
  background: #ffffff !important;
  border: 1px solid #E5E7EB !important;
  border-radius: 10px !important;
  padding: 8px 10px !important;
  text-align: left !important;
  font-size: 13px !important;
  color: #111827 !important;
  cursor: pointer !important;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease !important;
}

.pe-gt-item:hover {
  background: #F0F9E8 !important;
  color: #5A8902 !important;
  border-color: #5A8902 !important;
}

/* Highlight matched query */
.pe-gt-mark { background: #F0F9E8; color: #1f2937; border-radius: 3px; padding: 0 2px; }

.pe-gt-loading { padding: 24px; color: #6B7280; }

/* Scrollbar styling */
.pe-gt-list::-webkit-scrollbar { width: 10px; }
.pe-gt-list::-webkit-scrollbar-track { background: #F3F4F6; border-radius: 8px; }
.pe-gt-list::-webkit-scrollbar-thumb { background: #5A8902; border-radius: 8px; }
.pe-gt-list::-webkit-scrollbar-thumb:hover { background: #4a7002; }

/* Ensure default widget stays hidden (override old rules) */
#google_translate_element {
  position: fixed !important;
  bottom: 0 !important;
  right: 0 !important;
  width: 1px !important;
  height: 1px !important;
  opacity: 0 !important;
  pointer-events: none !important;
  z-index: -1 !important;
}

/* Force Google icon to be visible */
.goog-te-gadget-icon {
  display: inline-block !important;
  margin-right: 6px !important;
  margin-left: 0 !important;
  vertical-align: middle !important;
  width: 16px !important;
  height: 16px !important;
  background-size: contain !important;
  opacity: 1 !important;
  visibility: visible !important;
}

/* Style the main gadget container */
.goog-te-gadget-simple {
  background: transparent !important;
  border: none !important;
  padding: 0 !important;
  display: inline-flex !important;
  align-items: center !important;
  gap: 4px !important;
  cursor: pointer !important;
  font-family: 'Charlie', -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', sans-serif !important;
}

/* Style the clickable link/button - make it compact */
.goog-te-gadget-simple a.goog-te-menu-value,
.goog-te-gadget-simple .goog-te-menu-value,
.VIpgJd-ZVi9od-xl07Ob-lTBxed {
  text-decoration: none !important;
  color: #1f2937 !important;
  font-size: 12px !important;
  font-weight: 600 !important;
  font-family: 'Charlie', -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', sans-serif !important;
  display: inline-flex !important;
  align-items: center !important;
  gap: 4px !important;
  padding: 4px 8px !important;
  border-radius: 6px !important;
  background: #ffffff !important;
  border: 1px solid #5A8902 !important;
  transition: all 0.15s ease !important;
  white-space: nowrap !important;
  min-width: 0 !important;
  height: auto !important;
  line-height: 1.2 !important;
}

.VIpgJd-ZVi9od-xl07Ob-lTBxed:hover {
  background: #F0F9E8 !important;
  border-color: #5A8902 !important;
}

/* Style the dropdown arrow */
.goog-te-gadget-simple span[aria-hidden="true"] {
  color: #5A8902 !important;
  font-size: 10px !important;
  font-weight: bold !important;
  margin-left: 2px !important;
}

/* Hide the original language text and replace with custom text */
.goog-te-gadget-simple span:not([aria-hidden="true"]) {
  position: relative !important;
  font-size: 0 !important;
  color: transparent !important;
  font-weight: 600 !important;
  font-family: 'Charlie', -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', sans-serif !important;
}

.goog-te-gadget-simple span:not([aria-hidden="true"])::after {
  content: "Translate";
  font-size: 12px !important;
  color: #1f2937 !important;
  letter-spacing: 0.01em;
  position: absolute;
  left: 0;
  top: 0;
}

/* Keep separator visible but subtle */
.goog-te-gadget-simple span[style*="border-left"] {
  display: none !important;
}

/* Suppress Google's default dropdown completely (we use our modal) */
.VIpgJd-ZVi9od-xl07Ob-OEVmcd.skiptranslate {
  display: none !important;
  visibility: hidden !important;
  opacity: 0 !important;
  width: 0 !important;
  height: 0 !important;
  overflow: hidden !important;
}

/* Force iframe body to be properly sized and scrollable */
.goog-te-menu2 {
  border: none !important;
  background: #ffffff !important;
  padding: 8px !important;
  max-height: 280px !important;
  height: 280px !important;
  overflow-y: auto !important;
  overflow-x: hidden !important;
  font-family: 'Charlie', -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', sans-serif !important;
}

/* Custom scrollbar for language list */
.goog-te-menu2::-webkit-scrollbar {
  width: 8px !important;
}

.goog-te-menu2::-webkit-scrollbar-track {
  background: #F3F4F6 !important;
  border-radius: 10px !important;
}

.goog-te-menu2::-webkit-scrollbar-thumb {
  background: #5A8902 !important;
  border-radius: 10px !important;
}

.goog-te-menu2::-webkit-scrollbar-thumb:hover {
  background: #4a7002 !important;
}

/* Style individual language items - make them compact */
.goog-te-menu2-item div,
.goog-te-menu2-item:link div,
.goog-te-menu2-item:visited div,
.goog-te-menu2-item:active div {
  color: #1f2937 !important;
  padding: 8px 10px !important;
  border-radius: 6px !important;
  font-family: 'Charlie', -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', sans-serif !important;
  font-size: 12px !important;
  font-weight: 500 !important;
  transition: all 0.15s ease !important;
  cursor: pointer !important;
  line-height: 1.3 !important;
  white-space: nowrap !important;
  overflow: hidden !important;
  text-overflow: ellipsis !important;
}

.goog-te-menu2-item:hover div {
  background: #F0F9E8 !important;
  color: #5A8902 !important;
  font-weight: 600 !important;
}

.goog-te-menu2-item-selected div {
  background: #5A8902 !important;
  color: white !important;
  font-weight: 700 !important;
}

/* Hide the Google Translate banner at the top of the page */
.goog-te-banner-frame.skiptranslate {
  display: none !important;
}

/* Prevent body shift when translate banner would appear */
body {
  top: 0 !important;
  position: static !important;
}

html.translated-ltr body {
  top: 0 !important;
  position: static !important;
}

html.translated-rtl body {
  top: 0 !important;
  position: static !important;
}

/* Style the select dropdown (if using simple layout) */
.goog-te-combo {
  background: #ffffff !important;
  border: 1px solid #5A8902 !important;
  border-radius: 8px !important;
  padding: 6px 28px 6px 12px !important;
  font-size: 13px !important;
  color: #1f2937 !important;
  font-family: 'Charlie', -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', sans-serif !important;
  font-weight: 600 !important;
  cursor: pointer !important;
  outline: none !important;
  transition: all 0.15s ease !important;
  appearance: none !important;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%235A8902' d='M6 9L2.5 4.5h7z'/%3E%3C/svg%3E") !important;
  background-repeat: no-repeat !important;
  background-position: right 10px center !important;
}

.goog-te-combo:hover {
  background-color: #F0F9E8 !important;
}

.goog-te-combo:focus {
  border-color: #5A8902 !important;
  background-color: white !important;
  box-shadow: 0 0 0 3px rgba(90, 137, 2, 0.2) !important;
}

/* Remove margins for combo when inside gadget */
.goog-te-gadget .goog-te-combo {
  margin: 0 !important;
}

/* Responsive adjustments for mobile */
@media (max-width: 768px) {
  #google_translate_element {
    bottom: 12px;
    right: 12px;
    padding: 5px 9px;
  }

  .VIpgJd-ZVi9od-xl07Ob-lTBxed {
    font-size: 12px !important;
    padding: 5px 9px !important;
  }

  .VIpgJd-ZVi9od-xl07Ob-OEVmcd.skiptranslate {
    width: 220px !important;
    height: 220px !important;
  }
  
  .goog-te-menu2-item div {
    font-size: 12px !important;
    padding: 8px 10px !important;
  }
}

/* Keep clear images visible if needed */
img[src*="cleardot.gif"] {
  display: inline-block !important;
}

/* Ensure smooth rendering */
.goog-te-gadget *,
.goog-te-menu2 * {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Do not render Google's iframe UI */
iframe.goog-te-menu-frame {
  display: none !important;
  visibility: hidden !important;
  opacity: 0 !important;
  width: 0 !important;
  height: 0 !important;
}

/* Ensure the menu stays hidden */
body .skiptranslate iframe {
  visibility: hidden !important;
  display: none !important;
}
