/* Premium chat — voice indicator, attach chips */
.chat-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}
.chat-input-row {
  display: flex;
  align-items: stretch;
  gap: 0.5rem;
}
.chat-input-row input[type="text"] {
  flex: 1;
  min-width: 0;
}

/* Public chat — thanh nhập + mic cùng một hàng ngang */
.chat-compose-bar {
  display: flex;
  align-items: stretch;
  gap: 0.5rem;
}
.chat-compose-bar .chat-compose-input {
  flex: 1;
  min-width: 0;
  padding: 0.625rem 0.875rem;
  border: 1px solid #d1d5db;
  border-radius: 0.5rem;
  font-size: 1rem;
}
.chat-compose-bar .chat-voice-inline {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-shrink: 0;
  font-size: 0.75rem;
  color: #6b7280;
}
.chat-compose-bar:not(.voice-mode-active) .chat-voice-inline #voiceStatus:empty {
  display: none;
}
.chat-compose-bar.voice-mode-active .chat-compose-attach,
.chat-compose-bar.voice-mode-active .chat-compose-input,
.chat-compose-bar.voice-mode-active .chat-compose-send {
  display: none !important;
}
.chat-compose-bar.voice-mode-active .chat-voice-inline {
  flex: 1;
  justify-content: center;
  min-height: 2.75rem;
  padding: 0 0.75rem;
  border: 1px solid rgba(99, 102, 241, 0.28);
  border-radius: 0.5rem;
  background: rgba(99, 102, 241, 0.06);
  gap: 0.6rem;
}
.chat-compose-bar.voice-mode-active #voiceStatus {
  font-weight: 600;
  font-size: 0.875rem;
  color: #374151;
  white-space: nowrap;
}
.chat-compose-bar.voice-mode-active #voiceDot.voice-green,
.chat-compose-bar.voice-mode-active #voiceDot.voice-red {
  width: 0.75rem !important;
  height: 0.75rem !important;
}

.chat-icon-btn {
  flex-shrink: 0;
  width: 2.75rem;
  height: 2.75rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 0.5rem;
  border: 1px solid #d1d5db;
  background: #fff;
  cursor: pointer;
  font-size: 1.15rem;
  transition: background 0.15s, border-color 0.15s;
}
.chat-icon-btn:hover { background: #f3f4f6; }
.chat-icon-btn.voice-on {
  border-color: #10b981;
  background: #ecfdf5;
}
#voiceWrap {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.75rem;
  color: #6b7280;
  min-width: 0;
}
#voiceDot,
[id$="VoiceDot"] {
  display: inline-block;
  flex-shrink: 0;
  width: 0;
  height: 0;
  opacity: 0;
  overflow: hidden;
  border-radius: 50%;
  background: #9ca3af;
  transition: opacity 0.15s;
}
#voiceDot.voice-green,
#voiceDot.voice-red,
[id$="VoiceDot"].voice-green,
[id$="VoiceDot"].voice-red {
  width: 0.65rem;
  height: 0.65rem;
  opacity: 1;
}
[id$="VoiceDot"].voice-green,
[id$="VoiceDot"].voice-red {
  width: 0.5rem;
  height: 0.5rem;
}
#voiceDot.voice-green,
[id$="VoiceDot"].voice-green {
  background: #22c55e;
  box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.6);
  animation: voicePulseGreen 1.4s infinite;
}
#voiceDot.voice-red,
[id$="VoiceDot"].voice-red {
  background: #ef4444;
  box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.55);
  animation: voicePulseRed 0.9s infinite;
}
#voiceDot.voice-idle,
[id$="VoiceDot"].voice-idle { opacity: 0; width: 0; height: 0; animation: none; }

/* Mic mode — ẩn input, chỉ hiện trạng thái */
.chat-input-row.voice-input-hidden,
.chat-input-bar.voice-input-hidden {
  display: none !important;
}
.chat-voice-panel {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.75rem;
  color: #6b7280;
  min-width: 0;
}
.chat-voice-panel.voice-mode-active {
  flex: 1;
  justify-content: center;
  padding: 0.75rem 1rem;
  margin: 0.25rem 0;
  border-radius: 0.75rem;
  background: rgba(99, 102, 241, 0.06);
  border: 1px solid rgba(99, 102, 241, 0.2);
  font-size: 0.9rem;
  gap: 0.65rem;
  flex-wrap: wrap;
}
.voice-action-btn.hidden { display: none !important; }
.voice-action-btn:not(.hidden) { display: inline-flex; align-items: center; }
.chat-voice-panel.voice-mode-active #voiceDot,
.chat-voice-panel.voice-mode-active [id$="VoiceDot"] {
  width: 0.85rem !important;
  height: 0.85rem !important;
}
.chat-voice-panel.voice-mode-active #voiceStatus,
.chat-voice-panel.voice-mode-active [id$="VoiceStatus"] {
  font-weight: 600;
  min-width: 6rem;
}
.theme-dark .chat-voice-panel.voice-mode-active {
  background: rgba(99, 102, 241, 0.12);
  border-color: rgba(129, 140, 248, 0.35);
  color: #e2e8f0;
}
@keyframes voicePulseGreen {
  0% { box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.55); }
  70% { box-shadow: 0 0 0 8px rgba(34, 197, 94, 0); }
  100% { box-shadow: 0 0 0 0 rgba(34, 197, 94, 0); }
}
@keyframes voicePulseRed {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.45; }
}
#attachChips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-bottom: 0.5rem;
  min-height: 0;
}
.attach-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  font-size: 0.75rem;
  padding: 0.2rem 0.5rem;
  background: #eef2ff;
  color: #4338ca;
  border-radius: 9999px;
}
.attach-chip-uploading { opacity: 0.7; }
.attach-remove {
  border: none;
  background: transparent;
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
  color: #6366f1;
  padding: 0 0.15rem;
}
#chatToast {
  position: fixed;
  bottom: 1.5rem;
  left: 50%;
  transform: translateX(-50%) translateY(120%);
  background: #1e293b;
  color: #fff;
  padding: 0;
  border-radius: 0.5rem;
  font-size: 0.875rem;
  z-index: 100;
  transition: transform 0.25s;
  pointer-events: none;
  min-width: 0;
  min-height: 0;
}
#chatToast:empty { display: none; }
#chatToast.show {
  display: block;
  padding: 0.6rem 1rem;
  transform: translateX(-50%) translateY(0);
  pointer-events: auto;
}
.locale-select {
  padding: 0.25rem 0.5rem;
  border-radius: 0.375rem;
  border: 1px solid #d1d5db;
  font-size: 0.75rem;
  background: #fff;
}
.lang-badges { margin: 0.25rem 0; }
.lang-badge {
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  background: rgba(99, 102, 241, 0.08);
  border: 1px solid rgba(99, 102, 241, 0.25);
  color: #4b5563;
}
.lang-badge b { font-weight: 600; color: #4338ca; }

/* Bubble sublines — sửa chính tả / dịch */
.chat-bubble-wrap {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  max-width: 100%;
  margin-bottom: 0.35rem;
}
.chat-bubble-wrap-ai { align-items: flex-start; }
.chat-bubble-wrap.theme-light.chat-bubble-wrap-user { align-items: flex-end; }
.chat-bubble-wrap.theme-light.chat-bubble-wrap-ai { align-items: flex-start; }
.chat-bubble-wrap.theme-light.chat-bubble-wrap-user { margin-left: auto; max-width: 88%; }
.chat-bubble-wrap.theme-light.chat-bubble-wrap-ai { margin-right: auto; max-width: 88%; }
.chat-subline {
  font-size: 0.68rem;
  color: #9ca3af;
  font-style: italic;
  line-height: 1.4;
  margin-top: 0.2rem;
  padding: 0 0.25rem;
  max-width: 92%;
}
.chat-bubble-wrap-ai .chat-subline { align-self: flex-start; }
.chat-subline-link {
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 2px;
}
.chat-subline-link:hover { color: #6366f1; }
.chat-subline-speak {
  border: none;
  background: none;
  cursor: pointer;
  font-size: 0.65rem;
  margin-left: 0.25rem;
  opacity: 0.75;
}
.chat-subline-speak:hover { opacity: 1; }
.chat-subline-original {
  color: #ca8a04;
  font-style: italic;
  font-size: 0.68rem;
}
.theme-dark .chat-subline-original { color: #fbbf24; }
.chat-compose-btn.chat-compose-active {
  background: rgba(99, 102, 241, 0.2);
  box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.45);
}
.chat-compose-pop button { font-size: 0.8125rem; }
.chat-selection-tr-pop {
  position: fixed;
  z-index: 520;
  max-width: 280px;
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0,0,0,.12);
  padding: 0.5rem 0.65rem;
  font-size: 0.75rem;
  line-height: 1.45;
  color: #374151;
}
.chat-selection-tr-pop.hidden { display: none; }
.chat-ctx-hint { max-width: 200px; }
.chat-ctx-menu {
  position: fixed;
  z-index: 500;
  min-width: 168px;
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0,0,0,.12);
  padding: 0.25rem;
  max-height: 280px;
  overflow-y: auto;
}
.chat-ctx-menu.hidden { display: none; }
.chat-ctx-menu button {
  display: block;
  width: 100%;
  text-align: left;
  padding: 0.4rem 0.65rem;
  font-size: 0.75rem;
  border: none;
  background: none;
  cursor: pointer;
  border-radius: 4px;
  color: #374151;
}
.chat-ctx-menu button:hover:not(:disabled) { background: #f3f4f6; }
.chat-ctx-menu button:disabled { opacity: 0.45; cursor: default; }

/* Admin dark theme */
.theme-dark .chat-subline { color: #94a3b8; }
.theme-dark .chat-subline-link:hover { color: #a5b4fc; }
.theme-dark .chat-ctx-menu {
  background: #1e293b;
  border-color: #475569;
}
.theme-dark .chat-ctx-menu button { color: #e2e8f0; }
.theme-dark .chat-ctx-menu button:hover:not(:disabled) { background: #334155; }

/* Bot avatar — logosale.png */
.lila-bot-avatar {
  width: 2rem;
  height: 2rem;
  object-fit: contain;
  border-radius: 50%;
  flex-shrink: 0;
  background: #fff;
  padding: 2px;
}
.lila-bot-msg-head {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.35rem;
}
.lila-bot-msg-label { font-weight: 600; }
.lila-bot-message .lila-bot-msg-head { margin-bottom: 0.5rem; }
