/* Charge Qube chat widget. Scoped under .cq-chat to avoid clashing with host
   site styles. Override the colour variables to match the brand. */
.cq-chat {
  --cq-accent: #c8612d;        /* terracotta-ish accent, tweak to brand */
  --cq-accent-text: #ffffff;
  --cq-bg: #ffffff;
  --cq-text: #1a1a1a;
  --cq-muted: #6b6b6b;
  --cq-bot-bubble: #f2f2f0;
  --cq-user-bubble: var(--cq-accent); /* match the send button */
  --cq-user-text: #ffffff;
  --cq-radius: 16px;
  --cq-font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 2147483000;
  font-family: var(--cq-font);
}

.cq-chat *,
.cq-chat *::before,
.cq-chat *::after {
  box-sizing: border-box;
}

/* Launcher button */
.cq-launcher {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  border: none;
  background: transparent;
  padding: 0;
  cursor: pointer;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.22);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.cq-launcher:hover { transform: translateY(-2px); box-shadow: 0 10px 28px rgba(0, 0, 0, 0.28); }
.cq-launcher-icon { width: 60px; height: 60px; display: block; border-radius: 50%; pointer-events: none; }

/* Panel */
.cq-panel {
  position: absolute;
  right: 0;
  bottom: 76px;
  width: 380px;
  max-width: calc(100vw - 32px);
  height: 560px;
  max-height: calc(100vh - 120px);
  background: var(--cq-bg);
  color: var(--cq-text);
  border-radius: var(--cq-radius);
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.28);
  display: none;
  flex-direction: column;
  overflow: hidden;
}
.cq-chat.cq-open .cq-panel { display: flex; }

.cq-header {
  background: var(--cq-accent);
  color: var(--cq-accent-text);
  padding: 12px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.cq-avatar {
  width: 113px;
  height: 113px;
  flex: 0 0 auto;
  display: block;
  border-radius: 10px;
  overflow: hidden;
}
.cq-avatar svg { display: block; width: 113px; height: 113px; }
.cq-header-text { flex: 1 1 auto; min-width: 0; }
.cq-header h3 { margin: 0; font-size: 16px; font-weight: 600; }
.cq-header p { margin: 2px 0 0; font-size: 12px; opacity: 0.85; }
.cq-close { margin-left: auto; }
.cq-close {
  background: transparent;
  border: none;
  color: inherit;
  cursor: pointer;
  font-size: 22px;
  line-height: 1;
  padding: 4px;
}

.cq-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.cq-msg {
  max-width: 85%;
  padding: 10px 13px;
  border-radius: 14px;
  font-size: 14px;
  line-height: 1.45;
  white-space: pre-wrap;
  word-wrap: break-word;
}
.cq-msg.cq-bot { align-self: flex-start; background: var(--cq-bot-bubble); color: var(--cq-text); border-bottom-left-radius: 4px; }
.cq-msg.cq-user { align-self: flex-end; background: var(--cq-user-bubble); color: var(--cq-user-text); border-bottom-right-radius: 4px; }
.cq-msg { animation: cq-msg-in 0.18s ease-out; }
@keyframes cq-msg-in { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .cq-msg { animation: none; } }

.cq-status {
  align-self: center;
  font-size: 12px;
  color: var(--cq-muted);
  font-style: italic;
}

.cq-typing { display: inline-flex; gap: 4px; align-items: center; }
.cq-typing span {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--cq-muted); opacity: 0.5;
  animation: cq-bounce 1.2s infinite ease-in-out;
}
.cq-typing span:nth-child(2) { animation-delay: 0.15s; }
.cq-typing span:nth-child(3) { animation-delay: 0.3s; }
@keyframes cq-bounce { 0%, 80%, 100% { transform: translateY(0); opacity: 0.4; } 40% { transform: translateY(-4px); opacity: 1; } }

.cq-input {
  border-top: 1px solid #ececec;
  padding: 10px;
  display: flex;
  gap: 8px;
  align-items: flex-end;
}
.cq-input textarea {
  flex: 1;
  resize: none;
  border: 1px solid #dcdcdc;
  border-radius: 12px;
  padding: 10px 12px;
  font-family: inherit;
  font-size: 14px;
  line-height: 1.4;
  max-height: 120px;
  outline: none;
}
.cq-input textarea:focus { border-color: var(--cq-accent); }
.cq-send {
  border: none;
  background: var(--cq-accent);
  color: var(--cq-accent-text);
  border-radius: 12px;
  width: 42px;
  height: 42px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
}
.cq-send:disabled { opacity: 0.5; cursor: default; }
.cq-send svg { width: 20px; height: 20px; }

.cq-footer {
  text-align: center;
  font-size: 11px;
  color: var(--cq-muted);
  padding: 0 0 8px;
}

/* Contact form card */
.cq-form-card {
  max-width: 100%;
  width: 100%;
  background: var(--cq-bot-bubble);
}
.cq-form { display: flex; flex-direction: column; gap: 8px; }
.cq-field { display: flex; flex-direction: column; gap: 3px; }
.cq-field label { font-size: 12px; color: var(--cq-muted); font-weight: 600; }
.cq-field input {
  border: 1px solid #d6d6d4;
  border-radius: 9px;
  padding: 8px 10px;
  font-family: inherit;
  font-size: 14px;
  background: #fff;
  outline: none;
}
.cq-field input:focus { border-color: var(--cq-accent); }
.cq-hp { position: absolute; left: -9999px; width: 1px; height: 1px; opacity: 0; }
.cq-privacy { font-size: 11px; line-height: 1.4; color: var(--cq-muted); margin: 2px 0 0; }
.cq-form-error { font-size: 12px; color: #c0392b; }
.cq-form-submit {
  margin-top: 4px;
  border: none;
  background: var(--cq-accent);
  color: var(--cq-accent-text);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}
.cq-form-submit:disabled { opacity: 0.6; cursor: default; }
.cq-form-done { font-size: 14px; line-height: 1.5; }

/* Lock the host page behind the full-screen chat on mobile */
html.cq-lock, body.cq-lock { overflow: hidden !important; }

/* Mobile: full-screen app-like panel that slides up */
@media (max-width: 480px) {
  .cq-chat { right: 14px; bottom: 14px; }

  .cq-panel {
    position: fixed;
    inset: 0;
    width: 100vw;
    height: 100vh;
    height: 100dvh; /* accounts for mobile browser chrome and keyboard */
    max-width: none;
    max-height: none;
    border-radius: 0;
    display: flex;              /* always laid out so it can animate */
    transform: translateY(100%); /* parked off-screen when closed */
    transition: transform 0.3s ease;
    pointer-events: none;
  }
  .cq-chat.cq-open .cq-panel {
    transform: translateY(0);
    pointer-events: auto;
  }

  /* smaller avatar so the header is not top-heavy on a phone */
  .cq-avatar,
  .cq-avatar svg { width: 52px; height: 52px; }

  .cq-header { padding: 12px 14px; padding-top: calc(12px + env(safe-area-inset-top)); }
  /* clear, comfortably tappable close control in the full-screen header */
  .cq-close {
    font-size: 26px;
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.18);
  }

  /* 16px input text prevents iOS from auto-zooming on focus */
  .cq-input textarea,
  .cq-field input { font-size: 16px; }

  .cq-input { padding-bottom: calc(10px + env(safe-area-inset-bottom)); }
  .cq-msg { max-width: 90%; font-size: 15px; }
}
