/* ==========================================================================
   Amar Informatique - Premium AI Chatbot Widget Styles
   ========================================================================== */

:root {
  --chat-primary: #2563eb;
  --chat-primary-hover: #1d4ed8;
  --chat-accent: #f97316;
  --chat-bg: #ffffff;
  --chat-bg-dark: #0f172a;
  --chat-card-bg: #f8fafc;
  --chat-text: #1e293b;
  --chat-text-muted: #64748b;
  --chat-border: #e2e8f0;
  --chat-user-bubble: #2563eb;
  --chat-user-text: #ffffff;
  --chat-bot-bubble: #f1f5f9;
  --chat-bot-text: #0f172a;
  --chat-shadow: 0 20px 40px rgba(0, 0, 0, 0.15);
  --chat-radius: 20px;
}

body.dark-mode {
  --chat-bg: #0f172a;
  --chat-card-bg: #1e293b;
  --chat-text: #f8fafc;
  --chat-text-muted: #94a3b8;
  --chat-border: #334155;
  --chat-bot-bubble: #1e293b;
  --chat-bot-text: #f8fafc;
  --chat-shadow: 0 20px 40px rgba(0, 0, 0, 0.4);
}

/* Floating Trigger Button */
.chatbot-trigger-btn {
  position: fixed;
  bottom: 25px;
  right: 25px;
  width: 62px;
  height: 62px;
  border-radius: 50%;
  background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
  color: #ffffff;
  border: 2px solid rgba(255, 255, 255, 0.3);
  box-shadow: 0 10px 30px rgba(37, 99, 235, 0.4);
  cursor: pointer;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.chatbot-trigger-btn:hover {
  transform: scale(1.1) rotate(5deg);
  box-shadow: 0 14px 35px rgba(37, 99, 235, 0.5);
}

.chatbot-trigger-btn .badge-pulse {
  position: absolute;
  top: 0;
  right: 0;
  width: 16px;
  height: 16px;
  background-color: #10b981;
  border: 2px solid #ffffff;
  border-radius: 50%;
  animation: pulseGlow 2s infinite;
}

@keyframes pulseGlow {
  0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7); }
  70% { transform: scale(1); box-shadow: 0 0 0 10px rgba(16, 185, 129, 0); }
  100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}

/* Chat Window Wrapper */
.chatbot-window {
  position: fixed;
  bottom: 100px;
  right: 25px;
  width: 400px;
  max-width: calc(100vw - 30px);
  height: 600px;
  max-height: calc(100vh - 120px);
  background: var(--chat-bg);
  color: var(--chat-text);
  border-radius: var(--chat-radius);
  box-shadow: var(--chat-shadow);
  border: 1px solid var(--chat-border);
  z-index: 10000;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  opacity: 0;
  transform: translateY(30px) scale(0.95);
  pointer-events: none;
  transition: all 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}

.chatbot-window.active {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: all;
}

.chatbot-window.minimized {
  height: 65px;
}

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

.chatbot-header-info {
  display: flex;
  align-items: center;
  gap: 12px;
}

.chatbot-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: linear-gradient(135deg, #2563eb, #f97316);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
}

.chatbot-title-block h3 {
  margin: 0;
  font-size: 1rem;
  font-weight: 700;
  color: #ffffff;
  display: flex;
  align-items: center;
  gap: 6px;
}

.chatbot-status {
  font-size: 0.75rem;
  color: #10b981;
  display: flex;
  align-items: center;
  gap: 5px;
  margin-top: 2px;
}

.chatbot-status::before {
  content: '';
  width: 7px;
  height: 7px;
  background-color: #10b981;
  border-radius: 50%;
}

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

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

.chatbot-header-btn:hover {
  background: rgba(255, 255, 255, 0.25);
}

/* Messages Area */
.chatbot-messages {
  flex: 1;
  padding: 16px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
  background: var(--chat-bg);
}

.chat-message-row {
  display: flex;
  gap: 10px;
  max-width: 88%;
  animation: fadeInMsg 0.3s ease-out forwards;
}

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

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

.chat-message-row.bot {
  align-self: flex-start;
}

.chat-bubble {
  padding: 12px 16px;
  border-radius: 18px;
  font-size: 0.9rem;
  line-height: 1.45;
  word-break: break-word;
}

.chat-message-row.user .chat-bubble {
  background: var(--chat-user-bubble);
  color: var(--chat-user-text);
  border-bottom-right-radius: 4px;
}

.chat-message-row.bot .chat-bubble {
  background: var(--chat-bot-bubble);
  color: var(--chat-bot-text);
  border-bottom-left-radius: 4px;
  border: 1px solid var(--chat-border);
}

/* Typing Indicator */
.typing-indicator {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 10px 16px;
  background: var(--chat-bot-bubble);
  border-radius: 18px;
  width: fit-content;
  border: 1px solid var(--chat-border);
}

.typing-dot {
  width: 7px;
  height: 7px;
  background: var(--chat-text-muted);
  border-radius: 50%;
  animation: typingBlink 1.4s infinite ease-in-out both;
}

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

@keyframes typingBlink {
  0%, 80%, 100% { transform: scale(0); opacity: 0.3; }
  40% { transform: scale(1); opacity: 1; }
}

/* Quick Suggestions Pills */
.chatbot-suggestions {
  padding: 10px 16px;
  display: flex;
  gap: 8px;
  overflow-x: auto;
  white-space: nowrap;
  background: var(--chat-bg);
  border-top: 1px dashed var(--chat-border);
  scrollbar-width: none;
}

.chatbot-suggestions::-webkit-scrollbar {
  display: none;
}

.suggestion-chip {
  background: var(--chat-card-bg);
  color: var(--chat-primary);
  border: 1px solid var(--chat-border);
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  flex-shrink: 0;
}

.suggestion-chip:hover {
  background: var(--chat-primary);
  color: #ffffff;
  border-color: var(--chat-primary);
  transform: translateY(-2px);
}

/* Product Cards Carousel inside Chat */
.chat-products-grid {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 10px;
  width: 100%;
}

.chat-product-card {
  background: var(--chat-card-bg);
  border: 1px solid var(--chat-border);
  border-radius: 12px;
  padding: 10px;
  display: flex;
  gap: 12px;
  align-items: center;
  transition: 0.2s ease;
}

.chat-product-card:hover {
  border-color: var(--chat-primary);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

.chat-product-img {
  width: 65px;
  height: 65px;
  object-fit: contain;
  border-radius: 8px;
  background: #ffffff;
  padding: 4px;
  border: 1px solid var(--chat-border);
}

.chat-product-details {
  flex: 1;
  min-width: 0;
}

.chat-product-name {
  font-size: 0.85rem;
  font-weight: 700;
  margin: 0 0 4px 0;
  color: var(--chat-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-product-price {
  font-size: 0.9rem;
  font-weight: 800;
  color: var(--chat-accent);
  margin-bottom: 6px;
}

.chat-product-price del {
  font-size: 0.75rem;
  color: var(--chat-text-muted);
  font-weight: 400;
  margin-right: 6px;
}

.chat-product-actions {
  display: flex;
  gap: 6px;
}

.chat-btn-view {
  background: transparent;
  color: var(--chat-primary);
  border: 1px solid var(--chat-primary);
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.chat-btn-add {
  background: var(--chat-primary);
  color: #ffffff;
  border: none;
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  transition: 0.2s;
}

.chat-btn-add:hover {
  background: var(--chat-primary-hover);
}

/* Footer Input Area */
.chatbot-footer {
  padding: 12px 16px;
  background: var(--chat-bg);
  border-top: 1px solid var(--chat-border);
  display: flex;
  align-items: center;
  gap: 8px;
}

.chatbot-input {
  flex: 1;
  background: var(--chat-card-bg);
  color: var(--chat-text);
  border: 1px solid var(--chat-border);
  padding: 10px 16px;
  border-radius: 24px;
  font-size: 0.9rem;
  outline: none;
  transition: 0.2s;
}

.chatbot-input:focus {
  border-color: var(--chat-primary);
}

.chatbot-send-btn {
  background: var(--chat-primary);
  color: #ffffff;
  border: none;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  transition: 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
  flex-shrink: 0;
}

.chatbot-send-btn:hover {
  transform: scale(1.08);
  background: var(--chat-primary-hover);
}

/* Responsive adjustment for Mobile */
@media (max-width: 480px) {
  .chatbot-window {
    bottom: 0;
    right: 0;
    width: 100vw;
    height: 100vh;
    max-height: 100vh;
    border-radius: 0;
  }
  .chatbot-trigger-btn {
    bottom: 15px;
    right: 15px;
  }
}
