/* AI Shopping Assistant - Frontend Styles (Template-based Design) */

:root {
  --ai-primary-color: #F9A825;
  --ai-secondary-color: #F9A825;
  --ai-body-bg: #9dbfde;
  --ai-container-width: 360px;
  --ai-container-height: 500px;
}

/* Chat Widget Container */
.ai-chat-widget {
  position: fixed;
  z-index: 9999;
  font-family: Arial, sans-serif;
  --primary-color: var(--ai-primary-color);
  --secondary-color: var(--ai-secondary-color);
}

.ai-chat-bottom-right {
  bottom: 20px;
  right: 20px;
}

.ai-chat-bottom-left {
  bottom: 20px;
  left: 20px;
}

/* Chat Button (Bot Avatar) */
.ai-chat-button {
  height: 48px;
  width: 48px;
  cursor: pointer;
  border-radius: 50%;
  background-color: var(--primary-color);
  border: none;
  box-shadow: 0 0 6px rgba(0, 0, 0, 0.3);
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s ease;
  position: relative;
}

.ai-chat-button:hover {
  transform: scale(1.05);
}

.ai-chat-button:active {
  transform: scale(0.95);
}

.ai-chat-button svg {
  width: 28px;
  height: 28px;
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.2));
  position: absolute;
  transition: opacity 0.2s ease, transform 0.2s ease;
  color: var(--secondary-color);
  stroke: var(--secondary-color);
  fill: var(--secondary-color);
}

/* Bot icon visible by default */
.ai-chat-button .ai-bot-icon {
  opacity: 1;
  transform: scale(1) rotate(0deg);
}

/* Close icon hidden by default */
.ai-chat-button .ai-close-icon {
  opacity: 0;
  transform: scale(0) rotate(90deg);
  width: 24px;
  height: 24px;
}

/* When chat is open, swap icons */
.ai-chat-button.chat-open .ai-bot-icon {
  opacity: 0;
  transform: scale(0) rotate(-90deg);
}

.ai-chat-button.chat-open .ai-close-icon {
  opacity: 1;
  transform: scale(1) rotate(0deg);
}

/* Unread Badge */
.ai-unread-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  background: #ef4444;
  color: white;
  border-radius: 50%;
  min-width: 18px;
  height: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: bold;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

/* Greeting Tooltip */
.ai-greeting-tooltip {
  position: absolute;
  bottom: 60px;
  right: 70px;
  background: white;
  color: #333;
  padding: 12px 16px;
  border-radius: 8px;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.15);
  font-size: 14px;
  max-width: 200px;
  width: 170px;
  opacity: 1;
  transition: opacity 0.3s ease, transform 0.3s ease;
  pointer-events: none;
  z-index: 9998;
}

.ai-greeting-tooltip::after {
  content: "";
  position: absolute;
  bottom: -6px;
  right: 20px;
  width: 12px;
  height: 12px;
  background: white;
  transform: rotate(45deg);
  box-shadow: 2px 2px 4px rgba(0, 0, 0, 0.1);
}

.ai-chat-bottom-left .ai-greeting-tooltip {
  right: auto;
}

.ai-chat-bottom-left .ai-greeting-tooltip::after {
  left: 20px;
  right: auto;
}

.ai-greeting-tooltip.hidden {
  opacity: 0;
  transform: translateY(10px);
  pointer-events: none;
}

/* Chat Window */
.ai-chat-window {
  position: absolute;
  bottom: 60px;
  width: min(var(--ai-container-width), calc(100vw - 40px));
  height: min(var(--ai-container-height), calc(100vh - 120px));
  background-color: #ffffff !important;
  border: 0;
  border-radius: 5px;
  box-shadow: 0 0 10px rgba(0, 0, 0, 0.3);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform-origin: bottom center;
}

.ai-chat-bottom-left .ai-chat-window {
  left: 20px;
  transform-origin: bottom left;
}

.ai-chat-bottom-right .ai-chat-window {
  right: 20px;
  transform-origin: bottom right;
}

/* Scale-in animation */
.ai-chat-window.animation-scale-in {
  animation: scale-in 0.2s ease-in-out forwards, fade-in 0.2s ease-in-out forwards;
}

/* Scale-out animation */
.ai-chat-window.animation-scale-out {
  animation: scale-out 0.2s ease-in-out forwards, fade-out 0.2s ease-in-out forwards;
}

.ai-chat-window.hidden {
  display: none;
}

/* Chat Header */
.ai-chat-header {
  background-color: var(--primary-color);
  color: #FFFFFF;
  padding: 10px;
  text-align: center;
  flex: 0 0 auto;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.ai-chat-header-content {
  width: 100%;
  display: flex;
  justify-content: center;
}

.ai-chat-header-text h3 {
  margin: 0;
  font-size: 16px;
  font-weight: normal;
  color: #FFFFFF;
}

/* Hide avatar, status, and close button elements */
.ai-chat-avatar,
.ai-chat-status,
.ai-chat-close,
.ai-chat-header-left,
.ai-chat-header-right {
  display: none;
}

/* Messages Container (Body) */
.ai-chat-messages {
  height: 300px;
  overflow-y: auto;
  padding: 8px;
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  background-color: #ffffff !important;
  gap: 12px;
}

.ai-chat-messages::-webkit-scrollbar {
  width: 6px;
}

.ai-chat-messages::-webkit-scrollbar-track {
  background: rgba(0, 0, 0, 0.05);
}

.ai-chat-messages::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, 0.2);
  border-radius: 3px;
}

.ai-chat-messages::-webkit-scrollbar-thumb:hover {
  background: rgba(0, 0, 0, 0.3);
}

/* Messages - Chat Bubble Style */
.ai-message {
  display: flex;
  gap: 8px;
  align-items: flex-end;
  margin-bottom: 8px;
}

.ai-message-user {
  justify-content: flex-end;
}

.ai-message-assistant {
  justify-content: flex-start;
}

.ai-message-content {
  max-width: 75%;
  display: flex;
  flex-direction: column;
}

.ai-message-bubble {
  padding: 10px 14px;
  border-radius: 18px;
  font-size: 14px;
  line-height: 1.4;
  word-wrap: break-word;
  direction: rtl;
  text-align: right;
  position: relative;
}

.ai-message-assistant .ai-message-bubble {
  background: white;
  color: #333;
  border-bottom-left-radius: 4px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.ai-message-user .ai-message-bubble {
  background: var(--primary-color);
  color: white;
  border-bottom-right-radius: 4px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.ai-message-time {
  font-size: 10px;
  color: rgba(0, 0, 0, 0.5);
  margin-top: 4px;
  padding: 0 4px;
  text-align: right;
  direction: rtl;
}

.ai-message-user .ai-message-time {
  color: rgba(255, 255, 255, 0.7);
}

/* Hide avatar */
.ai-message-avatar {
  display: none;
}

/* Typing Indicator */
.ai-typing-indicator {
  display: flex;
  align-items: center;
  gap: 8px;
}

.ai-typing-dots {
  display: flex;
  gap: 4px;
}

.ai-typing-dot {
  width: 8px;
  height: 8px;
  background: #9ca3af;
  border-radius: 50%;
  animation: ai-typing 1.4s infinite ease-in-out;
}

.ai-typing-dot:nth-child(1) { animation-delay: -0.32s; }
.ai-typing-dot:nth-child(2) { animation-delay: -0.16s; }

/* Quick Actions - Completely Hidden */
.ai-quick-actions {
  display: none !important; /* Force hide suggested prompts */
}

/* Input Container (Footer) */
.ai-chat-input-container {
  flex: 0 0 auto;
  border-top: solid 1px #f1f1f1;
  padding: 10px;
  background: #ffffff !important;
}

.ai-chat-form {
  display: flex;
  gap: 10px;
  align-items: center;
}

.ai-chat-input-wrapper {
  flex: 1;
  position: relative;
}

.ai-chat-input {
  width: 100% !important;
  border: 1px solid #ddd !important;
  border-radius: 3px !important;
  padding: 8px 12px !important;
  font-size: 14px !important;
  resize: none !important;
  outline: none !important;
  font-family: Arial, sans-serif !important;
  min-height: 20px !important;
  max-height: 80px !important;
  direction: ltr !important;
  text-align: left !important;
  overflow: auto !important;
}

.ai-chat-input:focus {
  border-color: var(--primary-color) !important;
}

.ai-chat-send {
  border: none;
  background-color: var(--primary-color);
  color: white;
  padding: 8px 14px;
  border-radius: 3px;
  position: relative;
  overflow: hidden;
  cursor: pointer;
  transition: opacity 0.2s ease;
  font-size: 14px;
  font-family: Arial, sans-serif;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 60px;
  flex-shrink: 0;
}

.ai-chat-send::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: var(--primary-color);
  mix-blend-mode: multiply;
  opacity: 0;
  transition: opacity 0.2s ease;
  pointer-events: none;
}

.ai-chat-send:hover::before,
.ai-chat-send:focus::before,
.ai-chat-send:active::before {
  opacity: 0.8;
}

.ai-chat-send:disabled {
  background: #ccc;
  cursor: not-allowed;
}

.ai-chat-send:disabled::before {
  display: none;
}

.ai-chat-send svg {
  width: 20px;
  height: 20px;
}

.ai-chat-send .ai-loading-icon {
  animation: ai-spin 1s linear infinite;
  width: 18px;
  height: 18px;
}

/* Product Carousel with Swiper */
.ai-product-carousel {
  margin-top: 12px;
  position: relative;
  width: 100%;
}

.ai-product-cards-header {
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--ai-border-color);
}

.ai-product-query {
  font-size: 13px;
  font-weight: 600;
  color: var(--ai-text-color);
  margin-bottom: 4px;
}

.ai-product-count {
  font-size: 11px;
  color: #6b7280;
}

/* Swiper Container */
.ai-product-swiper {
  width: 100%;
  padding: 4px 0 12px 0;
  margin: 0;
}

.ai-product-swiper .swiper-wrapper {
  align-items: stretch;
}

.ai-product-swiper .swiper-slide {
  height: auto;
  display: flex;
  width: 100%;
}

/* Product Card */
.ai-product-card {
  background: white;
  border: 1px solid rgba(0, 0, 0, 0.06);
  border-radius: 16px;
  overflow: hidden;
  text-decoration: none;
  color: inherit;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100%;
  box-shadow: var(--ai-shadow);
}

.ai-product-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--ai-shadow-lg);
  border-color: var(--primary-color);
}

.ai-product-card:active {
  transform: translateY(-2px);
}

/* Swiper Navigation Buttons */
.ai-product-swiper .swiper-button-prev,
.ai-product-swiper .swiper-button-next {
  background: white;
  border: 2px solid rgba(0, 0, 0, 0.06);
  border-radius: 50%;
  width: 42px;
  height: 42px;
  box-shadow: var(--ai-shadow);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  backdrop-filter: blur(10px);
}

.ai-product-swiper .swiper-button-prev:after,
.ai-product-swiper .swiper-button-next:after {
  font-size: 18px;
  font-weight: bold;
  color: var(--ai-text-color);
  transition: color 0.3s;
}

.ai-product-swiper .swiper-button-prev:hover,
.ai-product-swiper .swiper-button-next:hover {
  background: var(--ai-gradient);
  border-color: transparent;
  box-shadow: var(--ai-shadow-lg);
  transform: scale(1.1);
}

.ai-product-swiper .swiper-button-prev:hover:after,
.ai-product-swiper .swiper-button-next:hover:after {
  color: white;
}

.ai-product-swiper .swiper-button-disabled {
  opacity: 0.3;
  cursor: not-allowed;
  transform: scale(1) !important;
}

/* Swiper Pagination */
.ai-product-swiper .swiper-pagination {
  position: relative;
  margin-top: 12px;
}

.ai-product-swiper .swiper-pagination-bullet {
  background: var(--ai-border-color);
  opacity: 1;
  width: 8px;
  height: 8px;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.ai-product-swiper .swiper-pagination-bullet-active {
  background: var(--ai-gradient);
  width: 24px;
  border-radius: 4px;
  box-shadow: 0 2px 8px rgba(59, 130, 246, 0.4);
}

.ai-product-image-wrapper {
  position: relative;
  width: 100%;
  padding-top: 100%;
  overflow: hidden;
  background: linear-gradient(135deg, #f9fafb 0%, #f3f4f6 100%);
}

.ai-product-image {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.ai-product-card:hover .ai-product-image {
  transform: scale(1.08);
}

.ai-product-stock {
  position: absolute;
  top: 12px;
  right: 12px;
  padding: 6px 12px;
  border-radius: 20px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  backdrop-filter: blur(10px);
  box-shadow: var(--ai-shadow);
}

.ai-product-stock.in-stock {
  background: rgba(16, 185, 129, 0.95);
  color: white;
}

.ai-product-stock.out-of-stock {
  background: rgba(239, 68, 68, 0.95);
  color: white;
}

.ai-product-details {
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  flex: 1;
  background: white;
}

.ai-product-name {
  font-size: 15px;
  font-weight: 700;
  color: var(--ai-text-color);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  line-height: 1.5;
  letter-spacing: -0.01em;
  transition: color 0.2s;
}

.ai-product-card:hover .ai-product-name {
  color: var(--primary-color);
}

.ai-product-price {
  font-size: 18px;
  color: var(--primary-color);
  font-weight: 800;
  margin-top: auto;
  letter-spacing: -0.02em;
}

/* Animations */
/* Animations */
@keyframes scale-in {
  0% { transform: scale(0); }
  100% { transform: scale(1); }
}

@keyframes scale-out {
  0% { transform: scale(1); }
  100% { transform: scale(0); }
}

@keyframes fade-in {
  0% { opacity: 0; }
  50% { opacity: 1; }
  100% { opacity: 1; }
}

@keyframes fade-out {
  0% { opacity: 1; }
  50% { opacity: 0; }
  100% { opacity: 0; }
}

@keyframes ai-typing {
  0%, 80%, 100% {
    transform: scale(0);
  }
  40% {
    transform: scale(1);
  }
}

@keyframes ai-spin {
  0% {
    transform: rotate(0deg);
  }
  100% {
    transform: rotate(360deg);
  }
}

@keyframes ai-typing {
  0%, 80%, 100% {
    transform: scale(0);
  }
  40% {
    transform: scale(1);
  }
}

@keyframes ai-spin {
  0% {
    transform: rotate(0deg);
  }
  100% {
    transform: rotate(360deg);
  }
}

/* Responsive Design */
@media (max-width: 768px) {
  .ai-chat-widget {
    bottom: 10px;
    right: 10px;
    left: 10px;
  }
  
  .ai-chat-window {
    width: 100%;
    height: 70vh;
    max-height: 500px;
    bottom: 70px;
  }
  
  .ai-chat-bottom-right .ai-chat-window,
  .ai-chat-bottom-left .ai-chat-window {
    right: 0;
    left: 0;
  }

  /* Mobile carousel adjustments */
  .ai-product-swiper .swiper-button-prev,
  .ai-product-swiper .swiper-button-next {
    width: 30px;
    height: 30px;
  }

  .ai-product-swiper .swiper-button-prev:after,
  .ai-product-swiper .swiper-button-next:after {
    font-size: 14px;
  }
}

@media (max-width: 480px) {
  .ai-chat-window {
    width: calc(100vw - 20px) !important;
    height: 80vh !important;
    bottom: 70px !important;
    left: 10px !important;
    right: 10px !important;
    border-radius: 8px !important;
    position: fixed !important;
  }
  
  .ai-chat-bottom-right .ai-chat-window {
    left: 10px !important;
    right: 10px !important;
  }
  
  .ai-chat-bottom-left .ai-chat-window {
    left: 10px !important;
    right: 10px !important;
  }
  
  .ai-message-content {
    max-width: 90% !important;
  }
  
  .ai-message-bubble {
    width: 100% !important;
    max-width: 100% !important;
  }

  /* Smaller elements on mobile */
  .ai-product-details {
    padding: 10px;
  }

  .ai-product-name {
    font-size: 13px;
  }

  .ai-product-price {
    font-size: 14px;
  }

  .ai-product-swiper .swiper-button-prev,
  .ai-product-swiper .swiper-button-next {
    width: 32px;
    height: 32px;
  }

  .ai-product-swiper .swiper-button-prev:after,
  .ai-product-swiper .swiper-button-next:after {
    font-size: 14px;
  }
  
  /* Full width carousel slides */
  .ai-product-swiper {
    width: 100%;
    margin: 0;
    padding: 4px 0 12px 0;
  }
  
  .ai-product-card {
    width: 100%;
  }
}

/* Mobile Responsive */
@media (max-width: 480px) {
  .ai-message-content {
    max-width: 85%;
  }
  
  .ai-chat-input {
    font-size: 16px; /* Prevents zoom on iOS */
  }
}
