/* ============================================================
   AI Tutor Chatbot — Shared Component Styles
   Include on any page to get the floating AI tutor.
   ============================================================ */

.ai-tutor-fab {
  position: fixed;
  bottom: 6rem;
  right: 2rem;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: linear-gradient(135deg, #d4a843, #b8922e);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  color: #0f0f1a;
  box-shadow: 0 4px 20px rgba(212,168,67,0.4), 0 0 0 0 rgba(212,168,67,0.3);
  z-index: 9990;
  transition: all 0.3s cubic-bezier(0.4,0,0.2,1);
  animation: tutorFabPulse 3s ease-in-out infinite;
}
.ai-tutor-fab:hover {
  transform: scale(1.1);
  box-shadow: 0 6px 30px rgba(212,168,67,0.5);
}
.ai-tutor-fab.has-unread::after {
  content: '';
  position: absolute;
  top: 2px;
  right: 2px;
  width: 12px;
  height: 12px;
  background: #e74c3c;
  border-radius: 50%;
  border: 2px solid #0f0f1a;
}
@keyframes tutorFabPulse {
  0%, 100% { box-shadow: 0 4px 20px rgba(212,168,67,0.4), 0 0 0 0 rgba(212,168,67,0.3); }
  50% { box-shadow: 0 4px 20px rgba(212,168,67,0.4), 0 0 0 8px rgba(212,168,67,0); }
}

/* Panel */
.ai-tutor-panel {
  position: fixed;
  bottom: 10rem;
  right: 2rem;
  width: 380px;
  max-height: 520px;
  background: var(--bg-card, #1a1a2e);
  border: 1px solid rgba(212,168,67,0.3);
  border-radius: 16px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.5);
  z-index: 9991;
  display: none;
  flex-direction: column;
  overflow: hidden;
  animation: tutorSlideUp 0.3s ease;
}
.ai-tutor-panel.open { display: flex; }
@keyframes tutorSlideUp {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Header */
.ai-tutor-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.875rem 1rem;
  background: linear-gradient(135deg, rgba(212,168,67,0.1), rgba(15,15,26,0.95));
  border-bottom: 1px solid var(--border-color, rgba(255,255,255,0.08));
}
.ai-tutor-header-left { display: flex; align-items: center; gap: 0.5rem; }
.ai-tutor-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, #d4a843, #b8922e);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
}
.ai-tutor-header-info h4 { font-size: 0.875rem; font-weight: 700; margin: 0; color: var(--text-primary, #e8e8e8); }
.ai-tutor-header-info span { font-size: 0.6875rem; color: var(--text-muted, #888); }
.ai-tutor-close {
  background: none;
  border: none;
  color: var(--text-muted, #888);
  font-size: 1.25rem;
  cursor: pointer;
  padding: 0.25rem;
  border-radius: 6px;
  transition: color 0.15s;
}
.ai-tutor-close:hover { color: var(--text-primary, #e8e8e8); }

/* Messages */
.ai-tutor-messages {
  flex: 1;
  overflow-y: auto;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  max-height: 340px;
  min-height: 200px;
}
.ai-tutor-messages::-webkit-scrollbar { width: 4px; }
.ai-tutor-messages::-webkit-scrollbar-thumb { background: var(--border-color, rgba(255,255,255,0.08)); border-radius: 2px; }
.ai-msg {
  max-width: 85%;
  padding: 0.625rem 0.875rem;
  border-radius: 12px;
  font-size: 0.8125rem;
  line-height: 1.5;
  word-wrap: break-word;
}
.ai-msg.user {
  align-self: flex-end;
  background: linear-gradient(135deg, rgba(212,168,67,0.2), rgba(212,168,67,0.1));
  border: 1px solid rgba(212,168,67,0.2);
  color: var(--text-primary, #e8e8e8);
  border-bottom-right-radius: 4px;
}
.ai-msg.bot {
  align-self: flex-start;
  background: var(--bg-tertiary, #141422);
  border: 1px solid var(--border-color, rgba(255,255,255,0.08));
  color: var(--text-secondary, #b0b0b0);
  border-bottom-left-radius: 4px;
}
.ai-msg.bot strong { color: var(--text-primary, #e8e8e8); }
.ai-msg.bot ul, .ai-msg.bot ol { margin: 0.25rem 0; padding-left: 1.25rem; }
.ai-msg.bot li { margin-bottom: 0.15rem; }
.ai-msg.bot code {
  background: rgba(212,168,67,0.1);
  padding: 0.1rem 0.3rem;
  border-radius: 3px;
  font-size: 0.75rem;
}

/* Typing indicator */
.ai-tutor-typing {
  display: none;
  align-self: flex-start;
  padding: 0.625rem 0.875rem;
  background: var(--bg-tertiary, #141422);
  border: 1px solid var(--border-color, rgba(255,255,255,0.08));
  border-radius: 12px;
  border-bottom-left-radius: 4px;
  margin: 0 1rem;
}
.ai-tutor-typing.visible { display: flex; gap: 0.25rem; align-items: center; }
.typing-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--text-muted, #888);
  animation: typingBounce 1.4s infinite ease-in-out;
}
.typing-dot:nth-child(2) { animation-delay: 0.2s; }
.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; }
}

/* Input row */
.ai-tutor-input-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 1rem;
  border-top: 1px solid var(--border-color, rgba(255,255,255,0.08));
  background: var(--bg-secondary, #16162a);
}
.ai-tutor-input {
  flex: 1;
  background: var(--bg-tertiary, #141422);
  border: 1px solid var(--border-color, rgba(255,255,255,0.08));
  border-radius: 20px;
  padding: 0.5rem 0.875rem;
  color: var(--text-primary, #e8e8e8);
  font-size: 0.8125rem;
  font-family: inherit;
  outline: none;
  transition: border-color 0.15s;
}
.ai-tutor-input:focus { border-color: #d4a843; }
.ai-tutor-input::placeholder { color: var(--text-muted, #888); }
.ai-tutor-send {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, #d4a843, #b8922e);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #0f0f1a;
  font-size: 1rem;
  transition: all 0.15s;
  flex-shrink: 0;
}
.ai-tutor-send:hover { transform: scale(1.05); }
.ai-tutor-send:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

/* Footer */
.ai-tutor-footer {
  text-align: center;
  padding: 0.375rem;
  font-size: 0.625rem;
  color: var(--text-muted, #888);
  border-top: 1px solid var(--border-color, rgba(255,255,255,0.08));
}

/* ── Mobile ── */
@media (max-width: 640px) {
  .ai-tutor-fab {
    bottom: 5rem;
    right: 1.25rem;
    width: 50px;
    height: 50px;
    font-size: 1.35rem;
  }
  .ai-tutor-panel {
    bottom: 8.5rem;
    right: 0.5rem;
    left: 0.5rem;
    width: auto;
    max-height: 70vh;
  }
}

/* ── Reduced motion ── */
@media (prefers-reduced-motion: reduce) {
  .ai-tutor-fab { animation: none; }
  .ai-tutor-panel { animation: none; }
  .typing-dot { animation: none; opacity: 0.7; }
}
