/* ==========================================================
   Wolff Wisdom AI Solutions — chat assistant
   Uses the brand tokens defined in styles.css (:root).
   ========================================================== */

/* Own design tokens, so the widget looks right on any website. */
.wwchat {
  --wwchat-w: 390px;
  --navy: #07080f; --light: #f4f5f9; --border: #e3e5ee; --text: #1c2533; --muted: #5b6676;
  --accent: #d81b76; --cyan: #22c8f0;
  --brand-gradient: linear-gradient(95deg, #e6207f 0%, #ff7a1a 100%);
  --spectrum: linear-gradient(90deg, #e6207f 0%, #ff7a1a 45%, #22c8f0 100%);
  --font: "Montserrat", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-family: var(--font);
  line-height: 1.5;
}
.wwchat *, .wwchat *::before, .wwchat *::after { box-sizing: border-box; }

/* PlowPath theme (plowpath.ca): its blue-to-violet brand colours. */
.wwchat[data-theme="plowpath"] {
  --navy: #0b1220;
  --accent: #2563eb; --cyan: #38bdf8;
  --brand-gradient: linear-gradient(95deg, #3b82f6 0%, #8b5cf6 100%);
  --spectrum: linear-gradient(90deg, #38bdf8 0%, #3b82f6 50%, #8b5cf6 100%);
}
.wwchat[data-theme="plowpath"] .wwchat-launcher { box-shadow: 0 10px 30px rgba(59, 130, 246, .45); }
.wwchat[data-theme="plowpath"] .wwchat-chip { border-color: rgba(37, 99, 235, .35); }

/* ---------- Launcher ---------- */
.wwchat-launcher {
  position: fixed; right: 24px; bottom: 24px; z-index: 300;
  width: 60px; height: 60px; border: 0; border-radius: 50%; cursor: pointer;
  display: grid; place-items: center; color: #fff;
  background: var(--brand-gradient);
  box-shadow: 0 10px 30px rgba(230, 32, 127, .4), 0 0 0 0 rgba(34, 200, 240, .5);
  transition: transform .2s, box-shadow .2s;
  animation: wwchat-ping 3s ease-out 2s 2;
}
.wwchat-launcher:hover { transform: translateY(-2px) scale(1.04); }
.wwchat-launcher:focus-visible { outline: 3px solid var(--cyan); outline-offset: 3px; }
.wwchat-launcher svg { width: 26px; height: 26px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.wwchat-launcher-close { display: none; }
.wwchat.is-open .wwchat-launcher-open { display: none; }
.wwchat.is-open .wwchat-launcher-close { display: grid; }
@keyframes wwchat-ping {
  0%   { box-shadow: 0 10px 30px rgba(230, 32, 127, .4), 0 0 0 0 rgba(34, 200, 240, .55); }
  100% { box-shadow: 0 10px 30px rgba(230, 32, 127, .4), 0 0 0 18px rgba(34, 200, 240, 0); }
}

/* ---------- Panel ---------- */
.wwchat-panel {
  position: fixed; right: 24px; bottom: 100px; z-index: 300;
  width: var(--wwchat-w); height: min(640px, calc(100vh - 140px));
  display: flex; flex-direction: column; overflow: hidden;
  background: #fff; color: var(--text);
  border-radius: 20px; border: 1px solid var(--border);
  box-shadow: 0 30px 70px rgba(7, 8, 15, .3);
  transform-origin: bottom right;
  animation: wwchat-in .22s ease-out;
}
.wwchat-panel[hidden] { display: none; }
@keyframes wwchat-in { from { opacity: 0; transform: translateY(12px) scale(.97); } to { opacity: 1; transform: none; } }

.wwchat-head {
  position: relative; display: flex; align-items: center; gap: 12px;
  padding: 16px 14px 16px 18px; color: #fff;
  background:
    radial-gradient(circle at 0% 100%, rgba(230, 32, 127, .35), transparent 55%),
    radial-gradient(circle at 100% 0%, rgba(34, 200, 240, .3), transparent 55%),
    var(--navy);
}
.wwchat-head::after { content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 2px; background: var(--spectrum); }
.wwchat-avatar {
  width: 38px; height: 38px; flex-shrink: 0; border-radius: 50%;
  display: grid; place-items: center; font-weight: 800; font-size: 16px;
  background: var(--brand-gradient);
}
.wwchat-head-text { flex: 1; min-width: 0; line-height: 1.25; }
.wwchat-title { display: block; font-size: 15.5px; }
.wwchat-subtitle { display: flex; align-items: center; gap: 6px; font-size: 12px; color: rgba(255,255,255,.7); }
.wwchat-subtitle::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: #2ecc71; flex-shrink: 0; }
.wwchat-icon-btn {
  width: 36px; height: 36px; border: 0; border-radius: 10px; cursor: pointer;
  display: grid; place-items: center; color: rgba(255,255,255,.85); background: transparent;
}
.wwchat-icon-btn:hover { background: rgba(255,255,255,.1); color: #fff; }
.wwchat-icon-btn:focus-visible { outline: 2px solid var(--cyan); }
.wwchat-icon-btn svg { width: 19px; height: 19px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- Messages ---------- */
.wwchat-log {
  flex: 1; overflow-y: auto; overscroll-behavior: contain;
  padding: 18px 16px 8px; display: flex; flex-direction: column; gap: 10px;
  background: var(--light);
}
.wwchat-msg {
  max-width: 86%; padding: 11px 14px; border-radius: 16px;
  font-size: 14.5px; line-height: 1.55; overflow-wrap: anywhere;
}
.wwchat-msg p { margin: 0 0 .6em; }
.wwchat-msg p:last-child, .wwchat-msg ul:last-child, .wwchat-msg ol:last-child { margin-bottom: 0; }
.wwchat-msg ul, .wwchat-msg ol { margin: 0 0 .6em; padding-left: 1.2em; }
.wwchat-msg li { margin-bottom: .25em; }
.wwchat-assistant {
  align-self: flex-start; background: #fff; color: var(--text);
  border: 1px solid var(--border); border-bottom-left-radius: 5px;
}
.wwchat-assistant a { color: var(--accent); font-weight: 600; text-decoration: underline; text-underline-offset: 2px; }
/* Tutorial video card (a whole assistant message) */
.wwchat-msg:has(> .wwchat-video) { padding: 0; border: 0; background: none; }
.wwchat-assistant a.wwchat-video {
  display: flex; align-items: center; gap: 12px; padding: 10px 14px 10px 10px;
  border: 1px solid var(--border); border-radius: 14px; background: #fff;
  color: var(--text); text-decoration: none; font-weight: 400;
  transition: border-color .15s, box-shadow .15s;
}
.wwchat-assistant a.wwchat-video:hover, .wwchat-assistant a.wwchat-video:focus-visible { border-color: var(--accent); box-shadow: 0 4px 14px rgba(0,0,0,.08); }
.wwchat-video-play {
  flex: none; display: grid; place-items: center; width: 44px; height: 44px; border-radius: 10px;
  background: var(--brand-gradient);
}
.wwchat-video-play svg { width: 20px; height: 20px; fill: #fff; margin-left: 2px; }
.wwchat-video-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.wwchat-video-text strong { font-weight: 600; line-height: 1.3; }
.wwchat-video-text small { color: var(--muted); font-size: 12.5px; }

.wwchat-user {
  align-self: flex-end; color: #fff; white-space: pre-wrap;
  background: var(--brand-gradient); border-bottom-right-radius: 5px;
}

.wwchat-typing { display: flex; gap: 5px; padding: 14px 16px; }
.wwchat-typing span { width: 7px; height: 7px; border-radius: 50%; background: var(--muted); opacity: .4; animation: wwchat-dot 1.2s infinite; }
.wwchat-typing span:nth-child(2) { animation-delay: .15s; }
.wwchat-typing span:nth-child(3) { animation-delay: .3s; }
@keyframes wwchat-dot { 0%, 60%, 100% { opacity: .3; transform: none; } 30% { opacity: 1; transform: translateY(-3px); } }

.wwchat-notice { align-self: center; max-width: 92%; padding: 7px 12px; border-radius: 10px; font-size: 13px; text-align: center; }
.wwchat-notice-success { color: #0f6b3a; background: #ddf6e7; }
.wwchat-notice-error { color: #9b1239; background: #fde4ec; }

/* ---------- Quick replies ---------- */
.wwchat-chips { display: flex; flex-wrap: wrap; gap: 8px; padding: 4px 16px 12px; background: var(--light); }
.wwchat-chips[hidden] { display: none; }
.wwchat-chip {
  padding: 8px 13px; border-radius: 50px; cursor: pointer;
  font: 600 13px/1.2 var(--font); color: var(--accent);
  background: #fff; border: 1px solid rgba(230, 32, 127, .35);
  transition: background .15s, color .15s;
}
.wwchat-chip:hover { background: var(--accent); color: #fff; }
.wwchat-chip:focus-visible { outline: 2px solid var(--cyan); outline-offset: 2px; }

/* ---------- Input ---------- */
.wwchat-form { display: flex; align-items: flex-end; gap: 8px; padding: 12px 12px 8px; border-top: 1px solid var(--border); background: #fff; }
.wwchat-input {
  flex: 1; resize: none; max-height: 120px; padding: 11px 14px; overflow-y: hidden;
  font: 15px/1.4 var(--font); color: var(--text);
  border: 1px solid var(--border); border-radius: 14px; background: var(--light);
}
.wwchat-input:focus { outline: none; border-color: var(--cyan); box-shadow: 0 0 0 3px rgba(34, 200, 240, .2); background: #fff; }
.wwchat-send {
  width: 44px; height: 44px; flex-shrink: 0; border: 0; border-radius: 12px; cursor: pointer;
  display: grid; place-items: center; color: #fff; background: var(--brand-gradient);
  transition: opacity .15s, transform .15s;
}
.wwchat-send:hover:not(:disabled) { transform: translateY(-1px); }
.wwchat-send:disabled { opacity: .45; cursor: default; }
.wwchat-send:focus-visible { outline: 2px solid var(--cyan); outline-offset: 2px; }
.wwchat-send svg { width: 19px; height: 19px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.wwchat-note { margin: 0; padding: 0 16px 10px; font-size: 11px; line-height: 1.4; color: var(--muted); background: #fff; }

/* ---------- Phones: full screen ---------- */
@media (max-width: 640px) {
  .wwchat-launcher { right: 16px; bottom: 16px; width: 56px; height: 56px; }
  .wwchat.is-open .wwchat-launcher { display: none; }
  .wwchat-panel {
    inset: 0; right: 0; bottom: 0; width: 100%; height: 100%; height: 100dvh;
    border-radius: 0; border: 0;
  }
  .wwchat-input { font-size: 16px; } /* prevents iOS zoom on focus */
  html.wwchat-lock, html.wwchat-lock body { overflow: hidden; }
}

@media (prefers-reduced-motion: reduce) {
  .wwchat-launcher, .wwchat-panel, .wwchat-typing span { animation: none; }
}
.wwchat-note a { color: var(--accent); text-decoration: underline; }

/* ---------- Greeting bubble next to the button ---------- */
.wwchat-popup {
  position: fixed; right: 24px; bottom: 96px; z-index: 299;
  display: flex; align-items: flex-start; gap: 4px; max-width: 280px;
  padding: 12px 8px 12px 16px; border-radius: 16px 16px 4px 16px;
  background: #fff; color: var(--text); border: 1px solid var(--border);
  box-shadow: 0 16px 40px rgba(7, 8, 15, .18);
  animation: wwchat-in .3s ease-out;
}
.wwchat-popup[hidden] { display: none; }
.wwchat-popup-text {
  flex: 1; padding: 0; border: 0; background: none; cursor: pointer; text-align: left;
  font: 500 14px/1.45 var(--font); color: var(--text);
}
.wwchat-popup-close {
  width: 26px; height: 26px; flex-shrink: 0; border: 0; border-radius: 50%; cursor: pointer;
  font: 400 18px/1 var(--font); color: var(--muted); background: transparent;
}
.wwchat-popup-close:hover { background: var(--light); color: var(--text); }
.wwchat-popup-text:focus-visible, .wwchat-popup-close:focus-visible { outline: 2px solid var(--cyan); outline-offset: 2px; }
.wwchat.is-open .wwchat-popup { display: none; }
@media (max-width: 640px) {
  .wwchat-popup { right: 16px; bottom: 84px; max-width: calc(100vw - 32px); }
}
