/* Leo – chat widget. Colours follow the site palette (black / white / #f45c20 accent). */
.nith-chat {
  --nc-ink: #000;
  --nc-ink-soft: #212934;
  --nc-muted: #898989;
  --nc-line: #e2e2e2;
  --nc-bg: #fff;
  --nc-bg-soft: #f4f4f6;
  --nc-accent: #f45c20;
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 100000;
  font-family: var(--awb-typography4-font-family, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif);
  font-size: 15px;
  line-height: 1.5;
  color: var(--nc-ink-soft);
}
.nith-chat *,
.nith-chat *::before,
.nith-chat *::after { box-sizing: border-box; }

.nith-chat:not(.is-open) { display: flex; flex-direction: column; align-items: flex-end; gap: 10px; }

/* Pop-up invitation above the chat button */
.nith-chat__tease {
  display: flex;
  align-items: center;
  max-width: 260px;
  background: var(--nc-bg);
  border: 1px solid var(--nc-line);
  border-radius: 14px 14px 4px 14px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .15);
  animation: nith-tease-in .35s ease-out;
}
.nith-chat__tease-text {
  border: 0;
  background: none;
  padding: 12px 4px 12px 14px;
  font: inherit;
  font-size: 14px;
  color: var(--nc-ink);
  text-align: left;
  cursor: pointer;
}
.nith-chat__tease-close {
  align-self: flex-start;
  border: 0;
  background: none;
  padding: 6px 10px;
  font-size: 18px;
  line-height: 1;
  color: var(--nc-muted);
  cursor: pointer;
}
.nith-chat__tease-close:hover { color: var(--nc-ink); }
@keyframes nith-tease-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .nith-chat__tease { animation: none; } }

/* Keep Avada's "back to top" button clear of the chat button */
.to-top-container.to-top-right { bottom: 88px !important; }

.nith-chat__launcher {
  position: relative;
  height: 58px;
  padding: 0 22px 0 8px;
  border: 1px solid rgba(185, 196, 255, .35);
  border-radius: 999px;
  background: linear-gradient(135deg, #2f3a66 0%, #1b2036 60%, #161a28 100%);
  color: #fff;
  display: flex;
  align-items: center;
  gap: 11px;
  font: inherit;
  white-space: nowrap;
  cursor: pointer;
  box-shadow: 0 10px 28px rgba(22, 26, 40, .45), 0 0 22px rgba(120, 140, 255, .30);
  transition: transform .2s ease, box-shadow .2s ease;
  animation: nith-launch-pulse 4s ease-in-out infinite;
}
.nith-chat__launcher:hover {
  transform: translateY(-3px);
  box-shadow: 0 14px 32px rgba(22, 26, 40, .5), 0 0 30px rgba(120, 140, 255, .55);
}
/* Glowing orb avatar, like the voice screen */
.nith-chat__avatar {
  position: relative;
  width: 42px;
  height: 42px;
  flex: none;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: radial-gradient(circle at 35% 30%, #c9d1ff 0%, #6e7caa 45%, #3a4677 100%);
  box-shadow: 0 0 16px rgba(150, 165, 255, .6);
  animation: nith-orb-breathe 3s ease-in-out infinite;
}
.nith-chat__launcher .nith-chat__avatar svg { width: 20px; height: 20px; fill: #fff; }
.nith-chat__avatar::after { /* green "online" dot */
  content: "";
  position: absolute;
  right: 1px;
  bottom: 1px;
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: #3ddc84;
  border: 2px solid #1b2036;
}
.nith-chat__label { display: flex; flex-direction: column; align-items: flex-start; line-height: 1.15; }
.nith-chat__label strong { font-size: 16px; font-weight: 700; letter-spacing: .2px; color: #fff; }
.nith-chat__label small { font-size: 12px; color: #b9c4ff; }
@keyframes nith-orb-breathe {
  0%, 100% { box-shadow: 0 0 12px rgba(150, 165, 255, .45); transform: scale(1); }
  50% { box-shadow: 0 0 22px rgba(150, 165, 255, .85); transform: scale(1.05); }
}
@keyframes nith-launch-pulse {
  0%, 70%, 100% { box-shadow: 0 10px 28px rgba(22, 26, 40, .45), 0 0 22px rgba(120, 140, 255, .30); }
  80% { box-shadow: 0 10px 28px rgba(22, 26, 40, .45), 0 0 0 8px rgba(120, 140, 255, .18), 0 0 30px rgba(120, 140, 255, .5); }
}
@media (prefers-reduced-motion: reduce) {
  .nith-chat__launcher, .nith-chat__avatar { animation: none; }
}
.nith-chat__launcher:focus-visible,
.nith-chat button:focus-visible,
.nith-chat textarea:focus-visible { outline: 2px solid var(--nc-accent); outline-offset: 2px; }
.nith-chat__launcher svg { width: 22px; height: 22px; flex: none; fill: currentColor; }
.nith-chat.is-open .nith-chat__launcher { display: none; }

.nith-chat__panel {
  width: 370px;
  height: min(580px, calc(100vh - 40px));
  background: var(--nc-bg);
  border: 1px solid var(--nc-line);
  border-radius: 14px;
  box-shadow: 0 16px 48px rgba(0, 0, 0, .22);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.nith-chat__panel[hidden] { display: none; }

.nith-chat__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  background: var(--nc-ink);
  color: #fff;
}
.nith-chat__header > div { flex: 1; }
.nith-chat__header strong { display: block; font-size: 16px; color: #fff; }
.nith-chat__header span { font-size: 12px; color: #c9c9c9; }
.nith-chat__new {
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: #fff;
  display: grid;
  place-items: center;
  cursor: pointer;
}
.nith-chat__new svg { width: 20px; height: 20px; fill: currentColor; }
.nith-chat__new:hover { background: rgba(255, 255, 255, .12); }
.nith-chat__restart { align-self: center; margin-top: 4px; }
.nith-chat__close {
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: #fff;
  font-size: 26px;
  line-height: 1;
  cursor: pointer;
}
.nith-chat__close:hover { background: rgba(255, 255, 255, .12); }

.nith-chat__log {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: var(--nc-bg);
}
.nith-chat__msg {
  max-width: 85%;
  padding: 10px 13px;
  border-radius: 14px;
  overflow-wrap: anywhere;
}
.nith-chat__msg p { margin: 0 0 6px; }
.nith-chat__msg p:last-child { margin-bottom: 0; }
.nith-chat__msg ul { margin: 4px 0 6px; padding-left: 18px; }
.nith-chat__msg li { margin: 2px 0; }
.nith-chat__msg a { color: inherit; text-decoration: underline; }
.nith-chat__msg--bot { align-self: flex-start; background: var(--nc-bg-soft); border-bottom-left-radius: 4px; }
.nith-chat__msg--user { align-self: flex-end; background: var(--nc-ink); color: #fff; border-bottom-right-radius: 4px; }

.nith-chat__typing { display: flex; gap: 4px; padding: 14px; }
.nith-chat__typing span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--nc-muted);
  animation: nith-chat-dot 1s infinite ease-in-out;
}
.nith-chat__typing span:nth-child(2) { animation-delay: .15s; }
.nith-chat__typing span:nth-child(3) { animation-delay: .3s; }
@keyframes nith-chat-dot { 0%, 80%, 100% { opacity: .3; } 40% { opacity: 1; } }

.nith-chat__chips { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 16px 10px; }
.nith-chat__chips[hidden] { display: none; }
.nith-chat__chip {
  border: 1px solid var(--nc-line);
  background: var(--nc-bg);
  color: var(--nc-ink-soft);
  border-radius: 999px;
  padding: 6px 12px;
  font: inherit;
  font-size: 13px;
  cursor: pointer;
}
.nith-chat__chip:hover { border-color: var(--nc-ink); }

.nith-chat__form {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 10px 12px;
  border-top: 1px solid var(--nc-line);
}
.nith-chat__form textarea {
  flex: 1;
  resize: none;
  min-height: 40px;
  max-height: 120px;
  overflow-y: hidden; /* scrollbar only appears once the text is taller than the box (set in JS) */
  padding: 9px 12px;
  border: 1px solid var(--nc-line);
  border-radius: 10px;
  font: inherit;
  color: var(--nc-ink);
  background: var(--nc-bg);
}
.nith-chat__form button {
  width: 40px;
  height: 40px;
  flex: none;
  border: 0;
  border-radius: 10px;
  background: var(--nc-ink);
  color: #fff;
  display: grid;
  place-items: center;
  cursor: pointer;
}
.nith-chat__form button:disabled { opacity: .4; cursor: default; }
.nith-chat__form svg { width: 18px; height: 18px; fill: currentColor; }
.nith-chat__form .nith-chat__voice-btn { background: var(--nc-bg-soft); color: var(--nc-ink); }
.nith-chat__form .nith-chat__voice-btn:hover { background: var(--nc-line); }
.nith-chat__form .nith-chat__voice-btn svg { width: 20px; height: 20px; }

/* ---------- Voice mode (inside the chat window) ---------- */
.nith-chat__panel { position: relative; }

.nith-voice {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 56px 20px calc(110px + env(safe-area-inset-bottom));
  background: #161a28;
  color: #e6e9f2;
  overflow: hidden;
  text-align: center;
  border-radius: inherit;
}
.nith-voice[hidden] { display: none; }
.nith-voice__title {
  position: absolute;
  top: 16px;
  left: 0;
  right: 0;
  margin: 0;
  font-size: 14px;
  font-weight: 600;
  color: #e6e9f2;
}
.nith-voice__title span { font-weight: 400; color: #8d95b3; }

.nith-voice__orb { position: absolute; inset: 0; pointer-events: none; }
.nith-voice__orb span {
  position: absolute;
  border-radius: 50%;
  filter: blur(40px);
  background: radial-gradient(circle, rgba(110, 124, 170, .85) 0%, rgba(80, 92, 135, .5) 45%, rgba(22, 26, 40, 0) 72%);
  transition: opacity .6s ease;
}
.nith-voice__orb span:nth-child(1) {
  width: 78%; aspect-ratio: 1;
  left: 50%; top: 14%;
  transform: translateX(-35%);
  animation: nith-orb-a 7s ease-in-out infinite;
}
.nith-voice__orb span:nth-child(2) {
  width: 66%; aspect-ratio: 1;
  left: 50%; top: 38%;
  transform: translateX(-80%);
  opacity: .8;
  animation: nith-orb-b 9s ease-in-out infinite;
}
@keyframes nith-orb-a {
  0%, 100% { transform: translate(-35%, 0) scale(1); }
  50% { transform: translate(-28%, 4%) scale(1.08); }
}
@keyframes nith-orb-b {
  0%, 100% { transform: translate(-80%, 0) scale(1); }
  50% { transform: translate(-72%, -5%) scale(1.1); }
}
.nith-voice[data-state="thinking"] .nith-voice__orb span { animation-duration: 2.2s, 2.8s; }
.nith-voice[data-state="speaking"] .nith-voice__orb span:nth-child(1) { animation: nith-orb-talk 1.1s ease-in-out infinite; }
.nith-voice[data-state="speaking"] .nith-voice__orb span:nth-child(2) { animation: nith-orb-talk2 1.4s ease-in-out infinite; }
.nith-voice[data-state="paused"] .nith-voice__orb span { opacity: .35; animation-play-state: paused; }
@keyframes nith-orb-talk {
  0%, 100% { transform: translate(-35%, 0) scale(1); }
  50% { transform: translate(-35%, 0) scale(1.18); }
}
@keyframes nith-orb-talk2 {
  0%, 100% { transform: translate(-80%, 0) scale(1.05); }
  50% { transform: translate(-80%, 0) scale(.92); }
}

.nith-voice__status {
  position: relative;
  margin: 0;
  font-size: 24px;
  font-weight: 500;
  letter-spacing: .2px;
  color: #e6e9f2;
}
.nith-voice__text {
  position: relative;
  max-width: 100%;
  max-height: 40%;
  margin: 12px 0 0;
  overflow-y: auto;
  font-size: 14px;
  line-height: 1.55;
  color: #aab1c5;
  white-space: pre-line;
}

.nith-voice__bar {
  position: absolute;
  left: 50%;
  bottom: calc(20px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 22px;
  padding: 8px 10px 8px 16px;
  border-radius: 999px;
  background: rgba(38, 45, 70, .92);
  box-shadow: 0 10px 30px rgba(0, 0, 0, .35);
}
.nith-voice__bar button {
  border: 0;
  cursor: pointer;
  display: grid;
  place-items: center;
  color: #e6e9f2;
}
.nith-voice__bar svg { fill: currentColor; }
.nith-voice__close {
  width: 44px; height: 44px;
  border-radius: 50%;
  background: transparent;
}
.nith-voice__close:hover { background: rgba(255, 255, 255, .08); }
.nith-voice__close svg { width: 22px; height: 22px; }
.nith-voice__mic {
  width: 64px; height: 64px;
  border-radius: 50%;
  background: radial-gradient(circle, #3a4677 0%, #273055 70%);
  border: 1px solid rgba(160, 175, 230, .35) !important;
  color: #b9c4ff !important;
  box-shadow: 0 0 24px rgba(120, 140, 255, .45);
}
.nith-voice[data-state="listening"] .nith-voice__mic { animation: nith-mic-glow 1.6s ease-in-out infinite; }
@keyframes nith-mic-glow {
  0%, 100% { box-shadow: 0 0 18px rgba(120, 140, 255, .35); }
  50% { box-shadow: 0 0 34px rgba(120, 140, 255, .7); }
}
.nith-voice__mic.is-muted { background: #2a3150; color: #8d95b3 !important; box-shadow: none; }
.nith-voice__mic svg { width: 28px; height: 28px; }
.nith-voice__bar button:focus-visible { outline: 2px solid rgba(185, 196, 255, .45); outline-offset: 4px; }

@media (prefers-reduced-motion: reduce) {
  .nith-voice__orb span,
  .nith-voice__mic { animation: none !important; }
}

.nith-chat__note { margin: 0; padding: 0 12px 8px; font-size: 11px; color: var(--nc-muted); text-align: center; }

@media (max-width: 540px) {
  .nith-chat { right: 16px; bottom: 16px; }
  .nith-chat.is-open { right: 0; bottom: 0; left: 0; top: 0; }
  .nith-chat__panel { width: 100%; height: 100%; border-radius: 0; border: 0; }
  .nith-chat__form textarea { font-size: 16px; } /* prevents iPhone zoom on focus */
}

/* ---------- Dark theme for the chat window (matches the voice screen) ---------- */
.nith-chat__panel {
  background:
    radial-gradient(circle at 85% 10%, rgba(110, 124, 170, .35), transparent 45%),
    radial-gradient(circle at 10% 80%, rgba(80, 92, 135, .30), transparent 50%),
    #161a28;
  border-color: rgba(255, 255, 255, .08);
  box-shadow: 0 18px 50px rgba(0, 0, 0, .45);
  color: #e6e9f2;
}
.nith-chat__header { background: rgba(22, 26, 40, .55); border-bottom: 1px solid rgba(255, 255, 255, .08); }
.nith-chat__header span { color: #8d95b3; }
.nith-chat__log {
  background: transparent;
  scrollbar-width: thin;
  scrollbar-color: rgba(185, 196, 255, .3) transparent;
}
.nith-chat__log::-webkit-scrollbar { width: 6px; }
.nith-chat__log::-webkit-scrollbar-track { background: transparent; }
.nith-chat__log::-webkit-scrollbar-thumb { background: rgba(185, 196, 255, .3); border-radius: 3px; }
.nith-chat__msg--bot { background: rgba(255, 255, 255, .07); border: 1px solid rgba(255, 255, 255, .06); color: #e6e9f2; }
.nith-chat__msg--user { background: linear-gradient(135deg, #3a4677, #2c3560); color: #fff; }
.nith-chat__msg a { color: #b9c4ff; }
.nith-chat__typing span { background: #8d95b3; }
.nith-chat__chip { background: transparent; border-color: rgba(185, 196, 255, .35); color: #cfd6ff; }
.nith-chat__chip:hover { background: rgba(185, 196, 255, .12); border-color: rgba(185, 196, 255, .6); }
.nith-chat__form { border-top-color: rgba(255, 255, 255, .08); }
.nith-chat__form textarea { background: rgba(255, 255, 255, .06); border-color: rgba(255, 255, 255, .12); color: #e6e9f2; }
.nith-chat__form textarea::placeholder { color: #8d95b3; }
.nith-chat__form .nith-chat__send {
  background: radial-gradient(circle, #3a4677 0%, #273055 75%);
  color: #b9c4ff;
  box-shadow: 0 0 14px rgba(120, 140, 255, .35);
}
.nith-chat__form .nith-chat__voice-btn { background: rgba(255, 255, 255, .08); color: #e6e9f2; }
.nith-chat__form .nith-chat__voice-btn:hover { background: rgba(255, 255, 255, .14); }
.nith-chat__note { color: #8d95b3; }
.nith-chat__panel button:focus-visible,
.nith-chat__panel textarea:focus-visible { outline-color: rgba(185, 196, 255, .6); }

/* ---------- Enlarge button: chat fills the whole window ---------- */
.nith-chat__expand {
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: #fff;
  display: grid;
  place-items: center;
  cursor: pointer;
}
.nith-chat__expand svg { width: 18px; height: 18px; fill: currentColor; }
.nith-chat__expand:hover { background: rgba(255, 255, 255, .12); }
/* Enlarged = a bigger window in the same corner (not full screen) */
.nith-chat.is-expanded .nith-chat__panel {
  width: min(700px, calc(100vw - 40px));
  height: min(680px, calc(100vh - 40px));
}
@media (max-width: 540px) {
  .nith-chat__expand { display: none; } /* already full screen on phones */
}

/* Header subtitle: green "online" dot */
.nith-chat__status { display: inline-flex; align-items: center; gap: 6px; }
.nith-chat__status::before {
  content: "";
  width: 8px;
  height: 8px;
  flex: none;
  border-radius: 50%;
  background: #3ddc84;
  box-shadow: 0 0 6px rgba(61, 220, 132, .7);
}
