/* ==========================================================================
   1. DESIGN SYSTEM & ROOT VARIABLES
   ========================================================================== */
:root {
  --sr-chatbot-accent-start: #FD7B41;
  --sr-chatbot-accent-end: #ff9b6b;
  --sr-chatbot-gradient: linear-gradient(135deg, var(--sr-chatbot-accent-start) 0%, var(--sr-chatbot-accent-end) 100%);
  --sr-chatbot-surface: rgba(255, 255, 255, 0.85);
  --sr-chatbot-surface-strong: rgba(255, 255, 255, 0.98);
  --sr-chatbot-border: rgba(255, 255, 255, 0.4);
  --sr-chatbot-text: #0f172a;
  --sr-chatbot-muted: #64748b;
  --sr-chatbot-shadow: 0 20px 50px rgba(15, 23, 42, 0.18);
  --sr-chatbot-panel-width: min(92vw, 380px);
  --sr-chatbot-radius: 24px;
  
  /* Animation Timing Functions */
  --ease-out-back: cubic-bezier(0.34, 1.56, 0.64, 1);
  --ease-out-expo: cubic-bezier(0.16, 1, 0.3, 1);
}

/* ==========================================================================
   2. BASE & RESET
   ========================================================================== */
* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: Inter, "Segoe UI", Roboto, Arial, sans-serif;
  background: linear-gradient(135deg, #eef6ff 0%, #f7fcff 100%);
  min-height: 100vh;
}

/* ==========================================================================
   3. DEMO SHELL BACKGROUND (For testing layout)
   ========================================================================== */
.sr-chatbot-demo-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.sr-chatbot-demo-card {
  max-width: 600px;
  text-align: center;
  padding: 32px;
  border-radius: var(--sr-chatbot-radius);
  background: rgba(255, 255, 255, 0.7);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid rgba(255, 255, 255, 0.5);
  box-shadow: 0 30px 60px rgba(15, 23, 42, 0.08);
}

.sr-chatbot-demo-label {
  margin: 0 0 12px;
  color: var(--sr-chatbot-accent-start);
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

.sr-chatbot-demo-title {
  margin: 0 0 12px;
  font-size: 2.2rem;
  font-weight: 800;
  color: var(--sr-chatbot-text);
}

.sr-chatbot-demo-copy {
  margin: 0;
  color: var(--sr-chatbot-muted);
  line-height: 1.6;
}

/* ==========================================================================
   4. CHATBOT CORE LAYER
   ========================================================================== */
.sr-chatbot-shell {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 2147483647;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  justify-content: flex-end;
  gap: 16px;
  pointer-events: none;
  isolation: isolate;
}

.sr-chatbot-launcher,
.sr-chatbot-panel {
  pointer-events: auto;
}

.sr-chatbot-launcher {
  position: relative;
  width: 64px;
  height: 64px;
  border: 0;
  border-radius: 50%;
  display: grid;
  place-items: center;
  cursor: pointer;
  background: var(--sr-chatbot-gradient);
  color: #fff;
  box-shadow: 0 16px 36px rgba(253, 123, 65, 0.35);
  transition: transform 0.3s var(--ease-out-back), box-shadow 0.3s ease;
  animation: sr-chatbot-float 3s ease-in-out infinite;
  margin: 0;
}

.sr-chatbot-launcher:hover {
  transform: translateY(-5px) scale(1.05);
  box-shadow: 0 22px 44px rgba(253, 123, 65, 0.45);
}

.sr-chatbot-launcher:active {
  transform: scale(0.95);
}

.sr-chatbot-panel {
  position: absolute;
  right: 0;
  bottom: calc(100% + 16px);
  width: var(--sr-chatbot-panel-width);
  height: 600px;
  max-height: 75vh;
  border-radius: var(--sr-chatbot-radius);
  overflow: hidden;
  background: var(--sr-chatbot-surface);
  backdrop-filter: blur(25px);
  -webkit-backdrop-filter: blur(25px);
  border: 1px solid var(--sr-chatbot-border);
  box-shadow: var(--sr-chatbot-shadow);
  display: flex;
  flex-direction: column;
  margin: 0;
  transform-origin: bottom right;
  transform: translateY(30px) scale(0.88);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: transform 0.4s var(--ease-out-back),
              opacity 0.3s ease,
              visibility 0.3s ease;
}

.sr-chatbot-launcher:hover .sr-chatbot-launcher-icon {
  transform: rotate(15deg);
}

.sr-chatbot-launcher-badge {
  position: absolute;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #22c55e;
  border: 2px solid #fff;
  right: 2px;
  top: 2px;
  box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.6);
  animation: sr-chatbot-badge-glow 2s infinite;
}

/* Chat window Entry & Exit Transitions */
.sr-chatbot-panel {
  position: absolute;
  right: 0;
  bottom: calc(100% + 16px);
  width: var(--sr-chatbot-panel-width);
  height: 600px;
  max-height: 75vh;
  border-radius: var(--sr-chatbot-radius);
  overflow: hidden;
  background: var(--sr-chatbot-surface);
  backdrop-filter: blur(25px);
  -webkit-backdrop-filter: blur(25px);
  border: 1px solid var(--sr-chatbot-border);
  box-shadow: var(--sr-chatbot-shadow);
  display: flex;
  flex-direction: column;
  margin: 0;
  
  /* State Control Animation Configuration */
  transform-origin: bottom right;
  transform: translateY(30px) scale(0.88);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: transform 0.4s var(--ease-out-back), 
              opacity 0.3s ease, 
              visibility 0.3s ease;
}

/* Activated Window Class */
.sr-chatbot-panel.sr-chatbot-open,
.sr-chatbot-panel.sr-chatbot-is-open {
  transform: translateY(0) scale(1);
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

.sr-chatbot-panel.sr-chatbot-is-minimized,
.sr-chatbot-hidden {
  display: none !important;
}

/* ==========================================================================
   5. CHAT COMPONENTS
   ========================================================================== */
.sr-chatbot-header {
  padding: 18px 20px;
  background: var(--sr-chatbot-gradient);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.sr-chatbot-header-main {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.sr-chatbot-avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.18);
  border: 1px solid rgba(255, 255, 255, 0.24);
  display: grid;
  place-items: center;
  font-weight: 800;
  letter-spacing: 0.04em;
  box-shadow: inset 0 1px 4px rgba(255, 255, 255, 0.2);
}

.sr-chatbot-title {
  margin: 0 0 2px;
  font-size: 1rem;
  font-weight: 700;
}

.sr-chatbot-status {
  margin: 0;
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.82rem;
  color: rgba(255, 255, 255, 0.88);
}

.sr-chatbot-status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #bbf7d0;
  box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.16);
}

.sr-chatbot-header-actions {
  display: flex;
  gap: 8px;
}

.sr-chatbot-icon-button {
  width: 32px;
  height: 32px;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: background 0.2s ease, transform 0.2s ease;
}

.sr-chatbot-icon-button:hover {
  background: rgba(255, 255, 255, 0.28);
  transform: translateY(-1px);
}

/* Message Display Feed Container */
.sr-chatbot-message-area {
  padding: 20px 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  overflow-y: auto;
  flex: 1;
  background: linear-gradient(180deg, rgba(248, 250, 252, 0.95) 0%, rgba(241, 245, 249, 0.92) 100%);
  scroll-behavior: smooth;
}

.sr-chatbot-message-area::-webkit-scrollbar {
  width: 6px;
}

.sr-chatbot-message-area::-webkit-scrollbar-thumb {
  background: rgba(253, 123, 65, 0.2);
  border-radius: 10px;
}

/* Chat Bubbles & Entry Scale Animations */
.sr-chatbot-bubble,
.sr-chatbot-message-bubble {
  max-width: 85%;
  padding: 12px 16px;
  border-radius: 18px;
  font-size: 0.94rem;
  line-height: 1.5;
  box-shadow: 0 4px 15px rgba(15, 23, 42, 0.04);
  word-break: break-word;
  animation: sr-chatbot-pop-in 0.35s var(--ease-out-back) forwards;
}

.sr-chatbot-bubble-user,
.sr-chatbot-message-bubble-user {
  align-self: flex-end;
  background: var(--sr-chatbot-gradient);
  color: #fff;
  border-bottom-right-radius: 4px;
  transform-origin: bottom right;
}

.sr-chatbot-bubble-assistant,
.sr-chatbot-message-bubble-assistant {
  align-self: flex-start;
  background: #fff;
  color: var(--sr-chatbot-text);
  border-bottom-left-radius: 4px;
  border: 1px solid rgba(15, 23, 42, 0.03);
  transform-origin: bottom left;
}

/* Enhanced Wave Typing Indicator */
.sr-chatbot-typing {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 12px 16px;
  background: #fff;
  border-radius: 18px;
  width: fit-content;
  box-shadow: 0 4px 15px rgba(15, 23, 42, 0.04);
  border-bottom-left-radius: 4px;
  animation: sr-chatbot-pop-in 0.3s var(--ease-out-back) forwards;
}

.sr-chatbot-typing span,
.sr-chatbot-typing-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--sr-chatbot-accent-start) 0%, var(--sr-chatbot-accent-end) 100%);
  display: inline-block;
  animation: sr-chatbot-wave 1.2s infinite ease-in-out;
}

.sr-chatbot-typing span:nth-child(2),
.sr-chatbot-typing-dot:nth-child(2) {
  animation-delay: 0.15s;
}

.sr-chatbot-typing span:nth-child(3),
.sr-chatbot-typing-dot:nth-child(3) {
  animation-delay: 0.3s;
}

/* Quick Actions List */
.sr-chatbot-quick-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 4px 16px 12px;
  background: rgba(255, 255, 255, 0.95);
}

.sr-chatbot-quick-action {
  border: 1px solid rgba(253, 123, 65, 0.15);
  border-radius: 20px;
  padding: 8px 14px;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--sr-chatbot-accent-start);
  background: #fff;
  cursor: pointer;
  transition: transform 0.2s cubic-bezier(0.2, 0.8, 0.2, 1), 
              box-shadow 0.2s ease, 
              background 0.2s ease, 
              color 0.2s ease;
}

.sr-chatbot-quick-action:hover {
  transform: translateY(-2px);
  background: var(--sr-chatbot-gradient);
  color: #fff;
  border-color: transparent;
  box-shadow: 0 8px 20px rgba(253, 123, 65, 0.2);
}

/* Chat Input Bar Form Elements */
.sr-chatbot-form {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  background: var(--sr-chatbot-surface-strong);
  border-top: 1px solid rgba(148, 163, 184, 0.15);
}

.sr-chatbot-input {
  flex: 1;
  border: 1px solid rgba(148, 163, 184, 0.25);
  border-radius: 28px;
  padding: 0 16px;
  height: 48px;
  font-size: 0.95rem;
  outline: none;
  background: #fff;
  color: var(--sr-chatbot-text);
  transition: border-color 0.25s ease, box-shadow 0.25s ease;
}

.sr-chatbot-input:focus {
  border-color: var(--sr-chatbot-accent-start);
  box-shadow: 0 0 0 3px rgba(253, 123, 65, 0.12);
}

.sr-chatbot-send-button {
  border: 0;
  border-radius: 50%;
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--sr-chatbot-gradient);
  color: #fff;
  cursor: pointer;
  box-shadow: 0 6px 16px rgba(253, 123, 65, 0.25);
  transition: transform 0.2s var(--ease-out-back), box-shadow 0.2s ease;
}

.sr-chatbot-send-button:hover {
  transform: scale(1.08) translateY(-1px);
  box-shadow: 0 8px 22px rgba(253, 123, 65, 0.35);
}

.sr-chatbot-send-button:active {
  transform: scale(0.95);
}

/* ==========================================================================
   6. ANIMATIONS & KEYFRAMES DEFINITIONS
   ========================================================================== */

/* Launcher Hover Idle Floating Animation */
@keyframes sr-chatbot-float {
  0%, 100% {
    transform: translateY(0);
    box-shadow: 0 16px 36px rgba(253, 123, 65, 0.35);
  }
  50% {
    transform: translateY(-6px);
    box-shadow: 0 24px 46px rgba(253, 123, 65, 0.25);
  }
}

/* Notification Badge Radial Pulse Loop */
@keyframes sr-chatbot-badge-glow {
  0% {
    box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.7);
  }
  70% {
    box-shadow: 0 0 0 6px rgba(34, 197, 94, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(34, 197, 94, 0);
  }
}

/* Pop-in scaling animation for fresh chat item streams */
@keyframes sr-chatbot-pop-in {
  0% {
    opacity: 0;
    transform: scale(0.82) translateY(12px);
  }
  100% {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

/* Wave Loading Motion for Typing dots */
@keyframes sr-chatbot-wave {
  0%, 60%, 100% {
    transform: translateY(0);
    opacity: 0.4;
  }
  30% {
    transform: translateY(-6px);
    opacity: 1;
  }
}

/* ==========================================================================
   7. RESPONSIVE BREAKPOINTS
   ========================================================================== */
@media (max-width: 640px) {
  .sr-chatbot-shell {
    right: 12px;
    bottom: 12px;
  }

  .sr-chatbot-panel {
    width: min(95vw, 360px);
    height: 80vh;
    max-height: 80vh;
    margin-right: 0;
  }
  
  .sr-chatbot-form {
    padding: 12px;
    gap: 8px;
  }
  
  .sr-chatbot-input {
    height: 44px;
  }
  
  .sr-chatbot-send-button {
    width: 44px;
    height: 44px;
  }
}