/* ============================================================
   Webbuildr site chatbot — floating launcher + slide-up panel
   Drop-in: include this + /js/chat.js on any V2 page. The widget
   injects its own DOM, so no per-page markup is needed.
   Design tokens come from site.css :root.
   ============================================================ */

.wb-chat,
.wb-chat * {
  box-sizing: border-box;
}

.wb-chat {
  position: fixed;
  right: clamp(16px, 3vw, 28px);
  bottom: clamp(16px, 3vw, 28px);
  z-index: 600; /* above film grain (z-400) */
  font-family: var(--font-body);
}

/* ---------- Launcher ---------- */
.wb-chat-launcher {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 13px 20px 13px 16px;
  border: 1px solid rgba(147, 197, 253, 0.35);
  border-radius: 100px;
  background: linear-gradient(135deg, var(--electric), var(--sky));
  color: #fff;
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 12px 34px rgba(29, 78, 216, 0.45);
  transition: transform 0.25s ease, box-shadow 0.25s ease, opacity 0.2s ease;
}
.wb-chat-launcher:hover {
  transform: translateY(-2px);
  box-shadow: 0 18px 46px rgba(29, 78, 216, 0.6);
}
.wb-chat-launcher:focus-visible {
  outline: 2px solid #fff;
  outline-offset: 3px;
}
.wb-chat-launcher svg {
  width: 22px;
  height: 22px;
  flex: 0 0 auto;
}
.wb-chat-launcher .wb-chat-dot {
  position: absolute;
  top: 10px;
  right: 14px;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--green-light);
  box-shadow: 0 0 0 3px rgba(110, 231, 183, 0.25);
}
/* Hide launcher when the panel is open */
.wb-chat.open .wb-chat-launcher {
  opacity: 0;
  pointer-events: none;
  transform: scale(0.9);
}

/* ---------- Panel ---------- */
.wb-chat-panel {
  position: absolute;
  right: 0;
  bottom: 0;
  width: min(384px, calc(100vw - 32px));
  height: min(580px, calc(100vh - 110px));
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: linear-gradient(180deg, #0a1838, var(--bg-deep));
  box-shadow: 0 30px 90px rgba(2, 6, 18, 0.7);
  opacity: 0;
  transform: translateY(18px) scale(0.98);
  transform-origin: bottom right;
  pointer-events: none;
  transition: opacity 0.28s ease, transform 0.28s ease;
}
.wb-chat.open .wb-chat-panel {
  opacity: 1;
  transform: none;
  pointer-events: auto;
}

/* ---------- Header ---------- */
.wb-chat-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 16px 15px;
  background: linear-gradient(135deg, rgba(29, 78, 216, 0.55), rgba(59, 130, 246, 0.25));
  border-bottom: 1px solid var(--line);
}
.wb-chat-avatar {
  width: 38px;
  height: 38px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: rgba(5, 12, 38, 0.5);
  border: 1px solid rgba(147, 197, 253, 0.4);
}
.wb-chat-avatar img {
  width: 22px;
  height: 22px;
}
.wb-chat-head-text {
  flex: 1 1 auto;
  min-width: 0;
}
.wb-chat-title {
  display: block;
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 600;
  color: #fff;
  line-height: 1.2;
}
.wb-chat-sub {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--t-secondary);
  margin-top: 2px;
}
.wb-chat-sub i {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--green-light);
  box-shadow: 0 0 8px rgba(110, 231, 183, 0.8);
}
.wb-chat-close {
  flex: 0 0 auto;
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--t-secondary);
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
}
.wb-chat-close:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
}
.wb-chat-close svg {
  width: 18px;
  height: 18px;
}

/* ---------- Messages ---------- */
.wb-chat-msgs {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 18px 16px 8px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  scrollbar-width: thin;
  scrollbar-color: rgba(147, 197, 253, 0.35) transparent;
}
.wb-chat-msgs::-webkit-scrollbar {
  width: 7px;
}
.wb-chat-msgs::-webkit-scrollbar-thumb {
  background: rgba(147, 197, 253, 0.3);
  border-radius: 100px;
}

.wb-msg {
  max-width: 86%;
  font-size: 14px;
  line-height: 1.55;
  padding: 11px 14px;
  border-radius: 16px;
  white-space: normal;
  word-wrap: break-word;
  overflow-wrap: anywhere;
}
.wb-msg a {
  color: var(--mist);
  text-decoration: underline;
  text-underline-offset: 2px;
}
.wb-msg a:hover {
  color: #fff;
}
.wb-msg p {
  margin: 0 0 8px;
}
.wb-msg p:last-child {
  margin-bottom: 0;
}
.wb-msg ul {
  margin: 6px 0;
  padding-left: 18px;
}
.wb-msg li {
  margin: 3px 0;
}
.wb-msg strong {
  color: #fff;
  font-weight: 600;
}
.wb-msg.bot {
  align-self: flex-start;
  background: rgba(20, 43, 92, 0.6);
  border: 1px solid var(--line);
  color: var(--t-body);
  border-bottom-left-radius: 6px;
}
.wb-msg.user {
  align-self: flex-end;
  background: linear-gradient(135deg, var(--electric), var(--sky));
  color: #fff;
  border-bottom-right-radius: 6px;
}

/* Typing indicator */
.wb-typing {
  display: inline-flex;
  gap: 4px;
  align-items: center;
  padding: 4px 2px;
}
.wb-typing span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--mist);
  opacity: 0.5;
  animation: wb-bounce 1.2s infinite ease-in-out;
}
.wb-typing span:nth-child(2) {
  animation-delay: 0.18s;
}
.wb-typing span:nth-child(3) {
  animation-delay: 0.36s;
}
@keyframes wb-bounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.5; }
  30% { transform: translateY(-4px); opacity: 1; }
}

/* ---------- Suggested chips ---------- */
.wb-chat-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 4px 16px 14px;
}
.wb-chip {
  font-family: var(--font-body);
  font-size: 12.5px;
  color: var(--t-secondary);
  background: rgba(20, 43, 92, 0.5);
  border: 1px solid var(--line);
  border-radius: 100px;
  padding: 8px 13px;
  cursor: pointer;
  transition: border-color 0.2s, color 0.2s, background 0.2s;
}
.wb-chip:hover {
  border-color: var(--sky);
  color: #fff;
  background: rgba(29, 78, 216, 0.3);
}

/* ---------- Composer ---------- */
.wb-chat-form {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 12px 14px;
  border-top: 1px solid var(--line);
  background: rgba(5, 12, 38, 0.4);
}
.wb-chat-input {
  flex: 1 1 auto;
  resize: none;
  max-height: 120px;
  font-family: var(--font-body);
  font-size: 14px;
  line-height: 1.4;
  color: var(--ice);
  background: rgba(5, 12, 38, 0.6);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 12px;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.wb-chat-input::placeholder {
  color: rgba(147, 197, 253, 0.5);
}
.wb-chat-input:focus {
  outline: none;
  border-color: var(--sky);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
}
.wb-chat-send {
  flex: 0 0 auto;
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border: none;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--electric), var(--sky));
  color: #fff;
  cursor: pointer;
  transition: transform 0.2s, opacity 0.2s, box-shadow 0.2s;
}
.wb-chat-send:hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 22px rgba(29, 78, 216, 0.5);
}
.wb-chat-send:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}
.wb-chat-send svg {
  width: 19px;
  height: 19px;
}
.wb-chat-foot {
  text-align: center;
  font-size: 11px;
  color: var(--t-muted);
  padding: 0 14px 10px;
}
.wb-chat-foot a {
  color: var(--mist);
  text-decoration: underline;
}

/* ---------- Mobile ---------- */
@media (max-width: 520px) {
  .wb-chat {
    right: 14px;
    bottom: 14px;
  }
  .wb-chat-panel {
    position: fixed;
    right: 10px;
    left: 10px;
    bottom: 10px;
    width: auto;
    height: min(78vh, 560px);
  }
  .wb-chat-launcher .wb-chat-label {
    display: none;
  }
  .wb-chat-launcher {
    padding: 14px;
  }
}

/* ---------- Reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  .wb-chat-launcher,
  .wb-chat-panel,
  .wb-chat-send,
  .wb-typing span {
    transition: none;
    animation: none;
  }
}
