/* ==========================================================================
   SR CHEMICALS INDUSTRIES - AI CHATBOT WIDGET STYLES
   Inspired by ChatGPT & Intercom - Glassmorphism, Modern & Fast UI
   ========================================================================== */

:root {
  --src-primary: #0F5286;
  --src-primary-hover: #0a3d66;
  --src-accent: #2773B7;
  --src-green: #67B346;
  --src-light-bg: #f8fafc;
  --src-card-bg: #ffffff;
  --src-text-main: #0f172a;
  --src-text-muted: #64748b;
  --src-border: rgba(15, 82, 134, 0.12);
  --src-user-bubble: linear-gradient(135deg, #0F5286 0%, #2773B7 100%);
  --src-bot-bubble: #ffffff;
  --src-shadow: 0 12px 40px -10px rgba(15, 82, 134, 0.22);
  --src-glass: rgba(255, 255, 255, 0.85);
  --src-font: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

#srcThemeToggle {
  display: none !important;
}

/* Dark Theme Variables */
[data-sr-theme="dark"] {
  --src-light-bg: #0b1329;
  --src-card-bg: #131e3a;
  --src-text-main: #f1f5f9;
  --src-text-muted: #94a3b8;
  --src-border: rgba(255, 255, 255, 0.1);
  --src-user-bubble: linear-gradient(135deg, #2773B7 0%, #0F5286 100%);
  --src-bot-bubble: #19274e;
  --src-shadow: 0 12px 40px -10px rgba(0, 0, 0, 0.6);
  --src-glass: rgba(19, 30, 58, 0.85);
}

/* Ultra-Premium Floating Trigger Button */
.src-chat-trigger {
  position: fixed !important;
  bottom: 28px !important;
  right: 28px !important;
  width: 64px !important;
  height: 64px !important;
  min-width: 64px !important;
  min-height: 64px !important;
  max-width: 64px !important;
  max-height: 64px !important;
  border-radius: 50% !important;
  padding: 0 !important;
  margin: 0 !important;
  aspect-ratio: 1 / 1 !important;
  background: linear-gradient(135deg, #0F5286 0%, #2773B7 100%) !important;
  color: #ffffff !important;
  border: 2px solid rgba(255, 255, 255, 0.45) !important;
  box-shadow: 0 10px 30px rgba(15, 82, 134, 0.4), 0 0 0 0 rgba(39, 115, 183, 0.4) !important;
  cursor: pointer !important;
  z-index: 999999 !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  outline: none !important;
  transition: all 0.35s cubic-bezier(0.34, 1.56, 0.64, 1) !important;
  animation: srcPulseRing 3s infinite ease-in-out !important;
}

@keyframes srcPulseRing {
  0% { box-shadow: 0 10px 30px rgba(15, 82, 134, 0.4), 0 0 0 0 rgba(39, 115, 183, 0.45); }
  70% { box-shadow: 0 14px 38px rgba(15, 82, 134, 0.5), 0 0 0 14px rgba(39, 115, 183, 0); }
  100% { box-shadow: 0 10px 30px rgba(15, 82, 134, 0.4), 0 0 0 0 rgba(39, 115, 183, 0); }
}

.src-chat-trigger:hover {
  transform: scale(1.1) translateY(-4px);
  box-shadow: 0 16px 40px rgba(15, 82, 134, 0.55);
}

.src-badge-pulse {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 16px;
  height: 16px;
  background: #67B346;
  border: 2.5px solid #ffffff;
  border-radius: 50%;
  box-shadow: 0 2px 6px rgba(0,0,0,0.2);
}

.src-badge-pulse::after {
  content: '';
  position: absolute;
  top: -2.5px;
  left: -2.5px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 2px solid #67B346;
  animation: pingBadge 1.8s cubic-bezier(0, 0, 0.2, 1) infinite;
}

@keyframes pingBadge {
  75%, 100% { transform: scale(1.8); opacity: 0; }
}

.src-trigger-icon-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.3s ease;
}

.src-chat-trigger.open .src-trigger-icon-wrap {
  transform: rotate(90deg);
}

.src-chat-trigger .src-icon-close {
  display: none;
  font-size: 26px;
}

.src-chat-trigger.open .src-icon-chat {
  display: none;
}

.src-chat-trigger.open .src-icon-close {
  display: block;
}

/* Main Chat Container */
.src-chat-widget {
  position: fixed;
  bottom: 104px;
  right: 28px;
  width: 420px;
  max-width: calc(100vw - 36px);
  height: 640px;
  max-height: calc(100vh - 140px);
  background: var(--src-light-bg);
  border-radius: 20px;
  box-shadow: var(--src-shadow);
  border: 1px solid var(--src-border);
  z-index: 999998;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  font-family: var(--src-font);
  opacity: 0;
  transform: translateY(20px) scale(0.95);
  pointer-events: none;
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.src-chat-widget.active {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: all;
}

/* Widget Header */
.src-chat-header {
  background: linear-gradient(135deg, #0F5286 0%, #1e5a96 100%);
  color: #ffffff;
  padding: 16px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.08);
}

.src-header-info {
  display: flex;
  align-items: center;
  gap: 12px;
}

.src-avatar-wrap {
  position: relative;
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background: #ffffff;
  padding: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.src-avatar-wrap img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.src-online-dot {
  position: absolute;
  bottom: 0px;
  right: 0px;
  width: 12px;
  height: 12px;
  background: var(--src-green);
  border: 2px solid #ffffff;
  border-radius: 50%;
}

.src-header-title {
  font-size: 16px;
  font-weight: 700;
  margin: 0;
  color: #ffffff;
  line-height: 1.2;
}

.src-header-status {
  font-size: 12px;
  opacity: 0.85;
  margin: 2px 0 0 0;
  display: flex;
  align-items: center;
  gap: 4px;
}

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

.src-btn-icon {
  background: rgba(255, 255, 255, 0.15);
  border: none;
  color: #ffffff;
  width: 34px;
  height: 34px;
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  transition: background 0.2s;
}

.src-btn-icon:hover {
  background: rgba(255, 255, 255, 0.3);
}

/* Chat Messages Area */
.src-chat-body {
  flex: 1;
  padding: 20px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
  scroll-behavior: smooth;
}

.src-message-row {
  display: flex;
  flex-direction: column;
  max-width: 88%;
  animation: fadeInMsg 0.3s ease-out forwards;
}

@keyframes fadeInMsg {
  from {
    opacity: 0;
    transform: translateY(8px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.src-message-row.user {
  align-self: flex-end;
}

.src-message-row.bot {
  align-self: flex-start;
}

.src-msg-bubble {
  padding: 14px 18px;
  border-radius: 18px;
  font-size: 14px;
  line-height: 1.55;
  position: relative;
  word-break: break-word;
}

.src-message-row.user .src-msg-bubble {
  background: var(--src-user-bubble);
  color: #ffffff;
  border-bottom-right-radius: 4px;
  box-shadow: 0 4px 15px rgba(15, 82, 134, 0.2);
}

.src-message-row.bot .src-msg-bubble {
  background: var(--src-bot-bubble);
  color: var(--src-text-main);
  border-bottom-left-radius: 4px;
  border: 1px solid var(--src-border);
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.04);
}

/* Markdown Formatting inside bot bubble */
.src-msg-bubble p {
  margin: 0 0 8px 0;
}

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

.src-msg-bubble h3 {
  font-size: 16px;
  font-weight: 700;
  margin: 4px 0 8px 0;
  color: #0F5286;
}

[data-sr-theme="dark"] .src-msg-bubble h3 {
  color: #60a5fa;
}

.src-msg-bubble h4 {
  font-size: 14px;
  font-weight: 700;
  margin: 10px 0 4px 0;
}

.src-msg-bubble ul {
  margin: 4px 0 8px 18px;
  padding: 0;
}

.src-msg-bubble li {
  margin-bottom: 4px;
}

.src-msg-bubble code {
  background: rgba(15, 82, 134, 0.08);
  padding: 2px 6px;
  border-radius: 4px;
  font-family: monospace;
  font-size: 13px;
}

[data-sr-theme="dark"] .src-msg-bubble code {
  background: rgba(255, 255, 255, 0.15);
  color: #93c5fd;
}

.src-msg-bubble a {
  color: var(--src-accent);
  text-decoration: underline;
  font-weight: 600;
}

.src-msg-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-size: 11px;
  color: var(--src-text-muted);
  margin-top: 4px;
  padding: 0 4px;
}

.src-copy-btn {
  background: none;
  border: none;
  color: var(--src-text-muted);
  cursor: pointer;
  font-size: 12px;
  padding: 2px 4px;
  transition: color 0.2s;
}

.src-copy-btn:hover {
  color: var(--src-primary);
}

/* Hide legacy scroll to top button ONLY */
.progress-wrap {
  display: none !important;
}

/* Typing Indicator */
.src-typing-indicator {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 12px 18px;
  background: var(--src-bot-bubble);
  border-radius: 18px;
  border-bottom-left-radius: 4px;
  width: fit-content;
  border: 1px solid var(--src-border);
}

.src-typing-indicator span {
  width: 7px;
  height: 7px;
  background: var(--src-primary);
  border-radius: 50%;
  animation: typingBounce 1.4s infinite ease-in-out both;
}

.src-typing-indicator span:nth-child(1) {
  animation-delay: -0.32s;
}

.src-typing-indicator span:nth-child(2) {
  animation-delay: -0.16s;
}

@keyframes typingBounce {

  0%,
  80%,
  100% {
    transform: scale(0);
  }

  40% {
    transform: scale(1);
  }
}

/* Suggested Questions Pills - Hidden */
.src-suggestions-wrap, .src-suggestion-chip {
  display: none !important;
}

/* Product Card UI */
.src-card-product {
  background: var(--src-card-bg);
  border-radius: 14px;
  padding: 14px;
  border: 1px solid var(--src-border);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.05);
  margin-top: 10px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.src-card-header {
  display: flex;
  gap: 12px;
  align-items: center;
}

.src-card-img {
  width: 56px;
  height: 56px;
  border-radius: 8px;
  object-fit: cover;
  border: 1px solid var(--src-border);
}

.src-card-title-wrap {
  flex: 1;
}

.src-card-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--src-text-main);
  margin: 0;
}

.src-card-badge {
  display: inline-block;
  background: #e0f2fe;
  color: #0369a1;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 10px;
  margin-top: 4px;
}

.src-card-actions {
  display: flex;
  gap: 8px;
  margin-top: 4px;
}

.src-btn-card {
  flex: 1;
  text-align: center;
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 600;
  text-decoration: none !important;
  transition: all 0.2s;
}

.src-btn-card-primary {
  background: var(--src-primary);
  color: #ffffff !important;
}

.src-btn-card-primary:hover {
  background: var(--src-primary-hover);
}

.src-btn-card-outline {
  border: 1px solid var(--src-primary);
  color: var(--src-primary) !important;
}

.src-btn-card-outline:hover {
  background: rgba(15, 82, 134, 0.08);
}

/* Glassmorphism Input Area */
.src-chat-footer {
  padding: 12px 16px;
  background: var(--src-glass);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-top: 1px solid var(--src-border);
}

.src-input-form {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  background: var(--src-card-bg);
  border: 1.5px solid var(--src-border);
  border-radius: 16px;
  padding: 8px 12px;
  transition: border-color 0.2s;
}

.src-input-form:focus-within {
  border-color: var(--src-primary);
  box-shadow: 0 0 0 3px rgba(15, 82, 134, 0.12);
}

.src-chat-input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  font-size: 14px;
  color: var(--src-text-main);
  resize: none;
  max-height: 100px;
  line-height: 1.4;
  font-family: inherit;
}

.src-send-btn {
  background: var(--src-primary);
  color: #ffffff;
  border: none;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  transition: all 0.2s;
  flex-shrink: 0;
}

.src-send-btn:hover {
  background: var(--src-primary-hover);
  transform: scale(1.05);
}

.src-send-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Mobile Responsiveness */
@media (max-width: 480px) {
  .src-chat-widget {
    right: 12px;
    bottom: 85px;
    width: calc(100vw - 24px);
    height: calc(100vh - 110px);
    border-radius: 16px;
  }

  .src-chat-trigger {
    right: 16px;
    bottom: 16px;
    width: 56px;
    height: 56px;
    font-size: 22px;
  }
}