/* ============================================================
   TL Lawn Care & Landscaping — Chatbot Widget Styles
   Namespaced with .cb-* to avoid collisions with host site.
   Pulls site CSS vars: --bg-primary, --bg-secondary, --text-*,
   --border, --accent-green, --accent-orange.
   ============================================================ */

#tl-chatbot-root,
#tl-chatbot-root * {
  box-sizing: border-box;
  font-family: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
}

#tl-chatbot-root {
  /* fallbacks in case site vars aren't defined */
  --cb-bg:        var(--bg-primary, #0F1F0F);
  --cb-bg-2:      var(--bg-secondary, #162316);
  --cb-text:      var(--text-primary, #F2EDE4);
  --cb-text-dim:  var(--text-secondary, #C5B89A);
  --cb-border:    var(--border, #2A3F2A);
  --cb-green:     var(--accent-green, #7A9E7E);
  --cb-orange:    var(--accent-orange, #f08c36);
  --cb-radius:    16px;
}

/* ============================================================
   LAUNCHER (floating CTA pill — NOT a bubble)
   ============================================================ */
.cb-launcher {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 99998;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 14px 22px;
  border: none;
  border-radius: 999px;
  cursor: pointer;
  color: #fff;
  font-weight: 700;
  font-size: 15px;
  letter-spacing: 0.01em;
  background: linear-gradient(135deg, var(--cb-green) 0%, var(--cb-orange) 100%);
  box-shadow:
    0 10px 28px rgba(240, 140, 54, 0.35),
    0 4px 10px rgba(0, 0, 0, 0.18);
  transition: transform 0.25s cubic-bezier(.34,1.56,.64,1), box-shadow 0.25s ease;
  animation: cbPulseShadow 2.6s ease-in-out infinite;
}
.cb-launcher:hover {
  transform: translateY(-3px) scale(1.03);
  box-shadow:
    0 16px 36px rgba(240, 140, 54, 0.45),
    0 6px 14px rgba(0, 0, 0, 0.22);
}
.cb-launcher:active { transform: translateY(0) scale(0.99); }
.cb-launcher-icon { font-size: 18px; line-height: 1; }
.cb-launcher-label { white-space: nowrap; }

@keyframes cbPulseShadow {
  0%, 100% { box-shadow: 0 10px 28px rgba(240, 140, 54, 0.30), 0 4px 10px rgba(0,0,0,0.18); }
  50%      { box-shadow: 0 14px 34px rgba(240, 140, 54, 0.50), 0 6px 14px rgba(0,0,0,0.22); }
}

/* Hide launcher when window is open */
#tl-chatbot-root.cb-open .cb-launcher {
  opacity: 0;
  pointer-events: none;
  transform: translateY(20px) scale(0.9);
}

/* ============================================================
   WINDOW
   ============================================================ */
.cb-window {
  position: fixed;
  bottom: 20px;
  right: 20px;
  width: 380px;
  height: 520px;
  max-height: calc(100vh - 40px);
  background: var(--cb-bg);
  border: 1px solid var(--cb-border);
  border-radius: var(--cb-radius);
  box-shadow:
    0 30px 60px -15px rgba(0, 0, 0, 0.55),
    0 12px 24px -8px rgba(0, 0, 0, 0.35);
  z-index: 99999;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  opacity: 0;
  transform: translateY(18px) scale(0.96);
  pointer-events: none;
  transition: opacity 0.28s ease, transform 0.32s cubic-bezier(.34,1.56,.64,1);
}
#tl-chatbot-root.cb-open .cb-window {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

/* ============================================================
   HEADER
   ============================================================ */
.cb-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  background: linear-gradient(135deg, #1a4a1a 0%, #0f7517 100%);
  color: #F2EDE4;
  border-bottom: 1px solid var(--cb-border);
  position: relative;
}
.cb-avatar {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: rgba(255,255,255,0.12);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  flex-shrink: 0;
}
.cb-header-info { flex: 1; min-width: 0; }
.cb-header-name {
  font-weight: 700;
  font-size: 15px;
  line-height: 1.2;
}
.cb-header-status {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11.5px;
  margin-top: 3px;
  color: rgba(242, 237, 228, 0.78);
}
.cb-status-dot {
  width: 7px;
  height: 7px;
  background: #5CB87A;
  border-radius: 50%;
  box-shadow: 0 0 0 2px rgba(92, 184, 122, 0.25);
  animation: cbStatusPulse 2s ease-in-out infinite;
}
@keyframes cbStatusPulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.55; }
}
.cb-close {
  width: 30px;
  height: 30px;
  border: none;
  background: rgba(255,255,255,0.12);
  color: #fff;
  border-radius: 8px;
  cursor: pointer;
  font-size: 22px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s ease, transform 0.2s ease;
}
.cb-close:hover { background: rgba(255,255,255,0.22); transform: rotate(90deg); }

/* ============================================================
   MESSAGES
   ============================================================ */
.cb-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  background: var(--cb-bg-2);
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.cb-messages::-webkit-scrollbar { width: 6px; }
.cb-messages::-webkit-scrollbar-track { background: transparent; }
.cb-messages::-webkit-scrollbar-thumb {
  background: rgba(255,255,255,0.12);
  border-radius: 3px;
}

.cb-msg {
  display: flex;
  max-width: 75%;
  animation: cbMsgIn 0.28s cubic-bezier(.34,1.56,.64,1);
}
.cb-msg-bot  { align-self: flex-start; }
.cb-msg-user { align-self: flex-end; }

@keyframes cbMsgIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

.cb-bubble {
  padding: 11px 14px;
  border-radius: 14px;
  font-size: 14px;
  line-height: 1.5;
  word-wrap: break-word;
}
.cb-msg-bot .cb-bubble {
  background: rgba(255, 255, 255, 0.07);
  color: var(--cb-text);
  border-bottom-left-radius: 4px;
  border: 1px solid rgba(255,255,255,0.05);
}
.cb-msg-user .cb-bubble {
  background: var(--cb-orange);
  color: #fff;
  border-bottom-right-radius: 4px;
}
.cb-bubble strong { font-weight: 700; color: var(--cb-orange); }
.cb-msg-user .cb-bubble strong { color: #fff; text-decoration: underline; }
.cb-bubble a { color: var(--cb-orange); text-decoration: underline; }
.cb-msg-user .cb-bubble a { color: #fff; }
.cb-bubble em { font-style: italic; opacity: 0.9; }

/* typing indicator */
.cb-typing {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 12px 14px;
  background: rgba(255,255,255,0.07);
  border-radius: 14px;
  border-bottom-left-radius: 4px;
  border: 1px solid rgba(255,255,255,0.05);
}
.cb-typing-dot {
  width: 6px; height: 6px;
  background: var(--cb-text-dim);
  border-radius: 50%;
  animation: cbTyping 1.3s ease-in-out infinite;
}
.cb-typing-dot:nth-child(2) { animation-delay: 0.15s; }
.cb-typing-dot:nth-child(3) { animation-delay: 0.3s; }
@keyframes cbTyping {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.45; }
  30%           { transform: translateY(-5px); opacity: 1; }
}

/* ============================================================
   QUICK CHIPS
   ============================================================ */
.cb-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 0 14px 12px;
  background: var(--cb-bg-2);
}
.cb-chips:empty { padding: 0; }
.cb-chip {
  padding: 8px 13px;
  border: 1px solid rgba(122, 158, 126, 0.45);
  background: rgba(122, 158, 126, 0.10);
  color: var(--cb-text);
  border-radius: 999px;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: transform 0.18s ease, background 0.18s ease, border-color 0.18s ease;
}
.cb-chip:hover {
  background: var(--cb-orange);
  border-color: var(--cb-orange);
  color: #fff;
  transform: translateY(-1px);
}

/* ============================================================
   INPUT
   ============================================================ */
.cb-input-row {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 12px 14px;
  background: var(--cb-bg);
  border-top: 1px solid var(--cb-border);
}
.cb-input {
  flex: 1;
  min-height: 40px;
  max-height: 120px;
  padding: 10px 12px;
  background: var(--cb-bg-2);
  border: 1px solid var(--cb-border);
  border-radius: 10px;
  color: var(--cb-text);
  font-size: 14px;
  line-height: 1.4;
  resize: none;
  outline: none;
  transition: border-color 0.18s ease, box-shadow 0.18s ease;
}
.cb-input::placeholder { color: var(--cb-text-dim); opacity: 0.7; }
.cb-input:focus {
  border-color: var(--cb-orange);
  box-shadow: 0 0 0 3px rgba(240, 140, 54, 0.18);
}
.cb-send {
  width: 40px;
  height: 40px;
  flex-shrink: 0;
  border: none;
  border-radius: 10px;
  background: var(--cb-orange);
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.18s ease, background 0.18s ease;
}
.cb-send:hover { background: #d97927; transform: scale(1.06); }
.cb-send:active { transform: scale(0.96); }
.cb-send:disabled { opacity: 0.55; cursor: not-allowed; transform: none; }

/* ============================================================
   MOBILE (<=640px) — full-screen window
   ============================================================ */
@media (max-width: 640px) {
  .cb-launcher {
    bottom: 16px;
    right: 16px;
    padding: 12px 18px;
    font-size: 14px;
  }
  .cb-window {
    bottom: 0;
    right: 0;
    left: 0;
    top: 0;
    width: 100vw;
    height: 100dvh;
    max-height: 100dvh;
    border-radius: 0;
    border: none;
  }
}

/* Light-theme defensive overrides — if the host site is in light mode,
   force the chatbot interior to read as a dark widget for contrast. */
[data-theme="light"] #tl-chatbot-root {
  --cb-bg:       #0F1F0F;
  --cb-bg-2:     #162316;
  --cb-text:     #F2EDE4;
  --cb-text-dim: #C5B89A;
  --cb-border:   #2A3F2A;
}
