/* =============================================================================
   CallCenturion™ — Website Chatbot Widget
   Standalone stylesheet; loaded on every marketing-website page.
   Uses brand tokens where present; defines own fallbacks for safe isolation.
   ============================================================================= */

/* ── Design tokens (fall back to brand values if tokens.css not loaded) ─────── */
:root {
  --cc-primary:      var(--color-primary,   #1E5EFF);
  --cc-cyan:         var(--color-cyan,       #40E0D0);
  --cc-bg-dark:      var(--color-bg-dark,    #090f1f);
  --cc-text:         var(--color-text,       #1A202C);
  --cc-text-muted:   var(--color-text-muted, #718096);
  --cc-border:       var(--color-border,     #E2E8F0);
  --cc-font:         var(--font, 'Inter', -apple-system, sans-serif);
  --cc-radius:       12px;
  --cc-shadow:       0 8px 32px rgba(0,0,0,0.18);
  --cc-widget-z:     9998;    /* below cookie banner (99999) */
  --cc-panel-w:      380px;
  --cc-panel-h:      560px;
}

/* ── Floating trigger button ─────────────────────────────────────────────────── */
/* Hidden by default; chatbot.js reveals it only after a successful /ping probe.
   This enables dark-deploy: the button stays invisible until CHATBOT_ENABLED=true
   is set on the Lambda, with no marketing-site re-deploy required. */
#cc-chat-btn {
  position: fixed;
  bottom: 28px;
  right: 28px;
  z-index: var(--cc-widget-z);
  width: 58px;
  height: 58px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--cc-primary) 0%, var(--cc-cyan) 100%);
  border: none;
  cursor: pointer;
  display: none;          /* hidden until probe succeeds */
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 16px rgba(30,94,255,0.4);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  outline-offset: 3px;
}
#cc-chat-btn.cc-visible { display: flex; }
#cc-chat-btn:hover  { transform: scale(1.08); box-shadow: 0 6px 22px rgba(30,94,255,0.5); }
#cc-chat-btn:focus-visible { outline: 3px solid var(--cc-cyan); }
#cc-chat-btn svg    { width: 26px; height: 26px; fill: #fff; pointer-events: none; }
#cc-chat-btn[data-open="true"] .cc-icon-chat    { display: none; }
#cc-chat-btn[data-open="true"] .cc-icon-close   { display: block; }
#cc-chat-btn[data-open="false"] .cc-icon-close  { display: none; }

/* Unread badge */
#cc-chat-badge {
  position: absolute;
  top: -2px;
  right: -2px;
  background: #e53e3e;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  min-width: 18px;
  height: 18px;
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
  display: none;
}
#cc-chat-badge.visible { display: flex; }

/* ── Chat panel ──────────────────────────────────────────────────────────────── */
#cc-chat-panel {
  position: fixed;
  bottom: 98px;
  right: 28px;
  z-index: var(--cc-widget-z);
  width: var(--cc-panel-w);
  max-width: calc(100vw - 32px);
  height: var(--cc-panel-h);
  max-height: calc(100vh - 120px);
  background: #fff;
  border-radius: var(--cc-radius);
  box-shadow: var(--cc-shadow);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  font-family: var(--cc-font);
  transform-origin: bottom right;
  transition: opacity 0.15s ease, transform 0.15s ease;
  border: 1px solid var(--cc-border);
}
#cc-chat-panel[hidden] {
  display: none !important;
}
#cc-chat-panel.cc-entering {
  opacity: 0;
  transform: scale(0.92) translateY(8px);
}

/* ── Header ──────────────────────────────────────────────────────────────────── */
#cc-chat-header {
  background: var(--cc-bg-dark);
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}
.cc-header-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--cc-primary) 0%, var(--cc-cyan) 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.cc-header-avatar svg { width: 18px; height: 18px; fill: #fff; }
.cc-header-text { flex: 1; min-width: 0; }
.cc-header-name {
  font-size: 14px;
  font-weight: 600;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.cc-header-sub { font-size: 11px; color: var(--cc-cyan); margin-top: 1px; }

.cc-header-actions { display: flex; gap: 4px; flex-shrink: 0; }
.cc-header-btn {
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 4px;
  border-radius: 6px;
  color: #8b949e;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.15s, background 0.15s;
}
.cc-header-btn:hover { color: #fff; background: rgba(255,255,255,0.1); }
.cc-header-btn:focus-visible { outline: 2px solid var(--cc-cyan); }
.cc-header-btn svg { width: 16px; height: 16px; fill: currentColor; }

/* Escalate pill — labelled primary-action button; distinct from icon-only reset/close */
.cc-btn-escalate {
  background: var(--cc-cyan);
  color: var(--cc-bg-dark);
  padding: 5px 10px 5px 8px;
  border-radius: 14px;
  font-size: 12px;
  font-weight: 600;
  font-family: var(--cc-font);
  gap: 5px;
  white-space: nowrap;
}
.cc-btn-escalate:hover { background: #2bc9b8; color: var(--cc-bg-dark); }
.cc-btn-escalate:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }
.cc-btn-escalate svg { width: 15px; height: 15px; }
/* Narrow phones: hide text, keep cyan icon so it stays visually distinct */
@media (max-width: 400px) {
  .cc-btn-escalate { padding: 4px 6px; border-radius: 8px; }
  .cc-escalate-label { display: none; }
}

/* ── Message list ────────────────────────────────────────────────────────────── */
#cc-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  scroll-behavior: smooth;
}
#cc-chat-messages::-webkit-scrollbar { width: 4px; }
#cc-chat-messages::-webkit-scrollbar-thumb { background: var(--cc-border); border-radius: 2px; }

.cc-msg {
  max-width: 86%;
  font-size: 14px;
  line-height: 1.5;
  word-wrap: break-word;
}
.cc-msg-user {
  align-self: flex-end;
  background: var(--cc-primary);
  color: #fff;
  padding: 9px 13px;
  border-radius: 14px 14px 4px 14px;
}
.cc-msg-assistant {
  align-self: flex-start;
  background: #F5F7FA;
  color: var(--cc-text);
  padding: 9px 13px;
  border-radius: 4px 14px 14px 14px;
  border: 1px solid var(--cc-border);
}

/* Confidence badge on assistant messages */
.cc-confidence {
  font-size: 10px;
  margin-top: 5px;
  display: flex;
  align-items: center;
  gap: 4px;
  color: var(--cc-text-muted);
}
.cc-confidence-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #48BB78;
}
.cc-confidence-dot.medium { background: #ECC94B; }
.cc-confidence-dot.low,
.cc-confidence-dot.unsupported { background: #e53e3e; }

/* Sources */
.cc-sources {
  margin-top: 6px;
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.cc-source-link {
  font-size: 11px;
  color: var(--cc-primary);
  text-decoration: underline;
  word-break: break-all;
}
.cc-source-link:hover { color: var(--cc-cyan); }

/* Suggested actions */
.cc-suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
  align-self: flex-start;
}
.cc-suggestion-btn {
  background: transparent;
  border: 1px solid var(--cc-primary);
  color: var(--cc-primary);
  font-size: 12px;
  padding: 5px 10px;
  border-radius: 16px;
  cursor: pointer;
  font-family: var(--cc-font);
  transition: background 0.15s, color 0.15s;
  line-height: 1.4;
}
.cc-suggestion-btn:hover  { background: var(--cc-primary); color: #fff; }
.cc-suggestion-btn:focus-visible { outline: 2px solid var(--cc-cyan); }

/* Typing indicator */
#cc-typing {
  display: none;
  align-self: flex-start;
  padding: 10px 14px;
  background: #F5F7FA;
  border: 1px solid var(--cc-border);
  border-radius: 4px 14px 14px 14px;
}
#cc-typing.visible { display: flex; align-items: center; gap: 4px; }
.cc-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--cc-text-muted);
  animation: cc-bounce 1.2s ease-in-out infinite;
}
.cc-dot:nth-child(2) { animation-delay: 0.15s; }
.cc-dot:nth-child(3) { animation-delay: 0.30s; }
@keyframes cc-bounce {
  0%, 80%, 100% { transform: translateY(0); }
  40%           { transform: translateY(-6px); }
}

/* Feedback row */
.cc-feedback-row {
  display: flex;
  gap: 8px;
  margin-top: 6px;
  align-items: center;
}
.cc-feedback-btn {
  background: transparent;
  border: 1px solid var(--cc-border);
  cursor: pointer;
  border-radius: 6px;
  padding: 3px 6px;
  font-size: 14px;
  line-height: 1;
  transition: background 0.15s;
}
.cc-feedback-btn:hover  { background: var(--cc-border); }
.cc-feedback-btn.active { background: var(--cc-cyan); border-color: var(--cc-cyan); }
.cc-feedback-label { font-size: 10px; color: var(--cc-text-muted); }

/* ── Input area ──────────────────────────────────────────────────────────────── */
#cc-chat-footer {
  border-top: 1px solid var(--cc-border);
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex-shrink: 0;
  background: #fff;
}
#cc-chat-form {
  display: flex;
  gap: 8px;
  align-items: flex-end;
}
#cc-chat-input {
  flex: 1;
  border: 1px solid var(--cc-border);
  border-radius: 8px;
  padding: 9px 12px;
  font-size: 14px;
  font-family: var(--cc-font);
  resize: none;
  line-height: 1.4;
  max-height: 100px;
  overflow-y: auto;
  outline: none;
  transition: border-color 0.15s;
  color: var(--cc-text);
}
#cc-chat-input:focus { border-color: var(--cc-primary); }
#cc-chat-input::placeholder { color: var(--cc-text-muted); }
#cc-chat-input:disabled { background: #f8f9fa; }

#cc-send-btn {
  width: 38px;
  height: 38px;
  background: var(--cc-primary);
  border: none;
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.15s, transform 0.1s;
}
#cc-send-btn:hover:not(:disabled) { background: #1648cc; }
#cc-send-btn:active:not(:disabled) { transform: scale(0.95); }
#cc-send-btn:disabled { background: var(--cc-border); cursor: not-allowed; }
#cc-send-btn:focus-visible { outline: 2px solid var(--cc-cyan); }
#cc-send-btn svg { width: 18px; height: 18px; fill: #fff; }

/* Footer branding */
.cc-footer-brand {
  text-align: center;
  font-size: 10px;
  color: var(--cc-text-muted);
}
.cc-footer-brand a {
  color: var(--cc-text-muted);
  text-decoration: none;
}
.cc-footer-brand a:hover { color: var(--cc-primary); }

/* ── System / error messages ─────────────────────────────────────────────────── */
.cc-msg-system {
  align-self: center;
  font-size: 12px;
  color: var(--cc-text-muted);
  text-align: center;
  padding: 4px 10px;
  background: #F5F7FA;
  border-radius: 10px;
  max-width: 90%;
}
.cc-msg-error {
  align-self: center;
  font-size: 12px;
  color: #e53e3e;
  text-align: center;
  padding: 6px 12px;
  background: #FFF5F5;
  border: 1px solid #FEB2B2;
  border-radius: 8px;
  max-width: 90%;
}

/* ── Lead capture form ───────────────────────────────────────────────────────── */
.cc-lead-form {
  align-self: stretch;
  background: #F5F7FA;
  border: 1px solid var(--cc-border);
  border-radius: 10px;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.cc-lead-intro {
  margin: 0;
  font-size: 13px;
  font-weight: 500;
  color: var(--cc-text);
}
.cc-lead-field {
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.cc-lead-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--cc-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.cc-lead-input {
  border: 1px solid var(--cc-border);
  border-radius: 7px;
  padding: 7px 10px;
  font-size: 13px;
  font-family: var(--cc-font);
  color: var(--cc-text);
  background: #fff;
  outline: none;
  transition: border-color 0.15s;
  width: 100%;
  box-sizing: border-box;
}
.cc-lead-input:focus { border-color: var(--cc-primary); }
.cc-lead-hint {
  margin: 0;
  font-size: 11px;
  color: var(--cc-text-muted);
}
.cc-consent-wrap {
  display: flex;
  align-items: flex-start;
  gap: 7px;
  cursor: pointer;
  font-size: 12px;
  color: var(--cc-text);
  line-height: 1.4;
}
.cc-consent-cb {
  flex-shrink: 0;
  margin-top: 2px;
  accent-color: var(--cc-primary);
  width: 14px;
  height: 14px;
  cursor: pointer;
}
.cc-lead-error {
  margin: 0;
  font-size: 11px;
  color: #e53e3e;
}
.cc-lead-submit {
  align-self: flex-start;
  background: var(--cc-primary);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 9px 16px;
  font-size: 13px;
  font-family: var(--cc-font);
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
}
.cc-lead-submit:hover:not(:disabled) { background: #1648cc; }
.cc-lead-submit:disabled {
  background: var(--cc-border);
  color: var(--cc-text-muted);
  cursor: not-allowed;
}
.cc-lead-submit:focus-visible { outline: 2px solid var(--cc-cyan); }

/* ── Auto-engagement nudge bubble ────────────────────────────────────────────── */
/* Appears to the left of the trigger button 8 s after the visitor's first visit.  */
#cc-nudge {
  position: fixed;
  bottom: 38px;        /* vertically centred with the 58 px button at bottom: 28 px */
  right: 98px;         /* 28 (btn right) + 58 (btn width) + 12 gap */
  z-index: var(--cc-widget-z);
  background: #fff;
  border: 1px solid var(--cc-border);
  border-radius: 10px;
  box-shadow: var(--cc-shadow);
  padding: 10px 32px 10px 14px;   /* right padding leaves room for dismiss × */
  max-width: 220px;
  font-family: var(--cc-font);
  font-size: 13px;
  line-height: 1.4;
  color: var(--cc-text);
  display: none;
  align-items: center;
  pointer-events: none;
  white-space: normal;
}
/* Right-pointing speech-bubble arrow */
#cc-nudge::before {
  content: '';
  position: absolute;
  top: 50%;
  right: -9px;
  transform: translateY(-50%);
  width: 0;
  height: 0;
  border-top: 8px solid transparent;
  border-bottom: 8px solid transparent;
  border-left: 9px solid var(--cc-border);
  border-right-width: 0;
}
#cc-nudge::after {
  content: '';
  position: absolute;
  top: 50%;
  right: -8px;
  transform: translateY(-50%);
  width: 0;
  height: 0;
  border-top: 7px solid transparent;
  border-bottom: 7px solid transparent;
  border-left: 8px solid #fff;
  border-right-width: 0;
}
#cc-nudge.cc-nudge-visible {
  display: flex;
  pointer-events: auto;
  animation: cc-nudge-in 0.25s ease;
}
@keyframes cc-nudge-in {
  from { opacity: 0; transform: translateX(8px); }
  to   { opacity: 1; transform: translateX(0);   }
}
.cc-nudge-text { flex: 1; }
.cc-nudge-dismiss {
  position: absolute;
  top: 5px;
  right: 6px;
  background: transparent;
  border: none;
  cursor: pointer;
  color: var(--cc-text-muted);
  font-size: 16px;
  line-height: 1;
  padding: 2px 4px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.cc-nudge-dismiss:hover { color: var(--cc-text); background: var(--cc-border); }
.cc-nudge-dismiss:focus-visible { outline: 2px solid var(--cc-cyan); }

/* ── Mobile adjustments ──────────────────────────────────────────────────────── */
@media (max-width: 480px) {
  #cc-chat-panel {
    bottom: 0;
    right: 0;
    left: 0;
    width: 100%;
    max-width: 100%;
    border-radius: var(--cc-radius) var(--cc-radius) 0 0;
    height: 80vh;
    max-height: 80vh;
  }
  #cc-chat-btn {
    bottom: 20px;
    right: 20px;
  }
  #cc-nudge {
    bottom: 30px;   /* centred with button at bottom: 20 px */
    right: 88px;    /* 20 (btn right) + 58 (btn width) + 10 gap */
    max-width: 180px;
    font-size: 12px;
  }
}

/* ── Print: hide entirely ────────────────────────────────────────────────────── */
@media print {
  #cc-chat-btn, #cc-chat-panel { display: none !important; }
}
