/* Balo Zen Guide — floating chat tuned to the baloservices.co.uk design system.
   Brand tokens mirror wp-content/themes/balo-theme global.css:
   ink #0f172a, muted #64748b, accent blue #3b82f6 + green #22c55e,
   marketplace CTA indigo #4f46e5, glassy cards, soft glows. No brown/amber. */

:root {
  --bzg-ink: #0f172a;
  --bzg-muted: #64748b;
  --bzg-accent: #4f46e5;         /* marketplace CTA indigo */
  --bzg-accent-2: #3b82f6;       /* brand blue */
  --bzg-accent-hover: #4338ca;
  --bzg-grad: linear-gradient(135deg, #6366f1 0%, #4f46e5 55%, #3b82f6 100%);
  --bzg-surface: rgba(255, 255, 255, 0.94);
  --bzg-surface-solid: #ffffff;
  --bzg-header: linear-gradient(180deg, #eef6ff 0%, #fbfdff 100%);
  --bzg-messages-bg: linear-gradient(180deg, #f7fafc 0%, #eef6f2 100%); /* zen mint */
  --bzg-border: rgba(2, 6, 23, 0.08);
  --bzg-user-bg: var(--bzg-grad);
  --bzg-user-ink: #ffffff;
  --bzg-bot-bg: rgba(255, 255, 255, 0.9);
  --bzg-bot-ink: #0f172a;
  --bzg-shadow: 0 24px 60px rgba(15, 23, 42, 0.22), 0 2px 8px rgba(15, 23, 42, 0.08);
  --bzg-fab-glow: 0 10px 34px rgba(79, 70, 229, 0.42), 0 0 0 1px rgba(255, 255, 255, 0.18) inset;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bzg-ink: #e9eefb;
    --bzg-muted: #9aa6b0;
    --bzg-accent: #818cf8;
    --bzg-accent-2: #60a5fa;
    --bzg-accent-hover: #a5b4fc;
    --bzg-surface: rgba(17, 26, 51, 0.9);
    --bzg-surface-solid: #111a33;
    --bzg-header: linear-gradient(180deg, #131d3a 0%, #0f1830 100%);
    --bzg-messages-bg: linear-gradient(180deg, #0a1224 0%, #0e1730 100%);
    --bzg-border: rgba(148, 163, 184, 0.16);
    --bzg-bot-bg: rgba(26, 36, 68, 0.92);
    --bzg-bot-ink: #e9eefb;
    --bzg-shadow: 0 24px 60px rgba(0, 0, 0, 0.5), 0 2px 8px rgba(0, 0, 0, 0.4);
    --bzg-fab-glow: 0 10px 34px rgba(99, 102, 241, 0.5), 0 0 0 1px rgba(255, 255, 255, 0.08) inset;
  }
}

/* Site theme toggles (match balo-theme global.css; balo-night is the live one) */
body.balo-night,
body.dark-mode,
body.night-mode,
html[data-theme="dark"],
:root[data-theme="dark"] {
  --bzg-ink: #e9eefb;
  --bzg-muted: #b8c2d0;
  --bzg-accent: #818cf8;
  --bzg-accent-2: #60a5fa;
  --bzg-accent-hover: #a5b4fc;
  --bzg-surface: rgba(17, 26, 51, 0.9);
  --bzg-surface-solid: #111a33;
  --bzg-header: linear-gradient(180deg, #131d3a 0%, #0f1830 100%);
  --bzg-messages-bg: linear-gradient(180deg, #0a1224 0%, #0e1730 100%);
  --bzg-border: rgba(148, 163, 184, 0.16);
  --bzg-bot-bg: rgba(26, 36, 68, 0.92);
  --bzg-bot-ink: #e9eefb;
  --bzg-shadow: 0 24px 60px rgba(0, 0, 0, 0.5), 0 2px 8px rgba(0, 0, 0, 0.4);
  --bzg-fab-glow: 0 10px 34px rgba(99, 102, 241, 0.5), 0 0 0 1px rgba(255, 255, 255, 0.08) inset;
}

#balo-zen-root {
  position: fixed;
  bottom: 1.25rem;
  right: 1.25rem;
  z-index: 99999;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 15px;
  color: var(--bzg-ink);
}

.bzg-fab {
  width: 3.5rem;
  height: 3.5rem;
  border-radius: 999px;
  border: none;
  background: var(--bzg-grad);
  color: #fff;
  font-size: 1.4rem;
  line-height: 1;
  cursor: pointer;
  box-shadow: var(--bzg-fab-glow), 0 12px 30px rgba(2, 6, 23, 0.28);
  transition: transform 0.18s ease, box-shadow 0.18s ease, filter 0.18s ease;
}

.bzg-fab:hover {
  transform: translateY(-2px) scale(1.04);
  filter: brightness(1.05);
}

.bzg-fab:focus-visible {
  outline: none;
  box-shadow: var(--bzg-fab-glow), 0 0 0 6px rgba(79, 70, 229, 0.18);
}

.bzg-panel {
  display: none;
  flex-direction: column;
  width: min(23rem, calc(100vw - 2rem));
  height: min(30rem, calc(100vh - 6rem));
  background: var(--bzg-surface);
  -webkit-backdrop-filter: saturate(1.2) blur(14px);
  backdrop-filter: saturate(1.2) blur(14px);
  border: 1px solid var(--bzg-border);
  border-radius: 1.25rem;
  box-shadow: var(--bzg-shadow);
  overflow: hidden;
  margin-bottom: 0.85rem;
  opacity: 0;
  transform: translateY(10px) scale(0.98);
  transition: opacity 0.18s ease, transform 0.18s ease;
}

.bzg-panel.open {
  display: flex;
  opacity: 1;
  transform: translateY(0) scale(1);
}

.bzg-header {
  padding: 0.85rem 1rem;
  border-bottom: 1px solid var(--bzg-border);
  background: var(--bzg-header);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
}

.bzg-header strong {
  color: var(--bzg-ink);
  font-weight: 700;
  font-size: 0.98rem;
}

.bzg-header span {
  color: var(--bzg-muted);
  font-size: 0.78rem;
}

/* Guarantee the header title + subtitle stay readable even when a site-wide
   night-mode rule tries to recolor descendants (id beats those selectors). */
#balo-zen-root .bzg-header strong { color: var(--bzg-ink); }
#balo-zen-root .bzg-header span { color: var(--bzg-muted); }

.bzg-close {
  background: none;
  border: none;
  color: var(--bzg-muted);
  font-size: 1.35rem;
  cursor: pointer;
  line-height: 1;
  border-radius: 8px;
  padding: 0 0.25rem;
  transition: color 0.15s ease, background 0.15s ease;
}

.bzg-close:hover {
  color: var(--bzg-ink);
  background: rgba(2, 6, 23, 0.06);
}

.bzg-messages {
  flex: 1;
  overflow-y: auto;
  padding: 0.85rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  background: var(--bzg-messages-bg);
}

.bzg-msg {
  max-width: 88%;
  padding: 0.58rem 0.8rem;
  border-radius: 1rem;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
  box-shadow: 0 1px 2px rgba(2, 6, 23, 0.06);
}

.bzg-msg.user {
  align-self: flex-end;
  background: var(--bzg-user-bg);
  color: var(--bzg-user-ink);
  border-bottom-right-radius: 0.35rem;
}

.bzg-msg.bot {
  align-self: flex-start;
  background: var(--bzg-bot-bg);
  color: var(--bzg-bot-ink);
  border: 1px solid var(--bzg-border);
  border-bottom-left-radius: 0.35rem;
}

.bzg-input-row {
  display: flex;
  gap: 0.5rem;
  padding: 0.7rem;
  border-top: 1px solid var(--bzg-border);
  background: var(--bzg-surface-solid);
}

.bzg-input {
  flex: 1;
  border: 1px solid var(--bzg-border);
  border-radius: 0.75rem;
  padding: 0.55rem 0.7rem;
  background: var(--bzg-surface-solid);
  color: var(--bzg-ink);
  font-size: 0.95rem;
}

.bzg-input::placeholder {
  color: var(--bzg-muted);
}

.bzg-input:focus {
  outline: none;
  border-color: var(--bzg-accent);
  box-shadow: 0 0 0 4px rgba(79, 70, 229, 0.14);
}

.bzg-send {
  border: none;
  border-radius: 0.75rem;
  padding: 0 1rem;
  background: var(--bzg-grad);
  color: #fff;
  font-weight: 600;
  cursor: pointer;
  transition: filter 0.15s ease, transform 0.15s ease;
}

.bzg-send:hover:not(:disabled) {
  filter: brightness(1.05);
  transform: translateY(-1px);
}

.bzg-send:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.bzg-thinking {
  color: var(--bzg-muted);
  font-size: 0.85rem;
  padding: 0 0.85rem 0.5rem;
}

@media (max-width: 640px) {
  #balo-zen-root {
    bottom: 0.9rem;
    right: 0.9rem;
  }
  .bzg-panel {
    width: calc(100vw - 1.5rem);
  }
}
