/* ==========================================================================
   Ajwa Store - AI Shopping Assistant Styles
   ========================================================================== */

:root {
  --ai-primary: #27ae60;
  --ai-primary-hover: #219653;
  --ai-primary-glow: rgba(39, 174, 96, 0.35);
  --ai-accent: #f39c12;
  --ai-bg: #ffffff;
  --ai-card-bg: #f8fafc;
  --ai-text-main: #1e293b;
  --ai-text-muted: #64748b;
  --ai-border: #e2e8f0;
  --ai-user-bubble: #27ae60;
  --ai-bot-bubble: #f1f5f9;
}

/* Floating AI Button */
.ai-assistant-btn {
  position: fixed;
  bottom: 95px;
  left: 25px; /* RTL friendly default, placed away from cart or on opposite side */
  z-index: 1050;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: linear-gradient(135deg, #10b981 0%, #059669 50%, #047857 100%);
  color: #ffffff;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 8px 24px var(--ai-primary-glow), 0 2px 6px rgba(0, 0, 0, 0.12);
  transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  outline: none;
}

html[dir="rtl"] .ai-assistant-btn {
  left: 25px;
  right: auto;
}

html[dir="ltr"] .ai-assistant-btn {
  right: 25px;
  left: auto;
}

.ai-assistant-btn:hover {
  transform: translateY(-4px) scale(1.05);
  box-shadow: 0 12px 28px rgba(16, 185, 129, 0.5);
  color: #fff;
}

.ai-assistant-btn:active {
  transform: scale(0.95);
}

.ai-assistant-btn .ai-icon-robot {
  width: 32px;
  height: 32px;
  fill: currentColor;
  transition: transform 0.3s ease;
}

.ai-assistant-btn:hover .ai-icon-robot {
  transform: rotate(10deg);
}

.ai-assistant-btn .ai-badge-pulse {
  position: absolute;
  top: -2px;
  right: -2px;
  width: 14px;
  height: 14px;
  background: #f59e0b;
  border: 2px solid #ffffff;
  border-radius: 50%;
  animation: ai-pulse 2s infinite;
}

@keyframes ai-pulse {
  0% {
    box-shadow: 0 0 0 0 rgba(245, 158, 11, 0.7);
  }
  70% {
    box-shadow: 0 0 0 8px rgba(245, 158, 11, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(245, 158, 11, 0);
  }
}

/* Tooltip on button hover */
.ai-assistant-tooltip {
  position: absolute;
  bottom: 72px;
  background: #1e293b;
  color: #ffffff;
  padding: 6px 12px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transform: translateY(6px);
  transition: all 0.25s ease;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.ai-assistant-btn:hover + .ai-assistant-tooltip,
.ai-assistant-tooltip.show {
  opacity: 1;
  transform: translateY(0);
}

/* AI Chat Window Modal / Drawer */
.ai-chat-window {
  position: fixed;
  bottom: 25px;
  width: 390px;
  max-width: calc(100vw - 32px);
  height: 600px;
  max-height: calc(100vh - 50px);
  background: #ffffff;
  border-radius: 20px;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.18), 0 0 0 1px rgba(0, 0, 0, 0.05);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: 1060;
  transform: translateY(20px) scale(0.95);
  opacity: 0;
  pointer-events: none;
  transition: all 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}

html[dir="rtl"] .ai-chat-window {
  left: 25px;
  right: auto;
}

html[dir="ltr"] .ai-chat-window {
  right: 25px;
  left: auto;
}

.ai-chat-window.open {
  transform: translateY(0) scale(1);
  opacity: 1;
  pointer-events: auto;
}

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

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

.ai-avatar {
  width: 40px;
  height: 40px;
  background: linear-gradient(135deg, #10b981, #059669);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  box-shadow: 0 2px 8px rgba(16, 185, 129, 0.4);
}

.ai-header-info h4 {
  margin: 0;
  font-size: 15px;
  font-weight: 700;
  color: #ffffff;
  display: flex;
  align-items: center;
  gap: 6px;
}

.ai-status-indicator {
  display: inline-block;
  width: 8px;
  height: 8px;
  background: #10b981;
  border-radius: 50%;
  box-shadow: 0 0 6px #10b981;
}

.ai-header-info small {
  display: block;
  font-size: 11px;
  color: #94a3b8;
}

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

.ai-header-btn {
  background: rgba(255, 255, 255, 0.1);
  border: none;
  color: #ffffff;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.2s;
}

.ai-header-btn:hover {
  background: rgba(255, 255, 255, 0.2);
}

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

/* Messages */
.ai-msg {
  display: flex;
  flex-direction: column;
  max-width: 85%;
  animation: ai-fadeIn 0.25s ease-out;
}

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

.ai-msg.user {
  align-self: flex-end;
}

.ai-msg.bot {
  align-self: flex-start;
}

.ai-bubble {
  padding: 12px 16px;
  border-radius: 16px;
  font-size: 13.5px;
  line-height: 1.55;
  word-break: break-word;
}

.ai-msg.user .ai-bubble {
  background: #10b981;
  color: #ffffff;
  border-bottom-right-radius: 4px;
}

html[dir="rtl"] .ai-msg.user .ai-bubble {
  border-bottom-right-radius: 16px;
  border-bottom-left-radius: 4px;
}

.ai-msg.bot .ai-bubble {
  background: #ffffff;
  color: #1e293b;
  border: 1px solid #e2e8f0;
  border-bottom-left-radius: 4px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

html[dir="rtl"] .ai-msg.bot .ai-bubble {
  border-bottom-left-radius: 16px;
  border-bottom-right-radius: 4px;
}

.ai-bubble p {
  margin: 0 0 6px 0;
}
.ai-bubble p:last-child {
  margin-bottom: 0;
}
.ai-bubble ul, .ai-bubble ol {
  margin: 6px 0;
  padding-right: 20px;
  padding-left: 20px;
}

.ai-time {
  font-size: 10px;
  color: #94a3b8;
  margin-top: 4px;
  padding: 0 4px;
}

.ai-msg.user .ai-time {
  text-align: left;
}
html[dir="rtl"] .ai-msg.user .ai-time {
  text-align: right;
}

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

.ai-typing-dot {
  width: 7px;
  height: 7px;
  background: #10b981;
  border-radius: 50%;
  animation: ai-typing-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-typing-bounce {
  0%, 80%, 100% { transform: scale(0); }
  40% { transform: scale(1); }
}

/* Product Recommendation Card inside Chat */
.ai-product-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  margin-top: 10px;
  width: 100%;
}

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

.ai-product-card:hover {
  border-color: #10b981;
  box-shadow: 0 3px 8px rgba(16, 185, 129, 0.15);
}

.ai-product-img {
  width: 48px;
  height: 48px;
  object-fit: cover;
  border-radius: 8px;
  background: #f1f5f9;
  flex-shrink: 0;
}

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

.ai-product-title {
  font-size: 13px;
  font-weight: 700;
  color: #1e293b;
  margin: 0 0 2px 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ai-product-price {
  font-size: 12.5px;
  color: #059669;
  font-weight: 700;
  margin: 0;
}

.ai-product-btn {
  background: #10b981;
  color: #ffffff;
  border: none;
  padding: 6px 12px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 4px;
  transition: background 0.2s;
  white-space: nowrap;
  flex-shrink: 0;
}

.ai-product-btn:hover {
  background: #059669;
}

/* Quick Prompts Suggestions */
.ai-quick-prompts {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 8px 14px;
  background: #ffffff;
  border-top: 1px solid #e2e8f0;
  scrollbar-width: none;
}

.ai-quick-prompts::-webkit-scrollbar {
  display: none;
}

.ai-prompt-chip {
  background: #f1f5f9;
  color: #334155;
  border: 1px solid #cbd5e1;
  padding: 6px 12px;
  border-radius: 20px;
  font-size: 12px;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.2s;
  flex-shrink: 0;
}

.ai-prompt-chip:hover {
  background: #e2e8f0;
  color: #0f172a;
  border-color: #94a3b8;
}

/* Chat Input Bar */
.ai-chat-footer {
  padding: 12px 14px;
  background: #ffffff;
  border-top: 1px solid #e2e8f0;
  display: flex;
  align-items: center;
  gap: 8px;
}

.ai-chat-input {
  flex: 1;
  background: #f8fafc;
  border: 1px solid #cbd5e1;
  border-radius: 24px;
  padding: 10px 16px;
  font-size: 13.5px;
  outline: none;
  transition: all 0.2s;
  color: #1e293b;
}

.ai-chat-input:focus {
  border-color: #10b981;
  background: #ffffff;
  box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.15);
}

.ai-send-btn {
  width: 40px;
  height: 40px;
  background: #10b981;
  color: #ffffff;
  border: none;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s;
  flex-shrink: 0;
}

.ai-send-btn:hover {
  background: #059669;
  transform: scale(1.05);
}

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

.ai-send-btn svg {
  width: 18px;
  height: 18px;
  fill: currentColor;
}

/* Mobile Responsiveness */
@media (max-width: 576px) {
  .ai-chat-window {
    width: 100vw;
    height: 100vh;
    max-height: 100vh;
    max-width: 100vw;
    bottom: 0 !important;
    left: 0 !important;
    right: 0 !important;
    border-radius: 0;
  }
  .ai-assistant-btn {
    bottom: 85px;
    width: 52px;
    height: 52px;
  }
}
