/* Specialist chat. Sits on the same black / blue system as the rest of the page. */

.chat-dock {
  position: fixed;
  z-index: 70;
  right: 22px;
  bottom: calc(16px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 12px;
  width: min(392px, calc(100vw - 32px));
  pointer-events: none;
  font-size: 15px;
  line-height: 1.45;
}

.chat-dock > * { pointer-events: auto; }

.chat-launcher {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: var(--blue);
  color: #fff;
  display: grid;
  place-items: center;
  box-shadow: 0 12px 40px rgba(77, 124, 254, 0.45);
  position: relative;
  flex: none;
}

.chat-launcher svg { width: 26px; height: 26px; }
.chat-launcher:hover { background: #fff; color: #000; }
.chat-launcher:focus-visible { outline: 2px solid #fff; outline-offset: 3px; }

.chat-badge {
  position: absolute;
  top: -2px;
  right: -2px;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: 999px;
  background: var(--cyan);
  color: #04120f;
  font-size: 11px;
  font-weight: 700;
  display: grid;
  place-items: center;
}

.chat-teaser {
  width: min(300px, 100%);
  padding: 14px 14px 14px 16px;
  border-radius: 18px;
  background: rgba(7, 8, 12, 0.96);
  border: 1px solid var(--line);
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.45);
  color: var(--text);
  text-align: start;
  position: relative;
}

.chat-teaser__top {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}

.chat-teaser strong {
  font-size: 14px;
  letter-spacing: -0.03em;
}

.chat-teaser em {
  font-style: normal;
  color: var(--faint);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.chat-teaser p {
  color: var(--muted);
  font-size: 14px;
  padding-inline-end: 18px;
}

.chat-teaser__x {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 28px;
  height: 28px;
  border-radius: 8px;
  color: var(--faint);
}

.chat-teaser__x:hover { background: rgba(255, 255, 255, 0.08); color: #fff; }

.chat-panel {
  width: 100%;
  height: min(680px, calc(100dvh - var(--header) - 36px));
  display: none;
  flex-direction: column;
  border-radius: 22px;
  overflow: hidden;
  background:
    radial-gradient(120% 80% at 100% 0%, rgba(77, 124, 254, 0.16), transparent 46%),
    #07080c;
  border: 1px solid var(--line);
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.55);
  text-align: start;
}

.chat-dock.is-open .chat-panel { display: flex; }
.chat-dock.is-open .chat-launcher,
.chat-dock.is-open .chat-teaser { display: none; }

html.is-motion .chat-panel { animation: chat-in 180ms ease; }

@keyframes chat-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}

.chat-top {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 14px 14px 16px;
  border-bottom: 1px solid var(--line);
}

.chat-avatar {
  width: 42px;
  height: 42px;
  border-radius: 14px;
  background-color: #101218;
  background-image: url("../velto-mark.svg");
  background-repeat: no-repeat;
  background-position: center;
  background-size: 26px 26px;
  border: 1px solid var(--line);
  display: grid;
  place-items: center;
  position: relative;
  flex: none;
}

.chat-avatar i {
  position: absolute;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #3dde9a;
  border: 2px solid #07080c;
  right: -2px;
  bottom: -2px;
}

.chat-top__id { min-width: 0; flex: 1; }
.chat-top__id strong {
  display: block;
  font-size: 15px;
  letter-spacing: -0.04em;
  line-height: 1.1;
}
.chat-top__id em {
  display: block;
  margin-top: 4px;
  font-style: normal;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted);
}
.chat-top__id span {
  display: block;
  margin-top: 4px;
  color: var(--faint);
  font-size: 12px;
}

.chat-x {
  width: 36px;
  height: 36px;
  border-radius: 12px;
  color: var(--muted);
  flex: none;
}
.chat-x:hover { background: rgba(255, 255, 255, 0.08); color: #fff; }
.chat-x:focus-visible,
.chat-send:focus-visible,
.chat-chip:focus-visible,
.chat-jump:focus-visible,
.chat-request:focus-visible { outline: 2px solid #8eb6ff; outline-offset: 2px; }

.chat-log {
  position: relative;
  flex: 1;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  padding: 18px 16px 8px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.28) transparent;
}

.chat-log::before {
  content: "";
  position: absolute;
  width: 180px;
  height: 120px;
  right: -30px;
  bottom: 24px;
  background: url("../velto-mark.svg") center / contain no-repeat;
  opacity: 0.07;
  pointer-events: none;
}

.chat-empty {
  position: relative;
  color: var(--muted);
  font-size: 15px;
  max-width: 28ch;
  margin-top: 8px;
}

.chat-time {
  align-self: center;
  color: var(--faint);
  font-size: 11px;
  letter-spacing: 0.04em;
}

.chat-spacer { flex: 1 1 auto; min-height: 0; }
.chat-row { display: flex; align-items: flex-end; gap: 8px; max-width: 100%; min-width: 0; }
.chat-row--user { align-self: flex-end; max-width: 85%; }
.chat-row--agent { align-self: flex-start; max-width: 92%; }
.chat-row.is-grouped { margin-top: -6px; }

.chat-bubble {
  min-width: 0;
  padding: 10px 14px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.chat-row--agent .chat-bubble {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 4px 18px 18px 18px;
}

.chat-row--user .chat-bubble {
  background: linear-gradient(180deg, #5c8bff, #2f5fe0);
  color: #fff;
  border-radius: 18px 18px 4px 18px;
}

html[dir="rtl"] .chat-row--agent .chat-bubble { border-radius: 18px 4px 18px 18px; }
html[dir="rtl"] .chat-row--user .chat-bubble { border-radius: 18px 18px 18px 4px; }

.chat-mini {
  width: 22px;
  height: 16px;
  flex: none;
  opacity: 0;
  background: url("../velto-mark.svg") center / contain no-repeat;
}
.chat-row.is-tail .chat-mini { opacity: 1; }

.chat-note {
  align-self: center;
  max-width: 34ch;
  text-align: center;
  color: var(--faint);
  font-size: 13px;
  padding: 4px 8px;
}

.chat-note button {
  display: inline;
  margin-inline-start: 6px;
  color: var(--cyan);
  font-weight: 700;
  font-size: 13px;
}
.chat-note button:hover { color: #fff; }

.chat-typing {
  display: inline-flex;
  gap: 4px;
  padding: 12px 14px;
  border-radius: 4px 18px 18px 18px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.1);
}
.chat-typing i {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: rgba(244, 247, 251, 0.7);
}
html.is-motion .chat-typing i { animation: chat-dot 1s infinite ease-in-out; }
html.is-motion .chat-typing i:nth-child(2) { animation-delay: 0.15s; }
html.is-motion .chat-typing i:nth-child(3) { animation-delay: 0.3s; }

@keyframes chat-dot {
  0%, 80%, 100% { transform: translateY(0); opacity: 0.35; }
  40% { transform: translateY(-3px); opacity: 1; }
}

.chat-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 4px 16px 12px;
}

.chat-chip {
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.04);
  padding: 8px 14px;
  font-size: 14px;
  font-weight: 600;
}
.chat-chip:hover {
  border-color: rgba(140, 186, 255, 0.7);
  background: rgba(27, 58, 130, 0.55);
}

.chat-jump {
  align-self: center;
  margin: 0 16px 8px;
  border-radius: 999px;
  background: #fff;
  color: #000;
  font-size: 13px;
  font-weight: 700;
  padding: 6px 12px;
}

.chat-request {
  margin: 0 16px 12px;
  min-height: 48px;
  border-radius: 12px;
  background: #fff;
  color: #000;
  font-size: 15px;
  font-weight: 600;
}
.chat-request:hover { background: var(--blue); color: #fff; }

.chat-form {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 12px 12px calc(12px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
  background: rgba(0, 0, 0, 0.28);
}

.chat-form textarea {
  flex: 1;
  min-height: 44px;
  max-height: 120px;
  resize: none;
  padding: 10px 4px 10px 8px;
  line-height: 1.4;
}

.chat-form textarea::placeholder { color: var(--faint); }
.chat-form textarea:focus { outline: none; }

.chat-send {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: #fff;
  color: #000;
  display: grid;
  place-items: center;
  flex: none;
}
.chat-send:disabled {
  background: transparent;
  color: rgba(244, 247, 251, 0.38);
  box-shadow: inset 0 0 0 1.5px rgba(255, 255, 255, 0.18);
  cursor: default;
}
.chat-send:not(:disabled):hover { background: var(--blue); color: #fff; }
.chat-send svg { width: 18px; height: 18px; }

.chat-sr {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
}

@media (max-width: 720px) {
  .chat-dock {
    right: 16px;
    bottom: calc(16px + env(safe-area-inset-bottom));
    width: auto;
  }
  .chat-teaser { display: none !important; }
  .chat-dock.is-open {
    inset: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    max-width: none;
  }
  .chat-panel {
    width: 100%;
    height: 100%;
    max-height: none;
    border-radius: 0;
    border: 0;
  }
}

html.chat-open,
html.chat-open body { overflow: hidden; }

@media (prefers-reduced-motion: reduce) {
  .chat-panel { animation: none; }
  .chat-typing i { animation: none; }
}

@media print {
  .chat-dock { display: none !important; }
}

body:has(.header.is-open) .chat-dock,
body:has(.overlay.is-open) .chat-dock {
  visibility: hidden;
}
