/* ==========================================================================
   SAR TECH SOFT — AI Chatbot Assistant Widget Styles
   Ultra-Modern Professional Enterprise Theme (Clean Vector Icons, Zero Emojis)
   Optimized for Desktop & Flawless Mobile Native Experience
   ========================================================================== */

/* ---------- Base Helper for Inline Vector Icons ---------- */
.sar-icon-svg {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  vertical-align: middle;
  flex-shrink: 0;
  position: relative;
  top: -1px;
}

/* ---------- Floating Action Dock (Hidden in Hero, Appears on Scroll) ---------- */
.sar-floating-dock {
  position: fixed;
  bottom: 28px;
  right: 28px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 12px;
  opacity: 0;
  pointer-events: none;
  transform: translateY(24px) scale(0.92);
  transition: opacity 0.3s cubic-bezier(0.16, 1, 0.3, 1), transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.sar-floating-dock.is-visible {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0) scale(1);
}

/* ---------- Floating Chat Launcher Button (Inside Dock) ---------- */
.sar-chatbot-launcher {
  position: relative;
  bottom: auto;
  right: auto;
  z-index: 1;
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  border: none;
  background: transparent;
  padding: 0;
  outline: none;
  font-family: var(--font-sans, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif);
  transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  -webkit-tap-highlight-color: transparent;
}

.sar-chatbot-launcher:hover {
  transform: translateY(-2px) scale(1.03);
}

.sar-chatbot-launcher:active {
  transform: translateY(0) scale(0.97);
}

/* ---------- Back to Top Button (Positioned Below Chat Launcher) ---------- */
.sar-back-to-top {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  background: rgba(15, 23, 42, 0.94);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid rgba(255, 255, 255, 0.14);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 10px 25px -4px rgba(15, 23, 42, 0.5), 0 0 15px rgba(37, 99, 235, 0.2);
  transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  outline: none;
  -webkit-tap-highlight-color: transparent;
}

.sar-back-to-top:hover {
  background: linear-gradient(135deg, #1d4ed8, #06b6d4);
  border-color: rgba(6, 182, 212, 0.55);
  box-shadow: 0 12px 30px -4px rgba(37, 99, 235, 0.65), 0 0 20px rgba(6, 182, 212, 0.4);
  transform: translateY(-2px) scale(1.05);
}

.sar-back-to-top:active {
  transform: translateY(0) scale(0.96);
}

.sar-back-to-top-icon {
  color: #ffffff;
  transition: transform 0.25s ease;
}

.sar-back-to-top:hover .sar-back-to-top-icon {
  transform: translateY(-2px);
}

/* Launcher Pill Label */
.sar-launcher-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: rgba(15, 23, 42, 0.94);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  color: #ffffff;
  padding: 10px 18px;
  border-radius: 9999px;
  font-size: 0.825rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  border: 1px solid rgba(255, 255, 255, 0.14);
  box-shadow: 0 10px 25px -5px rgba(15, 23, 42, 0.4), 0 0 20px rgba(37, 99, 235, 0.25);
  pointer-events: auto;
  transition: all 0.25s ease;
}

.sar-chatbot-launcher:hover .sar-launcher-pill {
  border-color: rgba(6, 182, 212, 0.5);
  box-shadow: 0 12px 30px -5px rgba(15, 23, 42, 0.5), 0 0 25px rgba(6, 182, 212, 0.35);
}

.sar-launcher-sparkle {
  color: #38bdf8;
  display: inline-flex;
}

/* Launcher Round Avatar Button */
.sar-launcher-avatar {
  position: relative;
  width: 58px;
  height: 58px;
  border-radius: 50%;
  background: linear-gradient(135deg, #1d4ed8 0%, #06b6d4 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #ffffff;
  box-shadow: 0 10px 30px -4px rgba(37, 99, 235, 0.6), 0 0 0 2px rgba(255, 255, 255, 0.2);
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.sar-launcher-avatar::before {
  content: '';
  position: absolute;
  inset: -3px;
  border-radius: 50%;
  background: linear-gradient(135deg, #2563eb, #06b6d4, #7c3aed, #2563eb);
  background-size: 300% 300%;
  z-index: -1;
  animation: sarGlowRotate 4s ease infinite;
  opacity: 0.85;
}

@keyframes sarGlowRotate {
  0% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}

.sar-launcher-icon-chat,
.sar-launcher-icon-close {
  transition: all 0.25s ease;
  position: absolute;
}

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

.sar-chatbot-open .sar-launcher-icon-chat {
  opacity: 0;
  transform: rotate(90deg) scale(0.6);
}

.sar-chatbot-open .sar-launcher-icon-close {
  opacity: 1;
  transform: rotate(0deg) scale(1);
}

/* When chat window is open, smoothly hide the launcher pill */
.sar-chatbot-open .sar-launcher-pill,
body.sar-chatbot-open .sar-launcher-pill {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translateX(12px) scale(0.9);
  max-width: 0;
  padding: 0;
  margin: 0;
  border: none;
  overflow: hidden;
}

/* Online Pulse Dot */
.sar-launcher-status-dot {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #10b981;
  border: 2px solid #0f172a;
}

.sar-launcher-status-dot::after {
  content: '';
  position: absolute;
  inset: -2px;
  border-radius: 50%;
  border: 2px solid #10b981;
  animation: sarDotPulse 2s cubic-bezier(0.24, 0, 0.38, 1) infinite;
}

@keyframes sarDotPulse {
  0% { transform: scale(1); opacity: 1; }
  100% { transform: scale(2.2); opacity: 0; }
}

/* ---------- Chatbot Window Modal Container ---------- */
.sar-chatbot-window {
  position: fixed;
  bottom: 125px;
  right: 28px;
  width: 410px;
  max-width: calc(100vw - 32px);
  height: 620px;
  max-height: calc(100vh - 120px);
  z-index: 9998;
  display: flex;
  flex-direction: column;
  background: rgba(11, 19, 43, 0.96);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 24px;
  box-shadow: 0 25px 60px -12px rgba(0, 0, 0, 0.65), 0 0 40px rgba(37, 99, 235, 0.2);
  overflow: hidden;
  font-family: var(--font-sans, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif);
  opacity: 0;
  transform: translateY(20px) scale(0.96);
  pointer-events: none;
  transition: opacity 0.28s cubic-bezier(0.16, 1, 0.3, 1), transform 0.28s cubic-bezier(0.16, 1, 0.3, 1);
}

.sar-chatbot-window.is-open {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

/* ---------- Chatbot Header ---------- */
.sar-chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  background: rgba(15, 23, 42, 0.9);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  flex-shrink: 0;
}

.sar-chat-header-profile {
  display: flex;
  align-items: center;
  gap: 12px;
}

.sar-chat-avatar {
  position: relative;
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: linear-gradient(135deg, #2563eb, #06b6d4);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #ffffff;
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.4);
}

.sar-chat-avatar img {
  width: 24px;
  height: 24px;
  object-fit: contain;
}

.sar-chat-header-info h3 {
  font-family: var(--font-display, 'Space Grotesk', sans-serif);
  font-size: 1rem;
  font-weight: 700;
  color: #ffffff;
  margin: 0;
  line-height: 1.2;
  display: flex;
  align-items: center;
  gap: 6px;
}

.sar-badge-ai {
  font-size: 0.625rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 1px 7px;
  border-radius: 9999px;
  background: rgba(6, 182, 212, 0.18);
  color: #38bdf8;
  border: 1px solid rgba(6, 182, 212, 0.3);
}

.sar-chat-header-status {
  font-size: 0.75rem;
  color: #94a3b8;
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 3px;
}

.sar-status-indicator {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #10b981;
  box-shadow: 0 0 8px #10b981;
}

.sar-chat-header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.sar-chat-btn-action {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: #94a3b8;
  width: 34px;
  height: 34px;
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
  outline: none;
}

.sar-chat-btn-action:hover {
  background: rgba(255, 255, 255, 0.14);
  color: #ffffff;
  border-color: rgba(255, 255, 255, 0.24);
}

/* ---------- Chat Messages Stream ---------- */
.sar-chat-body {
  flex: 1;
  overflow-y: auto;
  padding: 20px 18px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch;
}

.sar-chat-body::-webkit-scrollbar {
  width: 5px;
}

.sar-chat-body::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.15);
  border-radius: 9999px;
}

/* Intro Banner Card */
.sar-chat-welcome {
  background: linear-gradient(135deg, rgba(37, 99, 235, 0.12), rgba(6, 182, 212, 0.08));
  border: 1px solid rgba(37, 99, 235, 0.25);
  border-radius: 16px;
  padding: 18px;
  color: #e2e8f0;
}

.sar-chat-welcome-title {
  font-family: var(--font-display, 'Space Grotesk', sans-serif);
  font-size: 0.95rem;
  font-weight: 700;
  color: #ffffff;
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.sar-chat-welcome-title .sar-icon-svg {
  color: #38bdf8;
}

.sar-chat-welcome-text {
  font-size: 0.8125rem;
  line-height: 1.55;
  color: #94a3b8;
  margin-bottom: 14px;
}

/* Quick Question Suggestions (Clean Apple-Style Action Chips) */
.sar-quick-questions {
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.sar-quick-chip {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: #cbd5e1;
  font-size: 0.8rem;
  font-weight: 500;
  padding: 8px 12px;
  border-radius: 10px;
  cursor: pointer;
  text-align: left;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  outline: none;
}

.sar-chip-label-group {
  display: flex;
  align-items: center;
  gap: 9px;
  flex: 1;
}

.sar-chip-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 6px;
  background: rgba(37, 99, 235, 0.18);
  color: #38bdf8;
  flex-shrink: 0;
}

.sar-quick-chip:hover {
  background: rgba(37, 99, 235, 0.22);
  border-color: rgba(6, 182, 212, 0.45);
  color: #ffffff;
  transform: translateX(3px);
}

.sar-quick-chip:hover .sar-chip-icon {
  background: #2563eb;
  color: #ffffff;
}

.sar-quick-chip-arrow {
  color: #64748b;
  display: inline-flex;
  transition: all 0.2s ease;
}

.sar-quick-chip:hover .sar-quick-chip-arrow {
  color: #38bdf8;
  transform: translateX(2px);
}

/* Message Bubbles */
.sar-chat-msg {
  display: flex;
  gap: 10px;
  max-width: 93%;
  animation: sarMsgIn 0.24s cubic-bezier(0.16, 1, 0.3, 1);
}

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

.sar-chat-msg.sar-msg-user {
  margin-left: auto;
  flex-direction: row-reverse;
}

.sar-msg-user .sar-msg-bubble {
  background: linear-gradient(135deg, #2563eb, #1d4ed8);
  color: #ffffff;
  border-radius: 18px 18px 4px 18px;
  box-shadow: 0 4px 14px rgba(37, 99, 235, 0.35);
}

.sar-msg-ai .sar-msg-bubble {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: #e2e8f0;
  border-radius: 18px 18px 18px 4px;
}

.sar-msg-bubble {
  padding: 12px 16px;
  font-size: 0.84rem;
  line-height: 1.6;
  position: relative;
  word-break: normal;
  overflow-wrap: break-word;
}

.sar-msg-bubble p {
  margin: 0 0 8px;
  line-height: 1.55;
}

.sar-msg-bubble p:last-child {
  margin-bottom: 0;
}

.sar-msg-bubble ul {
  margin: 8px 0 10px 0;
  padding: 0;
  list-style: none;
}

.sar-msg-bubble li {
  margin-bottom: 8px;
  font-size: 0.825rem;
  line-height: 1.55;
  color: #cbd5e1;
  display: flex;
  align-items: flex-start;
  gap: 9px;
  position: relative;
}

.sar-msg-bubble li:last-child {
  margin-bottom: 0;
}

/* Bullet Vector Icon Box */
.sar-li-icon,
.sar-msg-bullet-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 16px;
  height: 16px;
  margin-top: 3px;
  color: #38bdf8;
}

.sar-li-icon .sar-icon-svg,
.sar-msg-bullet-icon .sar-icon-svg {
  width: 14px;
  height: 14px;
  margin: 0;
  top: 0;
}

/* Message Content Container (guarantees inline flow of bold titles & descriptions) */
.sar-li-text,
.sar-msg-item-text {
  flex: 1;
  min-width: 0;
  color: #cbd5e1;
  word-break: normal;
  overflow-wrap: break-word;
}

/* Direct Child Fallback if span wrapper is omitted */
.sar-msg-bubble li > .sar-icon-svg {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 14px;
  height: 14px;
  color: #38bdf8;
  margin-top: 3px;
}

.sar-msg-bubble strong {
  color: #ffffff;
  font-weight: 600;
}

.sar-msg-bubble a {
  color: #38bdf8;
  text-decoration: underline;
  text-underline-offset: 3px;
  word-break: break-word;
}

.sar-msg-bubble a:hover {
  color: #7dd3fc;
}

/* Action Buttons inside AI Responses */
.sar-msg-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-top: 12px;
}

.sar-msg-action-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(37, 99, 235, 0.2);
  border: 1px solid rgba(37, 99, 235, 0.4);
  color: #93c5fd;
  font-size: 0.775rem;
  font-weight: 600;
  padding: 6px 12px;
  border-radius: 8px;
  text-decoration: none !important;
  white-space: nowrap;
  transition: all 0.2s ease;
}

.sar-msg-action-btn:hover {
  background: rgba(37, 99, 235, 0.38);
  color: #ffffff;
  border-color: #38bdf8;
  transform: translateY(-1px);
}

.sar-msg-time {
  font-size: 0.65rem;
  color: #64748b;
  margin-top: 5px;
}

.sar-msg-user .sar-msg-time {
  text-align: right;
  color: rgba(255, 255, 255, 0.65);
}

/* Typing Indicator (AI Reasoning) */
.sar-typing-indicator {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 15px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 16px 16px 16px 4px;
}

.sar-typing-text {
  font-size: 0.75rem;
  color: #94a3b8;
  margin-right: 4px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.sar-typing-text .sar-icon-svg {
  color: #38bdf8;
}

.sar-typing-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #38bdf8;
  animation: sarDotBounce 1.4s infinite ease-in-out both;
}

.sar-typing-dot:nth-child(2) {
  animation-delay: -0.32s;
}

.sar-typing-dot:nth-child(3) {
  animation-delay: -0.16s;
}

@keyframes sarDotBounce {
  0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
  40% { transform: scale(1.1); opacity: 1; }
}

/* ---------- Chatbot Footer & Input Bar ---------- */
.sar-chat-footer {
  padding: 12px 18px 16px;
  background: rgba(15, 23, 42, 0.9);
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  flex-shrink: 0;
}

.sar-chat-input-form {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 14px;
  padding: 5px 6px 5px 14px;
  transition: all 0.2s ease;
}

.sar-chat-input-form:focus-within {
  border-color: #2563eb;
  background: rgba(255, 255, 255, 0.09);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.25);
}

.sar-chat-input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: #ffffff;
  font-family: inherit;
  font-size: 0.85rem;
  line-height: 1.4;
}

.sar-chat-input::placeholder {
  color: #64748b;
}

.sar-chat-btn-send {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  border: none;
  background: linear-gradient(135deg, #2563eb, #06b6d4);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.4);
  outline: none;
}

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

.sar-chat-btn-send:not(:disabled):hover {
  transform: scale(1.05);
  box-shadow: 0 6px 16px rgba(37, 99, 235, 0.6);
}

.sar-chat-footnote {
  text-align: center;
  font-size: 0.6875rem;
  color: #64748b;
  margin-top: 8px;
}

.sar-chat-footnote a {
  color: #94a3b8;
  text-decoration: none;
}

.sar-chat-footnote a:hover {
  color: #38bdf8;
}

/* ==========================================================================
   Mobile-First Ultra-Clean Full Screen Presentation (< 680px)
   Provides an app-like seamless sheet interface with safe area insets
   ========================================================================== */
@media (max-width: 680px) {
  /* Mobile Floating Dock Position (Sleek and compact) */
  .sar-floating-dock {
    bottom: 16px;
    right: 16px;
    gap: 8px;
  }

  /* Hide dock completely when chat is open on mobile */
  body.sar-chatbot-open .sar-floating-dock {
    opacity: 0 !important;
    pointer-events: none !important;
    transform: scale(0.8) !important;
  }

  .sar-launcher-pill {
    display: none; /* Keep clean circle icon launcher on small screens */
  }

  .sar-launcher-avatar {
    width: 48px;
    height: 48px;
  }

  .sar-back-to-top {
    width: 40px;
    height: 40px;
  }

  /* Full App Sheet Overlay on Mobile */
  .sar-chatbot-window {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100vw;
    max-width: 100vw;
    height: 100vh;
    height: 100dvh;
    max-height: 100dvh;
    border-radius: 0;
    border: none;
    box-shadow: none;
    background: #080d1e;
    z-index: 100000;
    transform: translateY(100%);
    transition: transform 0.32s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.2s ease;
  }

  .sar-chatbot-window.is-open {
    transform: translateY(0);
  }

  /* Mobile Header with Top Safe Area */
  .sar-chat-header {
    padding-top: max(16px, env(safe-area-inset-top, 16px));
    padding-bottom: 14px;
    padding-left: 16px;
    padding-right: 16px;
    background: #0b132b;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  }

  .sar-chat-header-actions .sar-chat-btn-action {
    width: 38px;
    height: 38px;
  }

  /* Mobile Chat Body */
  .sar-chat-body {
    padding: 16px 14px;
    gap: 14px;
  }

  .sar-chat-msg {
    max-width: 92%;
  }

  .sar-chat-welcome {
    padding: 14px;
  }

  .sar-quick-chip {
    padding: 10px 12px;
    font-size: 0.8125rem;
  }

  /* Mobile Footer with Bottom Safe Area */
  .sar-chat-footer {
    padding-top: 10px;
    padding-left: 14px;
    padding-right: 14px;
    padding-bottom: max(14px, env(safe-area-inset-bottom, 14px));
    background: #0b132b;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
  }

  .sar-chat-input {
    font-size: 16px; /* Prevents auto-zoom in mobile Safari */
  }

  .sar-chat-btn-send {
    width: 40px;
    height: 40px;
  }
}

/* Prevent body scroll when chat modal is open on mobile */
body.sar-chat-locked {
  overflow: hidden !important;
  touch-action: none;
}
