/* --- KORA AI chatbot widget (kora-chatbot.js) ---
   Mirrors floating-actions.css's z-index/shadow/radius language but sits at
   the opposite corner (bottom-left) so the two widgets never compete for
   the same space. All colors come from tokens.css custom properties, so
   light/dark follows the site's existing theme mechanism automatically —
   nothing theme-specific is hardcoded here. */

.kora-widget {
  position: fixed;
  left: var(--space-md);
  bottom: var(--space-md);
  z-index: calc(var(--z-toast) + 20);
}

body:has([data-cookie-banner]:not([hidden])) .kora-widget {
  bottom: 15rem;
}

@media (min-width: 48rem) {
  body:has([data-cookie-banner]:not([hidden])) .kora-widget {
    bottom: 7.5rem;
  }
}

/* The mascot renders full-figure, un-cropped, on no background chrome of
   its own — a solid circle behind it was clipping the character down to
   just its head. A drop-shadow under the character (not a box-shadow on a
   background shape, since there isn't one) is what reads as "floating
   clickable button" instead. */
.kora-launcher {
  position: relative;
  width: 6.5rem;
  height: 6.5rem;
  border: none;
  background: transparent;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  overflow: visible;
  padding: 0;
  filter: drop-shadow(0 10px 20px rgba(0, 0, 0, 0.28));
  transition: transform var(--duration-fast) var(--ease-out), filter var(--duration-fast) var(--ease-out);
}

.kora-launcher:hover {
  transform: translateY(-4px) scale(1.04);
  filter: drop-shadow(0 16px 28px rgba(0, 0, 0, 0.34));
}

@media (max-width: 30rem) {
  .kora-launcher {
    width: 5rem;
    height: 5rem;
  }
}

.kora-launcher__lottie {
  width: 100%;
  height: 100%;
}

.kora-launcher__lottie svg {
  width: 100% !important;
  height: 100% !important;
}

/* Static fallback glyph shown until lottie.min.js + the idle animation JSON
   finish loading (dynamically imported, not blocking first paint) — see
   kora-chatbot.js's loadLottie(). currentColor (not a hardcoded white) so
   it stays visible against the page behind it now that there's no solid
   background shape underneath it. */
.kora-launcher__fallback {
  width: 3rem;
  height: 3rem;
  color: var(--color-accent-blue);
}

.kora-launcher[data-loaded] .kora-launcher__fallback {
  display: none;
}

.kora-launcher__badge {
  position: absolute;
  top: -0.15rem;
  right: -0.15rem;
  min-width: 1.1rem;
  height: 1.1rem;
  padding: 0 0.3rem;
  border-radius: var(--radius-full);
  background: #e53e3e;
  color: #ffffff;
  font-size: 0.65rem;
  font-weight: var(--fw-bold);
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid var(--color-bg);
}

.kora-launcher__badge[hidden] {
  display: none;
}

/* --- Panel --- */

.kora-panel {
  position: fixed;
  inset: 0;
  z-index: calc(var(--z-toast) + 25);
  display: flex;
  align-items: flex-end;
  justify-content: flex-start;
  padding: var(--space-md);
  pointer-events: none;
}

.kora-panel[hidden] {
  display: none;
}

.kora-panel__backdrop {
  position: fixed;
  inset: 0;
  background: rgba(8, 12, 20, 0.5);
  pointer-events: auto;
}

.kora-panel__card {
  position: relative;
  width: min(100%, 24rem);
  height: min(70vh, 40rem);
  display: flex;
  flex-direction: column;
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: var(--color-bg-elevated);
  border: 1px solid var(--color-border);
  box-shadow: var(--shadow-lg);
  animation: kora-panel-in var(--duration-base) var(--ease-out);
  pointer-events: auto;
}

@keyframes kora-panel-in {
  from { opacity: 0; transform: translateY(1rem) scale(0.97); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

@media (prefers-reduced-motion: reduce) {
  .kora-panel__card {
    animation: none;
  }
}

.kora-panel__header {
  position: relative;
  display: flex;
  align-items: center;
  gap: var(--space-xs);
  padding: var(--space-sm) var(--space-md);
  background: var(--color-gradient-brand);
  color: #ffffff;
  flex-shrink: 0;
}

.kora-panel__avatar {
  width: 2.75rem;
  height: 2.75rem;
  flex-shrink: 0;
  border-radius: var(--radius-full);
  background: rgba(0, 0, 0, 0.2);
  overflow: hidden;
}

.kora-panel__title {
  flex: 1;
  min-width: 0;
}

.kora-panel__name {
  font-family: var(--font-display);
  font-weight: var(--fw-bold);
  font-size: var(--fs-md);
  line-height: 1.2;
}

.kora-panel__sub {
  font-size: var(--fs-xs);
  opacity: 0.85;
}

.kora-panel__close {
  width: 2rem;
  height: 2rem;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-full);
  border: none;
  background: rgba(255, 255, 255, 0.18);
  color: #ffffff;
  cursor: pointer;
  font-size: 1.25rem;
  line-height: 1;
}

.kora-panel__close:hover {
  background: rgba(255, 255, 255, 0.3);
}

.kora-panel__human {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.35rem 0.6rem;
  border-radius: var(--radius-full);
  border: none;
  background: rgba(255, 255, 255, 0.18);
  color: #ffffff;
  cursor: pointer;
  font-size: var(--fs-xs);
  font-weight: var(--fw-semibold);
}

.kora-panel__human:hover {
  background: rgba(255, 255, 255, 0.3);
}

.kora-panel__status {
  flex-shrink: 0;
  padding: var(--space-2xs) var(--space-md);
  font-size: var(--fs-xs);
  text-align: center;
  background: var(--color-bg-surface);
  border-bottom: 1px solid var(--color-border);
  color: var(--color-text-faint);
}

.kora-panel__status[hidden] {
  display: none;
}

.kora-panel__messages {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: var(--space-md);
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

.kora-msg {
  max-width: 85%;
  padding: var(--space-2xs) var(--space-sm);
  border-radius: var(--radius-md);
  font-size: var(--fs-sm);
  line-height: 1.45;
  white-space: pre-wrap;
  overflow-wrap: break-word;
}

.kora-msg--user {
  align-self: flex-end;
  background: var(--color-gradient-brand);
  color: #ffffff;
  border-bottom-right-radius: var(--radius-sm);
}

.kora-msg--bot {
  align-self: flex-start;
  background: var(--color-bg-surface);
  border: 1px solid var(--color-border);
  color: var(--color-text);
  border-bottom-left-radius: var(--radius-sm);
}

.kora-msg__label {
  font-size: 0.7rem;
  font-weight: var(--fw-semibold);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--color-accent-blue);
  margin-bottom: 0.2em;
}

.kora-msg code {
  font-family: ui-monospace, monospace;
  font-size: 0.9em;
  background: rgba(128, 128, 128, 0.15);
  padding: 0.1em 0.3em;
  border-radius: 4px;
}

.kora-msg--bot.is-typing {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: var(--space-xs) var(--space-sm);
}

.kora-typing-dot {
  width: 0.4rem;
  height: 0.4rem;
  border-radius: var(--radius-full);
  background: var(--color-text-faint);
  animation: kora-typing-bounce 1.2s infinite ease-in-out;
}

.kora-typing-dot:nth-child(2) { animation-delay: 0.15s; }
.kora-typing-dot:nth-child(3) { animation-delay: 0.3s; }

.kora-typing-note {
  margin-left: 0.4rem;
  font-size: var(--fs-xs);
  color: var(--color-text-faint);
}

.kora-typing-note[hidden] {
  display: none;
}

@keyframes kora-typing-bounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.5; }
  30% { transform: translateY(-0.2rem); opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
  .kora-typing-dot {
    animation: none;
  }
}

.kora-msg--system {
  align-self: center;
  max-width: 100%;
  background: transparent;
  color: var(--color-text-faint);
  font-size: var(--fs-xs);
  text-align: center;
  padding: 0.2rem 0;
}

.kora-msg--error {
  align-self: center;
  background: transparent;
  color: var(--color-error, #e53e3e);
  font-size: var(--fs-xs);
  text-align: center;
}

/* --- Inline OTP step, appears inside the message flow --- */

.kora-otp {
  align-self: flex-start;
  max-width: 90%;
  display: flex;
  gap: var(--space-3xs);
  padding: var(--space-2xs);
  border-radius: var(--radius-md);
  background: var(--color-bg-surface);
  border: 1px solid var(--color-border);
}

.kora-otp[hidden] {
  display: none;
}

.kora-otp__input {
  width: 7rem;
  padding: var(--space-3xs) var(--space-2xs);
  border-radius: var(--radius-sm);
  border: 1px solid var(--color-border);
  background: var(--color-bg-elevated);
  color: var(--color-text);
  font-size: var(--fs-sm);
  letter-spacing: 0.15em;
  text-align: center;
}

.kora-otp__input:focus-visible {
  outline: none;
  border-color: var(--color-accent-blue);
  box-shadow: var(--shadow-focus);
}

.kora-otp__status {
  font-size: var(--fs-xs);
  color: var(--color-text-faint);
  align-self: center;
}

/* --- Composer --- */

.kora-panel__form {
  flex-shrink: 0;
  display: flex;
  align-items: flex-end;
  gap: var(--space-2xs);
  padding: var(--space-sm);
  border-top: 1px solid var(--color-border);
  background: var(--color-bg-elevated);
}

.kora-panel__input {
  flex: 1;
  resize: none;
  max-height: 6rem;
  padding: var(--space-2xs) var(--space-sm);
  border-radius: var(--radius-md);
  border: 1px solid var(--color-border);
  background: var(--color-bg-surface);
  color: var(--color-text);
  font-family: inherit;
  font-size: var(--fs-sm);
  line-height: 1.4;
}

.kora-panel__input:focus-visible {
  outline: none;
  border-color: var(--color-accent-blue);
  box-shadow: var(--shadow-focus);
}

.kora-panel__send {
  width: 2.5rem;
  height: 2.5rem;
  flex-shrink: 0;
  border-radius: var(--radius-full);
  border: none;
  background: var(--color-gradient-brand);
  color: #ffffff;
  font-size: 1.1rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: opacity var(--duration-fast) var(--ease-out);
}

.kora-panel__send:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

@media (max-width: 30rem) {
  .kora-widget {
    left: var(--space-sm);
    bottom: var(--space-sm);
  }

  .kora-panel {
    padding: 0;
  }

  .kora-panel__card {
    width: 100%;
    height: 100%;
    border-radius: 0;
  }
}
