/* ==========================================================================
   SAMA AI SHOPPING ASSISTANT — ULTRA PREMIUM GLASSMORPHIC STYLES
   Scoped with #sama-ai-widget to avoid all theme CSS collisions.
   ========================================================================== */

:root {
  --sama-ai-primary: var(--theme-primary, #1DB954);
  --sama-ai-primary-hover: var(--theme-primary-hover, #169b45);
  --sama-ai-accent: var(--theme-accent, #6366f1);
  --sama-ai-font: var(--theme-font, 'Plus Jakarta Sans', 'Inter', -apple-system, BlinkMacSystemFont, sans-serif);
  --sama-ai-bg: #ffffff;
  --sama-ai-card-bg: #f8fafc;
  --sama-ai-text: #0f172a;
  --sama-ai-text-muted: #64748b;
  --sama-ai-border: #e2e8f0;
  --sama-ai-shadow: 0 20px 40px -15px rgba(0, 0, 0, 0.18), 0 0 0 1px rgba(0, 0, 0, 0.05);
}

#sama-ai-widget {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 999999;
  font-family: var(--sama-ai-font);
  box-sizing: border-box;
}

#sama-ai-widget * {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

/* --------------------------------------------------------------------------
   Floating Launcher Trigger Button
   -------------------------------------------------------------------------- */
.sama-ai-trigger {
  width: 62px;
  height: 62px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--sama-ai-primary) 0%, var(--sama-ai-accent) 100%);
  color: #ffffff;
  border: none;
  cursor: pointer;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.22), 0 0 0 3px rgba(255, 255, 255, 0.8);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.3s ease;
  outline: none;
}

.sama-ai-trigger:hover {
  transform: scale(1.08) translateY(-2px);
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.28), 0 0 0 4px rgba(255, 255, 255, 0.95);
}

.sama-ai-trigger:active {
  transform: scale(0.96);
}

.sama-ai-trigger-icon {
  width: 28px;
  height: 28px;
  transition: transform 0.3s ease, opacity 0.2s ease;
}

.sama-ai-close-icon {
  width: 22px;
  height: 22px;
  display: none;
  transition: transform 0.3s ease;
}

#sama-ai-widget.open .sama-ai-trigger-icon {
  display: none;
}

#sama-ai-widget.open .sama-ai-close-icon {
  display: block;
  transform: rotate(90deg);
}

/* Pulsing Online Ring */
.sama-ai-pulse-ring {
  position: absolute;
  top: -4px;
  left: -4px;
  right: -4px;
  bottom: -4px;
  border-radius: 50%;
  border: 2px solid var(--sama-ai-primary);
  opacity: 0.8;
  animation: samaAiPulse 2.4s infinite cubic-bezier(0.25, 0.46, 0.45, 0.94);
  pointer-events: none;
}

@keyframes samaAiPulse {
  0% { transform: scale(0.95); opacity: 0.8; }
  50% { transform: scale(1.18); opacity: 0; }
  100% { transform: scale(1.25); opacity: 0; }
}

.sama-ai-badge {
  position: absolute;
  top: -2px;
  right: -2px;
  background: #ef4444;
  color: #fff;
  font-size: 10px;
  font-weight: 800;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid #ffffff;
  box-shadow: 0 2px 6px rgba(0,0,0,0.2);
}

/* --------------------------------------------------------------------------
   Chat Container / Popover Window
   -------------------------------------------------------------------------- */
.sama-ai-box {
  position: absolute;
  bottom: 80px;
  right: 0;
  width: 410px;
  max-width: calc(100vw - 32px);
  height: 640px;
  max-height: calc(100vh - 120px);
  background: var(--sama-ai-bg);
  border-radius: 20px;
  box-shadow: var(--sama-ai-shadow);
  border: 1px solid var(--sama-ai-border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  opacity: 0;
  visibility: hidden;
  transform: translateY(20px) scale(0.94);
  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),
              visibility 0.3s;
}

#sama-ai-widget.open .sama-ai-box {
  opacity: 1;
  visibility: visible;
  transform: translateY(0) scale(1);
}

/* --------------------------------------------------------------------------
   Chat Header
   -------------------------------------------------------------------------- */
.sama-ai-header {
  background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
  color: #ffffff;
  padding: 16px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  flex-shrink: 0;
}

.sama-ai-header-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.sama-ai-avatar {
  width: 38px;
  height: 38px;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--sama-ai-primary) 0%, var(--sama-ai-accent) 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #ffffff;
  font-weight: 800;
  font-size: 16px;
  position: relative;
  box-shadow: 0 4px 10px rgba(0,0,0,0.25);
}

.sama-ai-online-dot {
  position: absolute;
  bottom: -2px;
  right: -2px;
  width: 10px;
  height: 10px;
  background: #22c55e;
  border: 2px solid #0f172a;
  border-radius: 50%;
}

.sama-ai-title-wrap h3 {
  font-size: 15px;
  font-weight: 700;
  color: #ffffff;
  line-height: 1.2;
  letter-spacing: -0.2px;
}

.sama-ai-title-wrap p {
  font-size: 11px;
  color: #94a3b8;
  margin-top: 2px;
}

.sama-ai-header-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.sama-ai-icon-btn {
  background: rgba(255, 255, 255, 0.08);
  border: none;
  color: #cbd5e1;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
  font-size: 13px;
}

.sama-ai-icon-btn:hover {
  background: rgba(255, 255, 255, 0.18);
  color: #ffffff;
}

/* --------------------------------------------------------------------------
   Messages Feed Area
   -------------------------------------------------------------------------- */
.sama-ai-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  background: #f8fafc;
  scroll-behavior: smooth;
}

.sama-ai-body::-webkit-scrollbar {
  width: 5px;
}
.sama-ai-body::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 4px;
}

/* Message Rows */
.sama-ai-msg-row {
  display: flex;
  gap: 10px;
  align-items: flex-end;
  animation: samaAiSlideUp 0.25s ease-out;
}

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

.sama-ai-msg-row.user {
  flex-direction: row-reverse;
}

.sama-ai-msg-avatar {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: #0f172a;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  flex-shrink: 0;
}

.sama-ai-msg-bubble {
  max-width: 84%;
  padding: 12px 16px;
  border-radius: 16px;
  font-size: 13.5px;
  line-height: 1.5;
  word-break: break-word;
}

.sama-ai-msg-row.assistant .sama-ai-msg-bubble {
  background: #ffffff;
  color: #1e293b;
  border: 1px solid #e2e8f0;
  border-bottom-left-radius: 4px;
  box-shadow: 0 2px 6px rgba(0,0,0,0.03);
}

.sama-ai-msg-row.user .sama-ai-msg-bubble {
  background: linear-gradient(135deg, var(--sama-ai-primary) 0%, var(--sama-ai-accent) 100%);
  color: #ffffff;
  border-bottom-right-radius: 4px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.08);
}

.sama-ai-msg-time {
  font-size: 10px;
  color: #94a3b8;
  margin-top: 4px;
  display: block;
}

.sama-ai-msg-row.user .sama-ai-msg-time {
  text-align: right;
  color: rgba(255,255,255,0.7);
}

/* Typing Indicator */
.sama-ai-typing {
  display: flex;
  gap: 5px;
  padding: 12px 16px;
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 16px;
  border-bottom-left-radius: 4px;
  width: fit-content;
  align-items: center;
}

.sama-ai-typing span {
  width: 6px;
  height: 6px;
  background: #94a3b8;
  border-radius: 50%;
  animation: samaAiBounce 1.2s infinite ease-in-out;
}

.sama-ai-typing span:nth-child(2) { animation-delay: 0.2s; }
.sama-ai-typing span:nth-child(3) { animation-delay: 0.4s; }

@keyframes samaAiBounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
  30% { transform: translateY(-5px); opacity: 1; }
}

/* --------------------------------------------------------------------------
   RICH VISUAL WIDGETS
   -------------------------------------------------------------------------- */

/* 1. Product Cards Grid / Horizontal Carousel inside chat */
.sama-ai-product-grid {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 10px;
  width: 100%;
}

.sama-ai-product-card {
  display: flex;
  gap: 12px;
  padding: 12px;
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 14px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.04);
  transition: transform 0.2s, box-shadow 0.2s;
  align-items: center;
}

.sama-ai-product-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(0,0,0,0.08);
  border-color: #cbd5e1;
}

.sama-ai-product-img {
  width: 68px;
  height: 68px;
  border-radius: 10px;
  background: #f1f5f9;
  object-fit: contain;
  padding: 4px;
  flex-shrink: 0;
}

.sama-ai-product-info {
  flex: 1;
  min-width: 0;
}

.sama-ai-product-title {
  font-size: 13px;
  font-weight: 600;
  color: #0f172a;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-decoration: none;
  display: block;
}

.sama-ai-product-meta {
  font-size: 11px;
  color: #64748b;
  margin-top: 2px;
}

.sama-ai-product-price-row {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 4px;
}

.sama-ai-product-price {
  font-size: 14px;
  font-weight: 700;
  color: var(--sama-ai-primary);
}

.sama-ai-product-old-price {
  font-size: 11px;
  color: #94a3b8;
  text-decoration: line-through;
}

.sama-ai-product-discount {
  font-size: 10px;
  font-weight: 700;
  color: #ef4444;
  background: #fee2e2;
  padding: 1px 6px;
  border-radius: 4px;
}

.sama-ai-btn-add-cart {
  padding: 6px 12px;
  background: var(--sama-ai-primary);
  color: #ffffff;
  border: none;
  border-radius: 8px;
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.2s, transform 0.1s;
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}

.sama-ai-btn-add-cart:hover {
  background: var(--sama-ai-primary-hover);
  transform: scale(1.04);
}

.sama-ai-btn-add-cart:active {
  transform: scale(0.96);
}

.sama-ai-btn-add-cart.added {
  background: #10b981;
}

/* 2. Order Tracking Timeline Widget */
.sama-ai-tracking-widget {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 14px;
  padding: 14px;
  margin-top: 10px;
}

.sama-ai-tracking-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid #f1f5f9;
  padding-bottom: 8px;
  margin-bottom: 12px;
}

.sama-ai-tracking-stepper {
  display: flex;
  justify-content: space-between;
  position: relative;
  margin: 16px 8px;
}

.sama-ai-tracking-stepper::before {
  content: '';
  position: absolute;
  top: 12px;
  left: 0;
  right: 0;
  height: 3px;
  background: #e2e8f0;
  z-index: 1;
}

.sama-ai-step {
  position: relative;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.sama-ai-step-circle {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: #ffffff;
  border: 3px solid #cbd5e1;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  color: #64748b;
  transition: all 0.3s;
}

.sama-ai-step.completed .sama-ai-step-circle {
  background: #10b981;
  border-color: #10b981;
  color: #ffffff;
}

.sama-ai-step.active .sama-ai-step-circle {
  background: var(--sama-ai-primary);
  border-color: var(--sama-ai-primary);
  color: #ffffff;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.2);
}

.sama-ai-step-label {
  font-size: 10px;
  font-weight: 600;
  color: #64748b;
  text-align: center;
}

.sama-ai-step.completed .sama-ai-step-label,
.sama-ai-step.active .sama-ai-step-label {
  color: #0f172a;
}

/* 3. Coupon Voucher Widget */
.sama-ai-coupon-card {
  background: linear-gradient(135deg, #fffbeb 0%, #fef3c7 100%);
  border: 1.5px dashed #f59e0b;
  border-radius: 12px;
  padding: 12px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 8px;
}

.sama-ai-coupon-code {
  font-family: monospace;
  font-size: 14px;
  font-weight: 800;
  color: #b45309;
  letter-spacing: 1px;
}

.sama-ai-coupon-btn {
  padding: 6px 14px;
  background: #b45309;
  color: #ffffff;
  border: none;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s;
}

.sama-ai-coupon-btn:hover {
  background: #92400e;
}

/* 4. Cart Summary Widget */
.sama-ai-cart-summary {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 14px;
  padding: 14px;
  margin-top: 10px;
}

.sama-ai-cart-row {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: #64748b;
  margin-bottom: 6px;
}

.sama-ai-cart-total-row {
  display: flex;
  justify-content: space-between;
  font-size: 14px;
  font-weight: 700;
  color: #0f172a;
  border-top: 1px solid #f1f5f9;
  padding-top: 8px;
  margin-top: 6px;
}

.sama-ai-btn-checkout {
  display: block;
  width: 100%;
  padding: 10px;
  background: #0f172a;
  color: #ffffff;
  text-align: center;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 700;
  text-decoration: none;
  margin-top: 10px;
  transition: background 0.2s;
}

.sama-ai-btn-checkout:hover {
  background: #1e293b;
  color: #ffffff;
}

/* --------------------------------------------------------------------------
   Quick Action Chips Tray
   -------------------------------------------------------------------------- */
.sama-ai-chips-tray {
  padding: 8px 16px;
  display: flex;
  gap: 8px;
  overflow-x: auto;
  background: #ffffff;
  border-top: 1px solid #f1f5f9;
  flex-shrink: 0;
  white-space: nowrap;
}

.sama-ai-chips-tray::-webkit-scrollbar {
  height: 3px;
}
.sama-ai-chips-tray::-webkit-scrollbar-thumb {
  background: #e2e8f0;
  border-radius: 2px;
}

.sama-ai-chip {
  background: #f1f5f9;
  color: #334155;
  border: 1px solid #e2e8f0;
  padding: 6px 12px;
  border-radius: 20px;
  font-size: 11.5px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  flex-shrink: 0;
  outline: none;
}

.sama-ai-chip:hover {
  background: var(--sama-ai-primary);
  color: #ffffff;
  border-color: var(--sama-ai-primary);
  transform: translateY(-1px);
}

/* --------------------------------------------------------------------------
   Input Bar & Controls
   -------------------------------------------------------------------------- */
.sama-ai-footer {
  padding: 12px 16px;
  background: #ffffff;
  border-top: 1px solid var(--sama-ai-border);
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.sama-ai-input {
  flex: 1;
  border: 1px solid #e2e8f0;
  background: #f8fafc;
  padding: 10px 14px;
  border-radius: 24px;
  font-size: 13px;
  color: #0f172a;
  outline: none;
  font-family: inherit;
  transition: border-color 0.2s, background 0.2s;
}

.sama-ai-input:focus {
  border-color: var(--sama-ai-primary);
  background: #ffffff;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.sama-ai-voice-btn {
  background: #f1f5f9;
  border: none;
  color: #64748b;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
  font-size: 14px;
  outline: none;
  flex-shrink: 0;
}

.sama-ai-voice-btn:hover {
  background: #e2e8f0;
  color: #0f172a;
}

.sama-ai-voice-btn.recording {
  background: #ef4444;
  color: #ffffff;
  animation: samaAiMicPulse 1.2s infinite;
}

@keyframes samaAiMicPulse {
  0% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.5); }
  70% { box-shadow: 0 0 0 8px rgba(239, 68, 68, 0); }
  100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0); }
}

.sama-ai-send-btn {
  background: var(--sama-ai-primary);
  border: none;
  color: #ffffff;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
  font-size: 14px;
  outline: none;
  flex-shrink: 0;
}

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

.sama-ai-send-btn:disabled {
  background: #cbd5e1;
  cursor: not-allowed;
  transform: none;
}

/* --------------------------------------------------------------------------
   Mobile Responsive Adjustments
   -------------------------------------------------------------------------- */
@media (max-width: 576px) {
  #sama-ai-widget {
    bottom: 16px;
    right: 16px;
  }
  .sama-ai-box {
    bottom: 74px;
    right: 0;
    width: calc(100vw - 32px);
    height: calc(100vh - 100px);
    max-height: 580px;
    border-radius: 16px;
  }
}
