/* CCMS Chat Widget — uses site theme vars from site.css (:root) */
#ccms-chat {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 1080; /* above Bootstrap sticky elements, below modals (1055) is fine too */
  font-size: 15px;
}

/* ── Toggle button ─────────────────────────────────────────── */
#ccms-chat-toggle {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: none;
  background: var(--brand, #3d8bff);
  color: #fff;
  cursor: pointer;
  box-shadow: var(--shadow, 0 8px 24px rgba(0, 0, 0, .35));
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform .15s ease, background .15s ease;
}
#ccms-chat-toggle:hover { transform: scale(1.06); background: var(--brand-2, #7bb0ff); }
#ccms-chat-toggle .ccms-chat-close-icon { display: none; font-size: 28px; line-height: 1; }
.ccms-chat-open #ccms-chat-toggle svg { display: none; }
.ccms-chat-open #ccms-chat-toggle .ccms-chat-close-icon { display: block; }

/* ── Panel ─────────────────────────────────────────────────── */
#ccms-chat-panel {
  position: absolute;
  right: 0;
  bottom: 70px;
  width: 370px;
  max-width: calc(100vw - 32px);
  height: 520px;
  max-height: calc(100vh - 110px);
  display: flex;
  flex-direction: column;
  background: var(--surface, #101b31);
  border: 1px solid var(--line, rgba(255, 255, 255, .08));
  border-radius: 14px;
  box-shadow: var(--shadow, 0 18px 48px rgba(3, 10, 24, .35));
  overflow: hidden;
}

.ccms-chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: var(--surface-2, #15213c);
  border-bottom: 1px solid var(--line, rgba(255, 255, 255, .08));
}
.ccms-chat-header strong { display: block; color: var(--white, #fff); }
.ccms-chat-header small { color: var(--muted, rgba(255, 255, 255, .8)); }
.ccms-chat-reset {
  border: none;
  background: transparent;
  color: var(--muted, rgba(255, 255, 255, .8));
  font-size: 20px;
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 6px;
}
.ccms-chat-reset:hover { color: var(--white, #fff); background: var(--line, rgba(255, 255, 255, .08)); }

/* ── Messages ──────────────────────────────────────────────── */
.ccms-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.ccms-chat-msg {
  max-width: 85%;
  padding: 9px 13px;
  border-radius: 14px;
  line-height: 1.45;
  word-wrap: break-word;
  color: var(--text, #fff);
}
.ccms-chat-msg-user {
  align-self: flex-end;
  background: var(--brand, #3d8bff);
  color: #fff;
  border-bottom-right-radius: 4px;
}
.ccms-chat-msg-assistant {
  align-self: flex-start;
  background: var(--surface-2, #15213c);
  border: 1px solid var(--line, rgba(255, 255, 255, .08));
  border-bottom-left-radius: 4px;
}
.ccms-chat-msg-assistant a { color: var(--brand-2, #7bb0ff); text-decoration: underline; }
.ccms-chat-msg-error {
  align-self: center;
  background: rgba(220, 53, 69, .15);
  border: 1px solid rgba(220, 53, 69, .4);
  font-size: 13px;
}

/* typing indicator */
.ccms-chat-typing { display: flex; gap: 4px; padding: 13px; }
.ccms-chat-typing span {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--muted, rgba(255, 255, 255, .8));
  animation: ccms-chat-blink 1.2s infinite both;
}
.ccms-chat-typing span:nth-child(2) { animation-delay: .2s; }
.ccms-chat-typing span:nth-child(3) { animation-delay: .4s; }
@keyframes ccms-chat-blink { 0%, 80%, 100% { opacity: .25; } 40% { opacity: 1; } }

/* ── Quick prompts ─────────────────────────────────────────── */
.ccms-chat-quick {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 0 14px;
}
.ccms-chat-quick:empty { display: none; }
.ccms-chat-quick button {
  border: 1px solid var(--brand, #3d8bff);
  background: transparent;
  color: var(--brand-2, #7bb0ff);
  border-radius: 999px;
  font-size: 13px;
  padding: 5px 12px;
  cursor: pointer;
}
.ccms-chat-quick button:hover { background: var(--brand, #3d8bff); color: #fff; }

/* ── Input ─────────────────────────────────────────────────── */
.ccms-chat-form {
  display: flex;
  gap: 8px;
  padding: 12px 14px;
  border-top: 1px solid var(--line, rgba(255, 255, 255, .08));
  margin: 0;
}
.ccms-chat-form input {
  flex: 1;
  border: 1px solid var(--line, rgba(255, 255, 255, .15));
  background: var(--bg-soft, #0e1a2f);
  color: var(--text, #fff);
  border-radius: 999px;
  padding: 9px 16px;
  outline: none;
}
.ccms-chat-form input:focus { border-color: var(--brand, #3d8bff); }
.ccms-chat-form input::placeholder { color: var(--muted, rgba(255, 255, 255, .6)); }
.ccms-chat-form button {
  width: 42px;
  height: 42px;
  flex: 0 0 42px;
  border: none;
  border-radius: 50%;
  background: var(--brand, #3d8bff);
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.ccms-chat-form button:disabled { opacity: .5; cursor: default; }

.ccms-chat-footer {
  padding: 6px 14px 10px;
  font-size: 11.5px;
  text-align: center;
  color: var(--muted, rgba(255, 255, 255, .6));
}
.ccms-chat-footer a { color: var(--brand-2, #7bb0ff); }

/* ── Mobile ────────────────────────────────────────────────── */
@media (max-width: 480px) {
  #ccms-chat { right: 12px; bottom: 12px; }
  #ccms-chat-panel {
    width: calc(100vw - 24px);
    height: min(560px, calc(100vh - 90px));
  }
}

@media print {
  #ccms-chat { display: none; }
}
