/* ==============================================================================
   StarTON AI Assistant - Floating Chatbot UI (3D Cosmic Aesthetic)
   Colors: White, Violet/Purple (#7c3aed, #8b5cf6), Royal Blue (#0284c7), Cyan (#06b6d4)
   ============================================================================== */

/* --- Floating Launcher Button --- */
#starton-ai-widget {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 999999;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  box-sizing: border-box;
}

#starton-ai-widget * {
  box-sizing: border-box;
}

.ai-launcher-btn {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: linear-gradient(135deg, #7c3aed 0%, #0284c7 100%);
  border: 2px solid #a855f7;
  box-shadow: 0 8px 24px rgba(124, 58, 237, 0.45), 0 0 18px rgba(6, 182, 212, 0.35);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  outline: none;
  padding: 0;
}

.ai-launcher-btn:hover {
  transform: scale(1.08) translateY(-3px);
  box-shadow: 0 12px 30px rgba(124, 58, 237, 0.6), 0 0 26px rgba(6, 182, 212, 0.5);
}

.ai-launcher-btn:active {
  transform: scale(0.96);
}

.ai-launcher-icon {
  width: 36px;
  height: 36px;
  object-fit: contain;
  filter: drop-shadow(0 2px 6px rgba(0, 0, 0, 0.25));
  transition: transform 0.3s ease;
}

.ai-launcher-btn:hover .ai-launcher-icon {
  transform: rotate(5deg) scale(1.08);
}

.ai-online-dot {
  position: absolute;
  top: 3px;
  right: 3px;
  width: 14px;
  height: 14px;
  background: #10b981;
  border: 2.5px solid #ffffff;
  border-radius: 50%;
  box-shadow: 0 0 8px #10b981;
  animation: ai-pulse-halo 2s infinite;
}

@keyframes ai-pulse-halo {
  0% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7); }
  70% { box-shadow: 0 0 0 8px rgba(16, 185, 129, 0); }
  100% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}

.ai-badge {
  position: absolute;
  top: -4px;
  left: -4px;
  background: #ef4444;
  color: #ffffff;
  font-size: 11px;
  font-weight: 800;
  padding: 2px 6px;
  border-radius: 10px;
  border: 2px solid #ffffff;
  box-shadow: 0 2px 6px rgba(0,0,0,0.2);
  display: none;
}

/* Tooltip bubble on first load */
.ai-launcher-tooltip {
  position: absolute;
  bottom: 74px;
  right: 0;
  background: #ffffff;
  color: #1e293b;
  padding: 10px 16px;
  border-radius: 12px;
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.15), 0 0 0 1px rgba(124, 58, 237, 0.15);
  border-left: 3px solid #7c3aed;
  opacity: 0;
  transform: translateY(10px);
  pointer-events: none;
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  gap: 8px;
}

.ai-launcher-tooltip.show {
  opacity: 1;
  transform: translateY(0);
}

.ai-launcher-tooltip::after {
  content: '';
  position: absolute;
  bottom: -6px;
  right: 26px;
  width: 12px;
  height: 12px;
  background: #ffffff;
  transform: rotate(45deg);
  box-shadow: 2px 2px 2px rgba(0,0,0,0.04);
}

/* --- Chat Container Window --- */
.ai-chat-window {
  position: absolute;
  bottom: 78px;
  right: 0;
  width: 390px;
  height: 620px;
  max-width: calc(100vw - 32px);
  max-height: calc(100vh - 100px);
  background: #ffffff;
  border-radius: 20px;
  box-shadow: 0 20px 45px -10px rgba(15, 23, 42, 0.25), 0 0 0 1px rgba(148, 163, 184, 0.2);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  opacity: 0;
  visibility: hidden;
  transform: translateY(20px) scale(0.96);
  transform-origin: bottom right;
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  border: 1px solid rgba(192, 132, 252, 0.35);
}

.ai-chat-window.open {
  opacity: 1;
  visibility: visible;
  transform: translateY(0) scale(1);
}

/* --- Chat Window Header --- */
.ai-header {
  background: linear-gradient(135deg, #6d28d9 0%, #0284c7 100%);
  padding: 14px 16px;
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid rgba(255, 255, 255, 0.15);
  box-shadow: 0 4px 12px rgba(109, 40, 217, 0.2);
  flex-shrink: 0;
}

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

.ai-avatar {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.18);
  border: 1.5px solid rgba(255, 255, 255, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 4px;
}

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

.ai-title-wrap {
  display: flex;
  flex-direction: column;
}

.ai-title {
  font-size: 14.5px;
  font-weight: 700;
  letter-spacing: 0.3px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.ai-status-text {
  font-size: 11px;
  color: #c4b5fd;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 5px;
}

.ai-status-indicator {
  width: 7px;
  height: 7px;
  background: #34d399;
  border-radius: 50%;
  display: inline-block;
}

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

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

.ai-ctrl-btn:hover {
  background: rgba(255, 255, 255, 0.28);
  transform: translateY(-1px);
}

.ai-ctrl-btn:active {
  transform: translateY(1px);
}

/* Language selector dropdown */
.ai-lang-select {
  background: rgba(255, 255, 255, 0.18);
  border: 1px solid rgba(255, 255, 255, 0.3);
  color: #ffffff;
  font-size: 11px;
  font-weight: 600;
  border-radius: 6px;
  padding: 3px 6px;
  outline: none;
  cursor: pointer;
}

.ai-lang-select option {
  background: #1e1b4b;
  color: #ffffff;
}

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

.ai-messages-area::-webkit-scrollbar {
  width: 5px;
}

.ai-messages-area::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 10px;
}

/* Welcome Card */
.ai-welcome-box {
  background: linear-gradient(180deg, #ffffff 0%, #f1f5f9 100%);
  border: 1px solid #e2e8f0;
  border-radius: 14px;
  padding: 16px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.04);
}

.ai-welcome-title {
  font-size: 14px;
  font-weight: 700;
  color: #4c1d95;
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.ai-welcome-text {
  font-size: 13px;
  line-height: 1.5;
  color: #334155;
  margin-bottom: 12px;
  white-space: pre-line;
}

/* Quick Action Buttons */
.ai-quick-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-top: 8px;
}

.ai-action-btn {
  background: #ffffff;
  color: #0369a1;
  border: 1px solid #bae6fd;
  border-radius: 20px;
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  transition: all 0.2s ease;
  box-shadow: 0 2px 4px rgba(2, 132, 199, 0.06);
}

.ai-action-btn:hover {
  background: #e0f2fe;
  border-color: #38bdf8;
  color: #0284c7;
  transform: translateY(-1px);
}

.ai-action-btn i {
  color: #7c3aed;
  font-size: 11px;
}

/* Chat Message Row */
.ai-message-row {
  display: flex;
  gap: 8px;
  max-width: 88%;
}

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

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

.ai-msg-avatar {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: #7c3aed;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #ffffff;
  font-size: 12px;
  flex-shrink: 0;
  margin-top: 2px;
}

.ai-message-bubble {
  padding: 10px 14px;
  border-radius: 14px;
  font-size: 13.5px;
  line-height: 1.5;
  position: relative;
  word-break: break-word;
}

.ai-message-row.user .ai-message-bubble {
  background: linear-gradient(135deg, #0284c7 0%, #0369a1 100%);
  color: #ffffff;
  border-bottom-right-radius: 2px;
  box-shadow: 0 4px 10px rgba(2, 132, 199, 0.25);
}

.ai-message-row.assistant .ai-message-bubble {
  background: #ffffff;
  color: #1e293b;
  border: 1px solid #e2e8f0;
  border-bottom-left-radius: 2px;
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.04);
}

/* Formatted Content inside Bubble */
.ai-message-bubble p {
  margin: 0 0 6px 0;
}
.ai-message-bubble p:last-child {
  margin-bottom: 0;
}
.ai-message-bubble strong {
  font-weight: 700;
  color: #0f172a;
}
.ai-message-row.user .ai-message-bubble strong {
  color: #ffffff;
}
.ai-message-bubble ul, .ai-message-bubble ol {
  margin: 6px 0 6px 18px;
  padding: 0;
}
.ai-message-bubble li {
  margin-bottom: 4px;
}
.ai-message-bubble a {
  color: #0284c7;
  text-decoration: underline;
  font-weight: 600;
}
.ai-message-bubble code {
  background: rgba(0, 0, 0, 0.06);
  padding: 2px 5px;
  border-radius: 4px;
  font-size: 12px;
  font-family: monospace;
}

/* Time & Actions Bar below AI message */
.ai-msg-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: 5px;
  font-size: 10.5px;
  color: #94a3b8;
}

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

.ai-icon-btn {
  background: transparent;
  border: none;
  color: #94a3b8;
  cursor: pointer;
  padding: 2px 4px;
  border-radius: 4px;
  font-size: 11px;
  transition: all 0.15s ease;
}

.ai-icon-btn:hover {
  color: #475569;
  background: #e2e8f0;
}

.ai-icon-btn.liked { color: #10b981; }
.ai-icon-btn.disliked { color: #ef4444; }

/* Product Cards Carousel inside Chat */
.ai-product-cards {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  margin-top: 8px;
  padding-bottom: 6px;
  scrollbar-width: thin;
}

.ai-product-card {
  min-width: 170px;
  max-width: 190px;
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  box-shadow: 0 2px 6px rgba(0,0,0,0.04);
}

.ai-prod-thumb {
  width: 100%;
  height: 70px;
  border-radius: 6px;
  object-fit: cover;
  background: #f1f5f9;
}

.ai-prod-name {
  font-size: 12px;
  font-weight: 700;
  color: #0f172a;
  line-height: 1.25;
}

.ai-prod-price {
  font-size: 11px;
  font-weight: 700;
  color: #d97706;
}

.ai-prod-btn {
  background: linear-gradient(180deg, #f59e0b 0%, #d97706 100%);
  color: #ffffff !important;
  font-size: 11px;
  font-weight: 700;
  padding: 5px;
  border-radius: 6px;
  text-align: center;
  text-decoration: none;
  box-shadow: 0 2px 0 #b45309;
}

/* Typing Indicator */
.ai-typing-indicator {
  display: none;
  align-items: center;
  gap: 4px;
  background: #ffffff;
  border: 1px solid #e2e8f0;
  padding: 8px 12px;
  border-radius: 12px;
  width: fit-content;
}

.ai-typing-indicator.show {
  display: flex;
}

.ai-typing-dot {
  width: 6px;
  height: 6px;
  background: #7c3aed;
  border-radius: 50%;
  animation: ai-dot-bounce 1.4s infinite ease-in-out both;
}

.ai-typing-dot:nth-child(1) { animation-delay: -0.32s; }
.ai-typing-dot:nth-child(2) { animation-delay: -0.16s; }

@keyframes ai-dot-bounce {
  0%, 80%, 100% { transform: scale(0); opacity: 0.4; }
  40% { transform: scale(1); opacity: 1; }
}

/* --- Support Handover Modal / Form --- */
.ai-support-form {
  background: #ffffff;
  border: 1.5px solid #a855f7;
  border-radius: 12px;
  padding: 14px;
  margin-top: 8px;
  display: none;
  box-shadow: 0 4px 14px rgba(168, 85, 247, 0.15);
}

.ai-support-form.show {
  display: block;
}

.ai-form-title {
  font-size: 13px;
  font-weight: 700;
  color: #6d28d9;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.ai-form-input, .ai-form-textarea, .ai-form-select {
  width: 100%;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  padding: 7px 10px;
  font-size: 12px;
  margin-bottom: 8px;
  outline: none;
  font-family: inherit;
}

.ai-form-input:focus, .ai-form-textarea:focus, .ai-form-select:focus {
  border-color: #7c3aed;
  box-shadow: 0 0 0 2px rgba(124, 58, 237, 0.15);
}

.ai-form-submit-btn {
  background: linear-gradient(135deg, #7c3aed 0%, #0284c7 100%);
  color: #ffffff;
  border: none;
  padding: 8px 14px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  width: 100%;
}

/* --- Input Area Bar --- */
.ai-input-bar {
  background: #ffffff;
  border-top: 1px solid #e2e8f0;
  padding: 10px 14px;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.ai-input-bar input {
  flex-grow: 1;
  border: 1.5px solid #e2e8f0;
  border-radius: 24px;
  padding: 9px 16px;
  font-size: 13.5px;
  outline: none;
  transition: all 0.2s ease;
  font-family: inherit;
  color: #1e293b;
}

.ai-input-bar input:focus {
  border-color: #7c3aed;
  box-shadow: 0 0 0 3px rgba(124, 58, 237, 0.12);
}

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

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

.ai-mic-btn.recording {
  background: #ef4444 !important;
  color: #ffffff !important;
  animation: ai-pulse-mic 1s infinite alternate;
}

@keyframes ai-pulse-mic {
  0% { transform: scale(1); box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.6); }
  100% { transform: scale(1.1); box-shadow: 0 0 0 8px rgba(239, 68, 68, 0); }
}

.ai-send-btn {
  background: linear-gradient(135deg, #7c3aed 0%, #0284c7 100%);
  border: none;
  color: #ffffff;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 14px;
  transition: all 0.2s ease;
  box-shadow: 0 4px 10px rgba(124, 58, 237, 0.3);
  padding: 0;
}

.ai-send-btn:hover {
  transform: scale(1.06);
  box-shadow: 0 6px 14px rgba(124, 58, 237, 0.45);
}

.ai-send-btn:active {
  transform: scale(0.94);
}

/* --- Mobile Responsiveness --- */
@media (max-width: 480px) {
  #starton-ai-widget {
    bottom: 16px;
    right: 16px;
  }
  .ai-chat-window {
    bottom: 0;
    right: 0;
    width: 100vw;
    height: 100vh;
    max-width: 100vw;
    max-height: 100vh;
    border-radius: 0;
  }
}
