/* ── Widget root ────────────────────────────────────────────────────────────── */
#cfc-root {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 2147483647;
  font-family: 'Red Hat Display', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 15px;
  line-height: 1.5;
  box-sizing: border-box;
}

#cfc-root *,
#cfc-root *::before,
#cfc-root *::after {
  box-sizing: inherit;
}

/* ── Launcher button ────────────────────────────────────────────────────────── */
#cfc-launcher {
  position: relative;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: linear-gradient(135deg, #181075 0%, #2050ce 100%);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  box-shadow: 0 4px 20px rgba(32, 80, 206, 0.45);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  padding: 0;
  outline-offset: 3px;
}

#cfc-launcher:hover {
  transform: scale(1.08);
  box-shadow: 0 6px 28px rgba(32, 80, 206, 0.55);
}

#cfc-launcher:focus-visible {
  outline: 3px solid #2050ce;
}

#cfc-launcher.cfc-pulse {
  animation: cfc-pulse 1.6s ease infinite;
}

/* ── Badge ──────────────────────────────────────────────────────────────────── */
.cfc-badge {
  position: absolute;
  top: -3px;
  right: -3px;
  width: 20px;
  height: 20px;
  background: #e74c3c;
  border-radius: 50%;
  border: 2px solid #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  color: #fff;
  animation: cfc-pop 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  pointer-events: none;
}

/* ── Panel ──────────────────────────────────────────────────────────────────── */
#cfc-panel {
  position: absolute;
  bottom: 68px;
  right: 0;
  width: 320px;
  background: #ffffff;
  border-radius: 16px;
  box-shadow: 0 8px 40px rgba(0, 0, 0, 0.18), 0 2px 8px rgba(0, 0, 0, 0.08);
  overflow: hidden;
  animation: cfc-slide-up 0.22s ease;
}

/* ── Panel header ───────────────────────────────────────────────────────────── */
.cfc-panel-header {
  background: linear-gradient(105deg, #181075 0%, #2050ce 58%, #d516b1 100%);
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: #fff;
}

.cfc-header-brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.cfc-header-logo {
  width: 36px;
  height: 36px;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 13px;
  flex-shrink: 0;
}

.cfc-panel-header strong {
  display: block;
  font-size: 14px;
  font-weight: 600;
}

.cfc-status-line {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  opacity: 0.85;
  margin-top: 2px;
}

.cfc-online-dot {
  width: 7px;
  height: 7px;
  background: #4ade80;
  border-radius: 50%;
  flex-shrink: 0;
}

.cfc-close-btn {
  background: none;
  border: none;
  color: rgba(255, 255, 255, 0.75);
  cursor: pointer;
  padding: 5px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  transition: background 0.15s, color 0.15s;
  outline-offset: 2px;
}

.cfc-close-btn:hover {
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
}

.cfc-close-btn:focus-visible {
  outline: 2px solid #fff;
}

/* ── Screens ────────────────────────────────────────────────────────────────── */
.cfc-screen {
  padding: 20px 16px 24px;
}

/* ── Greeting message ───────────────────────────────────────────────────────── */
.cfc-greeting-msg {
  display: flex;
  gap: 10px;
  margin-bottom: 20px;
  align-items: flex-start;
}

.cfc-msg-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: linear-gradient(135deg, #181075, #2050ce);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 11px;
  flex-shrink: 0;
  margin-top: 2px;
}

.cfc-msg-bubble {
  background: #f0f2fa;
  border-radius: 4px 12px 12px 12px;
  padding: 10px 13px;
  font-size: 14px;
  color: #1f2937;
  line-height: 1.55;
}

/* ── Triage buttons ─────────────────────────────────────────────────────────── */
.cfc-triage-btns {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.cfc-triage-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 14px;
  border: 1.5px solid #e5e7eb;
  border-radius: 10px;
  background: #fff;
  cursor: pointer;
  font-family: inherit;
  font-size: 14px;
  font-weight: 500;
  color: #1f2937;
  text-align: left;
  width: 100%;
  transition: border-color 0.15s, background 0.15s, color 0.15s;
}

.cfc-triage-btn:hover {
  border-color: #2050ce;
  background: #f4f6ff;
  color: #2050ce;
}

.cfc-triage-btn:focus-visible {
  outline: 3px solid #2050ce;
  outline-offset: 2px;
}

.cfc-triage-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.cfc-triage-btn svg {
  flex-shrink: 0;
}

/* ── Loading / support screen ───────────────────────────────────────────────── */
.cfc-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 44px 20px;
  gap: 14px;
}

.cfc-loading p {
  font-size: 14px;
  color: #6b7280;
  margin: 0;
}

.cfc-spinner {
  width: 32px;
  height: 32px;
  border: 3px solid #e5e7eb;
  border-top-color: #2050ce;
  border-radius: 50%;
  animation: cfc-spin 0.75s linear infinite;
}

/* ── Error state ────────────────────────────────────────────────────────────── */
.cfc-error-state {
  padding: 32px 20px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}

.cfc-error-state p {
  font-size: 13px;
  color: #c0392b;
  margin: 0;
}

/* ── Animations ─────────────────────────────────────────────────────────────── */
@keyframes cfc-slide-up {
  from {
    opacity: 0;
    transform: translateY(10px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes cfc-pop {
  0%   { transform: scale(0); }
  70%  { transform: scale(1.25); }
  100% { transform: scale(1); }
}

@keyframes cfc-spin {
  to { transform: rotate(360deg); }
}

@keyframes cfc-pulse {
  0%   { box-shadow: 0 4px 20px rgba(32, 80, 206, 0.45); }
  50%  { box-shadow: 0 4px 28px rgba(32, 80, 206, 0.75), 0 0 0 10px rgba(32, 80, 206, 0.08); }
  100% { box-shadow: 0 4px 20px rgba(32, 80, 206, 0.45); }
}

/* ── Launcher label (pill shape when label is present) ──────────────────────── */
#cfc-launcher.cfc-launcher--labelled {
  width: auto;
  border-radius: 28px;
  padding: 0 18px 0 12px;
  gap: 8px;
  justify-content: flex-start;
}

.cfc-launcher-label {
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
  color: #fff;
  letter-spacing: 0.01em;
}

/* Revert to circle when panel is open */
#cfc-launcher[aria-expanded="true"].cfc-launcher--labelled {
  width: 56px;
  border-radius: 50%;
  padding: 0;
  justify-content: center;
}

#cfc-launcher[aria-expanded="true"] .cfc-launcher-label {
  display: none;
}

/* ── Icon-only on mobile ────────────────────────────────────────────────────── */
@media (max-width: 63.9375em) {
  .cfc-launcher-label {
    display: none;
  }

  #cfc-launcher.cfc-launcher--labelled {
    width: 56px;
    border-radius: 50%;
    padding: 0;
    justify-content: center;
  }
}

/* ── Custom image variants ──────────────────────────────────────────────────── */

/* Launcher custom icon */
img#cfc-icon-chat {
  width: 26px;
  height: 26px;
  object-fit: contain;
  border-radius: 3px;
}

/* Header logo with avatar image */
.cfc-header-logo--img {
  padding: 0;
  overflow: hidden;
}

.cfc-header-logo--img img {
  width: 36px;
  height: 36px;
  object-fit: cover;
  border-radius: 50%;
  display: block;
}

/* Message bubble avatar with image */
.cfc-msg-avatar--img {
  padding: 0;
  overflow: hidden;
}

.cfc-msg-avatar--img img {
  width: 34px;
  height: 34px;
  object-fit: cover;
  border-radius: 50%;
  display: block;
}

/* ── Responsive ─────────────────────────────────────────────────────────────── */
@media (max-width: 480px) {
  #cfc-root {
    right: 16px;
    bottom: 16px;
  }

  #cfc-panel {
    width: calc(100vw - 32px);
    right: 0;
  }
}
