/**
 * AI Assistant Stylesheet
 * Project Codex - Floating Smart Assistant Widget
 */

/* Floating Toggle Button */
.ai-assistant-toggle-btn {
  position: fixed;
  bottom: 24px;
  left: 24px;
  z-index: 99999;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 18px;
  background: linear-gradient(135deg, #2563eb 0%, #7c3aed 100%);
  color: #ffffff;
  border: none;
  border-radius: 9999px;
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 10px 25px -5px rgba(37, 99, 235, 0.45), 0 8px 10px -6px rgba(124, 58, 237, 0.3);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  user-select: none;
}

.ai-assistant-toggle-btn:hover {
  transform: translateY(-3px) scale(1.03);
  box-shadow: 0 14px 28px -4px rgba(37, 99, 235, 0.55), 0 10px 12px -5px rgba(124, 58, 237, 0.4);
}

.ai-assistant-toggle-btn:active {
  transform: translateY(0) scale(0.98);
}

.ai-assistant-icon-pulse {
  position: relative;
  font-size: 1.25rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

.ai-pulse-dot {
  position: absolute;
  top: -2px;
  right: -2px;
  width: 8px;
  height: 8px;
  background-color: #10b981;
  border-radius: 50%;
  border: 2px solid #ffffff;
}

/* Chat Widget Container */
.ai-chat-window {
  position: fixed;
  bottom: 84px;
  left: 24px;
  width: 420px;
  max-width: calc(100vw - 48px);
  height: 560px;
  max-height: calc(100vh - 120px);
  background: #ffffff;
  border-radius: 18px;
  box-shadow: 0 20px 40px -10px rgba(15, 23, 42, 0.22), 0 0 0 1px rgba(0, 0, 0, 0.06);
  z-index: 100000;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  opacity: 0;
  transform: translateY(20px) scale(0.96);
  pointer-events: none;
  transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.ai-chat-window.active {
  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, #1e293b 0%, #0f172a 100%);
  color: #ffffff;
}

.ai-chat-header-title {
  display: flex;
  align-items: center;
  gap: 10px;
}

.ai-chat-header-title h4 {
  font-size: 1rem;
  font-weight: 700;
  margin: 0;
}

.ai-chat-header-title .ai-badge {
  font-size: 0.72rem;
  background: rgba(37, 99, 235, 0.25);
  color: #60a5fa;
  border: 1px solid rgba(96, 165, 250, 0.3);
  padding: 2px 8px;
  border-radius: 999px;
  font-weight: 600;
}

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

.ai-header-btn {
  background: transparent;
  border: none;
  color: #94a3b8;
  font-size: 1rem;
  cursor: pointer;
  padding: 4px 6px;
  border-radius: 6px;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
}

.ai-header-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #ffffff;
}

/* Suggestions / Chips bar */
.ai-chips-container {
  display: flex;
  gap: 6px;
  padding: 10px 14px;
  background: #f8fafc;
  border-bottom: 1px solid #e2e8f0;
  overflow-x: auto;
  white-space: nowrap;
  scrollbar-width: none;
}

.ai-chips-container::-webkit-scrollbar {
  display: none;
}

.ai-chip {
  background: #ffffff;
  border: 1px solid #cbd5e1;
  color: #334155;
  font-size: 0.78rem;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 999px;
  cursor: pointer;
  transition: all 0.2s;
  flex-shrink: 0;
}

.ai-chip:hover {
  background: #eff6ff;
  border-color: #93c5fd;
  color: #1d4ed8;
  transform: translateY(-1px);
}

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

.ai-message {
  display: flex;
  flex-direction: column;
  max-width: 88%;
  word-break: break-word;
}

.ai-message.user {
  align-self: flex-start; /* RTL: user on right, alignment right */
  margin-left: auto;
}

.ai-message.bot {
  align-self: flex-end;
  margin-right: auto;
}

.ai-message-bubble {
  padding: 10px 14px;
  border-radius: 14px;
  font-size: 0.88rem;
  line-height: 1.5;
}

.ai-message.user .ai-message-bubble {
  background: #2563eb;
  color: #ffffff;
  border-bottom-right-radius: 4px;
}

.ai-message.bot .ai-message-bubble {
  background: #ffffff;
  color: #0f172a;
  border: 1px solid #e2e8f0;
  border-bottom-left-radius: 4px;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.03);
}

.ai-message-bubble h3 {
  font-size: 0.96rem;
  font-weight: 800;
  margin-bottom: 6px;
  color: #1e3a8a;
}

.ai-message-bubble hr {
  border: 0;
  border-top: 1px dashed #cbd5e1;
  margin: 8px 0;
}

.ai-message-bubble code {
  background: rgba(15, 23, 42, 0.06);
  color: #0f172a;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.82rem;
  font-family: monospace;
}

.ai-message-bubble ul {
  padding-right: 18px;
  margin: 6px 0;
}

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

/* Action Buttons inside Bot Message */
.ai-actions-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}

.ai-action-btn {
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  color: #1d4ed8;
  font-size: 0.78rem;
  font-weight: 700;
  padding: 5px 12px;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.ai-action-btn:hover {
  background: #2563eb;
  color: #ffffff;
  border-color: #2563eb;
  transform: translateY(-1px);
}

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

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

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

.ai-chat-input {
  flex: 1;
  border: 1px solid #cbd5e1;
  border-radius: 10px;
  padding: 9px 12px;
  font-family: inherit;
  font-size: 0.88rem;
  outline: none;
  transition: border-color 0.2s;
  background: #f8fafc;
}

.ai-chat-input:focus {
  border-color: #2563eb;
  background: #ffffff;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.ai-mic-btn {
  background: #f1f5f9;
  color: #334155;
  border: 1px solid #cbd5e1;
  border-radius: 10px;
  width: 38px;
  height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 1.15rem;
  transition: all 0.2s ease;
  flex-shrink: 0;
  position: relative;
}

.ai-mic-btn:hover {
  background: #e2e8f0;
  border-color: #94a3b8;
  color: #0f172a;
  transform: scale(1.05);
}

.ai-mic-btn.listening {
  background: #ef4444;
  border-color: #dc2626;
  color: #ffffff;
  animation: aiMicPulse 1.2s infinite alternate ease-in-out;
  box-shadow: 0 0 14px rgba(239, 68, 68, 0.55);
}

@keyframes aiMicPulse {
  0% { transform: scale(1); box-shadow: 0 0 6px rgba(239, 68, 68, 0.4); }
  100% { transform: scale(1.12); box-shadow: 0 0 16px rgba(239, 68, 68, 0.8); }
}

.ai-send-btn {
  background: #2563eb;
  color: #ffffff;
  border: none;
  border-radius: 10px;
  width: 38px;
  height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 1.1rem;
  transition: all 0.2s;
  flex-shrink: 0;
}

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

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

/* Mobile Responsiveness */
@media (max-width: 640px) {
  .ai-assistant-toggle-btn {
    bottom: 16px;
    left: 16px;
    padding: 8px 14px;
    font-size: 0.85rem;
  }

  .ai-chat-window {
    bottom: 0;
    left: 0;
    right: 0;
    width: 100vw;
    max-width: 100vw;
    height: 85vh;
    max-height: 85vh;
    border-radius: 20px 20px 0 0;
  }
}
