/* ===================================================
   AI CHATBOT & EXIT-INTENT CONSULTANT (ROKAFLEX)
   =================================================== */

/* Chatbot Overlay & Modal */
.ai-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(10, 10, 12, 0.75);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 99999;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.35s ease, visibility 0.35s ease;
  padding: 16px;
}

.ai-modal-overlay.active {
  opacity: 1;
  visibility: visible;
}

.ai-chat-window {
  width: 100%;
  max-width: 480px;
  height: 640px;
  max-height: 90vh;
  background: #131418;
  border: 1px solid rgba(232, 160, 48, 0.3);
  border-radius: 20px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.7), 0 0 40px rgba(232, 160, 48, 0.15);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform: translateY(30px) scale(0.95);
  transition: transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
  font-family: 'Inter', system-ui, sans-serif;
  color: #e5e5e7;
}

.ai-modal-overlay.active .ai-chat-window {
  transform: translateY(0) scale(1);
}

/* Floating Widget Mode (when minimized) */
.ai-chat-window.floating-mode {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 400px;
  max-width: calc(100vw - 32px);
  height: 580px;
  max-height: calc(100vh - 100px);
  z-index: 100000;
  border-radius: 18px;
  transform: none;
}

/* Header */
.ai-chat-header {
  background: linear-gradient(135deg, #1c1e24 0%, #17181d 100%);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  padding: 16px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: relative;
}

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

.ai-avatar-wrap {
  position: relative;
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: linear-gradient(135deg, #e8a030, #c47d15);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #000;
  font-size: 1.25rem;
  box-shadow: 0 4px 14px rgba(232, 160, 48, 0.35);
}

.ai-avatar-pulse {
  position: absolute;
  bottom: -2px;
  right: -2px;
  width: 12px;
  height: 12px;
  background: #10b981;
  border: 2px solid #131418;
  border-radius: 50%;
}

.ai-header-titles h3 {
  margin: 0;
  font-size: 1rem;
  font-weight: 700;
  color: #fff;
  display: flex;
  align-items: center;
  gap: 6px;
}

.ai-header-titles .ai-badge {
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  background: rgba(232, 160, 48, 0.15);
  color: #e8a030;
  padding: 2px 6px;
  border-radius: 4px;
  letter-spacing: 0.05em;
}

.ai-header-titles p {
  margin: 2px 0 0 0;
  font-size: 0.75rem;
  color: #9ca3af;
}

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

.ai-ctrl-btn {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: #9ca3af;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
  font-size: 0.85rem;
}

.ai-ctrl-btn:hover {
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
}

/* Exit Intent Offer Banner */
.ai-offer-banner {
  background: linear-gradient(90deg, rgba(232, 160, 48, 0.15) 0%, rgba(232, 160, 48, 0.05) 100%);
  border-bottom: 1px solid rgba(232, 160, 48, 0.2);
  padding: 10px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.8rem;
  color: #fde68a;
}

.ai-offer-banner i {
  color: #e8a030;
  font-size: 1.1rem;
  flex-shrink: 0;
}

/* Messages Body */
.ai-chat-body {
  flex: 1;
  padding: 18px 16px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
  background: radial-gradient(circle at top right, rgba(232, 160, 48, 0.03), transparent 60%);
  scroll-behavior: smooth;
}

.ai-chat-body::-webkit-scrollbar {
  width: 5px;
}
.ai-chat-body::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.15);
  border-radius: 10px;
}

/* Message Bubbles */
.ai-msg {
  display: flex;
  gap: 10px;
  max-width: 92%;
  animation: ai-fade-in 0.3s ease forwards;
}

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

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

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

.ai-msg-bubble {
  padding: 12px 16px;
  border-radius: 16px;
  font-size: 0.875rem;
  line-height: 1.55;
  position: relative;
  word-break: break-word;
}

.ai-msg.bot .ai-msg-bubble {
  background: #1f2128;
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: #e5e5e7;
  border-bottom-left-radius: 4px;
}

.ai-msg.user .ai-msg-bubble {
  background: linear-gradient(135deg, #e8a030 0%, #d48b1d 100%);
  color: #000;
  font-weight: 500;
  border-bottom-right-radius: 4px;
  box-shadow: 0 4px 12px rgba(232, 160, 48, 0.25);
}

.ai-msg-bubble p {
  margin: 0 0 8px 0;
}
.ai-msg-bubble p:last-child {
  margin-bottom: 0;
}

.ai-msg-bubble strong {
  color: #fff;
}
.ai-msg.user .ai-msg-bubble strong {
  color: #000;
}

.ai-msg-bubble ul {
  margin: 6px 0 8px 0;
  padding-left: 18px;
}

.ai-msg-bubble li {
  margin-bottom: 4px;
}

.ai-msg-time {
  font-size: 0.65rem;
  color: #6b7280;
  margin-top: 4px;
  text-align: right;
}
.ai-msg.user .ai-msg-time {
  color: rgba(0, 0, 0, 0.6);
}

/* Typing Indicator */
.ai-typing-indicator {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 10px 14px;
  background: #1f2128;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 14px;
  border-bottom-left-radius: 4px;
  align-self: flex-start;
}

.ai-typing-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #e8a030;
  animation: ai-bounce 1.4s infinite ease-in-out;
}
.ai-typing-dot:nth-child(2) { animation-delay: 0.2s; }
.ai-typing-dot:nth-child(3) { animation-delay: 0.4s; }

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

/* Quick Suggestion Chips */
.ai-quick-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.ai-chip {
  background: rgba(232, 160, 48, 0.1);
  border: 1px solid rgba(232, 160, 48, 0.25);
  color: #f3c272;
  font-size: 0.75rem;
  padding: 6px 12px;
  border-radius: 100px;
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: normal;
  text-align: left;
}

.ai-chip:hover {
  background: #e8a030;
  color: #000;
  border-color: #e8a030;
  transform: translateY(-1px);
}

/* Inline Action Form inside Chat */
.ai-inline-form {
  margin-top: 10px;
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid rgba(232, 160, 48, 0.2);
  border-radius: 12px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.ai-inline-form input {
  background: #131418;
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: #fff;
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 0.8rem;
  outline: none;
}
.ai-inline-form input:focus {
  border-color: #e8a030;
}

.ai-inline-form button {
  background: #e8a030;
  color: #000;
  border: none;
  border-radius: 8px;
  padding: 8px 14px;
  font-size: 0.8rem;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.2s ease;
}
.ai-inline-form button:hover {
  background: #f5b642;
}

/* Chat Footer / Input Bar */
.ai-chat-footer {
  background: #17181d;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  padding: 12px 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.ai-input-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  background: #1f2128;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  padding: 4px 6px 4px 14px;
  transition: border-color 0.2s ease;
}

.ai-input-wrap:focus-within {
  border-color: #e8a030;
  box-shadow: 0 0 0 2px rgba(232, 160, 48, 0.15);
}

.ai-chat-input {
  flex: 1;
  background: transparent;
  border: none;
  color: #fff;
  font-family: inherit;
  font-size: 0.875rem;
  outline: none;
  padding: 8px 0;
}

.ai-chat-input::placeholder {
  color: #6b7280;
}

.ai-send-btn {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: #e8a030;
  color: #000;
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
  font-size: 0.9rem;
}

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

.ai-send-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.ai-footer-note {
  font-size: 0.7rem;
  color: #6b7280;
  text-align: center;
}

/* Mobile Responsiveness */
@media (max-width: 768px) {
  .ai-chat-window {
    height: 85vh;
    max-height: 600px;
    border-radius: 16px;
  }
  .ai-chat-window.floating-mode {
    bottom: 0;
    right: 0;
    width: 100vw;
    height: 100vh;
    max-width: 100vw;
    max-height: 100vh;
    border-radius: 0;
  }
}
