/* TTS Widget — KhoSachQuy Academic Theme */
.tts-widget {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  padding: 12px 16px;
  background: #f8f6f2;
  border: 1px solid #e8e4dc;
  border-radius: 8px;
  margin: 24px 0;
  font-size: 13px;
  font-family: 'Inter', 'Be Vietnam Pro', sans-serif;
}

.tts-widget-icon {
  color: #c9a84c;
  font-size: 16px;
  flex-shrink: 0;
}

.tts-widget-label {
  font-size: 12px;
  color: #6b6b6b;
  flex-shrink: 0;
  font-weight: 500;
}

.tts-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border: 1.5px solid #1a1a2e;
  border-radius: 6px;
  background: transparent;
  color: #1a1a2e;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  transition: all 0.2s;
  white-space: nowrap;
}

.tts-btn:hover {
  background: #1a1a2e;
  color: #fff;
}

#tts-play-btn[style*="c9a84c"],
.tts-btn.tts-active {
  background: #c9a84c;
  border-color: #c9a84c;
  color: #fff !important;
}

#tts-pause-btn {
  display: none;
  border-color: #6b6b6b;
  color: #6b6b6b;
}

#tts-pause-btn:hover {
  background: #6b6b6b;
  color: #fff;
}

.tts-rate-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-left: 4px;
}

.tts-rate-wrap label {
  font-size: 12px;
  color: #6b6b6b;
}

.tts-rate-wrap select {
  padding: 5px 8px;
  border: 1px solid #e8e4dc;
  border-radius: 5px;
  font-size: 12px;
  background: #fff;
  cursor: pointer;
  color: #2d2d2d;
  outline: none;
}

.tts-rate-wrap select:focus {
  border-color: #c9a84c;
}

/* Voice selector */
.tts-voice-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  width: 100%;
}

.tts-voice-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 1;
  min-width: 200px;
}

.tts-voice-wrap label {
  font-size: 12px;
  color: #6b6b6b;
  white-space: nowrap;
}

#tts-voice {
  flex: 1;
  min-width: 160px;
  max-width: 340px;
  padding: 5px 8px;
  border: 1px solid #e8e4dc;
  border-radius: 5px;
  font-size: 12px;
  background: #fff;
  cursor: pointer;
  color: #2d2d2d;
  outline: none;
}

#tts-voice:focus {
  border-color: #c9a84c;
}

#tts-voice:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.tts-quality-badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}

.tts-quality-excellent {
  background: #e8f5e9;
  color: #2e7d32;
  border: 1px solid #a5d6a7;
}

.tts-quality-good {
  background: #fff8e1;
  color: #8a6d1a;
  border: 1px solid #e8d5a3;
}

.tts-quality-fair {
  background: #e3f2fd;
  color: #1565c0;
  border: 1px solid #90caf9;
}

.tts-quality-basic {
  background: #f5f5f5;
  color: #757575;
  border: 1px solid #e0e0e0;
}

.tts-btn-sm {
  padding: 5px 10px !important;
  font-size: 12px !important;
}

#tts-voice-hint {
  width: 100%;
  font-size: 11px;
  color: #6b6b6b;
  line-height: 1.5;
  margin-top: 2px;
}

.tts-hint-browser {
  color: #1a1a2e;
  font-weight: 500;
}

.tts-hint-reason {
  color: #8a6d1a;
}

.tts-hint-warn {
  color: #c0392b;
}

#tts-status {
  font-size: 12px;
  color: #c9a84c;
  font-style: italic;
  min-width: 80px;
}

#tts-progress-wrap {
  display: none;
  width: 100%;
  height: 3px;
  background: #e8e4dc;
  border-radius: 2px;
  overflow: hidden;
  margin-top: 4px;
}

#tts-progress-bar {
  height: 100%;
  background: linear-gradient(90deg, #1a1a2e, #c9a84c);
  border-radius: 2px;
  transition: width 0.3s ease;
  width: 0%;
}

@media (max-width: 480px) {
  .tts-widget { padding: 10px 12px; gap: 8px; }
  .tts-btn { padding: 6px 12px; font-size: 12px; }
  .tts-widget-label { display: none; }
  #tts-voice { max-width: 100%; }
  .tts-voice-row { flex-direction: column; align-items: stretch; }
}
