/* Premium Sourcing AI Widget Stylesheet - Standalone CSS */
:root {
  --sourcing-primary: #1d1d1f;
  --sourcing-accent: #e72513;
  --sourcing-accent-light: #fff0ef;
  --sourcing-accent-hover: #c41e0f;
  --sourcing-slate-50: #f5f5f7;
  --sourcing-slate-100: #e8e8ed;
  --sourcing-slate-200: #d2d2d7;
  --sourcing-slate-300: #86868b;
  --sourcing-slate-400: #86868b;
  --sourcing-slate-500: #6e6e73;
  --sourcing-slate-700: #424245;
  --sourcing-slate-800: #1d1d1f;
  --sourcing-slate-900: #1d1d1f;
}

/* Scrollbar styling for widget */
.sourcing-widget-panel ::-webkit-scrollbar {
  width: 4px;
  height: 4px;
}
.sourcing-widget-panel ::-webkit-scrollbar-track {
  background: transparent;
}
.sourcing-widget-panel ::-webkit-scrollbar-thumb {
  background: var(--sourcing-slate-300);
  border-radius: 99px;
}
.sourcing-widget-panel ::-webkit-scrollbar-thumb:hover {
  background: var(--sourcing-slate-400);
}

/* FAB trigger button */
.sourcing-widget-fab {
  position: fixed;
  bottom: 24px;
  right: 24px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 99px;
  background-color: var(--sourcing-accent);
  color: #ffffff;
  border: none;
  cursor: pointer;
  z-index: 9999;
  padding: 0 20px;
  gap: 8px;
  box-shadow: 0 10px 25px rgba(231, 37, 19, 0.25);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 13px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  outline: none;
}
.sourcing-widget-fab:hover {
  transform: translateY(-2px) scale(1.03);
  background-color: var(--sourcing-accent-hover);
  box-shadow: 0 12px 28px rgba(231, 37, 19, 0.35);
}
.sourcing-widget-fab:active {
  transform: translateY(1px) scale(0.97);
}

/* Ping ring pulse */
.sourcing-widget-fab::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 99px;
  background-color: var(--sourcing-accent);
  opacity: 0.3;
  z-index: -1;
  animation: sourcing-ping 2.5s cubic-bezier(0, 0, 0.2, 1) infinite;
}
@keyframes sourcing-ping {
  75%, 100% {
    transform: scale(1.4);
    opacity: 0;
  }
}

.sourcing-widget-fab .sourcing-fab-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  height: 12px;
  width: 12px;
  background-color: #10b981;
  border: 2px solid #ffffff;
  border-radius: 50%;
}

/* Floating Dialog Viewport wrapper */
.sourcing-widget-viewport {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  pointer-events: none;
  z-index: 9998;
  opacity: 0;
  visibility: hidden;
  transform: translateY(20px);
  transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}
.sourcing-widget-viewport.open {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
  pointer-events: auto;
}

/* Backdrop */
.sourcing-widget-backdrop {
  position: absolute;
  inset: 0;
  background-color: rgba(29, 29, 31, 0.3);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  pointer-events: auto;
}

/* Main Dialog Card */
.sourcing-widget-panel {
  position: relative;
  width: 1200px;
  max-width: calc(100vw - 48px);
  background: rgba(255, 255, 255, 0.98);
  backdrop-filter: blur(12px);
  border: 1px solid rgba(226, 232, 240, 0.8);
  border-radius: 24px;
  box-shadow: 0 20px 45px rgba(29, 29, 31, 0.12);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  height: 900px;
  max-height: calc(100vh - 48px);
  pointer-events: auto;
  z-index: 10;
  transition: box-shadow 0.3s ease;
}

/* Dialog Header */
.sourcing-header {
  background: linear-gradient(135deg, var(--sourcing-slate-900), var(--sourcing-primary));
  padding: 16px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: #ffffff;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  position: relative;
  overflow: hidden;
}
.sourcing-header::after {
  content: '';
  position: absolute;
  top: 0;
  right: 0;
  width: 120px;
  height: 120px;
  background: rgba(231, 37, 19, 0.15);
  filter: blur(30px);
  border-radius: 50%;
  pointer-events: none;
}
.sourcing-header-left {
  display: flex;
  align-items: center;
  gap: 12px;
}
.sourcing-avatar-container {
  position: relative;
  width: 36px;
  height: 36px;
}
.sourcing-header-avatar {
  width: 100%;
  height: 100%;
  background: rgba(231, 37, 19, 0.15);
  border: 1px solid rgba(231, 37, 19, 0.3);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--sourcing-accent);
}
.sourcing-header-avatar svg {
  animation: sourcing-sparkle-pulse 2s infinite ease-in-out;
}
@keyframes sourcing-sparkle-pulse {
  0%, 100% { transform: scale(1); opacity: 0.7; }
  50% { transform: scale(1.15); opacity: 1; }
}
.sourcing-header-status {
  position: absolute;
  bottom: 0;
  right: 0;
  height: 10px;
  width: 10px;
  background-color: #10b981;
  border: 2px solid var(--sourcing-slate-900);
  border-radius: 50%;
}
.sourcing-header-title h3 {
  margin: 0;
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.3px;
}
.sourcing-header-subtitle {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 3px;
}
.sourcing-sub-active {
  font-size: 9px;
  color: #34d399;
  font-weight: 700;
}
.sourcing-sub-tag {
  font-size: 9px;
  color: var(--sourcing-slate-400);
  font-weight: 500;
}
.sourcing-header-close {
  background: transparent;
  border: none;
  color: var(--sourcing-slate-300);
  cursor: pointer;
  padding: 6px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}
.sourcing-header-close:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #ffffff;
}

/* Tabs Bar */
.sourcing-tabs-container {
  background-color: var(--sourcing-slate-50);
  border-bottom: 1px solid rgba(226, 232, 240, 0.6);
  padding: 10px 16px;
}
.sourcing-tabs-pills {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  background-color: rgba(226, 232, 240, 0.5);
  border-radius: 16px;
  padding: 4px;
}
.sourcing-tab-btn {
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 8px 4px;
  border-radius: 12px;
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: center;
  gap: 6px;
  color: var(--sourcing-slate-500);
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
}
.sourcing-tab-btn:hover {
  color: var(--sourcing-slate-800);
}
.sourcing-tab-btn.active {
  background-color: #ffffff;
  color: var(--sourcing-accent);
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.04);
}

/* Panel Body Panels */
.sourcing-panels {
  flex: 1;
  background: rgba(248, 250, 252, 0.3);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  height: 775px;
}
.sourcing-tab-panel {
  display: none;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
}
.sourcing-tab-panel.active {
  display: flex;
}

/* 1. Chat tab panel layout */
.sourcing-chat-layout {
  padding: 16px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  height: 100%;
  box-sizing: border-box;
}
.sourcing-chat-stream {
  flex: 1;
  overflow-y: auto;
  padding-right: 4px;
  margin-bottom: 8px;
}
.sourcing-msg-row {
  display: flex;
  flex-direction: column;
  margin-bottom: 12px;
  width: 100%;
}
.sourcing-msg-row.user {
  align-items: flex-end;
}
.sourcing-msg-row.ai {
  align-items: flex-start;
}
.sourcing-bubble {
  max-width: 85%;
  border-radius: 16px;
  padding: 10px 14px;
  font-size: 12px;
  line-height: 1.5;
  word-wrap: break-word;
  white-space: pre-wrap;
}
.sourcing-msg-row.user .sourcing-bubble {
  background: linear-gradient(135deg, var(--sourcing-accent), #f08e5a);
  color: #ffffff;
  border-bottom-right-radius: 2px;
  box-shadow: 0 3px 10px rgba(231, 37, 19, 0.15);
}
.sourcing-msg-row.ai .sourcing-bubble {
  background-color: #ffffff;
  color: var(--sourcing-slate-800);
  border: 1px solid var(--sourcing-slate-200);
  border-bottom-left-radius: 2px;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.02);
}

/* Product recommendation slider */
.sourcing-recommendations {
  width: 100%;
  margin-top: 10px;
}
.sourcing-recom-title {
  font-size: 9px;
  text-transform: uppercase;
  color: var(--sourcing-slate-400);
  font-weight: 700;
  letter-spacing: 0.5px;
  margin-left: 4px;
  margin-bottom: 6px;
  display: block;
}
.sourcing-recom-slider {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  padding-bottom: 6px;
}
.sourcing-product-card {
  flex-shrink: 0;
  width: 190px;
  background-color: #ffffff;
  border: 1px solid var(--sourcing-slate-200);
  border-radius: 12px;
  padding: 8px;
  box-shadow: 0 2px 6px rgba(0,0,0,0.02);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}
.sourcing-prod-header {
  display: flex;
  gap: 8px;
  align-items: flex-start;
}
.sourcing-prod-img {
  width: 36px;
  height: 36px;
  border-radius: 6px;
  object-fit: cover;
  border: 1px solid var(--sourcing-slate-100);
}
.sourcing-prod-meta {
  min-width: 0;
}
.sourcing-prod-name {
  margin: 0;
  font-size: 10px;
  font-weight: 800;
  color: var(--sourcing-slate-900);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sourcing-prod-moq {
  font-size: 8px;
  color: var(--sourcing-slate-400);
  font-weight: 700;
  margin-top: 2px;
  display: block;
}
.sourcing-prod-btn {
  margin-top: 8px;
  width: 100%;
  padding: 5px 0;
  border-radius: 8px;
  font-size: 8px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  text-align: center;
  border: 1px solid var(--sourcing-slate-900);
  background: var(--sourcing-slate-900);
  color: #ffffff;
  cursor: pointer;
  transition: all 0.2s ease;
}
.sourcing-prod-btn:hover {
  background: var(--sourcing-slate-800);
}
.sourcing-prod-btn.added {
  background-color: #ecfdf5;
  border-color: #a7f3d0;
  color: #059669;
}

/* Typing loader bubble */
.sourcing-typing-bubble {
  background-color: #ffffff;
  border: 1px solid var(--sourcing-slate-200);
  border-radius: 16px;
  padding: 10px 14px;
  display: flex;
  gap: 4px;
  align-items: center;
  width: 48px;
  justify-content: center;
}
.sourcing-dot {
  width: 6px;
  height: 6px;
  background-color: var(--sourcing-slate-400);
  border-radius: 50%;
  animation: sourcing-bounce 1.4s infinite ease-in-out both;
}
.sourcing-dot:nth-child(1) { animation-delay: -0.32s; }
.sourcing-dot:nth-child(2) { animation-delay: -0.16s; }
@keyframes sourcing-bounce {
  0%, 80%, 100% { transform: scale(0); }
  40% { transform: scale(1); }
}

/* Quick suggest chips */
.sourcing-chips-container {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding: 6px 0;
  border-top: 1px solid var(--sourcing-slate-100);
  flex-shrink: 0;
}
.sourcing-chip {
  flex-shrink: 0;
  background-color: var(--sourcing-slate-100);
  border: 1px solid rgba(226, 232, 240, 0.6);
  color: var(--sourcing-slate-700);
  font-size: 9px;
  font-weight: 700;
  padding: 5px 10px;
  border-radius: 99px;
  cursor: pointer;
  transition: all 0.2s ease;
}
.sourcing-chip:hover {
  background-color: var(--sourcing-slate-200);
  color: var(--sourcing-slate-900);
}

/* Chat input bar */
.sourcing-input-bar {
  border-top: 1px solid var(--sourcing-slate-150);
  padding-top: 8px;
  display: flex;
  gap: 8px;
  align-items: center;
  flex-shrink: 0;
}
.sourcing-chat-input {
  flex-grow: 1;
  background-color: var(--sourcing-slate-50);
  border: 1px solid var(--sourcing-slate-200);
  border-radius: 12px;
  padding: 8px 12px;
  font-size: 12px;
  color: var(--sourcing-slate-800);
  outline: none;
  transition: all 0.2s ease;
}
.sourcing-chat-input:focus {
  background-color: #ffffff;
  border-color: var(--sourcing-accent);
  box-shadow: 0 0 0 3px rgba(231, 37, 19, 0.1);
}
.sourcing-chat-submit {
  height: 32px;
  width: 32px;
  border-radius: 10px;
  background-color: var(--sourcing-accent);
  color: #ffffff;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s ease;
}
.sourcing-chat-submit:hover {
  background-color: var(--sourcing-accent-hover);
}

/* 2. RFQ Form Panel Layout */
.sourcing-form-layout {
  padding: 16px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  height: 100%;
  box-sizing: border-box;
}
.sourcing-form-success {
  text-align: center;
  margin: auto 0;
}
.sourcing-success-icon {
  margin: 0 auto 16px;
  height: 48px;
  width: 48px;
  border-radius: 50%;
  background-color: #ecfdf5;
  color: #059669;
  display: flex;
  align-items: center;
  justify-content: center;
}
.sourcing-success-icon svg {
  width: 24px;
  height: 24px;
}
.sourcing-form-success h4 {
  margin: 0;
  font-size: 14px;
  font-weight: 800;
  color: var(--sourcing-slate-900);
}
.sourcing-form-success p {
  font-size: 10px;
  color: var(--sourcing-slate-500);
  line-height: 1.6;
  margin: 10px 0 20px;
}
.sourcing-reset-btn {
  background-color: #ffffff;
  border: 1px solid var(--sourcing-slate-200);
  color: var(--sourcing-slate-700);
  padding: 8px 16px;
  font-size: 10px;
  font-weight: 700;
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.2s ease;
}
.sourcing-reset-btn:hover {
  background-color: var(--sourcing-slate-50);
}

/* Form inputs styling */
.sourcing-form {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  height: 100%;
}
.sourcing-attached-indicator {
  background-color: var(--sourcing-accent-light);
  border: 1px solid #a7f3d0;
  border-radius: 10px;
  padding: 8px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 9px;
  color: var(--sourcing-accent);
  font-weight: 800;
  margin-bottom: 6px;
}
.sourcing-form-row-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 10px;
}
.sourcing-field {
  margin-bottom: 10px;
  display: flex;
  flex-direction: column;
}
.sourcing-field label {
  font-size: 8px;
  font-weight: 800;
  text-transform: uppercase;
  color: var(--sourcing-slate-500);
  margin-bottom: 4px;
  letter-spacing: 0.3px;
}
.sourcing-field input, .sourcing-field textarea {
  background-color: rgba(241, 245, 249, 0.4);
  border: 1px solid var(--sourcing-slate-200);
  border-radius: 8px;
  padding: 6px 10px;
  font-size: 12px;
  color: var(--sourcing-slate-800);
  outline: none;
  transition: all 0.2s ease;
  font-family: inherit;
}
.sourcing-field input:focus, .sourcing-field textarea:focus {
  background-color: #ffffff;
  border-color: var(--sourcing-accent);
  box-shadow: 0 0 0 3px rgba(231, 37, 19, 0.1);
}
.sourcing-field textarea {
  resize: none;
}
.sourcing-form-submit {
  width: 100%;
  background-color: var(--sourcing-accent);
  color: #ffffff;
  border: none;
  border-radius: 12px;
  padding: 10px 0;
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(231, 37, 19, 0.15);
  transition: all 0.2s ease;
  margin-top: 4px;
}
.sourcing-form-submit:hover {
  background-color: var(--sourcing-accent-hover);
}
.sourcing-form-submit:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

/* 3. WhatsApp Panel Layout */
.sourcing-whatsapp-layout {
  padding: 20px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
  height: 100%;
  box-sizing: border-box;
}
.sourcing-profile-wrapper {
  position: relative;
  margin-bottom: 12px;
}
.sourcing-profile-border {
  height: 64px;
  width: 64px;
  border-radius: 50%;
  border: 2px solid rgba(16, 185, 129, 0.2);
  padding: 2px;
}
.sourcing-profile-img {
  height: 100%;
  width: 100%;
  border-radius: 50%;
  background-color: var(--sourcing-slate-100);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--sourcing-primary);
  font-size: 20px;
  font-weight: 900;
}
.sourcing-profile-active {
  position: absolute;
  bottom: 0;
  right: 0;
  height: 14px;
  width: 14px;
  background-color: #10b981;
  border: 2px solid #ffffff;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}
.sourcing-profile-active::before {
  content: '';
  width: 6px;
  height: 6px;
  background-color: #ffffff;
  border-radius: 50%;
  animation: sourcing-ping-small 2s infinite;
}
@keyframes sourcing-ping-small {
  0% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.4); opacity: 0.3; }
  100% { transform: scale(1); opacity: 1; }
}
.sourcing-whatsapp-layout h4 {
  margin: 0;
  font-size: 14px;
  font-weight: 800;
  color: var(--sourcing-slate-900);
}
.sourcing-whatsapp-layout .role {
  font-size: 8px;
  font-weight: 800;
  color: var(--sourcing-accent);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-top: 4px;
  display: block;
}
.sourcing-whatsapp-layout .quote {
  font-size: 10.5px;
  color: var(--sourcing-slate-500);
  line-height: 1.6;
  margin: 10px 0;
  padding: 0 10px;
  font-style: italic;
}
.sourcing-whatsapp-stats {
  display: flex;
  justify-content: center;
  gap: 16px;
  font-size: 9px;
  color: var(--sourcing-slate-400);
  font-weight: 700;
  margin-bottom: 16px;
}
.sourcing-wa-btn {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background-color: #10b981;
  color: #ffffff;
  border: none;
  border-radius: 12px;
  padding: 10px 0;
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  cursor: pointer;
  box-shadow: 0 4px 15px rgba(16, 185, 129, 0.2);
  text-decoration: none;
  transition: all 0.2s ease;
}
.sourcing-wa-btn:hover {
  background-color: #059669;
  box-shadow: 0 6px 18px rgba(16, 185, 129, 0.3);
}

/* Helper hidden utilities */
.sourcing-hide {
  display: none !important;
}

/* Mobile Responsiveness for Standalone Embed */
@media (max-width: 480px) {
  .sourcing-widget-fab {
    bottom: 16px;
    right: 16px;
    height: 48px;
    width: 48px;
    padding: 0;
    gap: 0;
  }
  .sourcing-widget-fab .sourcing-fab-text {
    display: none;
  }
  .sourcing-widget-viewport {
    padding: 8px;
    bottom: 0px;
  }
  .sourcing-widget-panel {
    border-radius: 20px;
    max-height: 480px;
  }
  .sourcing-panels {
    height: 340px;
  }
}

/* AI Model Selector Bar */
.sourcing-model-selector-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background-color: var(--sourcing-slate-100);
  border: 1px solid var(--sourcing-slate-200);
  border-radius: 12px;
  padding: 6px 12px;
  margin-bottom: 10px;
  font-size: 11px;
}
.sourcing-model-selector-label {
  font-weight: 700;
  color: var(--sourcing-slate-500);
  display: flex;
  align-items: center;
  gap: 4px;
}
.sourcing-model-selector-select {
  background-color: #ffffff;
  border: 1px solid var(--sourcing-slate-200);
  border-radius: 8px;
  padding: 3px 8px;
  font-size: 10.5px;
  font-weight: 700;
  color: var(--sourcing-slate-800);
  outline: none;
  cursor: pointer;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
  transition: border-color 0.2s ease;
}
.sourcing-model-selector-select:focus {
  border-color: var(--sourcing-accent);
}

