/* Compliancy Group AI Chatbot Styles */

:root {
  --cg-primary: #0066CC;
  --cg-primary-dark: #004FA3;
  --cg-primary-light: #E6F0FA;
  --cg-text: #1A1A2E;
  --cg-text-muted: #6B7280;
  --cg-border: #E5E7EB;
  --cg-bg: #FFFFFF;
  --cg-bg-secondary: #F9FAFB;
  --cg-bubble-user: #0066CC;
  --cg-bubble-bot: #F3F4F6;
  --cg-radius: 12px;
  --cg-shadow: 0 8px 32px rgba(0,0,0,0.14), 0 2px 8px rgba(0,0,0,0.08);
  --cg-z: 99999;
}

/* Launcher button */
#cg-chat-launcher {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 56px;
  height: 56px;
  background: var(--cg-primary);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: var(--cg-z);
  box-shadow: 0 4px 16px rgba(0, 102, 204, 0.35);
  transition: transform 0.2s, background 0.2s;
  border: none;
}
#cg-chat-launcher:hover {
  background: var(--cg-primary-dark);
  transform: scale(1.06);
}
#cg-chat-launcher.is-open svg {
  display: none;
}
#cg-chat-launcher.is-open::after {
  content: '×';
  color: white;
  font-size: 28px;
  line-height: 1;
  font-weight: 300;
}

.cg-chat-badge {
  position: absolute;
  top: -3px;
  right: -3px;
  background: #EF4444;
  color: white;
  font-size: 11px;
  font-weight: 600;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid white;
}

/* Chat window */
#cg-chat-window {
  position: fixed;
  bottom: 90px;
  right: 24px;
  width: 380px;
  max-height: 600px;
  background: var(--cg-bg);
  border-radius: var(--cg-radius);
  box-shadow: var(--cg-shadow);
  z-index: var(--cg-z);
  display: none;
  flex-direction: column;
  overflow: hidden;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 14px;
  border: 1px solid var(--cg-border);
  transition: opacity 0.2s, transform 0.2s;
}
#cg-chat-window.is-visible {
  display: flex;
  animation: cg-slide-up 0.25s ease;
}
@keyframes cg-slide-up {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* Header */
#cg-chat-header {
  background: var(--cg-primary);
  color: white;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}
#cg-chat-header-info {
  display: flex;
  align-items: center;
  gap: 10px;
}
#cg-chat-avatar {
  width: 36px;
  height: 36px;
  background: rgba(255,255,255,0.25);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.5px;
  flex-shrink: 0;
}
#cg-chat-name {
  font-weight: 600;
  font-size: 14px;
  line-height: 1.2;
}
#cg-chat-status {
  font-size: 12px;
  opacity: 0.85;
  display: flex;
  align-items: center;
  gap: 4px;
}
.cg-status-dot {
  width: 7px;
  height: 7px;
  background: #4ADE80;
  border-radius: 50%;
  display: inline-block;
}
#cg-chat-close {
  background: none;
  border: none;
  color: white;
  font-size: 22px;
  cursor: pointer;
  line-height: 1;
  padding: 0;
  opacity: 0.8;
  transition: opacity 0.15s;
}
#cg-chat-close:hover { opacity: 1; }

/* Messages */
#cg-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  scroll-behavior: smooth;
}
#cg-chat-messages::-webkit-scrollbar { width: 4px; }
#cg-chat-messages::-webkit-scrollbar-thumb { background: var(--cg-border); border-radius: 2px; }

.cg-msg {
  max-width: 88%;
  padding: 10px 13px;
  border-radius: 14px;
  line-height: 1.5;
  font-size: 14px;
  word-break: break-word;
}
.cg-msg-bot {
  background: var(--cg-bubble-bot);
  color: var(--cg-text);
  align-self: flex-start;
  border-bottom-left-radius: 4px;
}
.cg-msg-user {
  background: var(--cg-bubble-user);
  color: white;
  align-self: flex-end;
  border-bottom-right-radius: 4px;
}
.cg-msg a {
  color: var(--cg-primary);
  text-decoration: underline;
}
.cg-msg-user a { color: #BFD9F8; }

/* Quick reply chips */
.cg-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-self: flex-start;
  max-width: 100%;
}
.cg-chip {
  background: var(--cg-bg);
  border: 1px solid var(--cg-primary);
  color: var(--cg-primary);
  border-radius: 20px;
  padding: 5px 12px;
  font-size: 13px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  white-space: nowrap;
  font-family: inherit;
}
.cg-chip:hover {
  background: var(--cg-primary-light);
}

/* Typing indicator */
.cg-typing {
  display: flex;
  gap: 4px;
  padding: 10px 14px;
  background: var(--cg-bubble-bot);
  border-radius: 14px;
  border-bottom-left-radius: 4px;
  align-self: flex-start;
  width: 52px;
}
.cg-typing span {
  width: 6px;
  height: 6px;
  background: var(--cg-text-muted);
  border-radius: 50%;
  animation: cg-bounce 1.2s infinite;
}
.cg-typing span:nth-child(2) { animation-delay: 0.2s; }
.cg-typing span:nth-child(3) { animation-delay: 0.4s; }
@keyframes cg-bounce {
  0%, 60%, 100% { transform: translateY(0); }
  30% { transform: translateY(-5px); }
}

/* Email gate */
#cg-email-gate {
  padding: 16px;
  border-top: 1px solid var(--cg-border);
  flex-shrink: 0;
  background: var(--cg-bg-secondary);
}
#cg-email-gate p {
  margin: 0 0 10px;
  color: var(--cg-text-muted);
  font-size: 13px;
}
#cg-email-input {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--cg-border);
  border-radius: 8px;
  font-size: 14px;
  font-family: inherit;
  box-sizing: border-box;
  margin-bottom: 8px;
  color: var(--cg-text);
  background: white;
  transition: border-color 0.15s;
}
#cg-email-input:focus {
  outline: none;
  border-color: var(--cg-primary);
}
#cg-email-submit {
  width: 100%;
  padding: 9px;
  background: var(--cg-primary);
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.15s;
}
#cg-email-submit:hover { background: var(--cg-primary-dark); }

/* Chat input row */
#cg-chat-input-row {
  padding: 10px 12px;
  border-top: 1px solid var(--cg-border);
  display: flex;
  align-items: flex-end;
  gap: 8px;
  flex-shrink: 0;
  background: var(--cg-bg);
}
#cg-chat-input {
  flex: 1;
  padding: 9px 12px;
  border: 1px solid var(--cg-border);
  border-radius: 20px;
  font-size: 14px;
  font-family: inherit;
  resize: none;
  max-height: 120px;
  overflow-y: auto;
  line-height: 1.4;
  color: var(--cg-text);
  transition: border-color 0.15s;
  background: var(--cg-bg-secondary);
}
#cg-chat-input:focus {
  outline: none;
  border-color: var(--cg-primary);
  background: white;
}
#cg-chat-send {
  width: 36px;
  height: 36px;
  background: var(--cg-primary);
  border: none;
  border-radius: 50%;
  color: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.15s, transform 0.1s;
}
#cg-chat-send:hover { background: var(--cg-primary-dark); }
#cg-chat-send:active { transform: scale(0.94); }
#cg-chat-send:disabled { background: var(--cg-border); cursor: not-allowed; }

/* Chilipiper container */
#cg-chilipiper-container {
  padding: 12px;
  border-top: 1px solid var(--cg-border);
  flex-shrink: 0;
}

/* Resource link card */
.cg-resource-card {
  background: var(--cg-primary-light);
  border: 1px solid #C7DFFB;
  border-left: 3px solid var(--cg-primary);
  border-radius: 8px;
  padding: 10px 12px;
  margin-top: 6px;
  font-size: 13px;
}
.cg-resource-card a {
  font-weight: 500;
  color: var(--cg-primary);
  text-decoration: none;
}
.cg-resource-card a:hover { text-decoration: underline; }

/* Responsive */
@media (max-width: 440px) {
  #cg-chat-window {
    width: calc(100vw - 16px);
    right: 8px;
    bottom: 80px;
  }
  #cg-chat-launcher {
    right: 16px;
    bottom: 16px;
  }
}

/* ─── Live handoff transition ──────────────────────────────────────────────── */
#cg-handoff-screen {
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 32px 24px;
  flex: 1;
  text-align: center;
  background: var(--cg-bg);
}
#cg-handoff-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}
.cg-handoff-spinner {
  width: 36px;
  height: 36px;
  border: 3px solid var(--cg-border);
  border-top-color: var(--cg-primary);
  border-radius: 50%;
  animation: cg-spin 0.8s linear infinite;
}
@keyframes cg-spin { to { transform: rotate(360deg); } }
#cg-handoff-msg {
  font-size: 15px;
  font-weight: 500;
  color: var(--cg-text);
  margin: 0;
}
.cg-handoff-sub {
  font-size: 13px;
  color: var(--cg-text-muted);
  margin: 0;
}

/* ─── HubSpot embed container ──────────────────────────────────────────────── */
#cg-hs-embed {
  flex: 1;
  min-height: 320px;
  display: flex;
  flex-direction: column;
}
/* Override HS widget default fixed positioning when inline */
#cg-hs-embed iframe,
#cg-hs-embed .hs-messages-widget-open {
  position: relative !important;
  width: 100% !important;
  height: 100% !important;
  min-height: 320px;
  border: none;
}
