/* Floating assistant — works on public site (Bootstrap 5) and admin (Vuexy / Bootstrap 4) */

.hms-assistant {
  position: fixed;
  z-index: 10050;
  bottom: 1.25rem;
  left: 1.25rem;
  font-family: system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  font-size: 14px;
  line-height: 1.45;
}

.hms-assistant__launcher {
  width: 3.25rem;
  height: 3.25rem;
  border-radius: 50%;
  border: none;
  background: linear-gradient(135deg, #6366f1 0%, #4f46e5 100%);
  color: #fff;
  box-shadow: 0 6px 24px rgba(79, 70, 229, 0.45);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.hms-assistant__launcher:hover {
  transform: scale(1.05);
  color: #fff;
}

.hms-assistant__panel {
  position: absolute;
  bottom: 4rem;
  left: 0;
  width: min(100vw - 2rem, 380px);
  max-height: min(70vh, 520px);
  display: flex;
  flex-direction: column;
  background: #fff;
  color: #1e293b;
  border-radius: 14px;
  box-shadow: 0 16px 48px rgba(15, 23, 42, 0.22);
  border: 1px solid rgba(15, 23, 42, 0.08);
  overflow: hidden;
}

.hms-assistant__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.85rem 1rem;
  background: linear-gradient(135deg, #312e81 0%, #1e1b4b 100%);
  color: #fff;
}

.hms-assistant__title {
  display: block;
  font-size: 1rem;
}

.hms-assistant__badge {
  font-size: 0.7rem;
  opacity: 0.9;
  margin-top: 0.2rem;
  letter-spacing: 0.02em;
}

.hms-assistant__close {
  background: transparent;
  border: none;
  color: #fff;
  font-size: 1.5rem;
  line-height: 1;
  padding: 0 0.25rem;
  cursor: pointer;
  opacity: 0.85;
}

.hms-assistant__close:hover {
  opacity: 1;
}

.hms-assistant__intro {
  font-size: 0.78rem;
  color: #64748b;
  padding: 0.5rem 1rem;
  background: #f8fafc;
  border-bottom: 1px solid #e2e8f0;
}

.hms-assistant__messages {
  flex: 1;
  overflow-y: auto;
  padding: 0.75rem 1rem;
  min-height: 200px;
  max-height: 320px;
  background: #fff;
}

.hms-assistant__msg {
  margin-bottom: 0.75rem;
  padding: 0.55rem 0.7rem;
  border-radius: 10px;
  font-size: 0.88rem;
}

.hms-assistant__msg--user {
  margin-left: 1.5rem;
  background: #eef2ff;
  color: #1e1b4b;
}

.hms-assistant__msg--bot {
  margin-right: 1rem;
  background: #f1f5f9;
  color: #0f172a;
}

.hms-assistant__msg--bot strong {
  color: #312e81;
}

.hms-assistant__msg--meta {
  font-size: 0.68rem;
  color: #94a3b8;
  margin-top: 0.35rem;
}

.hms-assistant__chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  padding: 0.5rem 0.75rem 0.65rem;
  background: #f1f5f9;
  border-top: 1px solid #e2e8f0;
}

.hms-assistant__chip {
  font-size: 0.75rem;
  padding: 0.35rem 0.65rem;
  border-radius: 999px;
  border: 1px solid #c7d2fe;
  background: #eef2ff;
  color: #3730a3;
  cursor: pointer;
  max-width: 100%;
  text-align: left;
  line-height: 1.25;
}

.hms-assistant__chip:hover {
  background: #e0e7ff;
  border-color: #a5b4fc;
}

.hms-assistant__typing-dots {
  display: inline-flex;
  gap: 0.15rem;
  font-weight: 700;
  color: #64748b;
  letter-spacing: 0.05em;
}

.hms-assistant__typing-dots span {
  animation: hms-typing 1s infinite ease-in-out;
}

.hms-assistant__typing-dots span:nth-child(2) {
  animation-delay: 0.15s;
}

.hms-assistant__typing-dots span:nth-child(3) {
  animation-delay: 0.3s;
}

@keyframes hms-typing {
  0%,
  80%,
  100% {
    opacity: 0.25;
  }
  40% {
    opacity: 1;
  }
}

.hms-assistant__composer {
  padding: 0.65rem 0.75rem 0.85rem;
  border-top: 1px solid #e2e8f0;
  background: #f8fafc;
}

.hms-assistant__input {
  width: 100%;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  padding: 0.45rem 0.6rem;
  font-size: 0.88rem;
  resize: none;
  margin-bottom: 0.45rem;
}

.hms-assistant__input:focus {
  outline: none;
  border-color: #6366f1;
  box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.2);
}

.hms-assistant__actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.5rem;
}

.hms-assistant__mic {
  border: 1px solid #cbd5e1;
  background: #fff;
  border-radius: 8px;
  width: 2.25rem;
  height: 2.25rem;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: #475569;
}

.hms-assistant__mic:hover {
  background: #f1f5f9;
}

.hms-assistant__mic.is-listening {
  background: #fee2e2;
  border-color: #f87171;
  color: #b91c1c;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Admin dark layout */
body.dark-layout .hms-assistant__panel {
  background: #10163a;
  color: #ebeefd;
  border-color: #414561;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.5);
}

body.dark-layout .hms-assistant__intro {
  background: #161b3d;
  color: #9ca3c2;
  border-bottom-color: #414561;
}

body.dark-layout .hms-assistant__messages {
  background: #10163a;
}

body.dark-layout .hms-assistant__msg--user {
  background: #3730a3;
  color: #e0e7ff;
}

body.dark-layout .hms-assistant__msg--bot {
  background: #1a1f45;
  color: #c2c6dc;
}

body.dark-layout .hms-assistant__msg--bot strong {
  color: #fff;
}

body.dark-layout .hms-assistant__composer {
  background: #0f132e;
  border-top-color: #414561;
}

body.dark-layout .hms-assistant__input {
  background: #10163a;
  border-color: #414561;
  color: #ebeefd;
}

body.dark-layout .hms-assistant__mic {
  background: #10163a;
  border-color: #414561;
  color: #c2c6dc;
}

body.dark-layout .hms-assistant__chips {
  background: #0f132e;
  border-top-color: #414561;
}

body.dark-layout .hms-assistant__chip {
  background: rgba(115, 103, 240, 0.2);
  border-color: #5b5fc7;
  color: #e0e7ff;
}

body.dark-layout .hms-assistant__chip:hover {
  background: rgba(115, 103, 240, 0.35);
}

/* Bootstrap 5 dark theme (public site) */
[data-bs-theme='dark'] .hms-assistant__panel {
  background: var(--bs-body-bg);
  color: var(--bs-body-color);
  border-color: var(--bs-border-color);
}

[data-bs-theme='dark'] .hms-assistant__intro {
  background: var(--bs-secondary-bg);
  color: var(--bs-secondary-color);
  border-bottom-color: var(--bs-border-color);
}

[data-bs-theme='dark'] .hms-assistant__messages {
  background: var(--bs-body-bg);
}

[data-bs-theme='dark'] .hms-assistant__msg--user {
  background: rgba(99, 102, 241, 0.25);
  color: var(--bs-body-color);
}

[data-bs-theme='dark'] .hms-assistant__msg--bot {
  background: var(--bs-secondary-bg);
  color: var(--bs-body-color);
}

[data-bs-theme='dark'] .hms-assistant__composer {
  background: var(--bs-tertiary-bg);
  border-top-color: var(--bs-border-color);
}

[data-bs-theme='dark'] .hms-assistant__input {
  background: var(--bs-body-bg);
  border-color: var(--bs-border-color);
  color: var(--bs-body-color);
}

[data-bs-theme='dark'] .hms-assistant__mic {
  background: var(--bs-body-bg);
  border-color: var(--bs-border-color);
}

[data-bs-theme='dark'] .hms-assistant__chips {
  background: var(--bs-tertiary-bg);
  border-top-color: var(--bs-border-color);
}

[data-bs-theme='dark'] .hms-assistant__chip {
  background: rgba(99, 102, 241, 0.2);
  border-color: var(--bs-border-color);
  color: var(--bs-body-color);
}

/* -------------------------------------------------------------------------- */
/* Dark mode — full polish (answers, disclaimer, controls, public + admin)    */
/* -------------------------------------------------------------------------- */

html[data-bs-theme='dark'] .hms-assistant__panel,
body.dark-layout .hms-assistant__panel {
  color-scheme: dark;
}

/* Intro line + emphasis */
html[data-bs-theme='dark'] .hms-assistant__intro strong,
[data-bs-theme='dark'] .hms-assistant__intro strong {
  color: var(--bs-emphasis-color, #f8f9fa);
  font-weight: 600;
}

body.dark-layout .hms-assistant__intro strong {
  color: #e8eaf6;
  font-weight: 600;
}

/* Bot bubbles — body text + bold (LLM / rules use ** a lot) */
html[data-bs-theme='dark'] .hms-assistant__msg--bot,
[data-bs-theme='dark'] .hms-assistant__msg--bot {
  color: var(--bs-body-color, #e9ecef);
  border: 1px solid rgba(255, 255, 255, 0.06);
}

html[data-bs-theme='dark'] .hms-assistant__msg--bot strong,
[data-bs-theme='dark'] .hms-assistant__msg--bot strong {
  color: var(--bs-emphasis-color, #fff);
  font-weight: 650;
}

body.dark-layout .hms-assistant__msg--bot {
  border: 1px solid rgba(255, 255, 255, 0.06);
}

body.dark-layout .hms-assistant__msg--bot strong {
  color: #f1f5ff;
  font-weight: 650;
}

/* AI disclaimer + typing — readable muted text */
html[data-bs-theme='dark'] .hms-assistant__msg--meta,
[data-bs-theme='dark'] .hms-assistant__msg--meta {
  color: rgba(233, 236, 239, 0.72) !important;
}

body.dark-layout .hms-assistant__msg--meta {
  color: rgba(195, 198, 220, 0.88) !important;
}

html[data-bs-theme='dark'] .hms-assistant__typing-dots,
[data-bs-theme='dark'] .hms-assistant__typing-dots {
  color: rgba(233, 236, 239, 0.65);
}

body.dark-layout .hms-assistant__typing-dots {
  color: rgba(156, 163, 194, 0.95);
}

/* User bubble contrast */
html[data-bs-theme='dark'] .hms-assistant__msg--user,
[data-bs-theme='dark'] .hms-assistant__msg--user {
  border: 1px solid rgba(129, 140, 248, 0.35);
}

html[data-bs-theme='dark'] .hms-assistant__msg--user strong,
[data-bs-theme='dark'] .hms-assistant__msg--user strong {
  color: inherit;
}

body.dark-layout .hms-assistant__msg--user {
  border: 1px solid rgba(129, 140, 248, 0.35);
}

/* Composer: textarea placeholder + focus */
html[data-bs-theme='dark'] .hms-assistant__input::placeholder,
[data-bs-theme='dark'] .hms-assistant__input::placeholder {
  color: rgba(233, 236, 239, 0.45);
}

body.dark-layout .hms-assistant__input::placeholder {
  color: rgba(195, 198, 220, 0.45);
}

html[data-bs-theme='dark'] .hms-assistant__input:focus,
[data-bs-theme='dark'] .hms-assistant__input:focus {
  border-color: #818cf8;
  box-shadow: 0 0 0 2px rgba(129, 140, 248, 0.28);
}

body.dark-layout .hms-assistant__input:focus {
  border-color: #8b9bff;
  box-shadow: 0 0 0 2px rgba(139, 155, 255, 0.25);
}

/* Send — scoped so admin BS4 / public BS5 both look correct */
.hms-assistant .hms-assistant__send.btn-primary {
  border: none;
  font-weight: 600;
}

html[data-bs-theme='dark'] .hms-assistant .hms-assistant__send.btn-primary,
[data-bs-theme='dark'] .hms-assistant .hms-assistant__send.btn-primary {
  background: linear-gradient(135deg, #6366f1 0%, #4f46e5 100%);
  color: #fff;
}

html[data-bs-theme='dark'] .hms-assistant .hms-assistant__send.btn-primary:hover,
[data-bs-theme='dark'] .hms-assistant .hms-assistant__send.btn-primary:hover {
  background: linear-gradient(135deg, #7c7ff2 0%, #5b52eb 100%);
  color: #fff;
}

body.dark-layout .hms-assistant .hms-assistant__send.btn-primary {
  background: linear-gradient(135deg, #7367f0 0%, #5e50ee 100%);
  color: #fff;
}

body.dark-layout .hms-assistant .hms-assistant__send.btn-primary:hover {
  background: linear-gradient(135deg, #8b80f5 0%, #6d62f0 100%);
  color: #fff;
}

/* Mic — hover + listening in dark */
html[data-bs-theme='dark'] .hms-assistant__mic:hover,
[data-bs-theme='dark'] .hms-assistant__mic:hover {
  background: var(--bs-secondary-bg);
  color: var(--bs-body-color);
}

body.dark-layout .hms-assistant__mic:hover {
  background: #1a1f45;
  color: #e0e7ff;
}

html[data-bs-theme='dark'] .hms-assistant__mic.is-listening,
[data-bs-theme='dark'] .hms-assistant__mic.is-listening {
  background: rgba(248, 113, 113, 0.22);
  border-color: #f87171;
  color: #fecaca;
}

body.dark-layout .hms-assistant__mic.is-listening {
  background: rgba(185, 28, 28, 0.35);
  border-color: #f87171;
  color: #fecaca;
}

/* Message list scrollbar (WebKit) */
body.dark-layout .hms-assistant__messages,
html[data-bs-theme='dark'] .hms-assistant__messages,
[data-bs-theme='dark'] .hms-assistant__messages {
  scrollbar-color: rgba(148, 163, 184, 0.45) transparent;
  scrollbar-width: thin;
}

body.dark-layout .hms-assistant__messages::-webkit-scrollbar-thumb,
html[data-bs-theme='dark'] .hms-assistant__messages::-webkit-scrollbar-thumb,
[data-bs-theme='dark'] .hms-assistant__messages::-webkit-scrollbar-thumb {
  background: rgba(148, 163, 184, 0.4);
  border-radius: 6px;
}

body.dark-layout .hms-assistant__messages::-webkit-scrollbar-track,
html[data-bs-theme='dark'] .hms-assistant__messages::-webkit-scrollbar-track,
[data-bs-theme='dark'] .hms-assistant__messages::-webkit-scrollbar-track {
  background: transparent;
}
