/* ═══════════════════════════════════════════════════════════════
   Natural Stone Veneer — Premium Chatbot Styles
   Color palette: warm stone, charcoal, gold
   ═══════════════════════════════════════════════════════════════ */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --stone-50:  #faf8f5;
  --stone-100: #f4ede3;
  --stone-200: #e8d9c6;
  --stone-300: #d4bc9e;
  --stone-400: #b89870;
  --stone-500: #9c7a52;
  --stone-600: #7d5f3c;
  --stone-700: #5e4529;
  --stone-800: #3d2c17;
  --stone-900: #1e1509;

  --gold-400: #d4a943;
  --gold-500: #c49a32;

  --charcoal-900: #1a1a1a;
  --charcoal-800: #242424;
  --charcoal-700: #2e2e2e;
  --charcoal-600: #3a3a3a;
  --charcoal-400: #6b6b6b;
  --charcoal-200: #c4c4c4;
  --charcoal-100: #e8e8e8;

  --white: #ffffff;
  --error: #d64040;
  --success: #4caf7d;

  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --radius-xl: 28px;
  --radius-full: 9999px;

  --shadow-sm: 0 2px 8px rgba(0,0,0,.08);
  --shadow-md: 0 4px 20px rgba(0,0,0,.12);
  --shadow-lg: 0 12px 48px rgba(0,0,0,.18);
  --shadow-xl: 0 24px 72px rgba(0,0,0,.28);

  --font-serif: 'Cormorant Garamond', Georgia, serif;
  --font-sans:  'Inter', system-ui, sans-serif;

  --transition: all .22s cubic-bezier(.4,0,.2,1);
  --bounce: cubic-bezier(.34,1.56,.64,1);
}

body {
  font-family: var(--font-sans);
  background: var(--stone-50);
  min-height: 100vh;
  overflow-x: hidden;
}

/* ── FAB Toggle Button ──────────────────────────────────────────────────── */

.chat-fab {
  position: fixed;
  bottom: 28px;
  right: 28px;
  width: 60px;
  height: 60px;
  border-radius: var(--radius-full);
  background: linear-gradient(135deg, var(--stone-600), var(--stone-800));
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--white);
  box-shadow: 0 4px 20px rgba(93,68,41,.5), 0 0 0 0 rgba(157,122,82,.35);
  transition: var(--transition);
  z-index: 9998;
  animation: fabPulse 3s ease-in-out infinite 2s;
}

.chat-fab:hover {
  transform: scale(1.08);
  box-shadow: 0 8px 30px rgba(93,68,41,.65), 0 0 0 8px rgba(157,122,82,.15);
  animation: none;
}

.chat-fab.active { animation: none; }

@keyframes fabPulse {
  0%, 100% { box-shadow: 0 4px 20px rgba(93,68,41,.5), 0 0 0 0 rgba(157,122,82,.35); }
  50%       { box-shadow: 0 4px 20px rgba(93,68,41,.5), 0 0 0 10px rgba(157,122,82,.0); }
}

.fab-notification {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 10px;
  height: 10px;
  background: var(--gold-400);
  border-radius: var(--radius-full);
  border: 2px solid var(--stone-50);
  display: none;
}

.fab-notification.visible { display: block; }
.fab-icon { display: flex; }

/* ── Chat Window ────────────────────────────────────────────────────────── */

.chat-window {
  position: fixed;
  bottom: 100px;
  right: 28px;
  width: 400px;
  max-height: 680px;
  height: calc(100vh - 160px);
  background: var(--white);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-xl);
  display: flex;
  flex-direction: column;
  z-index: 9997;
  overflow: hidden;
  transform: scale(.92) translateY(16px);
  opacity: 0;
  pointer-events: none;
  transition: transform .28s var(--bounce), opacity .22s ease;
  border: 1px solid rgba(0,0,0,.06);
}

.chat-window.open {
  transform: scale(1) translateY(0);
  opacity: 1;
  pointer-events: all;
}

/* ── Header ─────────────────────────────────────────────────────────────── */

.chat-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 18px;
  background: linear-gradient(135deg, var(--stone-700) 0%, var(--stone-800) 100%);
  flex-shrink: 0;
}

.chat-header-avatar { position: relative; flex-shrink: 0; }

.avatar-stone {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-full);
  background: linear-gradient(135deg, var(--stone-400), var(--stone-600));
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-serif);
  font-size: 1.2rem;
  font-weight: 600;
  color: var(--white);
  border: 2px solid rgba(255,255,255,.2);
}

.avatar-status {
  position: absolute;
  bottom: 1px;
  right: 1px;
  width: 10px;
  height: 10px;
  background: var(--success);
  border-radius: var(--radius-full);
  border: 2px solid var(--stone-800);
}

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

.chat-agent-name {
  font-family: var(--font-serif);
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--white);
  line-height: 1.2;
}

.chat-agent-subtitle {
  font-size: .72rem;
  color: rgba(255,255,255,.6);
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-header-actions { display: flex; gap: 4px; }

.header-btn {
  width: 30px;
  height: 30px;
  border-radius: var(--radius-sm);
  background: transparent;
  border: none;
  cursor: pointer;
  color: rgba(255,255,255,.6);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
}
.header-btn:hover { background: rgba(255,255,255,.12); color: var(--white); }

/* ── Messages ───────────────────────────────────────────────────────────── */

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 20px 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  scroll-behavior: smooth;
}

.chat-messages::-webkit-scrollbar { width: 4px; }
.chat-messages::-webkit-scrollbar-track { background: transparent; }
.chat-messages::-webkit-scrollbar-thumb { background: var(--stone-200); border-radius: 4px; }

/* Welcome card */
.welcome-card {
  background: linear-gradient(135deg, var(--stone-50), var(--stone-100));
  border: 1px solid var(--stone-200);
  border-radius: var(--radius-lg);
  padding: 20px;
  text-align: center;
}

.welcome-card .welcome-icon {
  width: 52px;
  height: 52px;
  border-radius: var(--radius-full);
  background: linear-gradient(135deg, var(--stone-500), var(--stone-700));
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 14px;
  font-family: var(--font-serif);
  font-size: 1.6rem;
  color: var(--white);
}

.welcome-card h3 {
  font-family: var(--font-serif);
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--stone-800);
  margin-bottom: 8px;
}

.welcome-card p {
  font-size: .82rem;
  color: var(--stone-500);
  line-height: 1.55;
}

/* Message bubbles */
.message {
  display: flex;
  flex-direction: column;
  max-width: 88%;
  animation: msgIn .2s ease-out;
}

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

.message.user { align-self: flex-end; align-items: flex-end; }
.message.bot  { align-self: flex-start; align-items: flex-start; }

.message-bubble {
  padding: 10px 14px;
  border-radius: var(--radius-lg);
  font-size: .875rem;
  line-height: 1.6;
  word-break: break-word;
}

.message.user .message-bubble {
  background: linear-gradient(135deg, var(--stone-600), var(--stone-800));
  color: var(--white);
  border-bottom-right-radius: 4px;
}

.message.bot .message-bubble {
  background: var(--stone-50);
  color: var(--charcoal-800);
  border: 1px solid var(--stone-100);
  border-bottom-left-radius: 4px;
}

.message-bubble strong { font-weight: 600; }
.message-bubble em { font-style: italic; color: var(--stone-500); }

.message-bubble ul, .message-bubble ol {
  padding-left: 18px;
  margin: 6px 0;
}
.message-bubble li { margin-bottom: 3px; }

.message-bubble p { margin-bottom: 8px; }
.message-bubble p:last-child { margin-bottom: 0; }

.message-time {
  font-size: .68rem;
  color: var(--charcoal-400);
  margin-top: 4px;
  padding: 0 4px;
}

/* Typing indicator */
.typing-indicator {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 0;
  animation: msgIn .2s ease-out;
}

.typing-bubble {
  background: var(--stone-50);
  border: 1px solid var(--stone-100);
  border-radius: var(--radius-lg);
  border-bottom-left-radius: 4px;
  padding: 12px 16px;
  display: flex;
  gap: 5px;
  align-items: center;
}

.typing-dot {
  width: 7px;
  height: 7px;
  background: var(--stone-400);
  border-radius: var(--radius-full);
  animation: typingBounce 1.3s ease-in-out infinite;
}

.typing-dot:nth-child(2) { animation-delay: .16s; }
.typing-dot:nth-child(3) { animation-delay: .32s; }

@keyframes typingBounce {
  0%, 60%, 100% { transform: translateY(0); opacity: .5; }
  30%           { transform: translateY(-5px); opacity: 1; }
}

/* ── Quick Replies ──────────────────────────────────────────────────────── */

.quick-replies {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  padding: 0 16px 12px;
  min-height: 0;
  transition: var(--transition);
}

.quick-replies:empty { padding-bottom: 0; }

.qr-btn {
  padding: 7px 13px;
  border-radius: var(--radius-full);
  border: 1.5px solid var(--stone-300);
  background: var(--white);
  color: var(--stone-700);
  font-size: .78rem;
  font-family: var(--font-sans);
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
  white-space: nowrap;
}

.qr-btn:hover {
  background: var(--stone-700);
  color: var(--white);
  border-color: var(--stone-700);
  transform: translateY(-1px);
}

/* ── Lead Form ──────────────────────────────────────────────────────────── */

.lead-form-panel {
  margin: 0 12px 12px;
  background: var(--stone-50);
  border: 1px solid var(--stone-200);
  border-radius: var(--radius-md);
  padding: 16px;
  animation: msgIn .2s ease-out;
}

.lead-form-header {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-serif);
  font-size: .98rem;
  font-weight: 600;
  color: var(--stone-800);
  margin-bottom: 14px;
}

#leadForm { display: flex; flex-direction: column; gap: 9px; }

.form-row { display: flex; gap: 8px; }
.form-row > * { flex: 1; min-width: 0; }

input, select, textarea {
  width: 100%;
  padding: 9px 12px;
  border: 1.5px solid var(--stone-200);
  border-radius: var(--radius-sm);
  font-family: var(--font-sans);
  font-size: .82rem;
  color: var(--charcoal-800);
  background: var(--white);
  transition: var(--transition);
  outline: none;
}

input:focus, select:focus, textarea:focus {
  border-color: var(--stone-500);
  box-shadow: 0 0 0 3px rgba(156,122,82,.12);
}

textarea { resize: none; line-height: 1.5; }

.form-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 4px; }

.btn-cancel {
  padding: 8px 16px;
  border-radius: var(--radius-full);
  border: 1.5px solid var(--stone-300);
  background: transparent;
  color: var(--stone-600);
  font-size: .8rem;
  font-family: var(--font-sans);
  cursor: pointer;
  transition: var(--transition);
}
.btn-cancel:hover { background: var(--stone-100); }

.btn-submit {
  padding: 8px 18px;
  border-radius: var(--radius-full);
  border: none;
  background: linear-gradient(135deg, var(--stone-600), var(--stone-800));
  color: var(--white);
  font-size: .8rem;
  font-family: var(--font-sans);
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
}
.btn-submit:hover { transform: translateY(-1px); box-shadow: 0 4px 12px rgba(93,68,41,.35); }

/* ── Input Area ─────────────────────────────────────────────────────────── */

.chat-input-area {
  padding: 10px 12px 14px;
  border-top: 1px solid var(--stone-100);
  background: var(--white);
  flex-shrink: 0;
}

.chat-input-row {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  background: var(--stone-50);
  border: 1.5px solid var(--stone-200);
  border-radius: var(--radius-lg);
  padding: 8px 10px;
  transition: var(--transition);
}

.chat-input-row:focus-within {
  border-color: var(--stone-500);
  box-shadow: 0 0 0 3px rgba(156,122,82,.1);
  background: var(--white);
}

.input-action-btn {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-full);
  border: none;
  background: transparent;
  color: var(--stone-400);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
  flex-shrink: 0;
}
.input-action-btn:hover { color: var(--stone-700); background: var(--stone-100); }

.chat-textarea {
  flex: 1;
  border: none;
  background: transparent;
  font-family: var(--font-sans);
  font-size: .875rem;
  color: var(--charcoal-800);
  line-height: 1.5;
  outline: none;
  resize: none;
  max-height: 120px;
  padding: 4px 0;
}

.chat-textarea::placeholder { color: var(--stone-400); }

.send-btn {
  width: 34px;
  height: 34px;
  border-radius: var(--radius-full);
  border: none;
  background: linear-gradient(135deg, var(--stone-500), var(--stone-700));
  color: var(--white);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
  flex-shrink: 0;
}
.send-btn:hover:not(:disabled) { transform: scale(1.08); box-shadow: 0 3px 10px rgba(93,68,41,.4); }
.send-btn:disabled { opacity: .45; cursor: default; }

.chat-footer-text {
  text-align: center;
  font-size: .68rem;
  color: var(--stone-400);
  margin-top: 8px;
}

.chat-footer-text a { color: var(--stone-500); text-decoration: none; }
.chat-footer-text a:hover { text-decoration: underline; }

/* ── Notification Chip ──────────────────────────────────────────────────── */

.notification-chip {
  position: fixed;
  bottom: 100px;
  right: 28px;
  background: var(--charcoal-900);
  color: var(--white);
  padding: 10px 16px;
  border-radius: var(--radius-lg);
  font-size: .82rem;
  font-family: var(--font-sans);
  box-shadow: var(--shadow-md);
  z-index: 9996;
  animation: chipIn .35s var(--bounce);
  max-width: 260px;
  line-height: 1.4;
  cursor: pointer;
}

.notification-chip::after {
  content: '';
  position: absolute;
  bottom: -6px;
  right: 24px;
  width: 12px;
  height: 12px;
  background: var(--charcoal-900);
  clip-path: polygon(0 0, 100% 0, 50% 100%);
}

@keyframes chipIn {
  from { opacity: 0; transform: translateY(10px) scale(.9); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* ── Toast notification ─────────────────────────────────────────────────── */

.toast {
  position: fixed;
  bottom: 28px;
  left: 50%;
  transform: translateX(-50%) translateY(80px);
  background: var(--charcoal-900);
  color: var(--white);
  padding: 12px 24px;
  border-radius: var(--radius-full);
  font-size: .85rem;
  font-family: var(--font-sans);
  box-shadow: var(--shadow-md);
  z-index: 99999;
  transition: transform .35s var(--bounce), opacity .3s ease;
  opacity: 0;
  white-space: nowrap;
}

.toast.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

/* ── Markdown rendering in bubbles ──────────────────────────────────────── */
.message-bubble h1, .message-bubble h2, .message-bubble h3 {
  font-family: var(--font-serif);
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--stone-800);
}
.message-bubble h3 { font-size: .95rem; }

.message.user .message-bubble h1,
.message.user .message-bubble h2,
.message.user .message-bubble h3 { color: rgba(255,255,255,.9); }

.message-bubble code {
  background: rgba(0,0,0,.06);
  padding: 1px 5px;
  border-radius: 4px;
  font-size: .82em;
}

.message-bubble hr {
  border: none;
  border-top: 1px solid var(--stone-200);
  margin: 10px 0;
}

/* ── Mobile ─────────────────────────────────────────────────────────────── */

@media (max-width: 480px) {
  .chat-window {
    right: 0;
    bottom: 0;
    width: 100%;
    max-height: 100dvh;
    height: 100dvh;
    border-radius: 0;
    border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  }

  .chat-fab {
    bottom: 20px;
    right: 20px;
  }

}

/* ── Product Image Cards ─────────────────────────────────────────────────── */

.chat-img-card {
  margin: 8px 0 4px;
  border-radius: var(--radius-md);
  overflow: hidden;
  border: 1px solid var(--stone-200);
  background: var(--stone-50);
  max-width: 260px;
  box-shadow: var(--shadow-sm);
}

.chat-img-card img {
  width: 100%;
  display: block;
  object-fit: cover;
  max-height: 180px;
  transition: transform .3s ease;
  cursor: zoom-in;
}

.chat-img-card img:hover { transform: scale(1.02); }

.chat-img-caption {
  padding: 6px 10px 8px;
  font-size: .74rem;
  color: var(--stone-600);
  font-weight: 500;
  background: var(--stone-50);
  line-height: 1.3;
}

.chat-img-card.img-error {
  display: none;
}

/* Image lightbox on click */
.chat-img-card img:active { transform: scale(1); }

/* ── Scrollbar for entire page ───────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--stone-300); border-radius: 4px; }
