/**
 * SHAIVIKA IT TECHNOLOGIES - AI CHATBOT COMPONENT
 * Animated Robot Assistant & Floating Chatbot Stylesheet
 * 
 * Features:
 * - Ultra-premium Light Mode UI with frosted glassmorphism & brand-consistent palette:
 *   Primary Blue (#2563EB), Sky Blue (#38BDF8), Brand Purple (#8B5CF6), Navy (#172554)
 * - Realistic lifelike robot head sway & vertical floating motion (8s cycle, -4.5deg to +4.5deg)
 * - Interaction-responsive robot animations (enter, thinking nod, idle recovery)
 * - Complete preservation of Dark Mode styles under [data-theme="dark"]
 * - Full accessibility with WCAG AA text contrast and prefers-reduced-motion support
 * - Defensive layout coordination preventing WhatsApp floating button overlap
 */

/* =========================================================================
   1. DESIGN TOKENS / CSS CUSTOM PROPERTIES
   ========================================================================= */

/* Default: Premium Light Mode Palette */
:root:not([data-theme="dark"]),
[data-theme="light"] {
  --s-chat-primary: #2563eb;
  --s-chat-primary-hover: #1d4ed8;
  --s-chat-sky: #38bdf8;
  --s-chat-purple: #8b5cf6;
  --s-chat-navy: #172554;
  --s-chat-card-bg: rgba(255, 255, 255, 0.88);
  --s-chat-panel-fallback: #ffffff;
  --s-chat-header-bg: rgba(255, 255, 255, 0.95);
  --s-chat-convo-bg: #f8fafc;
  --s-chat-ai-bubble: #ffffff;
  --s-chat-ai-border: rgba(59, 130, 246, 0.16);
  --s-chat-ai-shadow: 0 4px 14px rgba(37, 99, 235, 0.06);
  --s-chat-user-bubble: #eaf3ff;
  --s-chat-user-border: rgba(37, 99, 235, 0.2);
  --s-chat-user-text: #172554;
  --s-chat-text: #172554;
  --s-chat-text-secondary: #64748b;
  --s-chat-border: rgba(59, 130, 246, 0.16);
  --s-chat-shadow: 0 12px 40px rgba(37, 99, 235, 0.12), 0 2px 10px rgba(0, 0, 0, 0.04);
  --s-robot-launcher-bg: radial-gradient(circle at 40% 30%, #ffffff 0%, #f0f7ff 65%, #dbeafe 100%);
  --s-robot-launcher-border: rgba(59, 130, 246, 0.35);
  --s-robot-launcher-glow: 0 10px 28px -4px rgba(37, 99, 235, 0.26), 0 4px 12px rgba(37, 99, 235, 0.12);
}

/* Dark Mode Tokens (Preserved exactly as original) */
[data-theme="dark"] {
  --s-chat-primary: #2563eb;
  --s-chat-primary-hover: #1d4ed8;
  --s-chat-purple: #7c3aed;
  --s-chat-accent: #38bdf8;
  --s-chat-dark: #0f172a;
  --s-chat-card-bg: rgba(15, 23, 42, 0.94);
  --s-chat-ai-bubble: rgba(30, 41, 59, 0.85);
  --s-chat-user-bubble: linear-gradient(135deg, #2563eb, #6366f1);
  --s-chat-text: #f8fafc;
  --s-chat-text-muted: #94a3b8;
  --s-chat-border: rgba(255, 255, 255, 0.12);
  --s-chat-shadow: 0 20px 45px -10px rgba(0, 0, 0, 0.5), 0 0 25px rgba(37, 99, 235, 0.25);
  --s-robot-glow: 0 10px 28px -4px rgba(37, 99, 235, 0.5), 0 0 22px rgba(56, 189, 248, 0.4);
}

/* =========================================================================
   2. BASE WRAPPER
   ========================================================================= */
#shaivika-chatbot-wrapper {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 99998;
  font-family: 'Outfit', 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  box-sizing: border-box;
}

#shaivika-chatbot-wrapper * {
  box-sizing: border-box;
}

/* =========================================================================
   3. REALISTIC ROBOT HEAD SWAY & LIFELIKE ANIMATION
   Slow left-to-right head rotation (-4.5deg to +4.5deg) and gentle upward float (0 to -4px)
   8-second smooth continuous cycle with cubic-bezier timing
   ========================================================================= */
@keyframes shaivika-robot-head-sway {
  0% {
    transform: translateY(0px) rotate(-4.5deg);
  }
  25% {
    transform: translateY(-2px) rotate(-1deg);
  }
  50% {
    transform: translateY(-4px) rotate(4.5deg);
  }
  75% {
    transform: translateY(-1.5px) rotate(1deg);
  }
  100% {
    transform: translateY(0px) rotate(-4.5deg);
  }
}

.shaivika-robot-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center center;
  display: block;
  border-radius: 50%;
  animation: shaivika-robot-head-sway 8s cubic-bezier(0.45, 0.05, 0.55, 0.95) infinite;
  transform-origin: 50% 65%;
  will-change: transform;
  transition: transform 0.3s ease;
}

.shaivika-chat-avatar-robot img {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
  display: block;
  animation: shaivika-robot-head-sway 8s cubic-bezier(0.45, 0.05, 0.55, 0.95) infinite;
  transform-origin: 50% 65%;
  will-change: transform;
}

/* Entrance Animation when user opens chatbot */
.shaivika-chat-window.is-open .shaivika-chat-avatar-robot {
  animation: shaivika-avatar-enter 0.5s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes shaivika-avatar-enter {
  0% {
    opacity: 0;
    transform: translateY(8px) scale(0.92);
  }
  100% {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* Thinking Nod for AI Assistant during response generation */
.shaivika-chat-avatar-robot.is-thinking img {
  animation: shaivika-robot-thinking-nod 1.6s ease-in-out infinite alternate;
}

@keyframes shaivika-robot-thinking-nod {
  0% {
    transform: translateY(0px) rotate(-2deg);
  }
  100% {
    transform: translateY(-3px) rotate(2deg);
  }
}

/* =========================================================================
   4. FLOATING CHATBOT LAUNCHER BUTTON
   ========================================================================= */
.shaivika-chat-launcher {
  width: 76px;
  height: 76px;
  border-radius: 50%;
  color: #ffffff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  outline: none;
  padding: 0;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  transition: transform 0.28s cubic-bezier(0.34, 1.56, 0.64, 1),
              box-shadow 0.28s ease,
              border-color 0.28s ease;
}

/* Light Mode Launcher */
:root:not([data-theme="dark"]) .shaivika-chat-launcher,
[data-theme="light"] .shaivika-chat-launcher {
  background: radial-gradient(circle at 40% 30%, #ffffff 0%, #f0f7ff 65%, #dbeafe 100%);
  border: 2px solid rgba(59, 130, 246, 0.35);
  box-shadow: 0 10px 28px -4px rgba(37, 99, 235, 0.26), 0 4px 12px rgba(37, 99, 235, 0.12);
  color: #172554;
  animation: shaivika-launcher-float-light 4.5s ease-in-out infinite alternate;
}

@keyframes shaivika-launcher-float-light {
  0% {
    transform: translateY(0);
    box-shadow: 0 10px 28px -4px rgba(37, 99, 235, 0.22), 0 4px 12px rgba(37, 99, 235, 0.1);
  }
  50% {
    box-shadow: 0 14px 32px -4px rgba(37, 99, 235, 0.3), 0 6px 16px rgba(139, 92, 246, 0.18);
  }
  100% {
    transform: translateY(-5px);
    box-shadow: 0 16px 36px -4px rgba(37, 99, 235, 0.28), 0 8px 18px rgba(56, 189, 248, 0.2);
  }
}

:root:not([data-theme="dark"]) .shaivika-chat-launcher:hover,
[data-theme="light"] .shaivika-chat-launcher:hover {
  transform: scale(1.05) translateY(-4px);
  box-shadow: 0 16px 36px -4px rgba(37, 99, 235, 0.38), 0 0 24px rgba(56, 189, 248, 0.35);
  border-color: rgba(37, 99, 235, 0.6);
}

:root:not([data-theme="dark"]) .shaivika-chat-launcher:focus-visible,
[data-theme="light"] .shaivika-chat-launcher:focus-visible {
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.45), 0 12px 28px rgba(37, 99, 235, 0.3);
}

/* Dark Mode Launcher (Preserved) */
[data-theme="dark"] .shaivika-chat-launcher {
  background: radial-gradient(circle at 50% 30%, #1e293b 0%, #0f172a 100%);
  border: 2px solid rgba(56, 189, 248, 0.45);
  box-shadow: var(--s-robot-glow);
  animation: shaivika-robot-float 3.2s ease-in-out infinite alternate;
}

[data-theme="dark"] .shaivika-chat-launcher:hover {
  transform: scale(1.05) translateY(-4px);
  box-shadow: 0 20px 42px -4px rgba(37, 99, 235, 0.7), 0 0 36px rgba(56, 189, 248, 0.65);
  border-color: rgba(56, 189, 248, 0.9);
}

[data-theme="dark"] .shaivika-chat-launcher:focus-visible {
  box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.65), 0 14px 30px rgba(37, 99, 235, 0.5);
}

@keyframes shaivika-robot-float {
  0% {
    transform: translateY(0);
    box-shadow: 0 10px 26px -4px rgba(37, 99, 235, 0.45), 0 0 20px rgba(56, 189, 248, 0.35);
  }
  50% {
    box-shadow: 0 16px 34px -4px rgba(37, 99, 235, 0.6), 0 0 26px rgba(124, 58, 237, 0.4);
  }
  100% {
    transform: translateY(-6px);
    box-shadow: 0 18px 38px -4px rgba(37, 99, 235, 0.52), 0 0 30px rgba(56, 189, 248, 0.48);
  }
}

.shaivika-chat-launcher:active {
  transform: scale(0.94) translateY(0);
}

/* Notification Pulse Ring */
.shaivika-chat-launcher.has-notification .shaivika-launcher-glow-ring {
  position: absolute;
  inset: -6px;
  border-radius: 50%;
  pointer-events: none;
}

:root:not([data-theme="dark"]) .shaivika-chat-launcher.has-notification .shaivika-launcher-glow-ring,
[data-theme="light"] .shaivika-chat-launcher.has-notification .shaivika-launcher-glow-ring {
  border: 2px solid rgba(37, 99, 235, 0.5);
  animation: shaivika-notify-ring-light 3s cubic-bezier(0.25, 1, 0.5, 1) infinite;
}

@keyframes shaivika-notify-ring-light {
  0% {
    transform: scale(0.94);
    opacity: 0.85;
    box-shadow: 0 0 10px rgba(37, 99, 235, 0.35);
  }
  50% {
    transform: scale(1.15);
    opacity: 0.25;
    box-shadow: 0 0 18px rgba(139, 92, 246, 0.25);
  }
  100% {
    transform: scale(1.26);
    opacity: 0;
  }
}

[data-theme="dark"] .shaivika-chat-launcher.has-notification .shaivika-launcher-glow-ring {
  border: 2px solid rgba(56, 189, 248, 0.8);
  animation: shaivika-notify-ring 2.8s cubic-bezier(0.25, 1, 0.5, 1) infinite;
}

@keyframes shaivika-notify-ring {
  0% { transform: scale(0.92); opacity: 0.9; box-shadow: 0 0 10px rgba(56, 189, 248, 0.6); }
  50% { transform: scale(1.16); opacity: 0.3; box-shadow: 0 0 22px rgba(124, 58, 237, 0.4); }
  100% { transform: scale(1.28); opacity: 0; }
}

/* Avatar Wrap */
.shaivika-launcher-avatar-wrap {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  position: relative;
  transition: opacity 0.25s ease, transform 0.25s ease;
}

[data-theme="dark"] .shaivika-launcher-avatar-wrap {
  background: radial-gradient(circle at 50% 35%, #1e293b 0%, #0f172a 100%);
}

.shaivika-chat-launcher:hover .shaivika-robot-img {
  transform: scale(1.06);
}

/* Active State (Launcher open -> Close Button) */
.shaivika-launcher-close-wrap {
  display: none;
  width: 100%;
  height: 100%;
  align-items: center;
  justify-content: center;
  color: #ffffff;
  transition: transform 0.25s ease;
}

.shaivika-launcher-close-wrap svg {
  width: 32px;
  height: 32px;
  fill: currentColor;
}

.shaivika-chat-launcher.is-active {
  background: linear-gradient(135deg, #2563eb 0%, #7c3aed 100%) !important;
  border-color: rgba(255, 255, 255, 0.4) !important;
  box-shadow: 0 12px 30px rgba(37, 99, 235, 0.45) !important;
  animation: none !important;
}

.shaivika-chat-launcher.is-active .shaivika-launcher-avatar-wrap {
  display: none;
}

.shaivika-chat-launcher.is-active .shaivika-launcher-close-wrap {
  display: flex;
}

.shaivika-chat-launcher.is-active .shaivika-launcher-badge {
  display: none;
}

.shaivika-chat-launcher.is-active .shaivika-launcher-glow-ring {
  display: none;
}

/* Fallback SVG */
.launcher-fallback-icon {
  width: 36px;
  height: 36px;
  fill: #2563eb;
}

[data-theme="dark"] .launcher-fallback-icon {
  fill: #38bdf8;
}

/* AI Sparkle Badge */
.shaivika-launcher-badge {
  position: absolute;
  top: -2px;
  right: -2px;
  color: #ffffff;
  font-size: 11px;
  font-weight: 800;
  border-radius: 12px;
  padding: 3px 7px;
  display: flex;
  align-items: center;
  gap: 2px;
  pointer-events: none;
}

:root:not([data-theme="dark"]) .shaivika-launcher-badge,
[data-theme="light"] .shaivika-launcher-badge {
  background: linear-gradient(135deg, #2563eb, #8b5cf6);
  border: 2px solid #ffffff;
  box-shadow: 0 2px 10px rgba(37, 99, 235, 0.35);
  animation: badge-pulse-light 2.2s infinite ease-in-out;
}

@keyframes badge-pulse-light {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.08); box-shadow: 0 4px 14px rgba(37, 99, 235, 0.5); }
}

[data-theme="dark"] .shaivika-launcher-badge {
  background: linear-gradient(135deg, #ec4899, #8b5cf6);
  border: 2px solid #0f172a;
  box-shadow: 0 2px 10px rgba(236, 72, 153, 0.6);
  animation: badge-pulse 2.2s infinite ease-in-out;
}

@keyframes badge-pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.08); box-shadow: 0 4px 14px rgba(236, 72, 153, 0.85); }
}

/* Tooltip */
.shaivika-chat-tooltip {
  position: absolute;
  bottom: calc(100% + 14px);
  right: 0;
  font-size: 13px;
  font-weight: 600;
  padding: 8px 16px;
  border-radius: 12px;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transform: translateY(6px);
  transition: opacity 0.25s ease, transform 0.25s ease;
}

:root:not([data-theme="dark"]) .shaivika-chat-tooltip,
[data-theme="light"] .shaivika-chat-tooltip {
  background: #ffffff;
  color: #172554;
  border: 1px solid rgba(59, 130, 246, 0.2);
  box-shadow: 0 6px 20px rgba(37, 99, 235, 0.15);
}

:root:not([data-theme="dark"]) .shaivika-chat-tooltip::after,
[data-theme="light"] .shaivika-chat-tooltip::after {
  content: '';
  position: absolute;
  top: 100%;
  right: 32px;
  border-width: 6px;
  border-style: solid;
  border-color: #ffffff transparent transparent transparent;
}

[data-theme="dark"] .shaivika-chat-tooltip {
  background: #0f172a;
  color: #ffffff;
  border: 1px solid rgba(255, 255, 255, 0.15);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.35);
}

[data-theme="dark"] .shaivika-chat-tooltip::after {
  content: '';
  position: absolute;
  top: 100%;
  right: 32px;
  border-width: 6px;
  border-style: solid;
  border-color: #0f172a transparent transparent transparent;
}

.shaivika-chat-launcher:hover .shaivika-chat-tooltip {
  opacity: 1;
  transform: translateY(0);
}

/* =========================================================================
   5. CHAT WINDOW CONTAINER (PANEL)
   ========================================================================= */
.shaivika-chat-window {
  position: fixed;
  bottom: 104px;
  right: 24px;
  width: 410px;
  max-width: calc(100vw - 32px);
  height: 570px;
  max-height: calc(100vh - 124px);
  border-radius: 20px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: 99997;
  opacity: 0;
  pointer-events: none;
  transform: scale(0.92) translateY(20px);
  transform-origin: bottom right;
  transition: opacity 0.3s cubic-bezier(0.16, 1, 0.3, 1), transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

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

/* Light Mode Panel */
:root:not([data-theme="dark"]) .shaivika-chat-window,
[data-theme="light"] .shaivika-chat-window {
  background: #ffffff;
  background: var(--s-chat-card-bg);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--s-chat-border);
  box-shadow: var(--s-chat-shadow);
}

/* Dark Mode Panel */
[data-theme="dark"] .shaivika-chat-window {
  background: var(--s-chat-card-bg);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border: 1px solid var(--s-chat-border);
  box-shadow: var(--s-chat-shadow);
}

/* Top Accent Gradient Line */
.shaivika-chat-window::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: linear-gradient(90deg, #2563eb, #8b5cf6, #38bdf8);
  z-index: 10;
}

/* =========================================================================
   6. CHATBOT HEADER
   ========================================================================= */
.shaivika-chat-header {
  padding: 11px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  position: relative;
  z-index: 2;
  min-height: 58px;
}

/* Light Mode Header */
:root:not([data-theme="dark"]) .shaivika-chat-header,
[data-theme="light"] .shaivika-chat-header {
  background: var(--s-chat-header-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  color: #172554;
  border-bottom: 1px solid rgba(59, 130, 246, 0.14);
}

/* Dark Mode Header */
[data-theme="dark"] .shaivika-chat-header {
  background: linear-gradient(135deg, #1e3a8a 0%, #312e81 60%, #4c1d95 100%);
  color: #ffffff;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.shaivika-chat-header-info {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  flex: 1;
}

/* Robot Avatar in Header with Online Badge */
.shaivika-chat-avatar-robot {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  position: relative;
  flex-shrink: 0;
  overflow: visible;
}

:root:not([data-theme="dark"]) .shaivika-chat-avatar-robot,
[data-theme="light"] .shaivika-chat-avatar-robot {
  background: #ffffff;
  border: 2px solid rgba(59, 130, 246, 0.28);
  box-shadow: 0 2px 10px rgba(37, 99, 235, 0.1);
}

[data-theme="dark"] .shaivika-chat-avatar-robot {
  background: radial-gradient(circle, #1e293b, #0f172a);
  border: 2px solid rgba(56, 189, 248, 0.5);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25), 0 0 10px rgba(56, 189, 248, 0.35);
}

.shaivika-status-dot-robot {
  position: absolute;
  bottom: 0px;
  right: 0px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #10b981;
}

:root:not([data-theme="dark"]) .shaivika-status-dot-robot,
[data-theme="light"] .shaivika-status-dot-robot {
  border: 2px solid #ffffff;
  box-shadow: 0 0 6px rgba(16, 185, 129, 0.6);
}

[data-theme="dark"] .shaivika-status-dot-robot {
  border: 2px solid #0f172a;
  box-shadow: 0 0 8px #10b981;
}

/* Thinking Glow on Header Robot Avatar */
:root:not([data-theme="dark"]) .shaivika-chat-avatar-robot.is-thinking,
[data-theme="light"] .shaivika-chat-avatar-robot.is-thinking {
  animation: avatar-thinking-pulse-light 1.4s ease-in-out infinite alternate;
}

@keyframes avatar-thinking-pulse-light {
  0% { box-shadow: 0 0 8px rgba(37, 99, 235, 0.3); border-color: rgba(37, 99, 235, 0.4); }
  100% { box-shadow: 0 0 18px rgba(139, 92, 246, 0.5), 0 0 8px rgba(56, 189, 248, 0.4); border-color: #38bdf8; }
}

[data-theme="dark"] .shaivika-chat-avatar-robot.is-thinking {
  animation: avatar-thinking-pulse 1.4s ease-in-out infinite alternate;
}

@keyframes avatar-thinking-pulse {
  0% { box-shadow: 0 0 8px rgba(56, 189, 248, 0.4); border-color: rgba(56, 189, 248, 0.5); }
  100% { box-shadow: 0 0 20px rgba(124, 58, 237, 0.8), 0 0 8px rgba(56, 189, 248, 0.8); border-color: #38bdf8; }
}

.shaivika-chat-titles {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  flex: 1;
  justify-content: center;
}

.shaivika-header-title-row {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  white-space: nowrap;
  flex-wrap: nowrap;
}

.shaivika-header-title-row h3 {
  font-size: 14.5px;
  font-weight: 700;
  margin: 0;
  line-height: 1.2;
  white-space: nowrap;
  letter-spacing: -0.2px;
}

:root:not([data-theme="dark"]) .shaivika-header-title-row h3,
[data-theme="light"] .shaivika-header-title-row h3 {
  color: #172554;
}

[data-theme="dark"] .shaivika-header-title-row h3 {
  color: #ffffff;
}

/* AI 2.0 Badge */
.shaivika-sparkle-pill {
  font-size: 9.5px;
  font-weight: 700;
  height: 19px;
  padding: 0 7px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  line-height: 1;
  letter-spacing: 0.2px;
  flex-shrink: 0;
}

:root:not([data-theme="dark"]) .shaivika-sparkle-pill,
[data-theme="light"] .shaivika-sparkle-pill {
  background: linear-gradient(135deg, rgba(37, 99, 235, 0.1), rgba(139, 92, 246, 0.12));
  color: #2563eb;
  border: 1px solid rgba(37, 99, 235, 0.24);
}

[data-theme="dark"] .shaivika-sparkle-pill {
  background: rgba(56, 189, 248, 0.2);
  color: #38bdf8;
  border: 1px solid rgba(56, 189, 248, 0.4);
}

.shaivika-chat-status {
  font-size: 11px;
  line-height: 1.2;
  display: flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

:root:not([data-theme="dark"]) .shaivika-chat-status,
[data-theme="light"] .shaivika-chat-status {
  color: #64748b;
}

[data-theme="dark"] .shaivika-chat-status {
  color: rgba(255, 255, 255, 0.82);
}

/* Thinking Indicator inside Header Subtitle */
.shaivika-thinking-spinner {
  display: inline-block;
  width: 11px;
  height: 11px;
  border-radius: 50%;
  animation: shaivika-spin 0.8s linear infinite;
  flex-shrink: 0;
}

:root:not([data-theme="dark"]) .shaivika-thinking-spinner,
[data-theme="light"] .shaivika-thinking-spinner {
  border: 2px solid rgba(37, 99, 235, 0.25);
  border-top-color: #2563eb;
}

[data-theme="dark"] .shaivika-thinking-spinner {
  border: 2px solid rgba(56, 189, 248, 0.3);
  border-top-color: #38bdf8;
}

.shaivika-thinking-text {
  font-weight: 600;
  letter-spacing: 0.2px;
}

:root:not([data-theme="dark"]) .shaivika-thinking-text,
[data-theme="light"] .shaivika-thinking-text {
  color: #2563eb;
}

[data-theme="dark"] .shaivika-thinking-text {
  color: #38bdf8;
}

@keyframes shaivika-spin {
  to { transform: rotate(360deg); }
}

/* Header Buttons */
.shaivika-chat-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}

.shaivika-header-btn {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
  outline: none;
}

.shaivika-header-btn svg {
  width: 14px;
  height: 14px;
}

:root:not([data-theme="dark"]) .shaivika-header-btn,
[data-theme="light"] .shaivika-header-btn {
  background: rgba(37, 99, 235, 0.06);
  border: 1px solid rgba(59, 130, 246, 0.15);
  color: #172554;
}

:root:not([data-theme="dark"]) .shaivika-header-btn:hover,
[data-theme="light"] .shaivika-header-btn:hover {
  background: rgba(37, 99, 235, 0.14);
  color: #2563eb;
  border-color: rgba(37, 99, 235, 0.3);
  transform: translateY(-1px);
}

:root:not([data-theme="dark"]) .shaivika-header-btn:focus-visible,
[data-theme="light"] .shaivika-header-btn:focus-visible {
  box-shadow: 0 0 0 2px #2563eb;
}

[data-theme="dark"] .shaivika-header-btn {
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: #ffffff;
}

[data-theme="dark"] .shaivika-header-btn:hover {
  background: rgba(255, 255, 255, 0.2);
  transform: translateY(-1px);
}

[data-theme="dark"] .shaivika-header-btn:focus-visible {
  box-shadow: 0 0 0 2px #38bdf8;
}

/* =========================================================================
   7. MESSAGES CONVERSATION AREA
   ========================================================================= */
.shaivika-chat-messages {
  flex: 1;
  padding: 18px 16px;
  overflow-y: auto;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
  gap: 14px;
  scroll-behavior: smooth;
}

:root:not([data-theme="dark"]) .shaivika-chat-messages,
[data-theme="light"] .shaivika-chat-messages {
  background: #f8fafc;
}

:root:not([data-theme="dark"]) .shaivika-chat-messages::-webkit-scrollbar,
[data-theme="light"] .shaivika-chat-messages::-webkit-scrollbar {
  width: 6px;
}

:root:not([data-theme="dark"]) .shaivika-chat-messages::-webkit-scrollbar-thumb,
[data-theme="light"] .shaivika-chat-messages::-webkit-scrollbar-thumb {
  background: rgba(100, 116, 139, 0.2);
  border-radius: 6px;
}

[data-theme="dark"] .shaivika-chat-messages::-webkit-scrollbar {
  width: 6px;
}

[data-theme="dark"] .shaivika-chat-messages::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.15);
  border-radius: 6px;
}

/* Message Bubble */
.shaivika-message {
  display: flex;
  gap: 10px;
  max-width: 90%;
  animation: message-pop 0.25s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

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

.shaivika-message-user {
  align-self: flex-end;
  flex-direction: row-reverse;
}

.shaivika-message-ai {
  align-self: flex-start;
}

/* AI Avatar next to message */
.shaivika-msg-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-top: 2px;
  overflow: hidden;
}

:root:not([data-theme="dark"]) .shaivika-msg-avatar,
[data-theme="light"] .shaivika-msg-avatar {
  background: #ffffff;
  border: 1px solid rgba(59, 130, 246, 0.25);
  box-shadow: 0 2px 6px rgba(37, 99, 235, 0.08);
}

[data-theme="dark"] .shaivika-msg-avatar {
  background: radial-gradient(circle, #1e293b, #0f172a);
  border: 1px solid rgba(56, 189, 248, 0.4);
}

.shaivika-msg-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
}

.shaivika-msg-body {
  display: flex;
  flex-direction: column;
}

.shaivika-msg-content {
  padding: 12px 16px;
  border-radius: 16px;
  font-size: 13.5px;
  line-height: 1.55;
  word-break: break-word;
}

/* User Message Bubble */
:root:not([data-theme="dark"]) .shaivika-message-user .shaivika-msg-content,
[data-theme="light"] .shaivika-message-user .shaivika-msg-content {
  background: #eaf3ff;
  color: #172554;
  border: 1px solid rgba(37, 99, 235, 0.2);
  border-bottom-right-radius: 4px;
  box-shadow: 0 2px 8px rgba(37, 99, 235, 0.08);
  font-weight: 500;
}

[data-theme="dark"] .shaivika-message-user .shaivika-msg-content {
  background: var(--s-chat-user-bubble);
  color: #ffffff;
  border-bottom-right-radius: 4px;
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.25);
}

/* AI Message Bubble */
:root:not([data-theme="dark"]) .shaivika-message-ai .shaivika-msg-content,
[data-theme="light"] .shaivika-message-ai .shaivika-msg-content {
  background: #ffffff;
  color: #172554;
  border: 1px solid rgba(59, 130, 246, 0.16);
  border-bottom-left-radius: 4px;
  box-shadow: 0 4px 14px rgba(37, 99, 235, 0.06);
}

[data-theme="dark"] .shaivika-message-ai .shaivika-msg-content {
  background: var(--s-chat-ai-bubble);
  color: #f8fafc;
  border: 1px solid var(--s-chat-border);
  border-bottom-left-radius: 4px;
}

.shaivika-msg-time {
  font-size: 10px;
  margin-top: 4px;
  padding: 0 4px;
}

:root:not([data-theme="dark"]) .shaivika-msg-time,
[data-theme="light"] .shaivika-msg-time {
  color: #64748b;
}

[data-theme="dark"] .shaivika-msg-time {
  color: var(--s-chat-text-muted);
}

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

/* Markdown Formatting */
:root:not([data-theme="dark"]) .shaivika-msg-content strong,
[data-theme="light"] .shaivika-msg-content strong {
  font-weight: 700;
  color: #0f172a;
}

[data-theme="dark"] .shaivika-msg-content strong {
  font-weight: 700;
  color: #ffffff;
}

.shaivika-msg-content ul {
  margin: 6px 0;
  padding-left: 18px;
}

.shaivika-msg-content li {
  margin-bottom: 4px;
}

:root:not([data-theme="dark"]) .shaivika-msg-content a,
[data-theme="light"] .shaivika-msg-content a {
  color: #2563eb;
  text-decoration: underline;
  text-underline-offset: 2px;
  font-weight: 600;
}

[data-theme="dark"] .shaivika-msg-content a {
  color: #38bdf8;
  text-decoration: underline;
  text-underline-offset: 2px;
}

/* =========================================================================
   8. QUICK ACTION CHIPS (RESTYLED WITH ELEGANT ACCENTS)
   ========================================================================= */
.shaivika-quick-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.shaivika-chip-btn {
  font-size: 11.5px;
  font-weight: 600;
  padding: 6px 12px;
  border-radius: 14px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  outline: none;
}

:root:not([data-theme="dark"]) .shaivika-chip-btn,
[data-theme="light"] .shaivika-chip-btn {
  background: #ffffff;
  border: 1px solid rgba(37, 99, 235, 0.25);
  color: #2563eb;
  box-shadow: 0 2px 6px rgba(37, 99, 235, 0.06);
}

:root:not([data-theme="dark"]) .shaivika-chip-btn:hover,
[data-theme="light"] .shaivika-chip-btn:hover {
  background: #eaf3ff;
  border-color: #2563eb;
  color: #1d4ed8;
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.16);
}

:root:not([data-theme="dark"]) .shaivika-chip-btn:focus-visible,
[data-theme="light"] .shaivika-chip-btn:focus-visible {
  box-shadow: 0 0 0 2px #2563eb;
}

[data-theme="dark"] .shaivika-chip-btn {
  background: rgba(37, 99, 235, 0.12);
  border: 1px solid rgba(56, 189, 248, 0.35);
  color: #93c5fd;
}

[data-theme="dark"] .shaivika-chip-btn:hover {
  background: rgba(37, 99, 235, 0.25);
  border-color: #38bdf8;
  color: #ffffff;
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.25);
}

[data-theme="dark"] .shaivika-chip-btn:focus-visible {
  box-shadow: 0 0 0 2px #38bdf8;
}

/* =========================================================================
   9. TYPING / LOADING INDICATOR
   ========================================================================= */
.shaivika-typing-bubble {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 12px 18px;
  border-radius: 16px;
  border-bottom-left-radius: 4px;
  width: fit-content;
}

:root:not([data-theme="dark"]) .shaivika-typing-bubble,
[data-theme="light"] .shaivika-typing-bubble {
  background: #ffffff;
  border: 1px solid rgba(59, 130, 246, 0.16);
  box-shadow: 0 4px 14px rgba(37, 99, 235, 0.06);
}

[data-theme="dark"] .shaivika-typing-bubble {
  background: var(--s-chat-ai-bubble);
  border: 1px solid var(--s-chat-border);
}

.shaivika-typing-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  animation: typing-bounce 1.3s infinite ease-in-out;
}

:root:not([data-theme="dark"]) .shaivika-typing-dot,
[data-theme="light"] .shaivika-typing-dot {
  background: #2563eb;
}

:root:not([data-theme="dark"]) .shaivika-typing-dot:nth-child(2),
[data-theme="light"] .shaivika-typing-dot:nth-child(2) {
  background: #8b5cf6;
}

:root:not([data-theme="dark"]) .shaivika-typing-dot:nth-child(3),
[data-theme="light"] .shaivika-typing-dot:nth-child(3) {
  background: #38bdf8;
}

[data-theme="dark"] .shaivika-typing-dot {
  background: #38bdf8;
}

[data-theme="dark"] .shaivika-typing-dot:nth-child(2) {
  background: #818cf8;
}

[data-theme="dark"] .shaivika-typing-dot:nth-child(3) {
  background: #c084fc;
}

@keyframes typing-bounce {
  0%, 80%, 100% { transform: translateY(0); opacity: 0.4; }
  40% { transform: translateY(-7px); opacity: 1; }
}

/* =========================================================================
   10. ERROR RECOVERY CARD
   ========================================================================= */
.shaivika-error-card {
  border-radius: 14px;
  padding: 10px 14px;
  font-size: 12.5px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

:root:not([data-theme="dark"]) .shaivika-error-card,
[data-theme="light"] .shaivika-error-card {
  background: #fef2f2;
  border: 1px solid rgba(239, 68, 68, 0.28);
  color: #b91c1c;
}

[data-theme="dark"] .shaivika-error-card {
  background: rgba(239, 68, 68, 0.12);
  border: 1px solid rgba(239, 68, 68, 0.35);
  color: #fca5a5;
}

.shaivika-retry-btn {
  background: #ef4444;
  color: #ffffff;
  border: none;
  font-size: 11px;
  font-weight: 700;
  padding: 5px 10px;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.2s ease;
  white-space: nowrap;
}

.shaivika-retry-btn:hover {
  background: #dc2626;
}

/* =========================================================================
   11. INPUT AREA
   ========================================================================= */
.shaivika-chat-input-area {
  padding: 12px 16px 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

:root:not([data-theme="dark"]) .shaivika-chat-input-area,
[data-theme="light"] .shaivika-chat-input-area {
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-top: 1px solid rgba(59, 130, 246, 0.14);
}

[data-theme="dark"] .shaivika-chat-input-area {
  background: rgba(15, 23, 42, 0.7);
  border-top: 1px solid var(--s-chat-border);
}

.shaivika-input-row {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  border-radius: 16px;
  padding: 8px 12px;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

:root:not([data-theme="dark"]) .shaivika-input-row,
[data-theme="light"] .shaivika-input-row {
  background: #ffffff;
  border: 1px solid rgba(59, 130, 246, 0.22);
  box-shadow: 0 2px 8px rgba(37, 99, 235, 0.04);
}

:root:not([data-theme="dark"]) .shaivika-input-row:focus-within,
[data-theme="light"] .shaivika-input-row:focus-within {
  border-color: #2563eb;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

[data-theme="dark"] .shaivika-input-row {
  background: rgba(30, 41, 59, 0.6);
  border: 1px solid var(--s-chat-border);
}

[data-theme="dark"] .shaivika-input-row:focus-within {
  border-color: #38bdf8;
  box-shadow: 0 0 0 2px rgba(56, 189, 248, 0.25);
}

.shaivika-chat-textarea {
  flex: 1;
  background: transparent;
  border: none;
  font-family: inherit;
  font-size: 13.5px;
  line-height: 1.4;
  resize: none;
  max-height: 100px;
  outline: none;
  padding: 2px 0;
}

:root:not([data-theme="dark"]) .shaivika-chat-textarea,
[data-theme="light"] .shaivika-chat-textarea {
  color: #172554;
}

:root:not([data-theme="dark"]) .shaivika-chat-textarea::placeholder,
[data-theme="light"] .shaivika-chat-textarea::placeholder {
  color: #64748b;
}

[data-theme="dark"] .shaivika-chat-textarea {
  color: var(--s-chat-text);
}

[data-theme="dark"] .shaivika-chat-textarea::placeholder {
  color: var(--s-chat-text-muted);
}

.shaivika-send-btn {
  border: none;
  width: 34px;
  height: 34px;
  border-radius: 10px;
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
  flex-shrink: 0;
  outline: none;
}

.shaivika-send-btn svg {
  width: 17px;
  height: 17px;
  fill: currentColor;
  transition: transform 0.2s ease;
}

:root:not([data-theme="dark"]) .shaivika-send-btn,
[data-theme="light"] .shaivika-send-btn {
  background: linear-gradient(135deg, #2563eb, #3b82f6);
  box-shadow: 0 3px 10px rgba(37, 99, 235, 0.28);
}

:root:not([data-theme="dark"]) .shaivika-send-btn:hover:not(:disabled),
[data-theme="light"] .shaivika-send-btn:hover:not(:disabled) {
  background: linear-gradient(135deg, #1d4ed8, #2563eb);
  transform: translateY(-1px);
  box-shadow: 0 5px 14px rgba(37, 99, 235, 0.38);
}

[data-theme="dark"] .shaivika-send-btn {
  background: var(--s-chat-primary);
}

[data-theme="dark"] .shaivika-send-btn:hover:not(:disabled) {
  background: var(--s-chat-primary-hover);
  transform: translateY(-1px);
}

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

/* Chat Footer Meta */
.shaivika-chat-footer-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 10.5px;
  padding: 0 4px;
}

:root:not([data-theme="dark"]) .shaivika-chat-footer-meta,
[data-theme="light"] .shaivika-chat-footer-meta {
  color: #64748b;
}

[data-theme="dark"] .shaivika-chat-footer-meta {
  color: var(--s-chat-text-muted);
}

.shaivika-char-counter {
  font-variant-numeric: tabular-nums;
}

/* =========================================================================
   12. DEFENSIVE WHATSAPP BUTTON COORDINATION (NO OVERLAP)
   ========================================================================= */
.whatsapp-float {
  bottom: 120px !important;
  right: 32px !important;
  transition: all 0.3s ease !important;
  z-index: 99996 !important;
}

/* =========================================================================
   13. RESPONSIVE DESIGN (ALL DEVICES: DESKTOP, TABLET, MOBILE)
   ========================================================================= */

/* Tablet and Small Laptops (max-width: 768px) */
@media screen and (max-width: 768px) {
  .shaivika-chat-window {
    bottom: 96px;
    right: 16px;
    width: 380px;
    max-width: calc(100vw - 32px);
    height: 540px;
    max-height: calc(100vh - 116px);
  }
  
  .shaivika-chat-launcher {
    width: 70px;
    height: 70px;
  }

  .whatsapp-float {
    bottom: 106px !important;
    right: 24px !important;
  }
}

/* Mobile Devices (max-width: 640px) */
@media screen and (max-width: 640px) {
  #shaivika-chatbot-wrapper {
    bottom: 16px;
    right: 16px;
  }

  .shaivika-chat-launcher {
    width: 66px;
    height: 66px;
  }

  /* Seamless Full-Screen / App-Style Modal on Mobile */
  .shaivika-chat-window {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    width: 100% !important;
    max-width: 100% !important;
    height: 100% !important;
    height: 100dvh !important;
    max-height: 100dvh !important;
    border-radius: 0 !important;
    border: none !important;
    box-shadow: none !important;
    z-index: 999999 !important;
    transform: translateY(100%) !important;
    transform-origin: center bottom !important;
    transition: transform 0.32s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.25s ease !important;
  }

  .shaivika-chat-window.is-open {
    transform: translateY(0) !important;
  }

  /* Hide floating launcher when chat is open on mobile to eliminate overlap */
  .shaivika-chat-launcher.is-active {
    opacity: 0 !important;
    pointer-events: none !important;
    transform: scale(0.5) !important;
  }

  /* Hide redundant minimize button on mobile; Close (X) is primary */
  #shaivikaMinimizeChatBtn {
    display: none !important;
  }

  /* Streamline title on mobile to prevent any horizontal squeezing */
  .shaivika-title-extra {
    display: none !important;
  }

  .shaivika-chat-header {
    padding: 12px 14px calc(12px + env(safe-area-inset-top, 0px)) !important;
  }

  .shaivika-chat-input-area {
    padding-bottom: calc(14px + env(safe-area-inset-bottom, 0px)) !important;
  }

  .whatsapp-float {
    bottom: 96px !important;
    right: 20px !important;
    width: 50px !important;
    height: 50px !important;
  }
}

/* Ultra-Small Mobile Viewports (max-width: 360px) */
@media screen and (max-width: 360px) {
  .shaivika-header-title-row h3 {
    font-size: 13.5px !important;
  }

  .shaivika-chat-avatar-robot {
    width: 34px !important;
    height: 34px !important;
  }

  .shaivika-chip-btn {
    font-size: 11.5px !important;
    padding: 6px 10px !important;
  }
}

/* =========================================================================
   14. ACCESSIBILITY: PREFERS-REDUCED-MOTION
   ========================================================================= */
@media (prefers-reduced-motion: reduce) {
  .shaivika-chat-launcher,
  .shaivika-robot-img,
  .shaivika-chat-avatar-robot img,
  .shaivika-chat-avatar-robot.is-thinking img,
  .shaivika-chat-avatar-robot {
    animation: none !important;
    transition: none !important;
    transform: none !important;
  }

  .shaivika-launcher-glow-ring {
    animation: none !important;
    display: none !important;
  }

  .shaivika-launcher-badge {
    animation: none !important;
  }

  .shaivika-chat-avatar-robot.is-thinking {
    animation: none !important;
  }

  .shaivika-thinking-spinner {
    animation: none !important;
  }

  .shaivika-typing-dot {
    animation: none !important;
  }

  .shaivika-chat-window {
    transition: opacity 0.1s ease !important;
  }
}
