/* ==========================================================================
   AI ASSISTANT CHATBOT (DEEPSEEK & GEMINI) - QUÁN ĂN 396
   Design: Modern Sizzling Glassmorphism, Theme-Aware, Mobile-First
   ========================================================================== */

/* Floating Launcher Button */
.ai-fab-launcher {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9990;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 20px 12px 14px;
  background: linear-gradient(135deg, #f97316 0%, #ea580c 50%, #dc2626 100%);
  color: #ffffff;
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: 9999px;
  box-shadow: 0 10px 30px rgba(234, 88, 12, 0.45), 0 0 20px rgba(249, 115, 22, 0.3);
  cursor: pointer;
  font-family: var(--font-body, 'Be Vietnam Pro', sans-serif);
  font-size: 0.92rem;
  font-weight: 700;
  letter-spacing: 0.2px;
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  user-select: none;
}

.ai-fab-launcher:hover {
  transform: translateY(-4px) scale(1.03);
  box-shadow: 0 16px 36px rgba(234, 88, 12, 0.6), 0 0 28px rgba(249, 115, 22, 0.45);
}

.ai-fab-icon-box {
  position: relative;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  box-shadow: inset 0 2px 4px rgba(255, 255, 255, 0.3);
}

.ai-fab-pulse-ring {
  position: absolute;
  top: -4px;
  left: -4px;
  right: -4px;
  bottom: -4px;
  border-radius: 50%;
  border: 2px solid #fdba74;
  opacity: 0.8;
  animation: fabPulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

@keyframes fabPulse {
  0% { transform: scale(0.9); opacity: 0.9; }
  50% { transform: scale(1.3); opacity: 0; }
  100% { transform: scale(1.3); opacity: 0; }
}

.ai-fab-text {
  display: flex;
  flex-direction: column;
  line-height: 1.15;
  text-align: left;
}

.ai-fab-title {
  font-size: 0.92rem;
  font-weight: 800;
}

.ai-fab-sub {
  font-size: 0.72rem;
  font-weight: 500;
  opacity: 0.92;
  color: #ffedd5;
}

.ai-fab-badge {
  position: absolute;
  top: -6px;
  right: -6px;
  background: #10b981;
  color: #ffffff;
  font-size: 0.65rem;
  font-weight: 800;
  padding: 3px 7px;
  border-radius: 9999px;
  border: 2px solid #0f141c;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
}

/* Chat Container Window */
.ai-chat-window {
  position: fixed;
  bottom: 88px;
  right: 24px;
  width: 410px;
  max-width: calc(100vw - 32px);
  height: 620px;
  max-height: calc(100vh - 110px);
  background: rgba(18, 24, 34, 0.96);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid rgba(249, 115, 22, 0.3);
  border-radius: 20px;
  box-shadow: 0 25px 60px -10px rgba(0, 0, 0, 0.7), 0 0 35px rgba(249, 115, 22, 0.2);
  display: flex;
  flex-direction: column;
  z-index: 9995;
  overflow: hidden;
  font-family: var(--font-body, 'Be Vietnam Pro', sans-serif);
  color: #f8fafc;
  opacity: 0;
  transform: translateY(20px) scale(0.95);
  pointer-events: none;
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

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

/* Header */
.ai-chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  background: linear-gradient(135deg, rgba(30, 41, 59, 0.95) 0%, rgba(24, 32, 44, 0.95) 100%);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.ai-chat-profile {
  display: flex;
  align-items: center;
  gap: 12px;
}

.ai-avatar {
  position: relative;
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: linear-gradient(135deg, #f97316 0%, #dc2626 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.3rem;
  box-shadow: 0 4px 12px rgba(234, 88, 12, 0.4);
}

.ai-online-dot {
  position: absolute;
  bottom: -2px;
  right: -2px;
  width: 11px;
  height: 11px;
  background: #10b981;
  border: 2px solid #18202c;
  border-radius: 50%;
}

.ai-profile-meta {
  display: flex;
  flex-direction: column;
}

.ai-title {
  font-size: 0.96rem;
  font-weight: 800;
  color: #ffffff;
  display: flex;
  align-items: center;
  gap: 6px;
}

.ai-provider-pill {
  font-size: 0.65rem;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 9999px;
  background: rgba(249, 115, 22, 0.2);
  color: #fdba74;
  border: 1px solid rgba(249, 115, 22, 0.4);
}

.ai-status-text {
  font-size: 0.72rem;
  color: #94a3b8;
}

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

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

.ai-icon-btn:hover {
  background: rgba(249, 115, 22, 0.25);
  border-color: rgba(249, 115, 22, 0.5);
  color: #ffffff;
}

/* Quick Suggestion Chips */
.ai-chips-bar {
  padding: 10px 14px;
  background: rgba(15, 20, 28, 0.7);
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  display: flex;
  gap: 6px;
  overflow-x: auto;
  scrollbar-width: none;
}
.ai-chips-bar::-webkit-scrollbar {
  display: none;
}

.ai-chip {
  flex-shrink: 0;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: #e2e8f0;
  font-size: 0.74rem;
  font-weight: 500;
  padding: 5px 11px;
  border-radius: 9999px;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.2s;
}

.ai-chip:hover {
  background: rgba(249, 115, 22, 0.25);
  border-color: rgba(249, 115, 22, 0.5);
  color: #fdba74;
}

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

.ai-msg {
  display: flex;
  gap: 10px;
  max-width: 88%;
  animation: msgFade 0.25s ease-out;
}

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

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

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

.ai-msg-avatar {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: linear-gradient(135deg, #f97316, #dc2626);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  flex-shrink: 0;
  margin-top: 2px;
}

.ai-msg-bubble {
  padding: 11px 14px;
  border-radius: 14px;
  font-size: 0.88rem;
  line-height: 1.55;
  word-break: break-word;
}

.ai-msg.user .ai-msg-bubble {
  background: linear-gradient(135deg, #ea580c 0%, #c2410c 100%);
  color: #ffffff;
  border-bottom-right-radius: 4px;
  box-shadow: 0 4px 14px rgba(234, 88, 12, 0.3);
}

.ai-msg.bot .ai-msg-bubble {
  background: rgba(30, 41, 59, 0.85);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: #f1f5f9;
  border-bottom-left-radius: 4px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.2);
}

.ai-msg.bot .ai-msg-bubble strong {
  color: #fbbf24;
}

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

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

.ai-msg.bot .ai-msg-bubble a {
  color: #38bdf8;
  text-decoration: underline;
}

.ai-msg-time {
  font-size: 0.65rem;
  color: #64748b;
  margin-top: 4px;
  align-self: flex-end;
}

/* Typing Indicator */
.ai-typing-indicator {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 12px 16px;
  background: rgba(30, 41, 59, 0.7);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 14px;
  width: fit-content;
  border-bottom-left-radius: 4px;
}

.ai-typing-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #f97316;
  animation: typingBounce 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 typingBounce {
  0%, 80%, 100% { transform: translateY(0); opacity: 0.4; }
  40% { transform: translateY(-6px); opacity: 1; }
}

/* Chat Input Bar */
.ai-chat-footer {
  padding: 12px 14px;
  background: rgba(15, 20, 28, 0.95);
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.ai-input-form {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(30, 41, 59, 0.7);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 12px;
  padding: 6px 8px 6px 14px;
  transition: all 0.2s;
}

.ai-input-form:focus-within {
  border-color: #f97316;
  box-shadow: 0 0 0 2px rgba(249, 115, 22, 0.25);
  background: rgba(30, 41, 59, 0.95);
}

.ai-input-field {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: #ffffff;
  font-family: inherit;
  font-size: 0.88rem;
  line-height: 1.4;
  resize: none;
  max-height: 80px;
}

.ai-input-field::placeholder {
  color: #64748b;
}

.ai-send-btn {
  background: linear-gradient(135deg, #f97316 0%, #ea580c 100%);
  border: none;
  color: #ffffff;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s;
  flex-shrink: 0;
}

.ai-send-btn:hover:not(:disabled) {
  transform: scale(1.05);
  background: linear-gradient(135deg, #ea580c 0%, #c2410c 100%);
}

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

.ai-footer-note {
  font-size: 0.65rem;
  color: #64748b;
  text-align: center;
  margin-top: 6px;
}

/* Settings Modal */
.ai-settings-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(10, 14, 20, 0.9);
  backdrop-filter: blur(10px);
  z-index: 10;
  display: none;
  flex-direction: column;
  padding: 20px;
  animation: fadeIn 0.2s ease-out;
}

.ai-settings-overlay.open {
  display: flex;
}

.ai-settings-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.ai-settings-header h4 {
  font-size: 1rem;
  font-weight: 800;
  color: #f8fafc;
  display: flex;
  align-items: center;
  gap: 6px;
}

.ai-settings-body {
  display: flex;
  flex-direction: column;
  gap: 14px;
  overflow-y: auto;
  flex: 1;
}

.ai-setting-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.ai-setting-group label {
  font-size: 0.78rem;
  font-weight: 700;
  color: #cbd5e1;
}

.ai-setting-select,
.ai-setting-input {
  background: rgba(30, 41, 59, 0.9);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 8px;
  padding: 8px 12px;
  color: #f8fafc;
  font-family: inherit;
  font-size: 0.82rem;
  outline: none;
}

.ai-setting-select:focus,
.ai-setting-input:focus {
  border-color: #f97316;
}

.ai-setting-help {
  font-size: 0.7rem;
  color: #94a3b8;
  line-height: 1.35;
}

.ai-settings-footer {
  display: flex;
  gap: 10px;
  margin-top: 14px;
}

.ai-btn-save {
  flex: 1;
  background: #f97316;
  color: #ffffff;
  border: none;
  padding: 10px;
  border-radius: 8px;
  font-weight: 700;
  cursor: pointer;
  font-size: 0.82rem;
}

.ai-btn-reset {
  background: rgba(255, 255, 255, 0.1);
  color: #cbd5e1;
  border: 1px solid rgba(255, 255, 255, 0.15);
  padding: 10px 14px;
  border-radius: 8px;
  font-weight: 600;
  cursor: pointer;
  font-size: 0.82rem;
}

/* Mobile Responsiveness */
@media (max-width: 480px) {
  .ai-fab-launcher {
    bottom: 16px;
    right: 16px;
    padding: 10px 16px 10px 12px;
  }
  .ai-chat-window {
    bottom: 0;
    right: 0;
    width: 100vw;
    max-width: 100vw;
    height: 100vh;
    max-height: 100vh;
    border-radius: 0;
    border: none;
  }
}
