/* ============================================
   Sitemap AI Chatbot - Modern Glassmorphism UI
   ============================================ */

@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;500;600;700&display=swap');

:root {
  --scbot-primary: #6c63ff;
  --scbot-primary-dark: #4f46e5;
  --scbot-primary-light: #8b5cf6;
  --scbot-surface: rgba(15, 15, 25, 0.96);
  --scbot-surface-2: rgba(255,255,255,0.04);
  --scbot-border: rgba(255,255,255,0.08);
  --scbot-text: #f0f0f8;
  --scbot-text-muted: rgba(240,240,248,0.5);
  --scbot-user-bubble: var(--scbot-primary);
  --scbot-bot-bubble: rgba(255,255,255,0.07);
  --scbot-radius: 20px;
  --scbot-shadow: 0 24px 64px rgba(0,0,0,0.5), 0 0 0 1px rgba(255,255,255,0.05);
  --scbot-font: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  --scbot-transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  --scbot-z: 999999;
}

/* ---- Wrapper ---- */
#scbot-wrapper {
  position: fixed;
  z-index: var(--scbot-z);
  font-family: var(--scbot-font);
  --scbot-primary: attr(style --scbot-primary, #6c63ff);
}

.scbot-position-bottom-right {
  bottom: 24px;
  right: 24px;
}

.scbot-position-bottom-left {
  bottom: 24px;
  left: 24px;
}

/* ---- Toggle Button ---- */
.scbot-toggle {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--scbot-primary), var(--scbot-primary-light));
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 8px 32px rgba(108,99,255,0.4), 0 0 0 0 rgba(108,99,255,0.3);
  transition: transform var(--scbot-transition), box-shadow var(--scbot-transition);
  position: relative;
  animation: scbot-pulse 3s ease-in-out infinite;
}

.scbot-toggle:hover {
  transform: scale(1.08);
  box-shadow: 0 12px 40px rgba(108,99,255,0.6), 0 0 0 8px rgba(108,99,255,0.1);
  animation: none;
}

.scbot-toggle:active {
  transform: scale(0.95);
}

.scbot-toggle svg {
  width: 26px;
  height: 26px;
  color: #fff;
  transition: transform var(--scbot-transition), opacity var(--scbot-transition);
}

@keyframes scbot-pulse {
  0%, 100% { box-shadow: 0 8px 32px rgba(108,99,255,0.4), 0 0 0 0 rgba(108,99,255,0.3); }
  50% { box-shadow: 0 8px 32px rgba(108,99,255,0.4), 0 0 0 10px rgba(108,99,255,0); }
}

/* Notification badge */
.scbot-notification-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  width: 20px;
  height: 20px;
  background: #ef4444;
  color: #fff;
  border-radius: 50%;
  font-size: 11px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid #fff;
  animation: scbot-badge-bounce 0.5s cubic-bezier(0.36,0.07,0.19,0.97) both;
}

@keyframes scbot-badge-bounce {
  0%, 100% { transform: scale(1); }
  40% { transform: scale(1.4); }
  60% { transform: scale(0.9); }
}

/* ---- Chat Window ---- */
.scbot-window {
  position: absolute;
  bottom: 76px;
  width: 380px;
  max-height: 600px;
  min-height: 480px;
  background: var(--scbot-surface);
  border-radius: var(--scbot-radius);
  border: 1px solid var(--scbot-border);
  box-shadow: var(--scbot-shadow);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);

  /* Hidden state */
  opacity: 0;
  transform: translateY(16px) scale(0.97);
  pointer-events: none;
  transition: opacity var(--scbot-transition), transform var(--scbot-transition);
  transform-origin: bottom center;
}

.scbot-position-bottom-right .scbot-window { right: 0; }
.scbot-position-bottom-left .scbot-window { left: 0; }

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

/* Noise texture overlay */
.scbot-window::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.65' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)' opacity='0.02'/%3E%3C/svg%3E");
  pointer-events: none;
  z-index: 0;
  opacity: 0.3;
}

/* ---- Header ---- */
.scbot-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 18px;
  background: linear-gradient(135deg, var(--scbot-primary) 0%, var(--scbot-primary-light) 100%);
  position: relative;
  overflow: hidden;
  flex-shrink: 0;
}

/* Header shimmer effect */
.scbot-header::after {
  content: '';
  position: absolute;
  top: -50%;
  right: -20%;
  width: 200px;
  height: 200px;
  background: radial-gradient(circle, rgba(255,255,255,0.15) 0%, transparent 70%);
  pointer-events: none;
}

.scbot-header-info {
  display: flex;
  align-items: center;
  gap: 12px;
  position: relative;
  z-index: 1;
}

.scbot-avatar {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: rgba(255,255,255,0.15);
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid rgba(255,255,255,0.3);
  flex-shrink: 0;
}

.scbot-avatar svg {
  width: 24px;
  height: 24px;
}

.scbot-header-name {
  font-size: 15px;
  font-weight: 700;
  color: #fff;
  line-height: 1.2;
  letter-spacing: -0.02em;
}

.scbot-header-status {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  color: rgba(255,255,255,0.8);
  font-weight: 500;
}

.scbot-status-dot {
  width: 7px;
  height: 7px;
  background: #4ade80;
  border-radius: 50%;
  box-shadow: 0 0 0 2px rgba(74,222,128,0.3);
  animation: scbot-status-pulse 2s ease-in-out infinite;
}

@keyframes scbot-status-pulse {
  0%, 100% { box-shadow: 0 0 0 2px rgba(74,222,128,0.3); }
  50% { box-shadow: 0 0 0 4px rgba(74,222,128,0.1); }
}

.scbot-header-actions {
  display: flex;
  gap: 6px;
  position: relative;
  z-index: 1;
}

.scbot-btn-icon {
  width: 50px !important;
  height: 32px;
  border: none;
  background: rgba(255,255,255,0.12);
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: rgba(255,255,255,0.85);
  transition: background var(--scbot-transition), transform var(--scbot-transition);
}

.scbot-btn-icon:hover {
  background: rgba(255,255,255,0.22);
  transform: scale(1.05);
}

.scbot-btn-icon svg {
  width: 16px;
  height: 16px;
}

/* ---- Messages ---- */
.scbot-messages {
  flex: 1;
  overflow-y: auto;
  padding: 20px 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  scroll-behavior: smooth;
  position: relative;
  z-index: 1;
}

/* Custom scrollbar */
.scbot-messages::-webkit-scrollbar { width: 4px; }
.scbot-messages::-webkit-scrollbar-track { background: transparent; }
.scbot-messages::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 2px; }
.scbot-messages::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.2); }

/* Message groups */
.scbot-message {
  display: flex;
  gap: 10px;
  animation: scbot-msg-in 0.35s cubic-bezier(0.34, 1.56, 0.64, 1) both;
  max-width: 100%;
}

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

.scbot-message.scbot-message-user {
  flex-direction: row-reverse;
}

.scbot-message-icon {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--scbot-primary), var(--scbot-primary-light));
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-top: 2px;
}

.scbot-message-icon svg {
  width: 16px;
  height: 16px;
  color: #fff;
}

.scbot-bubble {
  max-width: calc(100% - 48px);
  padding: 10px 14px;
  border-radius: 16px;
  font-size: 13.5px;
  line-height: 1.6;
  font-weight: 400;
  word-break: break-word;
}

.scbot-message-bot .scbot-bubble {
  background: var(--scbot-bot-bubble);
  border: 1px solid var(--scbot-border);
  color: var(--scbot-text);
  border-bottom-left-radius: 4px;
}

.scbot-message-user .scbot-bubble {
  background: linear-gradient(135deg, var(--scbot-primary), var(--scbot-primary-dark));
  color: #fff;
  border-bottom-right-radius: 4px;
  box-shadow: 0 4px 16px rgba(108,99,255,0.3);
}

/* Sources */
.scbot-sources {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--scbot-border);
}

.scbot-sources-label {
  font-size: 10px;
  color: var(--scbot-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 600;
  margin-bottom: 4px;
}

.scbot-source-link {
  display: block;
  font-size: 11px;
  color: var(--scbot-primary-light);
  text-decoration: none;
  padding: 2px 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: color 0.2s;
}

.scbot-source-link:hover { color: #fff; }

/* Timestamp */
.scbot-msg-time {
  font-size: 10px;
  color: var(--scbot-text-muted);
  margin-top: 3px;
  padding: 0 4px;
}

.scbot-message-user .scbot-msg-time { text-align: right; }

/* Typing indicator */
.scbot-typing {
  display: flex;
  gap: 5px;
  align-items: center;
  padding: 12px 14px;
}

.scbot-typing span {
  width: 7px;
  height: 7px;
  background: var(--scbot-primary-light);
  border-radius: 50%;
  animation: scbot-typing-bounce 1.2s ease-in-out infinite;
}

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

@keyframes scbot-typing-bounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
  30% { transform: translateY(-6px); opacity: 1; }
}

/* Error message */
.scbot-bubble.scbot-error {
  background: rgba(239,68,68,0.12);
  border-color: rgba(239,68,68,0.25);
  color: #fca5a5;
}

/* ---- Suggestions ---- */
.scbot-suggestions {
  padding: 8px 16px 4px;
  border-top: 1px solid var(--scbot-border);
  position: relative;
  z-index: 1;
}

.scbot-suggestions-label {
  font-size: 10px;
  color: var(--scbot-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 600;
  margin-bottom: 6px;
}

.scbot-suggestions-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.scbot-suggestion-chip {
  background: var(--scbot-surface-2);
  border: 1px solid var(--scbot-border);
  color: var(--scbot-text);
  font-size: 11px;
  font-weight: 500;
  padding: 5px 10px;
  border-radius: 20px;
  cursor: pointer;
  transition: all var(--scbot-transition);
  font-family: var(--scbot-font);
  white-space: nowrap;
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.scbot-suggestion-chip:hover {
  background: rgba(108,99,255,0.15);
  border-color: rgba(108,99,255,0.4);
  color: #c4b5fd;
  transform: translateY(-1px);
}

/* ---- Input Area ---- */
.scbot-input-area {
  padding: 12px 16px 14px;
  border-top: 1px solid var(--scbot-border);
  background: rgba(255,255,255,0.02);
  position: relative;
  z-index: 1;
}

.scbot-input-wrapper {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  background: rgba(255,255,255,0.05);
  border: 1px solid var(--scbot-border);
  border-radius: 14px;
  padding: 10px 10px 10px 14px;
  transition: border-color var(--scbot-transition), box-shadow var(--scbot-transition);
}

.scbot-input-wrapper:focus-within {
  border-color: rgba(108,99,255,0.5);
  box-shadow: 0 0 0 3px rgba(108,99,255,0.1);
}

.scbot-input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  resize: none;
  color: var(--scbot-text);
  font-size: 13.5px;
  line-height: 1.5;
  font-family: var(--scbot-font);
  min-height: 22px;
  max-height: 100px;
  overflow-y: auto;
}

.scbot-input::placeholder {
  color: var(--scbot-text-muted);
}

.scbot-input::-webkit-scrollbar { width: 3px; }
.scbot-input::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 2px; }

.scbot-send-btn {
  width: 50px !important;
  height: 36px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--scbot-primary), var(--scbot-primary-dark));
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: transform var(--scbot-transition), box-shadow var(--scbot-transition), opacity var(--scbot-transition);
  box-shadow: 0 4px 12px rgba(108,99,255,0.3);
}

.scbot-send-btn:hover {
  transform: scale(1.05);
  box-shadow: 0 6px 18px rgba(108,99,255,0.5);
}

.scbot-send-btn:active { transform: scale(0.95); }

.scbot-send-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.scbot-send-btn svg {
  width: 16px;
  height: 16px;
  color: #fff;
}

.scbot-input-footer {
  text-align: center;
  margin-top: 6px;
  font-size: 10px;
  color: var(--scbot-text-muted);
  font-weight: 500;
}

/* ---- Mobile ---- */
@media (max-width: 480px) {
  .scbot-window {
    width: calc(100vw - 32px);
    max-height: 70vh;
  }

  .scbot-position-bottom-right .scbot-window,
  .scbot-position-bottom-left .scbot-window {
    right: 0;
    left: 0;
  }

  .scbot-position-bottom-right,
  .scbot-position-bottom-left {
    bottom: 16px;
    right: 16px;
    left: auto;
  }
}

/* ── Ratings ─────────────────────────────────────────────── */
.scbot-ratings {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 6px;
  padding-left: 4px;
}
.scbot-rate-label {
  font-size: 10px;
  color: var(--scbot-text-muted);
  font-weight: 500;
}
.scbot-rate-btn {
  background: rgba(255,255,255,0.06);
  border: 1px solid var(--scbot-border);
  border-radius: 6px;
  padding: 3px 8px;
  cursor: pointer;
  font-size: 14px;
  transition: all 0.2s;
  line-height: 1;
}
.scbot-rate-btn:hover {
  background: rgba(255,255,255,0.14);
  transform: scale(1.1);
}
.scbot-rated {
  font-size: 11px;
  color: var(--scbot-text-muted);
  font-style: italic;
}
/* ============================================================
   CHATBOT v4.0 — NEW FEATURE STYLES
   Lead Capture · Human Handoff · Proactive · Dark Theme
   ============================================================ */

/* ── Dark Theme ─────────────────────────────────────────── */
.scbot-theme-dark #scbot-window {
  background: #1a1a2e;
  color: #e0e0e0;
}
.scbot-theme-dark .scbot-messages {
  background: #16213e;
}
.scbot-theme-dark .scbot-input-area {
  background: #1a1a2e;
  border-top: 1px solid #2d2d4e;
}
.scbot-theme-dark .scbot-input {
  background: #0f3460;
  color: #e0e0e0;
  border-color: #2d2d4e;
}
.scbot-theme-dark .scbot-input::placeholder { color: #8888aa; }
.scbot-theme-dark .scbot-suggestion-chip {
  background: #0f3460;
  color: #c4b5fd;
  border-color: #2d2d4e;
}
.scbot-theme-dark .scbot-suggestion-chip:hover { background: #1a1a5e; }
.scbot-theme-dark .scbot-message-user .scbot-bubble {
  background: var(--scbot-primary);
}

/* ── Handoff Bar ────────────────────────────────────────── */
.scbot-handoff-bar {
  display: flex;
  justify-content: center;
  padding: 6px 16px 0;
}
.scbot-handoff-btn {
  width: 100%;
  padding: 8px 16px;
  background: transparent;
  border: 1.5px solid var(--scbot-primary);
  color: var(--scbot-primary);
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}
.scbot-handoff-btn:hover {
  background: var(--scbot-primary);
  color: #fff;
}

/* ── Handoff Card (in message) ──────────────────────────── */
.scbot-bubble-plain {
  background: rgba(255,255,255,0.08) !important;
  border: 1px solid rgba(255,255,255,0.15);
}
.scbot-handoff-card {
  padding: 4px 0;
}
.scbot-handoff-title {
  font-weight: 700;
  font-size: 14px;
  margin-bottom: 4px;
}
.scbot-handoff-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 10px;
}
.scbot-handoff-action {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 14px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  border: none;
  transition: opacity 0.2s, transform 0.15s;
}
.scbot-handoff-action:hover { opacity: 0.88; transform: translateY(-1px); }
.scbot-handoff-wa {
  background: #25d366;
  color: #fff;
}
.scbot-handoff-email {
  background: var(--scbot-primary);
  color: #fff;
}

/* ── Handoff Suggestion Banner ───────────────────────────── */
.scbot-handoff-suggestion {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 14px;
  margin: 6px 12px;
  background: rgba(255,255,255,0.07);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 10px;
  font-size: 12px;
  opacity: 0.9;
}
.scbot-btn-suggest {
  padding: 5px 12px;
  background: var(--scbot-primary);
  color: #fff;
  border: none;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}

/* ── Lead / Handoff Form (in message bubble) ─────────────── */
.scbot-lead-form {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 4px 0;
}
.scbot-form-title {
  font-weight: 700;
  font-size: 13px;
  margin-bottom: 4px;
}
.scbot-form-input {
  padding: 8px 12px;
  border-radius: 8px;
  border: 1px solid rgba(255,255,255,0.2);
  background: rgba(255,255,255,0.1);
  color: #fff;
  font-size: 13px;
  width: 100%;
  box-sizing: border-box;
  outline: none;
  transition: border-color 0.2s;
}
.scbot-form-input::placeholder { color: rgba(255,255,255,0.5); }
.scbot-form-input:focus { border-color: rgba(255,255,255,0.5); }
.scbot-form-input.scbot-input-error { border-color: #f87171; }
.scbot-form-submit {
  padding: 9px 16px;
  background: var(--scbot-primary);
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.2s;
  margin-top: 4px;
}
.scbot-form-submit:hover { opacity: 0.88; }

/* ── Proactive Preview Bubble ────────────────────────────── */
.scbot-proactive-preview {
  position: absolute;
  bottom: 70px;
  right: 0;
  background: #fff;
  color: #1e1b3a;
  padding: 12px 36px 12px 14px;
  border-radius: 14px 14px 4px 14px;
  max-width: 230px;
  font-size: 13px;
  line-height: 1.5;
  box-shadow: 0 8px 30px rgba(0,0,0,0.18);
  cursor: pointer;
  animation: scbot-slide-in 0.35s ease;
  z-index: 9999;
}
.scbot-proactive-close {
  position: absolute;
  top: 6px;
  right: 8px;
  font-size: 12px;
  opacity: 0.5;
  cursor: pointer;
}
.scbot-proactive-close:hover { opacity: 1; }
@keyframes scbot-slide-in {
  from { opacity:0; transform:translateY(10px); }
  to   { opacity:1; transform:translateY(0); }
}
