/* ============================================================
   cd-bot.css — PC Recovery & Towing
   Dark/amber palette — urgent, trustworthy, emergency-ready
   v1.0.1 — pulse bubble, action buttons, contact bar
============================================================ */

/* ============================================================
   THEME VARIABLES
============================================================ */

:root {
  --bot-primary:     #9E0202;
  --bot-primary-dk:  #7a0101;
  --bot-primary-lt:  #fff5f5;
  --bot-dark:        #111827;
  --bot-bg:          #F9FAFB;
  --bot-msg-bg:      #FFFFFF;
  --bot-border:      #E5E7EB;
  --bot-text:        #1F2937;
  --bot-muted:       #9CA3AF;
  --bot-green:       #22C55E;   /* WhatsApp / online dot */
}

/* ============================================================
   FLOATING CHATBOT — BUBBLE
============================================================ */

#cd-assistant {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 2147483647;
}

/* Bubble button — clean circle, no image */
#cd-assistant .cd-bubble {
  position: relative;
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: var(--bot-primary);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 20px rgba(158, 2, 2, 0.4);
  transition: transform 0.2s, box-shadow 0.2s;
}

#cd-assistant .cd-bubble:hover {
  transform: scale(1.08);
  box-shadow: 0 6px 24px rgba(158, 2, 2, 0.55);
}

#cd-assistant .cd-bubble-inner {
  font-size: 28px;
  line-height: 1;
  position: relative;
  z-index: 2;
}

/* Pulse ring */
#cd-assistant .cd-bubble-pulse {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: var(--bot-primary);
  opacity: 0.35;
  animation: cd-pulse 2.2s ease-out infinite;
  z-index: 1;
}

@keyframes cd-pulse {
  0%   { transform: scale(1);   opacity: 0.35; }
  70%  { transform: scale(1.55); opacity: 0; }
  100% { transform: scale(1.55); opacity: 0; }
}

/* ============================================================
   FLOATING PANEL
============================================================ */

#cd-assistant .cd-panel {
  display: none;
  position: fixed;
  right: 20px;
  bottom: 100px;
  width: 380px;
  height: clamp(520px, 75vh, 720px);
  flex-direction: column;
  background: #ffffff;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.22);
  font-family: system-ui, -apple-system, sans-serif;
  overflow: hidden;
  box-sizing: border-box;
  border-radius: 16px;
}

#cd-assistant .cd-panel.is-open {
  display: flex;
}

/* ── PANEL HEADER ── */
#cd-assistant .cd-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bot-dark);
  padding: 14px 16px;
  border-radius: 16px 16px 0 0;
  flex-shrink: 0;
}

#cd-assistant .cd-header-identity {
  display: flex;
  align-items: center;
  gap: 10px;
}

#cd-assistant .cd-header-icon {
  font-size: 24px;
  line-height: 1;
}

#cd-assistant .cd-header-name {
  color: #ffffff;
  font-size: 0.95rem;
  font-weight: 700;
  line-height: 1.2;
}

#cd-assistant .cd-header-status {
  display: flex;
  align-items: center;
  gap: 5px;
  color: rgba(255,255,255,0.7);
  font-size: 0.75rem;
  margin-top: 2px;
}

#cd-assistant .cd-status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--bot-green);
  display: inline-block;
  box-shadow: 0 0 6px var(--bot-green);
}

#cd-assistant .cd-actions {
  display: flex;
  gap: 8px;
}

#cd-assistant .cd-close {
  background: none;
  border: none;
  color: #ffffff;
  font-size: 22px;
  cursor: pointer;
  line-height: 1;
  opacity: 0.7;
  transition: opacity 0.15s;
}
#cd-assistant .cd-close:hover { opacity: 1; }

#cd-assistant .cd-reset {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 16px;
  opacity: 0.5;
  color: #ffffff;
  transition: opacity 0.15s;
}
#cd-assistant .cd-reset:hover { opacity: 1; }

/* ── QUICK-REPLY ACTION BUTTONS ── */
#cd-assistant .cd-action-btns {
  display: flex;
  gap: 8px;
  padding: 12px 12px 0 12px;
  background: #ffffff;
  flex-shrink: 0;
}

#cd-assistant .cd-action-btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 8px;
  border: 1.5px solid var(--bot-border);
  border-radius: 10px;
  background: var(--bot-primary-lt);
  color: var(--bot-text);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
  text-align: center;
  line-height: 1.2;
}

#cd-assistant .cd-action-btn:hover {
  background: var(--bot-primary);
  border-color: var(--bot-primary);
  color: #ffffff;
}

#cd-assistant .cd-action-icon {
  font-size: 1rem;
}

/* ── CHAT LOG ── */
#cd-assistant .cd-chat-log {
  flex: 1;
  overflow-y: auto;
  padding: 14px;
  background: #fafafa;
}

#cd-assistant .cd-msg {
  margin-bottom: 10px;
  padding: 12px 14px;
  border-radius: 12px;
  font-size: 15px;
  line-height: 1.6;
  max-width: 85%;
}

#cd-assistant .cd-msg.cd-user {
  background: var(--bot-primary);
  color: #ffffff;
  font-weight: 600;
  margin-left: auto;
  border-bottom-right-radius: 4px;
}

#cd-assistant .cd-msg.cd-bot {
  background: #ffffff;
  border: 1px solid #eee;
  border-bottom-left-radius: 4px;
}

/* Links in bot messages */
#cd-assistant .cd-msg a {
  color: var(--bot-primary-dk);
  font-weight: 700;
  text-decoration: none;
}
#cd-assistant .cd-msg a:hover { text-decoration: underline; }

/* ── INPUT BAR ── */
#cd-assistant .cd-inputbar {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 10px 12px;
  background: #ffffff;
  border-top: 1px solid #eeeeee;
  flex-shrink: 0;
}

#cd-assistant .cd-inputbar textarea {
  flex: 1;
  border: 1px solid #e4e4e4;
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 15px;
  resize: none;
  max-height: 100px;
  line-height: 1.5;
  font-family: inherit;
}

#cd-assistant .cd-inputbar textarea:focus {
  outline: none;
  border-color: var(--bot-primary);
}

#cd-assistant .cd-send {
  background: var(--bot-primary);
  color: #ffffff;
  font-weight: 700;
  border-radius: 10px;
  padding: 10px 14px;
  border: none;
  cursor: pointer;
  white-space: nowrap;
  align-self: flex-end;
  font-size: 0.9rem;
  transition: background 0.15s;
}
#cd-assistant .cd-send:hover { background: var(--bot-primary-dk); }

/* ── BOTTOM CONTACT BAR ── */
#cd-assistant .cd-contact-bar {
  display: flex;
  flex-shrink: 0;
}

#cd-assistant .cd-contact-btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 14px 10px;
  font-size: 0.9rem;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
  border: none;
  transition: filter 0.15s;
  letter-spacing: 0.01em;
}

#cd-assistant .cd-contact-btn:hover {
  filter: brightness(0.92);
}

#cd-assistant .cd-contact-call {
  background: var(--bot-primary);
  color: #ffffff;
}

#cd-assistant .cd-contact-whatsapp {
  background: #25D366;
  color: #ffffff;
}

/* ============================================================
   TYPING INDICATOR
============================================================ */

#cd-bot-hero .cd-typing span,
#cd-assistant .cd-typing span {
  display: inline-block;
  width: 7px;
  height: 7px;
  background: #bbb;
  border-radius: 50%;
  margin-right: 4px;
  animation: cd-blink 1.4s infinite both;
}

#cd-bot-hero .cd-typing span:nth-child(2),
#cd-assistant .cd-typing span:nth-child(2) { animation-delay: 0.2s; }
#cd-bot-hero .cd-typing span:nth-child(3),
#cd-assistant .cd-typing span:nth-child(3) { animation-delay: 0.4s; }

@keyframes cd-blink {
  0%   { opacity: .2; }
  20%  { opacity: 1;  }
  100% { opacity: .2; }
}

/* ============================================================
   HERO / EMBEDDED BOT
============================================================ */

#cd-bot-hero .cd-hero-chat {
  max-width: 560px;
  margin-top: 20px;
}

#cd-bot-hero .cd-hero-chat-panel {
  max-height: 300px;
  overflow-y: auto;
  margin-bottom: 12px;
  border-radius: 12px;
}

#cd-bot-hero .cd-hero-chat-panel.is-empty {
  display: none;
}

#cd-bot-hero .cd-hero-chat-panel.is-active {
  display: block;
  background: #ffffff;
  padding: 12px;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.08);
}

#cd-bot-hero .cd-hero-messages {
  margin-bottom: 4px;
}

#cd-bot-hero .cd-msg {
  margin-bottom: 10px;
  line-height: 1.6;
  font-size: 15px;
}

#cd-bot-hero .cd-user {
  text-align: right;
  font-weight: 600;
}

#cd-bot-hero .cd-hero-inputbar {
  display: flex;
  gap: 8px;
  align-items: flex-end;
}

#cd-bot-hero .cd-hero-inputbar textarea {
  flex: 1;
  resize: none;
  padding: 12px 14px;
  border-radius: 10px;
  border: 1px solid #ddd;
  background: #ffffff;
  font-size: 15px;
  line-height: 1.5;
  font-family: inherit;
}

#cd-bot-hero .cd-hero-inputbar button:not(.cd-reset) {
  padding: 12px 18px;
  min-height: 44px;
  border-radius: 10px;
  border: none;
  background: var(--bot-primary);
  color: #ffffff;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
}

#cd-bot-hero .cd-reset {
  padding: 12px 16px;
  min-height: 44px;
  border-radius: 10px;
  border: none;
  background: var(--bot-primary);
  color: #ffffff;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  align-self: stretch;
}

#cd-bot-hero .cd-reset:hover { background: var(--bot-primary-dk); }

/* Links in hero bot messages */
#cd-bot-hero .cd-msg a {
  color: var(--bot-primary-dk);
  font-weight: 700;
  text-decoration: none;
}
#cd-bot-hero .cd-msg a:hover { text-decoration: underline; }

/* ============================================================
   HOMEPAGE HERO WRAPPER (wp-dai layout)
============================================================ */

.wp-dai-wrap {
  display: flex;
  background: #ffffff;
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 40px 100px rgba(0,0,0,0.25), 0 0 0 1px rgba(0,0,0,0.08);
  max-width: 1000px;
  margin: 40px auto 0 auto;
}

.wp-dai-sidepanel {
  width: 300px;
  flex-shrink: 0;
  position: relative;
  overflow: hidden;
  border-radius: 16px 0 0 16px;
}
.wp-dai-sidepanel img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.wp-dai-overlay {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  padding: 24px 20px;
  background: linear-gradient(to top, rgba(0,0,0,0.8) 0%, rgba(0,0,0,0) 100%);
}
.wp-dai-stats { display: flex; flex-direction: column; gap: 10px; }
.wp-dai-stat {
  color: #ffffff;
  font-size: 0.82rem;
  font-weight: 500;
  line-height: 1.3;
}
.wp-dai-stat-intro {
  color: #ffffff;
  font-size: 0.82rem;
  font-weight: 600;
  line-height: 1.4;
  margin-bottom: 8px;
}
.wp-dai-stat-label {
  color: rgba(255,255,255,0.6);
  font-size: 0.72rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 4px;
}

.wp-dai-chat {
  flex: 1;
  min-width: 0;
  display: flex !important;
  flex-direction: column !important;
  background: var(--bot-bg);
  padding: 20px 24px 0 24px;
  box-sizing: border-box;
}

.wp-dai-chat #cd-bot-hero .cd-hero-chat-panel {
  flex: 1 !important;
  max-height: 300px !important;
  min-height: 240px !important;
  overflow-y: auto !important;
  margin-bottom: 12px !important;
  border-radius: 12px !important;
  background: #ffffff !important;
  padding: 16px !important;
  box-shadow: 0 6px 18px rgba(0,0,0,0.08) !important;
  display: block !important;
}

.wp-dai-chat #cd-bot-hero .cd-hero-chat { max-width: 100% !important; margin-top: 0 !important; }

.wp-dai-chat #cd-bot-hero .cd-msg {
  font-size: 0.95rem !important;
  line-height: 1.6 !important;
  margin-bottom: 10px !important;
  padding: 12px 16px !important;
  border-radius: 12px !important;
  max-width: 92% !important;
  text-align: left !important;
}

.wp-dai-chat #cd-bot-hero .cd-user {
  background: var(--bot-primary) !important;
  color: #ffffff !important;
  font-weight: 600 !important;
  text-align: right !important;
  margin-left: auto !important;
  border-bottom-right-radius: 4px !important;
}

.wp-dai-chat #cd-bot-hero .cd-msg:not(.cd-user) {
  background: var(--bot-msg-bg) !important;
  border: 1px solid var(--bot-border) !important;
  color: var(--bot-text) !important;
  border-bottom-left-radius: 4px !important;
}

.wp-dai-chat #cd-bot-hero .cd-hero-inputbar {
  background: #ffffff !important;
  border-top: 1px solid var(--bot-border) !important;
  padding: 14px 0 0 0 !important;
  display: flex !important;
  align-items: center !important;
  gap: 10px !important;
  flex-shrink: 0 !important;
  box-sizing: border-box !important;
  margin: 0 -24px !important;
  padding-left: 24px !important;
  padding-right: 24px !important;
  flex-wrap: wrap !important;
}

.wp-dai-chat #cd-bot-hero .cd-hero-inputbar textarea {
  background: var(--bot-msg-bg) !important;
  border: 1px solid var(--bot-border) !important;
  color: var(--bot-text) !important;
  border-radius: 8px !important;
  padding: 12px 16px !important;
  font-size: 0.95rem !important;
  min-width: 0 !important;
  box-sizing: border-box !important;
  resize: none !important;
  flex: 1 !important;
}

.wp-dai-chat #cd-bot-hero .cd-hero-inputbar textarea:focus {
  outline: none !important;
  border-color: var(--bot-primary) !important;
  background: #ffffff !important;
}

.wp-dai-chat #cd-bot-hero .cd-hero-inputbar button:not(.cd-reset) {
  background: var(--bot-primary) !important;
  color: #ffffff !important;
  border: none !important;
  border-radius: 8px !important;
  padding: 0 !important;
  height: 46px !important;
  width: 46px !important;
  cursor: pointer !important;
  flex-shrink: 0 !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  font-size: 0 !important;
}
.wp-dai-chat #cd-bot-hero .cd-hero-inputbar button:not(.cd-reset)::after {
  content: '➤' !important;
  font-size: 1rem !important;
  color: #ffffff !important;
}
.wp-dai-chat #cd-bot-hero .cd-hero-inputbar button:not(.cd-reset):hover {
  background: var(--bot-primary-dk) !important;
}

.wp-dai-chat #cd-bot-hero .cd-reset {
  order: 3 !important;
  width: 100% !important;
  background: transparent !important;
  color: var(--bot-muted) !important;
  font-size: 0.72rem !important;
  border: none !important;
  padding: 4px 0 10px !important;
  text-align: right !important;
  cursor: pointer !important;
  border-radius: 0 !important;
  min-height: auto !important;
}

/* ============================================================
   MOBILE
============================================================ */

@media (max-width: 768px) {

  #cd-assistant .cd-panel {
    bottom: 0 !important;
    left: 0 !important;
    right: 0 !important;
    width: 100vw !important;
    height: 100dvh !important;
    border-radius: 0 !important;
  }

  #cd-assistant .cd-bubble {
    width: 58px;
    height: 58px;
  }

  #cd-assistant .cd-bubble-inner {
    font-size: 24px;
  }

  /* Both CTA buttons equal weight on mobile */
  #cd-assistant .cd-contact-btn {
    font-size: 0.95rem;
    padding: 16px 10px;
  }

  .wp-dai-sidepanel { display: none !important; }
  .wp-dai-wrap {
    flex-direction: column !important;
    margin: 24px 16px 0 16px;
    width: auto !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
  }
  .wp-dai-chat { padding: 16px 16px 0 16px; }
  .wp-dai-chat #cd-bot-hero .cd-hero-inputbar {
    margin: 0 -16px !important;
    padding-left: 16px !important;
    padding-right: 16px !important;
  }

  #cd-bot-hero .cd-hero-inputbar { flex-direction: row; gap: 10px; }
  #cd-bot-hero .cd-hero-inputbar button:not(.cd-reset) {
    width: 46px;
    padding: 0;
    font-size: 0;
    min-height: 46px;
  }
}

@media (min-width: 768px) and (max-width: 991px) {
  .wp-dai-sidepanel { width: 200px; }
}

/* ============================================================
   HERO EMBED — CONTACT BAR (Call Us + WhatsApp)
   Sits below the input field inside .wp-dai-chat
============================================================ */

.cd-hero-contact-bar {
  display: flex;
  flex-shrink: 0;
  margin: 0 -24px;        /* bleed to edge of wp-dai-chat padding */
}

.cd-hero-contact-bar .cd-contact-btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 14px 10px;
  font-size: 0.9rem;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
  border: none;
  transition: filter 0.15s;
  letter-spacing: 0.01em;
}

.cd-hero-contact-bar .cd-contact-btn:hover {
  filter: brightness(0.92);
}

.cd-hero-contact-bar .cd-contact-call {
  background: #9E0202;
  color: #ffffff;
}

.cd-hero-contact-bar .cd-contact-whatsapp {
  background: #25D366;
  color: #ffffff;
}

/* Mobile — full bleed, slightly taller tap targets */
@media (max-width: 768px) {
  .cd-hero-contact-bar {
    margin: 0 -16px;
  }
  .cd-hero-contact-bar .cd-contact-btn {
    padding: 16px 10px;
    font-size: 0.95rem;
  }
}

/* ============================================================
   HERO EMBED — QUICK-REPLY BUTTONS
   Sits above the input bar inside the hero chat
============================================================ */

.cd-hero-action-btns {
  display: flex;
  gap: 8px;
  padding: 0 0 12px 0;
  background: #ffffff;
  flex-shrink: 0;
}

.cd-hero-action-btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 8px;
  border: 1.5px solid var(--bot-border);
  border-radius: 10px;
  background: #fff5f5;
  color: var(--bot-text);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
  text-align: center;
  line-height: 1.2;
  font-family: inherit;
}

.cd-hero-action-btn:hover {
  background: #9E0202;
  border-color: #9E0202;
  color: #ffffff;
}

@media (max-width: 768px) {
  .cd-hero-action-btns {
    gap: 6px;
  }
  .cd-hero-action-btn {
    font-size: 0.78rem;
    padding: 10px 6px;
  }
}

/* ============================================================
   WHATSAPP LINK — green in bot message bubbles
============================================================ */
#cd-assistant .cd-msg a.cd-wa,
#cd-bot-hero .cd-msg a.cd-wa,
.wp-dai-chat #cd-bot-hero .cd-msg a.cd-wa {
  color: #25D366 !important;
}

/* ============================================================
   WHATSAPP LINK — green override (higher specificity)
============================================================ */
#cd-assistant .cd-msg a.cd-wa,
#cd-bot-hero .cd-msg a.cd-wa,
.wp-dai-chat #cd-bot-hero .cd-msg a.cd-wa {
  color: #25D366 !important;
}

/* ============================================================
   WHATSAPP LINK — green, targeted by href attribute
============================================================ */
#cd-assistant .cd-msg a[href*="wa.me"],
#cd-bot-hero .cd-msg a[href*="wa.me"] {
  color: #25D366 !important;
}

/* ============================================================
   BUBBLE — hidden on page load when hero bot is present
   IntersectionObserver in footer script reveals it when
   the hero scrolls out of view. Prevents flash on load.
============================================================ */
body:has(#cd-bot-hero) #cd-assistant .cd-bubble {
  display: none;
}

/* ============================================================
   HIDE BUBBLE WHEN PANEL IS OPEN
============================================================ */
#cd-assistant:has(.cd-panel.is-open) .cd-bubble {
  display: none !important;
  animation: none !important;
}

/* ============================================================
   PHONE / WHATSAPP LINK SPACING IN BOT MESSAGES
============================================================ */
#cd-assistant .cd-msg.cd-bot br,
#cd-bot-hero .cd-msg br {
  display: block;
  margin-bottom: 6px;
}
