/* ============================================================
   LAM Gutters LLC — AI Chatbot Styles
   Brand: #F9CD39 gold · #1c1c1c dark · Premium Lowcountry
   ============================================================ */

:root {
  --cb-primary:   #F9CD39;
  --cb-primary-d: #e6b800;
  --cb-dark:      #1c1c1c;
  --cb-surface:   #242424;
  --cb-surface2:  #2e2e2e;
  --cb-surface3:  #383838;
  --cb-border:    rgba(249,205,57,0.15);
  --cb-text:      #f0f0f0;
  --cb-text-muted:#a0a0a0;
  --cb-radius:    20px;
  --cb-shadow:    0 24px 64px rgba(0,0,0,0.55), 0 4px 16px rgba(0,0,0,0.3);
  --cb-z:         9999;
}
/* ── Reset scoped to chatbot (UI chrome only — not bubble content) ── */
#lam-chatbot *,
#lam-chatbot *::before,
#lam-chatbot *::after {
  box-sizing: border-box;
}

#lam-chat-trigger,
#lam-chat-badge,
.cb-header,
.cb-avatar,
.cb-header-info,
.cb-header-name,
.cb-header-status,
.cb-status-dot,
.cb-close-btn,
.cb-messages,
.cb-msg,
.cb-msg-avatar,
.cb-typing,
.cb-typing-dots,
.cb-quick-wrap,
.cb-quick-btn,
.cb-input-area,
.cb-textarea,
.cb-send-btn {
  margin: 0;
  padding: 0;
}

/* ============================================================
   FLOATING TRIGGER BUTTON
   NOT a circle — branded rounded square with gutter icon
   ============================================================ */

#lam-chat-trigger {
  position: fixed;
  bottom: 28px;
  right: 28px;
  z-index: var(--cb-z);
  width: 64px;
  height: 64px;
  border-radius: 16px;
  background: var(--cb-dark);
  border: 1.5px solid rgba(249,205,57,0.4);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.25s cubic-bezier(0.34,1.56,0.64,1),
              box-shadow 0.25s ease,
              border-color 0.25s ease;
  box-shadow: 0 4px 20px rgba(0,0,0,0.4), 0 0 0 0 rgba(249,205,57,0.4);
  animation: cb-pulse 3s ease-in-out infinite;
  outline: none;
}

#lam-chat-trigger:hover {
  transform: scale(1.07) translateY(-2px);
  box-shadow: 0 8px 28px rgba(0,0,0,0.5), 0 0 20px rgba(249,205,57,0.35);
  border-color: rgba(249,205,57,0.8);
  animation: none;
}

#lam-chat-trigger.is-open {
  border-color: var(--cb-primary);
  box-shadow: 0 8px 28px rgba(0,0,0,0.5), 0 0 24px rgba(249,205,57,0.4);
  animation: none;
}

/* Notification badge */
#lam-chat-badge {
  position: absolute;
  top: -6px;
  right: -6px;
  width: 18px;
  height: 18px;
  background: #e54545;
  border-radius: 50%;
  border: 2px solid var(--cb-dark);
  display: none;
  animation: cb-badge-pulse 2s ease-in-out infinite;
}

#lam-chat-badge.visible {
  display: block;
}

/* Icon wrappers — normal & close */
.cb-icon-normal,
.cb-icon-close {
  position: absolute;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.cb-icon-close {
  opacity: 0;
  transform: rotate(-90deg) scale(0.6);
}

#lam-chat-trigger.is-open .cb-icon-normal {
  opacity: 0;
  transform: rotate(90deg) scale(0.6);
}

#lam-chat-trigger.is-open .cb-icon-close {
  opacity: 1;
  transform: rotate(0deg) scale(1);
}

/* ============================================================
   CHAT PANEL
   ============================================================ */

#lam-chat-panel {
  position: fixed;
  bottom: 104px;
  right: 28px;
  z-index: var(--cb-z);
  width: 390px;
  height: 580px;
  background: var(--cb-surface);
  border-radius: var(--cb-radius);
  box-shadow: var(--cb-shadow);
  border: 1px solid var(--cb-border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  /* Hidden state */
  opacity: 0;
  transform: translateY(16px) scale(0.96);
  pointer-events: none;
  transition: opacity 0.25s ease, transform 0.3s cubic-bezier(0.34,1.4,0.64,1);
  transform-origin: bottom right;
}

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

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

.cb-avatar {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--cb-primary) 0%, var(--cb-primary-d) 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

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

.cb-header-name {
  font-family: 'Montserrat', sans-serif;
  font-weight: 800;
  font-size: 14px;
  color: var(--cb-text);
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cb-header-status {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  color: var(--cb-text-muted);
  margin-top: 2px;
}

.cb-status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #4ade80;
  animation: cb-status-pulse 2.5s ease-in-out infinite;
  flex-shrink: 0;
}

.cb-close-btn {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--cb-text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 4px;
  border-radius: 6px;
  transition: color 0.15s, background 0.15s;
  flex-shrink: 0;
}

.cb-close-btn:hover {
  color: var(--cb-text);
  background: var(--cb-surface3);
}

/* ── Messages area ── */
.cb-messages {
  flex: 1;
  overflow-y: auto;
  padding: 20px 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  scroll-behavior: smooth;
}

.cb-messages::-webkit-scrollbar {
  width: 4px;
}

.cb-messages::-webkit-scrollbar-track {
  background: transparent;
}

.cb-messages::-webkit-scrollbar-thumb {
  background: var(--cb-surface3);
  border-radius: 4px;
}

/* Message rows */
.cb-msg {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  animation: cb-msg-in 0.28s cubic-bezier(0.34,1.3,0.64,1) both;
}

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

/* ── Bubble base ── */
.cb-msg-bubble {
  max-width: 82%;
  padding: 11px 15px;
  border-radius: 18px;
  font-family: 'Inter', -apple-system, sans-serif;
  font-size: 14px;
  line-height: 1.65;
  word-break: break-word;
}

/* ── Typography inside bubbles ── */
.cb-msg-bubble p          { margin: 0 0 8px; }
.cb-msg-bubble p:last-child { margin-bottom: 0; }
.cb-msg-bubble strong     { font-weight: 700; }
.cb-msg-bubble em         { font-style: italic; }
.cb-msg-bubble ul,
.cb-msg-bubble ol         { padding-left: 20px; margin: 6px 0; }
.cb-msg-bubble li         { margin-bottom: 4px; line-height: 1.55; }
.cb-msg-bubble br + br    { display: block; content: ''; margin-top: 4px; }

/* ── Bot bubble ── */
.cb-msg-bot .cb-msg-bubble {
  background: #2f2f2f;
  color: #f0f0f0;
  border: 1px solid rgba(255,255,255,0.08);
  border-bottom-left-radius: 5px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.35);
}

/* ── User bubble ── */
.cb-msg-user .cb-msg-bubble {
  background: linear-gradient(140deg, #F9CD39 0%, #e6b800 100%);
  color: #1a1a1a;
  border-bottom-right-radius: 5px;
  font-weight: 500;
  box-shadow: 0 2px 10px rgba(249,205,57,0.3);
}

/* ── Links in bot bubbles ── */
.cb-msg-bot .cb-msg-bubble a {
  color: var(--cb-primary);
  text-decoration: underline;
  text-underline-offset: 2px;
}

/* Typing indicator */
.cb-typing {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  animation: cb-msg-in 0.25s ease both;
}

.cb-typing-dots {
  background: #2f2f2f;
  border: 1px solid rgba(255,255,255,0.08);
  border-bottom-left-radius: 5px;
  border-radius: 18px;
  padding: 13px 18px;
  display: flex;
  gap: 5px;
  align-items: center;
  box-shadow: 0 2px 8px rgba(0,0,0,0.35);
}

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

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

/* Small bot avatar in messages */
.cb-msg-avatar {
  width: 30px;
  height: 30px;
  border-radius: 9px;
  background: linear-gradient(135deg, var(--cb-primary) 0%, var(--cb-primary-d) 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  box-shadow: 0 2px 6px rgba(249,205,57,0.25);
}

/* ── Quick options ── */
.cb-quick-wrap {
  padding: 10px 16px;
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  border-top: 1px solid var(--cb-border);
  background: var(--cb-surface);
}

.cb-quick-btn {
  background: var(--cb-surface2);
  border: 1px solid var(--cb-surface3);
  color: var(--cb-text);
  font-family: 'Inter', sans-serif;
  font-size: 12px;
  font-weight: 500;
  padding: 7px 13px;
  border-radius: 20px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s, transform 0.1s;
  white-space: nowrap;
}

.cb-quick-btn:hover {
  background: var(--cb-surface3);
  border-color: rgba(249,205,57,0.5);
  color: var(--cb-primary);
  transform: translateY(-1px);
}

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

.cb-textarea {
  flex: 1;
  background: var(--cb-surface2);
  border: 1px solid var(--cb-surface3);
  border-radius: 12px;
  color: var(--cb-text);
  font-family: 'Inter', -apple-system, sans-serif;
  font-size: 13.5px;
  padding: 10px 13px;
  resize: none;
  outline: none;
  max-height: 100px;
  min-height: 40px;
  line-height: 1.4;
  transition: border-color 0.2s;
  overflow-y: auto;
}

.cb-textarea::placeholder {
  color: var(--cb-text-muted);
}

.cb-textarea:focus {
  border-color: rgba(249,205,57,0.5);
}

.cb-send-btn {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: var(--cb-primary);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.15s, transform 0.15s;
}

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

.cb-send-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

.cb-send-btn svg {
  fill: var(--cb-dark);
}

/* ============================================================
   ANIMATIONS
   ============================================================ */

@keyframes cb-pulse {
  0%, 100% { box-shadow: 0 4px 20px rgba(0,0,0,0.4), 0 0 0 0 rgba(249,205,57,0.35); }
  50%       { box-shadow: 0 4px 20px rgba(0,0,0,0.4), 0 0 0 10px rgba(249,205,57,0); }
}

@keyframes cb-badge-pulse {
  0%, 100% { transform: scale(1); }
  50%       { transform: scale(1.2); }
}

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

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

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

/* ============================================================
   MOBILE — Full screen on small devices
   ============================================================ */

@media (max-width: 480px) {
  #lam-chat-trigger {
    bottom: 20px;
    right: 20px;
  }

  #lam-chat-panel {
    bottom: 0;
    right: 0;
    left: 0;
    width: 100vw;
    height: 100svh;
    max-height: 100svh;
    border-radius: 0;
    border: none;
    transform-origin: bottom center;
  }

  #lam-chat-panel.is-open {
    transform: translateY(0) scale(1);
  }
}
