/* =====================================================================
   CalmTech Assistant — widget styles (matches calmtech.ca brand)
   z-index 9000 keeps the chat BELOW the site's Terms/Privacy/FAQ pop-ups.
   ===================================================================== */
#ctc-launcher, #ctc-window, #ctc-teaser {
  --ctc-navy: #0B1F3A; --ctc-teal: #087A78; --ctc-mid: #0ABFBC; --ctc-sky: #2ED8D5;
  --ctc-ice: #E0FAFA; --ctc-bg: #F4FEFE; --ctc-text: #1C2B3A; --ctc-muted: #627B96;
  --ctc-border: #B2E8E8;
  font-family: 'Poppins', system-ui, -apple-system, 'Segoe UI', sans-serif;
  box-sizing: border-box;
}
#ctc-window *, #ctc-window *::before, #ctc-window *::after { box-sizing: border-box; }

/* ---------- Launcher button ---------- */
#ctc-launcher {
  position: fixed; right: 24px; bottom: 24px; z-index: 9000;
  width: 62px; height: 62px; border-radius: 50%; border: none; cursor: pointer;
  background: linear-gradient(135deg, var(--ctc-mid), var(--ctc-teal));
  box-shadow: 0 8px 24px rgba(8, 122, 120, .45);
  display: flex; align-items: center; justify-content: center;
  transition: transform .2s ease, box-shadow .2s ease;
}
#ctc-launcher:hover { transform: translateY(-2px) scale(1.04); box-shadow: 0 12px 28px rgba(8, 122, 120, .55); }
#ctc-launcher:focus-visible { outline: 3px solid var(--ctc-sky); outline-offset: 3px; }
#ctc-launcher svg { width: 28px; height: 28px; position: absolute; transition: opacity .2s, transform .2s; }
#ctc-launcher .ctc-ico-chat { fill: #fff; }
#ctc-launcher .ctc-ico-close { fill: none; stroke: #fff; stroke-width: 2.5; stroke-linecap: round; opacity: 0; transform: rotate(-90deg); }
#ctc-launcher.ctc-active .ctc-ico-chat { opacity: 0; transform: rotate(90deg); }
#ctc-launcher.ctc-active .ctc-ico-close { opacity: 1; transform: rotate(0); }
#ctc-badge {
  position: absolute; top: -2px; right: -2px; min-width: 20px; height: 20px; padding: 0 5px;
  border-radius: 10px; background: #D97706; color: #fff; font-size: 11px; font-weight: 700;
  line-height: 20px; text-align: center; border: 2px solid #fff;
}

/* ---------- Teaser bubble ---------- */
#ctc-teaser {
  position: fixed; right: 24px; bottom: 98px; z-index: 9000; max-width: 260px;
  background: #fff; color: var(--ctc-text); border: 1px solid var(--ctc-border);
  border-radius: 14px 14px 4px 14px; padding: 12px 34px 12px 14px;
  font-size: 13.5px; line-height: 1.45; box-shadow: 0 10px 30px rgba(11, 31, 58, .15);
  cursor: pointer; opacity: 0; transform: translateY(8px); pointer-events: none;
  transition: opacity .3s, transform .3s;
}
#ctc-teaser.ctc-show { opacity: 1; transform: none; pointer-events: auto; }
#ctc-teaser button {
  position: absolute; top: 4px; right: 6px; border: none; background: none; cursor: pointer;
  font-size: 18px; color: var(--ctc-muted); line-height: 1; padding: 4px;
}

/* ---------- Chat window ---------- */
#ctc-window {
  position: fixed; right: 24px; bottom: 98px; z-index: 9000;
  width: 380px; height: min(600px, calc(100vh - 130px));
  background: #fff; border-radius: 18px; overflow: hidden;
  box-shadow: 0 18px 50px rgba(11, 31, 58, .28);
  display: flex; flex-direction: column;
  opacity: 0; transform: translateY(16px) scale(.98); pointer-events: none; visibility: hidden;
  transition: opacity .22s ease, transform .22s ease, visibility 0s linear .22s;
}
#ctc-window.ctc-open {
  opacity: 1; transform: none; pointer-events: auto; visibility: visible;
  transition: opacity .22s ease, transform .22s ease;
}

#ctc-header {
  display: flex; align-items: center; gap: 12px; padding: 14px 16px;
  background: var(--ctc-navy); color: #fff; border-bottom: 2px solid var(--ctc-mid);
}
.ctc-avatar {
  width: 38px; height: 38px; border-radius: 10px; flex-shrink: 0;
  background: linear-gradient(135deg, var(--ctc-mid), var(--ctc-sky));
  display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: 13px;
}
.ctc-title { flex: 1; display: flex; flex-direction: column; line-height: 1.3; }
.ctc-title strong { font-size: 15px; font-weight: 600; }
.ctc-title span { font-size: 11.5px; color: rgba(255, 255, 255, .7); display: flex; align-items: center; gap: 6px; }
.ctc-title i { width: 7px; height: 7px; border-radius: 50%; background: #22C55E; display: inline-block; }
#ctc-close {
  background: none; border: none; color: #fff; font-size: 26px; line-height: 1; cursor: pointer;
  width: 34px; height: 34px; border-radius: 8px; opacity: .8;
}
#ctc-close:hover { background: rgba(255, 255, 255, .1); opacity: 1; }

#ctc-messages {
  flex: 1; overflow-y: auto; padding: 16px 14px 8px; background: var(--ctc-bg);
  display: flex; flex-direction: column; gap: 8px; overscroll-behavior: contain;
}
.ctc-msg {
  max-width: 86%; padding: 10px 13px; border-radius: 14px; font-size: 13.5px; line-height: 1.55;
  white-space: pre-line; word-wrap: break-word; animation: ctc-in .2s ease;
}
.ctc-bot { align-self: flex-start; background: #fff; color: var(--ctc-text); border: 1px solid var(--ctc-border); border-bottom-left-radius: 4px; }
.ctc-user { align-self: flex-end; background: var(--ctc-teal); color: #fff; border-bottom-right-radius: 4px; }
.ctc-bot strong { color: var(--ctc-navy); font-weight: 600; }
.ctc-note { margin-top: 8px; padding-top: 6px; border-top: 1px dashed var(--ctc-border); font-size: 11.5px; color: var(--ctc-muted); }

.ctc-actions { display: flex; flex-wrap: wrap; gap: 6px; align-self: flex-start; max-width: 92%; margin-bottom: 4px; }
.ctc-action {
  display: inline-block; padding: 6px 11px; border-radius: 8px; font: inherit; font-size: 12.5px; font-weight: 500;
  background: var(--ctc-navy); color: #fff !important; text-decoration: none; border: none; cursor: pointer;
}
.ctc-action:hover { background: var(--ctc-teal); }

.ctc-typing { display: flex; gap: 4px; padding: 13px 14px; }
.ctc-typing span { width: 7px; height: 7px; border-radius: 50%; background: var(--ctc-mid); animation: ctc-dot 1s infinite ease-in-out; }
.ctc-typing span:nth-child(2) { animation-delay: .15s; }
.ctc-typing span:nth-child(3) { animation-delay: .3s; }

#ctc-chips { display: flex; gap: 6px; padding: 8px 12px; overflow-x: auto; background: var(--ctc-bg); scrollbar-width: thin; }
#ctc-chips:empty { display: none; }
.ctc-chip {
  flex-shrink: 0; padding: 6px 12px; border-radius: 16px; font: inherit; font-size: 12.5px; cursor: pointer;
  background: #fff; color: var(--ctc-teal); border: 1px solid var(--ctc-mid); white-space: nowrap;
}
.ctc-chip:hover { background: var(--ctc-ice); }

#ctc-form { display: flex; align-items: center; gap: 8px; padding: 10px 12px; border-top: 1px solid var(--ctc-border); background: #fff; }
#ctc-input {
  flex: 1; min-width: 0; border: 1px solid var(--ctc-border); border-radius: 22px; padding: 10px 14px;
  font: inherit; font-size: 14px; color: var(--ctc-text); outline: none; background: #fff;
}
#ctc-input:focus { border-color: var(--ctc-mid); box-shadow: 0 0 0 3px rgba(10, 191, 188, .15); }
#ctc-send {
  width: 40px; height: 40px; flex-shrink: 0; border-radius: 50%; border: none; cursor: pointer;
  background: var(--ctc-teal); display: flex; align-items: center; justify-content: center;
}
#ctc-send:hover { background: var(--ctc-navy); }
#ctc-send svg { width: 18px; height: 18px; fill: #fff; }
#ctc-footer { font-size: 10.5px; color: var(--ctc-muted); text-align: center; padding: 0 12px 8px; background: #fff; }

@keyframes ctc-in { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
@keyframes ctc-dot { 0%, 80%, 100% { opacity: .3; transform: translateY(0); } 40% { opacity: 1; transform: translateY(-3px); } }

/* ---------- Phones: full-screen chat ---------- */
@media (max-width: 600px) {
  #ctc-launcher { right: 16px; bottom: 16px; width: 56px; height: 56px; }
  #ctc-teaser { right: 16px; bottom: 84px; }
  #ctc-window { right: 0; bottom: 0; width: 100%; height: 100%; height: 100dvh; border-radius: 0; }
  #ctc-launcher.ctc-active { display: none; }
  #ctc-input { font-size: 16px; } /* stops iPhone zooming in */
}

@media (prefers-reduced-motion: reduce) {
  #ctc-window, #ctc-teaser, #ctc-launcher, .ctc-msg, .ctc-typing span { transition: none !important; animation: none !important; }
}
