/* Dart assistant. Loaded on every page from partials/footer.php.
   Scoped under #dchat so it cannot reach into any page's own styles. */

#dchat {
  --dc-ink: #ffffff;
  --dc-muted: rgba(255, 255, 255, .62);
  --dc-line: rgba(255, 255, 255, .12);
  --dc-panel: #121216;
  --dc-raise: #1b1b21;
  --dc-brand: #a41ee0;
  --dc-brand-2: #e0218a;
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 9999;
  font-family: inherit;
}

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

/* launcher */
#dchat .dchat-fab {
  width: 56px; height: 56px;
  border: 0; border-radius: 50%;
  background: linear-gradient(135deg, var(--dc-brand), var(--dc-brand-2));
  color: #fff;
  cursor: pointer;
  display: grid; place-items: center;
  box-shadow: 0 10px 30px rgba(164, 30, 224, .38);
  transition: transform .18s ease, box-shadow .18s ease;
}
#dchat .dchat-fab:hover { transform: translateY(-2px); box-shadow: 0 14px 36px rgba(164, 30, 224, .5); }
#dchat .dchat-fab:focus-visible { outline: 2px solid #fff; outline-offset: 3px; }
#dchat .dchat-fab svg { width: 26px; height: 26px; fill: currentColor; }
#dchat .dchat-fab .i-close { display: none; }
#dchat.on .dchat-fab .i-chat { display: none; }
#dchat.on .dchat-fab .i-close { display: block; }

/* panel */
#dchat .dchat-panel {
  position: absolute;
  right: 0; bottom: 70px;
  width: min(370px, calc(100vw - 32px));
  max-height: min(560px, calc(100vh - 130px));
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--dc-panel);
  color: var(--dc-ink);
  border: 1px solid var(--dc-line);
  border-radius: 18px;
  box-shadow: 0 26px 70px rgba(0, 0, 0, .55);
  opacity: 0;
  transform: translateY(10px) scale(.98);
  transform-origin: bottom right;
  transition: opacity .18s ease, transform .18s ease;
}
#dchat.on .dchat-panel { opacity: 1; transform: none; }

#dchat .dchat-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 14px 12px;
  border-bottom: 1px solid var(--dc-line);
  background: linear-gradient(135deg, rgba(164, 30, 224, .20), rgba(224, 33, 138, .12));
}
#dchat .dchat-head .dot {
  width: 9px; height: 9px;
  border-radius: 50%;
  background: #2fd07a;
  box-shadow: 0 0 0 3px rgba(47, 208, 122, .18);
  flex: none;
}
#dchat .dchat-head b { display: block; font-size: 15px; line-height: 1.2; }
#dchat .dchat-head i { display: block; font-style: normal; font-size: 12px; color: var(--dc-muted); }
#dchat .dchat-x {
  margin-left: auto;
  width: 28px; height: 28px;
  border: 0; border-radius: 8px;
  background: transparent;
  color: var(--dc-muted);
  font-size: 20px; line-height: 1;
  cursor: pointer;
}
#dchat .dchat-x:hover { background: rgba(255, 255, 255, .08); color: #fff; }

#dchat .dchat-log {
  flex: 1;
  min-height: 150px;
  overflow-y: auto;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

#dchat .dchat-msg {
  max-width: 86%;
  padding: 10px 13px;
  border-radius: 14px;
  font-size: 14px;
  line-height: 1.5;
  word-wrap: break-word;
}
#dchat .dchat-msg.bot {
  align-self: flex-start;
  background: var(--dc-raise);
  border: 1px solid var(--dc-line);
  border-bottom-left-radius: 5px;
  color: rgba(255, 255, 255, .88);
}
#dchat .dchat-msg.me {
  align-self: flex-end;
  background: linear-gradient(135deg, var(--dc-brand), var(--dc-brand-2));
  border-bottom-right-radius: 5px;
  color: #fff;
}
#dchat .dchat-msg a { color: #d98bff; text-decoration: underline; }
#dchat .dchat-msg.me a { color: #fff; }

#dchat .dchat-msg.typing { display: flex; gap: 4px; padding: 13px; }
#dchat .dchat-msg.typing span {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--dc-muted);
  animation: dchat-blink 1.1s infinite;
}
#dchat .dchat-msg.typing span:nth-child(2) { animation-delay: .18s; }
#dchat .dchat-msg.typing span:nth-child(3) { animation-delay: .36s; }
@keyframes dchat-blink { 0%, 60%, 100% { opacity: .25 } 30% { opacity: 1 } }

#dchat .dchat-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  padding: 0 14px 10px;
}
#dchat .dchat-chips button {
  border: 1px solid var(--dc-line);
  background: rgba(255, 255, 255, .04);
  color: rgba(255, 255, 255, .8);
  font: inherit;
  font-size: 12.5px;
  padding: 6px 11px;
  border-radius: 999px;
  cursor: pointer;
}
#dchat .dchat-chips button:hover { background: rgba(255, 255, 255, .1); color: #fff; }

#dchat .dchat-form {
  display: flex;
  gap: 8px;
  padding: 10px 12px 12px;
  border-top: 1px solid var(--dc-line);
}
#dchat .dchat-form input {
  flex: 1;
  min-width: 0;
  background: var(--dc-raise);
  border: 1px solid var(--dc-line);
  border-radius: 10px;
  padding: 10px 12px;
  color: #fff;
  font: inherit;
  font-size: 14px;
}
#dchat .dchat-form input::placeholder { color: rgba(255, 255, 255, .42) }
#dchat .dchat-form input:focus { outline: none; border-color: rgba(164, 30, 224, .7) }
#dchat .dchat-form button {
  width: 40px;
  border: 0; border-radius: 10px;
  background: linear-gradient(135deg, var(--dc-brand), var(--dc-brand-2));
  color: #fff;
  cursor: pointer;
  display: grid; place-items: center;
  flex: none;
}
#dchat .dchat-form button svg { width: 17px; height: 17px; fill: currentColor }

@media (max-width: 520px) {
  #dchat { right: 14px; bottom: 14px }
  #dchat .dchat-panel { bottom: 66px; max-height: calc(100vh - 110px) }
}

@media (prefers-reduced-motion: reduce) {
  #dchat .dchat-fab,
  #dchat .dchat-panel { transition: none }
  #dchat .dchat-msg.typing span { animation: none }
}
