/* ── Leksihjelp Content Script Styles ── */

/* ── TTS Floating Widget ── */
#lexi-tts-widget {
  position: fixed;
  z-index: 2147483647;
  display: none;
  flex-direction: column;
  gap: 8px;
  padding: 14px 16px;
  min-width: 300px;
  max-width: 420px;
  background: rgba(255, 255, 255, 0.78);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid rgba(255, 255, 255, 0.4);
  border-radius: 14px;
  box-shadow: 0 8px 40px rgba(0, 0, 0, 0.12), 0 2px 8px rgba(0, 0, 0, 0.06);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 13px;
  color: #1e293b;
  max-height: 70vh;
  overflow-y: auto;
  scroll-behavior: smooth;
  transition: opacity 0.2s, transform 0.2s;
  /* Position at bottom center */
  left: 50% !important;
  transform: translateX(-50%);
  bottom: 24px !important;
  top: auto !important;
}

#lexi-tts-widget.visible {
  display: flex;
  animation: lexi-fadein 0.2s ease-out;
}

@keyframes lexi-fadein {
  from { opacity: 0; transform: translateX(-50%) translateY(10px) scale(0.97); }
  to   { opacity: 1; transform: translateX(-50%) translateY(0) scale(1); }
}

/* ── Language Toggle ── */
#lexi-tts-widget .lh-lang-toggle {
  display: flex;
  gap: 4px;
  margin-bottom: 4px;
}

#lexi-tts-widget .lh-lang-btn {
  flex: 1;
  padding: 6px 10px;
  border: 1px solid rgba(0, 0, 0, 0.08);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.5);
  font-size: 11px;
  font-weight: 500;
  color: #64748b;
  cursor: pointer;
  transition: all 0.15s;
}

#lexi-tts-widget .lh-lang-btn:hover {
  background: rgba(99, 102, 241, 0.05);
}

#lexi-tts-widget .lh-lang-btn.active {
  background: #6366f1;
  color: white;
  border-color: #6366f1;
}

#lexi-tts-widget .lh-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: grab;
  user-select: none;
  -webkit-user-select: none;
}

#lexi-tts-widget .lh-header:active {
  cursor: grabbing;
}

#lexi-tts-widget.dragged {
  left: auto !important;
  bottom: auto !important;
  transform: none !important;
  animation: none !important;
}

#lexi-tts-widget .lh-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #6366f1;
}

#lexi-tts-widget .lh-close {
  background: none;
  border: none;
  font-size: 16px;
  color: #94a3b8;
  cursor: pointer;
  padding: 0 2px;
  line-height: 1;
}
#lexi-tts-widget .lh-close:hover {
  color: #1e293b;
}

/* ── Text area with font controls ── */
#lexi-tts-widget .lh-text-area-wrapper {
  position: relative;
  display: flex;
  flex-direction: column;
}

#lexi-tts-widget .lh-font-controls {
  position: absolute;
  top: 4px;
  right: 4px;
  display: flex;
  gap: 2px;
  z-index: 1;
}

#lexi-tts-widget .lh-font-btn {
  width: 24px;
  height: 24px;
  border: 1px solid rgba(0, 0, 0, 0.08);
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.7);
  font-size: 11px;
  font-weight: 600;
  color: #64748b;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
  padding: 0;
  line-height: 1;
}

#lexi-tts-widget .lh-font-btn:hover {
  background: rgba(99, 102, 241, 0.1);
  color: #6366f1;
}

#lexi-tts-widget .lh-text-area {
  font-size: 15px;
  color: #1e293b;
  line-height: 1.6;
  min-height: 40px;
  padding: 8px 10px;
  padding-right: 56px;
  border: 1px solid rgba(0, 0, 0, 0.06);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.4);
  white-space: pre-wrap;
  word-break: break-word;
}


#lexi-tts-widget::-webkit-scrollbar {
  width: 4px;
}
#lexi-tts-widget::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, 0.1);
  border-radius: 2px;
}

/* ── Word highlighting in text area ── */
#lexi-tts-widget .lh-word {
  border-radius: 2px;
  transition: background 0.15s ease, color 0.15s ease;
}

#lexi-tts-widget .lh-word-active {
  background: rgba(99, 102, 241, 0.25);
  color: #4338ca;
  border-radius: 3px;
  box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.15);
}

#lexi-tts-widget .lh-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}

#lexi-tts-widget .lh-play-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: none;
  background: #6366f1;
  color: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.15s;
}
#lexi-tts-widget .lh-play-btn:hover {
  background: #4f46e5;
}
#lexi-tts-widget .lh-play-btn:disabled {
  background: #94a3b8;
  cursor: default;
}
#lexi-tts-widget .lh-play-btn.loading {
  background: #a5b4fc;
}

#lexi-tts-widget .lh-slider-group {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

#lexi-tts-widget .lh-slider-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

#lexi-tts-widget .lh-slider-label {
  font-size: 10px;
  color: #94a3b8;
  min-width: 52px;
  font-weight: 500;
}

#lexi-tts-widget .lh-slider {
  flex: 1;
  -webkit-appearance: none;
  appearance: none;
  height: 4px;
  border-radius: 2px;
  background: #e2e8f0;
  outline: none;
}
#lexi-tts-widget .lh-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #6366f1;
  cursor: pointer;
  border: 2px solid white;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.15);
}

#lexi-tts-widget .lh-voice-select {
  width: 100%;
  padding: 6px 8px;
  border: 1px solid rgba(0, 0, 0, 0.08);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.5);
  font-size: 12px;
  color: #1e293b;
  outline: none;
  cursor: pointer;
}
#lexi-tts-widget .lh-voice-select:focus {
  border-color: #6366f1;
}

#lexi-tts-widget .lh-mode-badge {
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 4px;
  background: rgba(99, 102, 241, 0.1);
  color: #6366f1;
  font-weight: 500;
  text-align: center;
}

/* ── Word Prediction Dropdown ── */
#lexi-prediction-dropdown {
  position: fixed;
  z-index: 2147483646;
  display: none;
  min-width: 180px;
  max-width: 300px;
  max-height: 200px;
  overflow-y: auto;
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid rgba(255, 255, 255, 0.4);
  border-radius: 10px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  padding: 4px;
}

#lexi-prediction-dropdown.visible {
  display: block;
  animation: lexi-fadein 0.15s ease-out;
}

#lexi-prediction-dropdown .lh-pred-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 7px 10px;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.1s;
  gap: 8px;
}
#lexi-prediction-dropdown .lh-pred-item:hover,
#lexi-prediction-dropdown .lh-pred-item.selected {
  background: rgba(99, 102, 241, 0.1);
}

#lexi-prediction-dropdown .lh-pred-word {
  font-size: 13px;
  font-weight: 600;
  color: #1e293b;
}

#lexi-prediction-dropdown .lh-pred-translation {
  font-size: 11px;
  color: #94a3b8;
  text-align: right;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 120px;
}

#lexi-prediction-dropdown .lh-pred-hint {
  font-size: 10px;
  color: #cbd5e1;
  text-align: center;
  padding: 3px 6px;
  border-top: 1px solid rgba(0, 0, 0, 0.04);
}

/* Scrollbar for dropdown */
#lexi-prediction-dropdown::-webkit-scrollbar {
  width: 4px;
}
#lexi-prediction-dropdown::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, 0.1);
  border-radius: 2px;
}
