/* ============================================
   Patio Pros — AI Chatbot Widget
   Dark premium theme · Gold accent
   ============================================ */

:root {
  --cb-primary: #F4A836;
  --cb-primary-dark: #D4841A;
  --cb-primary-glow: rgba(244, 168, 54, 0.35);
  --cb-bg: #0A0A0A;
  --cb-surface: #111111;
  --cb-surface-2: #1A1A1A;
  --cb-surface-3: #242424;
  --cb-text: #E8E8E8;
  --cb-text-muted: #777777;
  --cb-border: rgba(244, 168, 54, 0.12);
  --cb-border-hover: rgba(244, 168, 54, 0.3);
  --cb-radius: 16px;
  --cb-shadow: 0 24px 64px rgba(0,0,0,0.6), 0 0 0 1px rgba(244,168,54,0.08);
  --cb-z: 99999;
}

/* ── Keyframes ── */
@keyframes cb-fadeUp {
  from { opacity: 0; transform: translateY(16px) scale(0.97); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

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

@keyframes cb-pulse-glow {
  0%, 100% { box-shadow: 0 8px 32px rgba(0,0,0,0.5), 0 0 0 0 var(--cb-primary-glow); }
  50%       { box-shadow: 0 8px 32px rgba(0,0,0,0.5), 0 0 24px 6px var(--cb-primary-glow); }
}

@keyframes cb-dot-bounce {
  0%, 60%, 100% { transform: translateY(0); }
  30%           { transform: translateY(-5px); }
}

@keyframes cb-badge-pop {
  0%   { transform: scale(0); }
  60%  { transform: scale(1.3); }
  100% { transform: scale(1); }
}

@keyframes cb-slide-in {
  from { opacity: 0; transform: scale(0.9) translateY(20px); transform-origin: bottom right; }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}

/* ── TRIGGER BUTTON — Patio Slab Shape ── */
#cb-trigger {
  position: fixed;
  bottom: 28px;
  right: 0;
  z-index: var(--cb-z);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 20px 12px 16px;
  background: linear-gradient(135deg, #1A1208 0%, #0A0A0A 100%);
  border: 1px solid var(--cb-border-hover);
  border-right: none;
  border-radius: 12px 0 0 12px;
  box-shadow: -4px 4px 24px rgba(0,0,0,0.5), -1px 0 0 rgba(244,168,54,0.15);
  transition: transform 0.3s cubic-bezier(0.34,1.56,0.64,1),
              box-shadow 0.3s ease,
              border-color 0.3s ease;
  animation: cb-pulse-glow 3s ease-in-out infinite;
  user-select: none;
}

#cb-trigger:hover {
  transform: translateX(-5px);
  border-color: rgba(244,168,54,0.5);
  box-shadow: -8px 4px 32px rgba(244,168,54,0.2), -4px 0 0 rgba(244,168,54,0.2);
  animation: none;
}

#cb-trigger.cb-open {
  animation: none;
  background: linear-gradient(135deg, #1a1208 0%, #0f0a02 100%);
}

/* SVG icon */
#cb-trigger .cb-icon-wrap {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  position: relative;
}

#cb-trigger .cb-icon-wrap svg {
  width: 32px;
  height: 32px;
  transition: transform 0.35s cubic-bezier(0.34,1.56,0.64,1), opacity 0.25s ease;
}

#cb-trigger .cb-icon-close {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transform: rotate(-90deg) scale(0.5);
  transition: transform 0.35s cubic-bezier(0.34,1.56,0.64,1), opacity 0.25s ease;
}

#cb-trigger.cb-open .cb-icon-main { opacity: 0; transform: rotate(90deg) scale(0.5); }
#cb-trigger.cb-open .cb-icon-close { opacity: 1; transform: rotate(0deg) scale(1); }

/* Label next to icon */
#cb-trigger .cb-label {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
}

#cb-trigger .cb-label-top {
  font-family: -apple-system, BlinkMacSystemFont, 'Inter', sans-serif;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--cb-primary);
}

#cb-trigger .cb-label-bottom {
  font-family: -apple-system, BlinkMacSystemFont, 'Inter', sans-serif;
  font-size: 10px;
  color: rgba(232,232,232,0.5);
  letter-spacing: 0.02em;
}

/* Notification badge */
#cb-badge {
  position: absolute;
  top: -6px;
  left: -6px;
  width: 18px;
  height: 18px;
  background: #ef4444;
  border-radius: 50%;
  font-family: -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 10px;
  font-weight: 700;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  animation: cb-badge-pop 0.4s cubic-bezier(0.34,1.56,0.64,1) forwards;
}

#cb-badge.cb-visible { opacity: 1; }

/* ── CHAT CONTAINER ── */
#cb-container {
  position: fixed;
  bottom: 24px;
  right: 12px;
  z-index: calc(var(--cb-z) - 1);
  width: 380px;
  height: 540px;
  background: var(--cb-bg);
  border: 1px solid var(--cb-border-hover);
  border-radius: var(--cb-radius);
  box-shadow: var(--cb-shadow);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  opacity: 0;
  pointer-events: none;
  transform: scale(0.9) translateY(20px);
  transform-origin: bottom right;
  transition: opacity 0.35s cubic-bezier(0.34,1.56,0.64,1),
              transform 0.35s cubic-bezier(0.34,1.56,0.64,1);
}

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

/* ── HEADER ── */
#cb-header {
  background: linear-gradient(135deg, #1A1208 0%, #0D0D0D 100%);
  border-bottom: 1px solid var(--cb-border);
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}

#cb-avatar {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: linear-gradient(135deg, #F4A836 0%, #D4841A 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 18px;
  box-shadow: 0 0 0 2px rgba(244,168,54,0.2);
}

#cb-header-info {
  flex: 1;
  min-width: 0;
}

#cb-header-name {
  font-family: -apple-system, BlinkMacSystemFont, 'Inter', sans-serif;
  font-size: 14px;
  font-weight: 700;
  color: var(--cb-text);
  line-height: 1.2;
}

#cb-header-status {
  display: flex;
  align-items: center;
  gap: 5px;
  font-family: -apple-system, BlinkMacSystemFont, 'Inter', sans-serif;
  font-size: 11px;
  color: var(--cb-text-muted);
  margin-top: 2px;
}

#cb-header-status::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #22c55e;
  flex-shrink: 0;
  box-shadow: 0 0 0 2px rgba(34,197,94,0.2);
}

#cb-header-actions {
  display: flex;
  gap: 4px;
}

.cb-header-btn {
  width: 30px;
  height: 30px;
  border: none;
  background: rgba(255,255,255,0.04);
  border-radius: 8px;
  color: var(--cb-text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s, color 0.2s;
  font-size: 14px;
}

.cb-header-btn:hover {
  background: rgba(244,168,54,0.1);
  color: var(--cb-primary);
}

/* ── MESSAGES AREA ── */
#cb-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  scroll-behavior: smooth;
}

#cb-messages::-webkit-scrollbar { width: 4px; }
#cb-messages::-webkit-scrollbar-track { background: transparent; }
#cb-messages::-webkit-scrollbar-thumb { background: rgba(244,168,54,0.2); border-radius: 2px; }

/* Message bubbles */
.cb-msg {
  display: flex;
  gap: 8px;
  animation: cb-msgIn 0.3s ease forwards;
  max-width: 90%;
}

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

.cb-msg-user {
  align-self: flex-end;
  flex-direction: row-reverse;
}

.cb-msg-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: linear-gradient(135deg, #F4A836, #D4841A);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  flex-shrink: 0;
  margin-top: 2px;
}

.cb-msg-bubble {
  padding: 10px 14px;
  border-radius: 14px;
  font-family: -apple-system, BlinkMacSystemFont, 'Inter', sans-serif;
  font-size: 13.5px;
  line-height: 1.55;
  max-width: calc(100% - 40px);
}

.cb-msg-bot .cb-msg-bubble {
  background: var(--cb-surface-2);
  color: var(--cb-text);
  border-radius: 4px 14px 14px 14px;
  border: 1px solid var(--cb-border);
}

.cb-msg-user .cb-msg-bubble {
  background: linear-gradient(135deg, #F4A836 0%, #D4841A 100%);
  color: #0A0A0A;
  font-weight: 500;
  border-radius: 14px 4px 14px 14px;
}

.cb-msg-bubble strong { font-weight: 700; }
.cb-msg-bubble em { font-style: italic; }
.cb-msg-bubble a { color: var(--cb-primary); text-decoration: underline; }
.cb-msg-bot .cb-msg-bubble ul { margin: 6px 0; padding-left: 16px; }
.cb-msg-bot .cb-msg-bubble li { margin: 2px 0; }
.cb-msg-bot .cb-msg-bubble p { margin: 4px 0; }

/* Typing indicator */
#cb-typing {
  display: none;
  align-self: flex-start;
  animation: cb-msgIn 0.3s ease forwards;
}

#cb-typing.cb-visible { display: flex; }

.cb-typing-dots {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 10px 14px;
  background: var(--cb-surface-2);
  border-radius: 4px 14px 14px 14px;
  border: 1px solid var(--cb-border);
}

.cb-typing-dots span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--cb-primary);
  opacity: 0.6;
  animation: cb-dot-bounce 1.2s ease-in-out infinite;
}

.cb-typing-dots span:nth-child(2) { animation-delay: 0.15s; }
.cb-typing-dots span:nth-child(3) { animation-delay: 0.3s; }

/* ── QUICK OPTIONS ── */
#cb-quick-wrap {
  padding: 8px 16px 4px;
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  flex-shrink: 0;
  border-top: 1px solid var(--cb-border);
  background: var(--cb-surface);
}

.cb-quick-btn {
  font-family: -apple-system, BlinkMacSystemFont, 'Inter', sans-serif;
  font-size: 11px;
  font-weight: 600;
  padding: 6px 12px;
  border: 1px solid var(--cb-border-hover);
  background: transparent;
  color: var(--cb-primary);
  border-radius: 20px;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s, color 0.2s, transform 0.15s;
  white-space: nowrap;
}

.cb-quick-btn:hover {
  background: rgba(244,168,54,0.1);
  border-color: var(--cb-primary);
  transform: translateY(-1px);
}

/* ── INPUT AREA ── */
#cb-input-wrap {
  padding: 12px 16px;
  border-top: 1px solid var(--cb-border);
  display: flex;
  gap: 8px;
  align-items: flex-end;
  background: var(--cb-surface);
  flex-shrink: 0;
}

#cb-input {
  flex: 1;
  background: var(--cb-surface-2);
  border: 1px solid var(--cb-border);
  border-radius: 12px;
  padding: 10px 14px;
  font-family: -apple-system, BlinkMacSystemFont, 'Inter', sans-serif;
  font-size: 13px;
  color: var(--cb-text);
  resize: none;
  min-height: 42px;
  max-height: 120px;
  overflow-y: auto;
  outline: none;
  transition: border-color 0.2s;
  line-height: 1.5;
}

#cb-input::placeholder { color: var(--cb-text-muted); }
#cb-input:focus { border-color: var(--cb-border-hover); }

#cb-send {
  width: 40px;
  height: 40px;
  border: none;
  border-radius: 10px;
  background: linear-gradient(135deg, #F4A836, #D4841A);
  color: #0A0A0A;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: transform 0.2s, opacity 0.2s;
}

#cb-send svg { width: 16px; height: 16px; display: block; flex-shrink: 0; }
#cb-send:hover { transform: scale(1.05); }
#cb-send:active { transform: scale(0.95); }
#cb-send:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

/* ── MOBILE ── */
@media (max-width: 480px) {
  #cb-container {
    width: 100vw;
    height: 100dvh;
    bottom: 0;
    right: 0;
    border-radius: 0;
    border: none;
  }

  #cb-trigger {
    bottom: 16px;
  }
}
