/* ── CallConnect Chat Widget ─────────────────────────────────────────────────
   All class names are prefixed with ccc- to avoid conflicts with theme CSS.
   CSS custom properties (--ccc-*) are set inline by the JS from cccConfig.
   ─────────────────────────────────────────────────────────────────────────── */

:root {
  --ccc-primary:    #0057FF;
  --ccc-primary-dk: #0040cc;
  --ccc-radius:     14px;
  --ccc-shadow:     0 8px 32px rgba(0,0,0,.18);
  --ccc-font:       -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --ccc-z:          999999;
}

/* ── Root container ────────────────────────────────────────────────────────── */
#ccc-root {
  position: fixed;
  bottom: 24px;
  right:  24px;
  z-index: var(--ccc-z);
  font-family: var(--ccc-font);
  font-size:   14px;
  line-height: 1.5;
}
#ccc-root.ccc-pos-bottom-left {
  right: auto;
  left:  24px;
}

/* ── Launcher button ───────────────────────────────────────────────────────── */
#ccc-launcher {
  width:  60px;
  height: 60px;
  border-radius: 50%;
  background: var(--ccc-primary);
  border: none;
  cursor: pointer;
  box-shadow: var(--ccc-shadow);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform .2s, box-shadow .2s;
  margin-left: auto;
  position: relative;
}
.ccc-pos-bottom-left #ccc-launcher { margin-left: 0; margin-right: auto; }
#ccc-launcher:hover { transform: scale(1.08); box-shadow: 0 12px 36px rgba(0,0,0,.24); }

/* FIX: Don't set fill on svg — let the path attributes control fill/stroke */
#ccc-launcher svg {
  width: 28px;
  height: 28px;
  display: block;
  overflow: visible;
}
/* Chat icon — filled white */
#ccc-launcher .ccc-icon-chat path { fill: #fff; }
/* Close icon — stroked white, no fill */
#ccc-launcher .ccc-icon-close { display: none; }
#ccc-launcher .ccc-icon-close path { fill: none; stroke: #fff; stroke-width: 2.5; stroke-linecap: round; }
#ccc-launcher.ccc-open .ccc-icon-chat  { display: none; }
#ccc-launcher.ccc-open .ccc-icon-close { display: block; }

/* Unread badge */
#ccc-badge {
  position: absolute;
  top: -3px; right: -3px;
  min-width: 18px; height: 18px;
  background: #e53e3e;
  border-radius: 9px;
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
}
#ccc-badge.ccc-visible { display: flex; }

/* ── Chat window ───────────────────────────────────────────────────────────── */
#ccc-window {
  width:  370px;
  max-width: calc(100vw - 32px);
  height: 560px;
  max-height: calc(100vh - 110px);
  background: #fff;
  border-radius: var(--ccc-radius);
  box-shadow: var(--ccc-shadow);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  margin-bottom: 12px;

  /* Animation */
  transform-origin: bottom right;
  transform: scale(.92) translateY(16px);
  opacity: 0;
  pointer-events: none;
  transition: transform .22s cubic-bezier(.34,1.56,.64,1), opacity .18s;
}
.ccc-pos-bottom-left #ccc-window { transform-origin: bottom left; }
#ccc-window.ccc-visible {
  transform: scale(1) translateY(0);
  opacity: 1;
  pointer-events: auto;
}

/* ── Header ────────────────────────────────────────────────────────────────── */
#ccc-header {
  background: var(--ccc-primary);
  color: #fff;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}
#ccc-header-avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  object-fit: cover;
  background: rgba(255,255,255,.25);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 15px;
  flex-shrink: 0;
}
#ccc-header-avatar img { width: 100%; height: 100%; border-radius: 50%; object-fit: cover; }
#ccc-header-info { flex: 1; min-width: 0; }
#ccc-header-name { font-weight: 600; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#ccc-header-status { font-size: 11px; opacity: .82; }

/* ── Agent selector ────────────────────────────────────────────────────────── */
#ccc-agent-selector {
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  overflow-y: auto;
  flex: 1;
}
#ccc-agent-selector h2 { margin: 0 0 4px; font-size: 16px; color: #111; }
#ccc-agent-selector p  { margin: 0 0 12px; color: #555; font-size: 13px; }

.ccc-agent-card {
  border: 2px solid #e2e8f0;
  border-radius: 10px;
  padding: 12px 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 12px;
  transition: border-color .15s, background .15s;
  background: #fff;
  text-align: left;
}
.ccc-agent-card:hover { border-color: var(--ccc-primary); background: #f0f5ff; }
.ccc-agent-card-avatar {
  width: 42px; height: 42px; border-radius: 50%; object-fit: cover;
  background: #dde4f5;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 16px; color: var(--ccc-primary);
  flex-shrink: 0;
}
.ccc-agent-card-avatar img { width: 100%; height: 100%; border-radius: 50%; object-fit: cover; }
.ccc-agent-card-name { font-weight: 600; font-size: 14px; color: #1a202c; }
.ccc-agent-card-desc { font-size: 12px; color: #718096; margin-top: 2px; }

/* ── Messages ──────────────────────────────────────────────────────────────── */
#ccc-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  scroll-behavior: smooth;
}
#ccc-messages::-webkit-scrollbar { width: 4px; }
#ccc-messages::-webkit-scrollbar-thumb { background: #d0d7de; border-radius: 4px; }

.ccc-msg {
  max-width: 80%;
  padding: 10px 13px;
  border-radius: 16px;
  font-size: 14px;
  line-height: 1.55;
  word-break: break-word;
}
.ccc-msg-bot {
  background: #f0f2f5;
  color: #1a202c;
  border-bottom-left-radius: 4px;
  align-self: flex-start;
}
.ccc-msg-user {
  background: var(--ccc-primary);
  color: #fff;
  border-bottom-right-radius: 4px;
  align-self: flex-end;
}
.ccc-msg-error {
  background: #fff5f5;
  color: #c53030;
  border: 1px solid #fed7d7;
  align-self: flex-start;
  font-size: 13px;
}
.ccc-msg-time {
  font-size: 10px;
  color: #a0aec0;
  margin-top: 4px;
  text-align: right;
}
.ccc-msg-bot + .ccc-msg-time { text-align: left; }

/* Typing indicator */
.ccc-typing {
  display: flex;
  gap: 5px;
  padding: 10px 14px;
  background: #f0f2f5;
  border-radius: 16px;
  border-bottom-left-radius: 4px;
  align-self: flex-start;
  align-items: center;
}
.ccc-typing span {
  width: 7px; height: 7px; border-radius: 50%;
  background: #94a3b8;
  animation: ccc-bounce .9s infinite;
}
.ccc-typing span:nth-child(2) { animation-delay: .15s; }
.ccc-typing span:nth-child(3) { animation-delay: .30s; }
@keyframes ccc-bounce {
  0%,80%,100% { transform: translateY(0); }
  40%         { transform: translateY(-6px); }
}

/* ── Input bar ─────────────────────────────────────────────────────────────── */
#ccc-input-bar {
  border-top: 1px solid #e2e8f0;
  padding: 10px 12px;
  display: flex;
  gap: 8px;
  flex-shrink: 0;
  background: #fff;
  align-items: flex-end;
}
#ccc-input {
  flex: 1;
  border: 1px solid #d1d5db;
  border-radius: 22px;
  padding: 9px 14px;
  font-size: 14px;
  font-family: var(--ccc-font);
  outline: none;
  resize: none;
  min-height: 38px;
  max-height: 100px;
  overflow-y: auto;
  background: #f9fafb;
  transition: border-color .15s;
  line-height: 1.4;
}
#ccc-input:focus { border-color: var(--ccc-primary); background: #fff; }

#ccc-send {
  width: 38px;
  height: 38px;
  min-width: 38px;
  border-radius: 50%;
  background: var(--ccc-primary);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background .15s, transform .1s;
  padding: 0;
}
#ccc-send:hover  { background: var(--ccc-primary-dk); }
#ccc-send:active { transform: scale(.93); }
#ccc-send:disabled { opacity: .45; cursor: not-allowed; }

/* FIX: Send icon — stroked white arrow, no fill override */
#ccc-send svg {
  width: 18px;
  height: 18px;
  display: block;
  overflow: visible;
}
#ccc-send svg path {
  fill: none;
  stroke: #fff;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* ── Powered-by footer ─────────────────────────────────────────────────────── */
#ccc-powered {
  text-align: center;
  padding: 5px 0 7px;
  font-size: 10px;
  color: #a0aec0;
  border-top: 1px solid #f0f0f0;
  flex-shrink: 0;
}
#ccc-powered a { color: inherit; text-decoration: none; }
#ccc-powered a:hover { text-decoration: underline; }

/* ── Responsive ────────────────────────────────────────────────────────────── */
@media (max-width: 480px) {
  #ccc-root {
    bottom: 0; right: 0; left: 0;
    width: 100%;
  }
  .ccc-pos-bottom-left #ccc-root { left: 0; right: 0; }
  #ccc-window {
    width: 100%;
    max-width: 100%;
    height: 80vh;
    border-radius: var(--ccc-radius) var(--ccc-radius) 0 0;
    margin-bottom: 0;
  }
  #ccc-launcher {
    position: fixed;
    bottom: 20px; right: 20px;
    margin: 0;
  }
  .ccc-pos-bottom-left #ccc-launcher { right: auto; left: 20px; }
}
