/* ============================================================
   PPCPartner — Lead Qualification Chatbot Widget
   File: assets/css/chatbot.css
   ============================================================
   To customise brand colours, edit the :root block below.
   All spacing, radii and sizes use CSS custom properties
   so changes cascade automatically.
   ============================================================ */

/* ── Design tokens ─────────────────────────────────────────── */
:root {
  --cb-primary:        #1e40af;   /* main blue — buttons, user bubble    */
  --cb-primary-hover:  #1d4ed8;
  --cb-dark:           #0f172a;   /* panel header background             */
  --cb-dark-2:         #1e293b;   /* header gradient end                 */
  --cb-surface:        #ffffff;   /* chat panel background               */
  --cb-bg:             #f8fafc;   /* messages area background            */
  --cb-bot-bubble:     #ffffff;   /* bot message bubble                  */
  --cb-user-bubble:    #1e40af;   /* user message bubble                 */
  --cb-user-text:      #ffffff;
  --cb-border:         #e2e8f0;
  --cb-text:           #1e293b;
  --cb-text-muted:     #64748b;
  --cb-text-light:     #94a3b8;
  --cb-wa-green:       #25d366;
  --cb-wa-hover:       #20ba5a;
  --cb-error:          #ef4444;
  --cb-radius-panel:   20px;
  --cb-radius-btn:     10px;
  --cb-radius-bubble:  14px;
  --cb-panel-w:        376px;
  --cb-panel-h:        560px;
  --cb-z:              9998;      /* below WA float (z-50 = 50 in Tailwind ~ 50) */
  --cb-font:           -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto,
                       'Inter', sans-serif;
}

/* ── Reset for widget elements ──────────────────────────────── */
#cb-container,
#cb-container * {
  box-sizing: border-box;
  -webkit-font-smoothing: antialiased;
}

/* ── Outer container ────────────────────────────────────────── */
#cb-container {
  position: fixed;
  bottom: 92px;      /* stacks above the existing WhatsApp float at bottom:24px */
  right: 24px;
  z-index: var(--cb-z);
  font-family: var(--cb-font);
  font-size: 14px;
  line-height: 1.5;
}

/* ============================================================
   TOGGLE BUTTON
   ============================================================ */
#cb-toggle {
  position: relative;
  width: 54px;
  height: 54px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--cb-primary) 0%, #2563eb 100%);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 20px rgba(30, 64, 175, 0.42),
              0 2px 8px  rgba(30, 64, 175, 0.28);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  outline: none;
  color: #fff;
  -webkit-tap-highlight-color: transparent;
}

#cb-toggle:hover {
  transform: scale(1.06);
  box-shadow: 0 6px 28px rgba(30, 64, 175, 0.52),
              0 3px 12px rgba(30, 64, 175, 0.32);
}

#cb-toggle:active { transform: scale(0.97); }

#cb-toggle-icon-open,
#cb-toggle-icon-close {
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.15s ease, transform 0.15s ease;
}

#cb-toggle svg {
  width: 22px;
  height: 22px;
  pointer-events: none;
}

/* Notification dot */
#cb-unread-dot {
  display: none;
  position: absolute;
  top: 1px;
  right: 1px;
  width: 13px;
  height: 13px;
  background: #ef4444;
  border-radius: 50%;
  border: 2px solid #fff;
  animation: cb-dot-pulse 2.2s ease-in-out infinite;
}

@keyframes cb-dot-pulse {
  0%, 100% { transform: scale(1);   opacity: 1; }
  50%       { transform: scale(1.3); opacity: 0.7; }
}

/* ============================================================
   CHAT PANEL
   ============================================================ */
#cb-panel {
  position: absolute;
  bottom: 64px;
  right: 0;
  width: var(--cb-panel-w);
  height: var(--cb-panel-h);
  background: var(--cb-surface);
  border-radius: var(--cb-radius-panel);
  border: 1px solid rgba(226, 232, 240, 0.9);
  box-shadow: 0 20px 64px rgba(0, 0, 0, 0.16),
              0  6px 24px rgba(0, 0, 0, 0.09),
              0  2px  8px rgba(0, 0, 0, 0.06);
  display: flex;
  flex-direction: column;
  overflow: hidden;

  /* Closed state */
  opacity: 0;
  transform: translateY(14px) scale(0.97);
  pointer-events: none;
  transform-origin: bottom right;
  transition: opacity 0.22s ease, transform 0.22s ease;
}

#cb-panel.cb-open {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: all;
}

/* ============================================================
   HEADER
   ============================================================ */
#cb-header {
  background: linear-gradient(135deg, var(--cb-dark) 0%, var(--cb-dark-2) 100%);
  padding: 13px 15px 13px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
  border-bottom: 1px solid rgba(255,255,255,0.06);
}

#cb-header-info {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* Avatar / brand mark */
#cb-avatar {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: linear-gradient(135deg, #1e40af 0%, #3b82f6 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(37,99,235,0.4);
}

#cb-avatar svg {
  width: 18px;
  height: 18px;
}

#cb-brand-name {
  font-size: 13.5px;
  font-weight: 700;
  color: #fff;
  letter-spacing: -0.01em;
  line-height: 1.3;
}

#cb-brand-sub {
  font-size: 10.5px;
  color: rgba(255,255,255,0.42);
  font-weight: 400;
  margin-top: 1px;
  letter-spacing: 0.01em;
}

/* Online indicator dot */
#cb-online-dot {
  display: inline-block;
  width: 6px;
  height: 6px;
  background: #4ade80;
  border-radius: 50%;
  margin-right: 4px;
  flex-shrink: 0;
  animation: cb-online-pulse 2.5s ease-in-out infinite;
}

@keyframes cb-online-pulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.45; }
}

#cb-header-actions {
  display: flex;
  align-items: center;
  gap: 2px;
}

#cb-restart,
#cb-close {
  background: none;
  border: none;
  cursor: pointer;
  color: rgba(255,255,255,0.45);
  width: 30px;
  height: 30px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s ease, color 0.15s ease;
  padding: 0;
}

#cb-restart:hover,
#cb-close:hover {
  background: rgba(255,255,255,0.1);
  color: #fff;
}

#cb-restart svg,
#cb-close svg {
  width: 14px;
  height: 14px;
  pointer-events: none;
}

/* ============================================================
   MESSAGES AREA
   ============================================================ */
#cb-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  scroll-behavior: smooth;
  background: var(--cb-bg);
}

/* Thin, elegant scrollbar */
#cb-messages::-webkit-scrollbar          { width: 3px; }
#cb-messages::-webkit-scrollbar-track    { background: transparent; }
#cb-messages::-webkit-scrollbar-thumb    { background: #cbd5e1; border-radius: 4px; }
#cb-messages                              { scrollbar-width: thin; scrollbar-color: #cbd5e1 transparent; }

/* ============================================================
   MESSAGE BUBBLES
   ============================================================ */
.cb-msg {
  display: flex;
  max-width: 88%;
  animation: cb-msg-in 0.19s ease both;
}

@keyframes cb-msg-in {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

.cb-msg-bot  { align-self: flex-start; }
.cb-msg-user { align-self: flex-end; }

.cb-bubble {
  padding: 10px 13px;
  font-size: 13.5px;
  line-height: 1.58;
  font-weight: 400;
}

/* Bot bubble */
.cb-msg-bot .cb-bubble {
  background: var(--cb-bot-bubble);
  color: var(--cb-text);
  border-radius: var(--cb-radius-bubble);
  border-bottom-left-radius: 4px;
  border: 1px solid var(--cb-border);
  box-shadow: 0 1px 4px rgba(0,0,0,0.05);
}

/* User bubble */
.cb-msg-user .cb-bubble {
  background: var(--cb-user-bubble);
  color: var(--cb-user-text);
  border-radius: var(--cb-radius-bubble);
  border-bottom-right-radius: 4px;
}

/* ============================================================
   TYPING INDICATOR
   ============================================================ */
.cb-typing-bubble {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 12px 16px !important;
  min-width: 52px;
}

.cb-typing-bubble span {
  display: block;
  width: 7px;
  height: 7px;
  background: #94a3b8;
  border-radius: 50%;
  animation: cb-type-bounce 1.35s ease-in-out infinite;
  flex-shrink: 0;
}

.cb-typing-bubble span:nth-child(2) { animation-delay: 0.16s; }
.cb-typing-bubble span:nth-child(3) { animation-delay: 0.32s; }

@keyframes cb-type-bounce {
  0%, 60%, 100% { transform: translateY(0);   opacity: 0.35; }
  30%            { transform: translateY(-6px); opacity: 1; }
}

/* ============================================================
   INPUT AREA (wrapper for all input types)
   ============================================================ */
#cb-input-area {
  border-top: 1px solid var(--cb-border);
  background: var(--cb-surface);
  flex-shrink: 0;
  max-height: 230px;
  overflow-y: auto;
}

#cb-input-area::-webkit-scrollbar       { width: 3px; }
#cb-input-area::-webkit-scrollbar-thumb { background: #e2e8f0; border-radius: 3px; }

/* ============================================================
   CHOICE BUTTONS
   ============================================================ */
.cb-choices {
  padding: 11px 12px 13px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.cb-choice-btn {
  width: 100%;
  background: #fff;
  border: 1.5px solid var(--cb-border);
  border-radius: var(--cb-radius-btn);
  padding: 9px 12px;
  font-size: 13px;
  font-family: var(--cb-font);
  color: var(--cb-text);
  cursor: pointer;
  text-align: left;
  font-weight: 500;
  line-height: 1.4;
  transition: background 0.14s ease, border-color 0.14s ease, color 0.14s ease,
              transform 0.1s ease;
  -webkit-tap-highlight-color: transparent;
}

.cb-choice-btn:hover {
  background: #eff6ff;
  border-color: #93c5fd;
  color: var(--cb-primary);
}

.cb-choice-btn:active { transform: scale(0.98); }

/* ============================================================
   FREE TEXT INPUT ROW
   ============================================================ */
.cb-text-input-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
}

.cb-text-input {
  flex: 1;
  border: 1.5px solid var(--cb-border);
  border-radius: var(--cb-radius-btn);
  padding: 9px 12px;
  font-size: 13px;
  font-family: var(--cb-font);
  color: var(--cb-text);
  background: var(--cb-bg);
  outline: none;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.cb-text-input:focus {
  border-color: var(--cb-primary);
  background: #fff;
  box-shadow: 0 0 0 3px rgba(37,99,235,0.08);
}

.cb-text-input::placeholder { color: var(--cb-text-light); }

/* Send button */
.cb-send-btn {
  width: 36px;
  height: 36px;
  border-radius: var(--cb-radius-btn);
  background: var(--cb-primary);
  border: none;
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.14s ease, transform 0.1s ease;
  flex-shrink: 0;
  -webkit-tap-highlight-color: transparent;
}

.cb-send-btn:hover  { background: var(--cb-primary-hover); }
.cb-send-btn:active { transform: scale(0.94); }

.cb-send-btn svg {
  width: 14px;
  height: 14px;
  pointer-events: none;
}

/* ============================================================
   CONTACT FORM
   ============================================================ */
.cb-contact-form {
  padding: 12px 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.cb-form-group {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.cb-form-label {
  font-size: 10.5px;
  font-weight: 700;
  color: var(--cb-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.055em;
}

.cb-form-input {
  border: 1.5px solid var(--cb-border);
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 13px;
  font-family: var(--cb-font);
  color: var(--cb-text);
  background: var(--cb-bg);
  outline: none;
  transition: border-color 0.15s ease, background 0.15s ease, box-shadow 0.15s ease;
}

.cb-form-input:focus {
  border-color: var(--cb-primary);
  background: #fff;
  box-shadow: 0 0 0 3px rgba(37,99,235,0.08);
}

.cb-form-input::placeholder { color: var(--cb-text-light); }

.cb-form-error {
  font-size: 11px;
  color: var(--cb-error);
  min-height: 13px;
  font-weight: 500;
}

.cb-form-input.cb-input-error {
  border-color: var(--cb-error);
  box-shadow: 0 0 0 3px rgba(239,68,68,0.08);
}

.cb-form-submit {
  background: var(--cb-primary);
  color: #fff;
  border: none;
  border-radius: var(--cb-radius-btn);
  padding: 11px;
  font-size: 13px;
  font-weight: 600;
  font-family: var(--cb-font);
  cursor: pointer;
  transition: background 0.14s ease, transform 0.1s ease;
  margin-top: 3px;
  letter-spacing: 0.01em;
  -webkit-tap-highlight-color: transparent;
}

.cb-form-submit:hover  { background: var(--cb-primary-hover); }
.cb-form-submit:active { transform: scale(0.98); }

.cb-form-submit:disabled {
  opacity: 0.65;
  cursor: not-allowed;
  transform: none;
}

/* ============================================================
   WHATSAPP CTA BUTTON
   ============================================================ */
.cb-wa-cta {
  padding: 12px 12px 14px;
}

.cb-wa-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  width: 100%;
  background: var(--cb-wa-green);
  color: #fff !important;
  text-decoration: none !important;
  border-radius: 12px;
  padding: 12px 16px;
  font-size: 13.5px;
  font-weight: 700;
  font-family: var(--cb-font);
  transition: background 0.14s ease, transform 0.12s ease, box-shadow 0.14s ease;
  letter-spacing: 0.01em;
  box-shadow: 0 3px 14px rgba(37,211,102,0.35);
  -webkit-tap-highlight-color: transparent;
}

.cb-wa-btn:hover {
  background: var(--cb-wa-hover);
  transform: scale(1.02);
  box-shadow: 0 5px 20px rgba(37,211,102,0.45);
}

.cb-wa-btn:active { transform: scale(0.98); }

.cb-wa-btn svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

/* ============================================================
   STATUS MESSAGE (success / error)
   ============================================================ */
.cb-status {
  margin: 0 12px 10px;
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 500;
  display: flex;
  align-items: flex-start;
  gap: 7px;
}

.cb-status-success {
  background: #f0fdf4;
  color: #166534;
  border: 1px solid #bbf7d0;
}

.cb-status-error {
  background: #fef2f2;
  color: #991b1b;
  border: 1px solid #fecaca;
}

.cb-status svg {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
  margin-top: 1px;
}

/* ============================================================
   MOBILE RESPONSIVE
   ============================================================ */
@media (max-width: 480px) {
  #cb-container {
    bottom: 88px;
    right: 16px;
  }

  #cb-panel {
    width: calc(100vw - 32px);
    right: 0;
    bottom: 62px;
    height: min(78vh, 520px);
  }
}

@media (max-width: 360px) {
  #cb-panel {
    width: calc(100vw - 24px);
    right: -4px;
  }
}
