/* ==========================================================================
   SCIEMATICS INSIGHTS - INTERACTIVE CHATBOT WIDGET STYLESHEET
   Brand Aligned With Sciematics Navy, Teal and Aqua Palette
   Strictly Zero Em-Dashes and En-Dashes
   ========================================================================== */

:root {
  --chat-brand-grad: linear-gradient(135deg, #071e2c 0%, #092139 45%, #007f88 100%);
  --chat-brand-grad-hover: linear-gradient(135deg, #051520 0%, #06192c 45%, #006a72 100%);
  --chat-primary: #007f88;
  --chat-primary-hover: #006a72;
  --chat-navy: #071e2c;
  --chat-ink: #092139;
  --chat-teal: #007f88;
  --chat-aqua: #b8ece5;
  --chat-accent-green: #10b981;
  --chat-border: #dce4e7;
  --chat-bg-bubble: #f2f7f7;
  --chat-text: #092139;
  --chat-text-muted: #5a6b77;
}

/* Floating WhatsApp button removed entirely */
.whatsapp {
  display: none !important;
}

/* Scroll-to-Top Button at bottom position */
.back-top {
  bottom: 24px !important;
  right: 27px !important;
  z-index: 9989 !important;
  transition: opacity 0.3s ease, transform 0.3s ease !important;
}

body.chat-active .back-top {
  opacity: 0 !important;
  pointer-events: none !important;
  transform: scale(0.6) !important;
}

/* Floating Launcher Container - positioned directly above Scroll-to-Top */
.sciematics-chat-widget {
  position: fixed;
  bottom: 84px;
  right: 20px;
  z-index: 9999;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  user-select: none;
}

/* Floating Launcher Toggle Button */
.chat-launcher-btn {
  width: 58px;
  height: 58px;
  border-radius: 50%;
  background: var(--chat-brand-grad);
  color: #ffffff;
  border: 2px solid rgba(184, 236, 229, 0.4);
  box-shadow: 0 10px 25px -5px rgba(9, 33, 57, 0.5), 0 8px 10px -6px rgba(0, 127, 136, 0.35);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  position: relative;
  transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.25s ease, border-color 0.2s ease;
  outline: none;
}

.chat-launcher-btn:hover {
  transform: scale(1.08) translateY(-2px);
  box-shadow: 0 16px 32px -5px rgba(9, 33, 57, 0.6), 0 10px 18px -4px rgba(0, 127, 136, 0.45);
  border-color: #ffffff;
}

.chat-launcher-btn:active {
  transform: scale(0.95);
}

.sciematics-chat-widget.chat-open .chat-launcher-btn,
.chat-launcher-btn.chat-launcher-hidden {
  opacity: 0 !important;
  transform: scale(0.4) !important;
  pointer-events: none !important;
  visibility: hidden !important;
  display: none !important;
}

.chat-launcher-icon-wrap {
  width: 40px;
  height: 40px;
  background: #ffffff;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
  transition: transform 0.25s ease;
}

.chat-launcher-btn:hover .chat-launcher-icon-wrap {
  transform: scale(1.06);
}

.chat-launcher-favicon {
  width: 26px;
  height: 26px;
  object-fit: contain;
  display: block;
}

.chat-launcher-btn svg {
  width: 26px;
  height: 26px;
  stroke: #ffffff;
  transition: transform 0.2s ease;
}

/* Online Pulse Dot */
.chat-pulse-indicator {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 12px;
  height: 12px;
  display: flex;
}

.chat-pulse-ping {
  position: absolute;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  background-color: var(--chat-accent-green);
  opacity: 0.75;
  animation: chat-ping 1.5s cubic-bezier(0, 0, 0.2, 1) infinite;
}

.chat-pulse-dot {
  position: relative;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  background-color: var(--chat-accent-green);
  border: 2px solid #ffffff;
}

@keyframes chat-ping {
  75%, 100% {
    transform: scale(2);
    opacity: 0;
  }
}

/* Tooltip Badge on Initial Visit */
.chat-launcher-tooltip {
  position: absolute;
  bottom: calc(100% + 12px);
  right: 0;
  background: var(--chat-navy);
  color: #ffffff;
  padding: 8px 14px;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 600;
  white-space: nowrap;
  box-shadow: 0 10px 20px -3px rgba(7, 30, 44, 0.4), 0 4px 12px rgba(0, 127, 136, 0.25);
  border: 1px solid rgba(184, 236, 229, 0.35);
  display: flex;
  align-items: center;
  gap: 6px;
  animation: chat-bounce 2s infinite ease-in-out;
  pointer-events: none;
}

.chat-launcher-tooltip svg {
  width: 14px;
  height: 14px;
  color: var(--chat-aqua);
}

@keyframes chat-bounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-5px); }
}

/* Dialogue Window Container */
.chat-dialog-panel {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 385px;
  max-width: calc(100vw - 32px);
  height: 600px;
  max-height: calc(100vh - 48px);
  background: #ffffff;
  border-radius: 18px;
  border: 1px solid var(--chat-border);
  box-shadow: 0 20px 45px -12px rgba(7, 30, 44, 0.35), 0 0 0 1px rgba(9, 33, 57, 0.08);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  opacity: 0;
  transform: translateY(20px) scale(0.95);
  pointer-events: none;
  transition: opacity 0.25s ease, transform 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  z-index: 10000;
}

.chat-dialog-panel.active {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

/* Chat Header */
.chat-header {
  padding: 14px 18px;
  background: var(--chat-brand-grad);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid rgba(184, 236, 229, 0.2);
  box-shadow: 0 2px 8px rgba(7, 30, 44, 0.25);
  flex-shrink: 0;
}

.chat-header-brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.chat-header-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: #ffffff;
  border: 1.5px solid rgba(255, 255, 255, 0.9);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  flex-shrink: 0;
  overflow: visible;
}

.chat-header-favicon {
  width: 24px;
  height: 24px;
  object-fit: contain;
  display: block;
}

.chat-header-status-dot {
  position: absolute;
  bottom: -1px;
  right: -1px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--chat-accent-green);
  border: 2px solid #ffffff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

.chat-header-title {
  font-size: 0.875rem;
  font-weight: 700;
  line-height: 1.2;
  color: #ffffff;
  margin: 0;
}

.chat-header-subtitle {
  font-size: 0.6875rem;
  font-family: monospace;
  color: rgba(184, 236, 229, 0.9);
  letter-spacing: 0.05em;
  text-transform: uppercase;
  margin: 2px 0 0 0;
}

.chat-header-actions {
  display: flex;
  align-items: center;
  gap: 4px;
}

.chat-action-btn {
  background: transparent;
  border: none;
  color: rgba(255, 255, 255, 0.85);
  width: 28px;
  height: 28px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.chat-action-btn:hover {
  background: rgba(255, 255, 255, 0.2);
  color: #ffffff;
}

/* Persistent "Chat with Human" Bar */
.chat-human-bar {
  padding: 8px 14px;
  background: #f8fafc;
  border-bottom: 1px solid var(--chat-border);
  display: flex;
  align-items: center;
  flex-shrink: 0;
}

.chat-human-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 8px 14px;
  background: #16a34a;
  color: #ffffff !important;
  font-size: 0.7813rem;
  font-weight: 600;
  border-radius: 8px;
  text-decoration: none;
  box-shadow: 0 2px 6px rgba(22, 163, 74, 0.25);
  transition: background 0.15s ease, transform 0.15s ease, box-shadow 0.15s ease;
}

.chat-human-btn:hover {
  background: #15803d;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(22, 163, 74, 0.35);
  color: #ffffff !important;
}

.chat-human-wa-icon {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  fill: currentColor;
}

.chat-human-arrow {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
  stroke: currentColor;
  margin-left: auto;
  transition: transform 0.15s ease;
}

.chat-human-btn:hover .chat-human-arrow {
  transform: translateX(3px);
}

/* Messages Area */
.chat-messages-container {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  background: #ffffff;
  font-size: 0.8125rem;
  position: relative;
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch;
}

.chat-msg-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-width: 88%;
  outline: none;
}

.chat-msg-row.assistant {
  align-self: flex-start;
}

.chat-msg-row.user {
  align-self: flex-end;
}

.chat-msg-category {
  font-size: 0.625rem;
  font-family: monospace;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--chat-teal);
  background: rgba(0, 127, 136, 0.08);
  padding: 2px 8px;
  border-radius: 4px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  align-self: flex-start;
  border: 1px solid rgba(0, 127, 136, 0.2);
}

.chat-bubble {
  padding: 12px 14px;
  border-radius: 14px;
  line-height: 1.55;
  word-break: break-word;
}

.chat-msg-row.assistant .chat-bubble {
  background: var(--chat-bg-bubble);
  border: 1px solid var(--chat-border);
  color: var(--chat-text);
  border-bottom-left-radius: 2px;
}

.chat-msg-row.user .chat-bubble {
  background: var(--chat-brand-grad);
  color: #ffffff;
  font-weight: 500;
  border-bottom-right-radius: 2px;
  box-shadow: 0 4px 12px rgba(9, 33, 57, 0.25);
}

.chat-bubble p {
  margin: 0 0 8px 0;
}

.chat-bubble p:last-child {
  margin-bottom: 0;
}

/* Callout Quote in Bot Answer */
.chat-quote-block {
  margin-top: 10px;
  padding: 8px 12px;
  background: rgba(0, 127, 136, 0.05);
  border-left: 3px solid var(--chat-teal);
  border-radius: 0 6px 6px 0;
  font-size: 0.75rem;
  font-style: italic;
  color: #1e293b;
}

.chat-quote-source {
  font-style: normal;
  font-family: monospace;
  font-size: 0.6875rem;
  color: var(--chat-text-muted);
  margin-top: 4px;
  display: block;
}

/* Action Link Buttons */
.chat-link-box {
  margin-top: 10px;
}

.chat-action-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--chat-teal);
  color: #ffffff !important;
  font-weight: 600;
  font-size: 0.75rem;
  padding: 6px 12px;
  border-radius: 6px;
  text-decoration: none;
  transition: background 0.15s ease, transform 0.15s ease;
}

.chat-action-link:hover {
  background: var(--chat-primary-hover);
  transform: translateY(-1px);
  color: #ffffff !important;
}

.chat-action-link.whatsapp-link {
  background: #16a34a;
}

.chat-action-link.whatsapp-link:hover {
  background: #15803d;
}

/* Suggested Followup Chips */
.chat-followups-container {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 6px;
}

.chat-chip-btn {
  background: #ffffff;
  color: var(--chat-teal);
  border: 1px solid rgba(0, 127, 136, 0.35);
  border-radius: 9999px;
  padding: 5px 11px;
  font-size: 0.7188rem;
  font-weight: 500;
  cursor: pointer;
  line-height: 1.25;
  transition: all 0.15s ease;
  text-align: left;
}

.chat-chip-btn:hover {
  background: rgba(0, 127, 136, 0.08);
  border-color: var(--chat-teal);
  color: var(--chat-primary-hover);
  transform: translateY(-1px);
}

/* Typing Indicator */
.chat-typing-indicator {
  align-self: flex-start;
  padding: 10px 14px;
  background: var(--chat-bg-bubble);
  border: 1px solid var(--chat-border);
  border-radius: 14px;
  border-bottom-left-radius: 2px;
  display: flex;
  align-items: center;
  gap: 4px;
  width: fit-content;
}

.chat-typing-dot {
  width: 6px;
  height: 6px;
  background: var(--chat-text-muted);
  border-radius: 50%;
  animation: chat-bounce-dot 1.2s infinite ease-in-out;
}

.chat-typing-dot:nth-child(2) {
  animation-delay: 0.2s;
}

.chat-typing-dot:nth-child(3) {
  animation-delay: 0.4s;
}

@keyframes chat-bounce-dot {
  0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
  40% { transform: scale(1); opacity: 1; }
}

/* High-Yield Topics Autosliding Ribbon */
.chat-topics-bar {
  flex-shrink: 0;
  padding: 6px 10px;
  background: #f8fafc;
  border-top: 1px solid var(--chat-border);
  display: flex;
  align-items: center;
  gap: 8px;
  overflow: hidden;
  position: relative;
}

.chat-topics-label-wrap {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  flex-shrink: 0;
  padding-right: 8px;
  border-right: 1px solid var(--chat-border);
  z-index: 2;
  user-select: none;
}

.chat-topics-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--chat-teal);
  box-shadow: 0 0 0 2px rgba(0, 127, 136, 0.2);
}

.chat-topics-label {
  color: var(--chat-text-muted);
  font-family: monospace;
  font-size: 0.6875rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.chat-topics-slider {
  flex: 1;
  overflow: hidden;
  position: relative;
  mask-image: linear-gradient(to right, transparent 0%, black 12px, black calc(100% - 12px), transparent 100%);
  -webkit-mask-image: linear-gradient(to right, transparent 0%, black 12px, black calc(100% - 12px), transparent 100%);
}

.chat-topics-track {
  display: flex;
  align-items: center;
  gap: 8px;
  width: max-content;
  will-change: transform;
  animation: chat-topics-scroll 34s linear infinite;
}

/* Pause autosliding on hover, focus, or touch */
.chat-topics-slider:hover .chat-topics-track,
.chat-topics-slider:focus-within .chat-topics-track,
.chat-topics-track.is-paused {
  animation-play-state: paused;
}

@keyframes chat-topics-scroll {
  0% {
    transform: translateX(0);
  }
  100% {
    transform: translateX(-50%);
  }
}

.chat-topic-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  flex-shrink: 0;
  background: #ffffff;
  border: 1px solid var(--chat-border);
  color: var(--chat-text);
  cursor: pointer;
  padding: 3px 10px;
  border-radius: 9999px;
  font-size: 0.6875rem;
  font-weight: 500;
  box-shadow: 0 1px 2px rgba(7, 30, 44, 0.04);
  transition: all 0.18s ease;
  white-space: nowrap;
  outline: none;
}

.chat-topic-chip:hover,
.chat-topic-chip:focus-visible {
  color: #ffffff;
  background: var(--chat-brand-grad);
  border-color: transparent;
  transform: translateY(-1px);
  box-shadow: 0 4px 10px rgba(0, 127, 136, 0.25);
}

.chat-topic-emoji {
  font-size: 0.75rem;
  line-height: 1;
  display: inline-block;
}

.chat-topic-chip-human {
  color: #16a34a;
  border-color: rgba(22, 163, 74, 0.35);
  background: rgba(22, 163, 74, 0.05);
  font-weight: 600;
}

.chat-topic-chip-human:hover,
.chat-topic-chip-human:focus-visible {
  background: #16a34a;
  color: #ffffff;
  border-color: #16a34a;
  box-shadow: 0 4px 10px rgba(22, 163, 74, 0.3);
}

.chat-topic-wa-icon {
  width: 12px;
  height: 12px;
  fill: currentColor;
  display: block;
}

.chat-topic-tag {
  background: #ffffff;
  border: 1px solid var(--chat-border);
  color: var(--chat-text);
  padding: 3px 8px;
  border-radius: 4px;
  font-size: 0.6875rem;
  cursor: pointer;
  transition: all 0.15s ease;
  flex-shrink: 0;
}

.chat-topic-tag:hover {
  background: var(--chat-teal);
  color: #ffffff;
  border-color: var(--chat-teal);
}

/* Input Form */
.chat-input-form {
  padding: 10px 14px;
  background: #ffffff;
  border-top: 1px solid var(--chat-border);
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.chat-text-input {
  flex: 1;
  padding: 9px 12px;
  background: #f8fafc;
  border: 1px solid var(--chat-border);
  border-radius: 8px;
  font-size: 0.8125rem;
  color: var(--chat-text);
  outline: none;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.chat-text-input:focus {
  border-color: var(--chat-teal);
  background: #ffffff;
  box-shadow: 0 0 0 2px rgba(0, 127, 136, 0.15);
}

.chat-send-btn {
  background: var(--chat-teal);
  border: none;
  color: #ffffff;
  width: 36px;
  height: 36px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.15s ease, transform 0.15s ease;
  flex-shrink: 0;
}

.chat-send-btn:hover {
  background: var(--chat-primary-hover);
  transform: translateY(-1px);
}

.chat-send-btn:active {
  transform: scale(0.95);
}

/* Mobile Responsiveness */
@media (max-width: 480px) {
  .chat-dialog-panel {
    bottom: 0;
    right: 0;
    width: 100vw;
    max-width: 100vw;
    height: 100vh;
    max-height: 100vh;
    border-radius: 0;
    border: none;
  }

  .sciematics-chat-widget {
    bottom: 16px;
    right: 16px;
  }

  .chat-launcher-btn {
    width: 54px;
    height: 54px;
  }

  .chat-launcher-icon-wrap {
    width: 36px;
    height: 36px;
  }

  .chat-launcher-favicon {
    width: 22px;
    height: 22px;
  }

  .sciematics-chat-widget {
    bottom: 74px;
    right: 11px;
  }

  .back-top {
    bottom: 16px !important;
    right: 16px !important;
  }
}
