/* ==============================================================================
   SYNAPSE HUB - TUTOR IA FLUTUANTE ULTRA PREMIUM (LHAMA PIXEL ART)
   Design System: Cyberpunk Glassmorphism + Micro-Interactions + Dynamic Motion
   ============================================================================== */

/* --- ANIMAÇÕES GLOBAIS --- */
@keyframes tutorFloat {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-6px); }
}

@keyframes tutorGlowRotate {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

@keyframes tutorPulseRing {
  0% { transform: scale(0.95); opacity: 0.8; }
  50% { transform: scale(1.15); opacity: 0.2; }
  100% { transform: scale(0.95); opacity: 0.8; }
}

@keyframes tutorWaveListen {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.25); background: #EC4899; box-shadow: 0 0 15px #EC4899; }
}

/* --- BOTÃO FLUTUANTE DO LANÇADOR (SYNAPSE BRAND) --- */
.synapse-tutor-launcher {
  position: fixed;
  bottom: 26px;
  right: 26px;
  width: 62px;
  height: 62px;
  border-radius: 50%;
  background: #070C18;
  cursor: pointer;
  z-index: 99999;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.3s ease;
  user-select: none;
  animation: tutorFloat 4s ease-in-out infinite;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.7), 0 0 24px rgba(0, 210, 180, 0.28);
}

.synapse-tutor-launcher:hover {
  transform: scale(1.1) translateY(-4px);
  animation-play-state: paused;
  box-shadow: 0 14px 40px rgba(0, 0, 0, 0.8), 0 0 35px rgba(0, 210, 180, 0.45);
}

/* Anel de Gradiente Animado (Border Glow Conic Synapse) */
.synapse-tutor-launcher::before {
  content: '';
  position: absolute;
  inset: -2.5px;
  border-radius: 50%;
  background: conic-gradient(from 0deg, #00D2B4, #3B82F6, #00F2FE, #00D2B4);
  z-index: -1;
  animation: tutorGlowRotate 5s linear infinite;
  opacity: 0.85;
}

.synapse-tutor-launcher:hover::before {
  opacity: 1;
  filter: blur(3px);
}

/* Avatar Interno */
.synapse-tutor-launcher .launcher-avatar {
  width: 58px;
  height: 58px;
  border-radius: 50%;
  object-fit: cover;
  transition: transform 0.3s ease;
  display: block;
}

.synapse-tutor-launcher:hover .launcher-avatar {
  transform: rotate(5deg) scale(1.05);
}

/* Indicador de Status Online Pulse (Synapse Cyan) */
.launcher-status-dot {
  position: absolute;
  top: 1px;
  right: 1px;
  width: 14px;
  height: 14px;
  background: #00D2B4;
  border: 2.5px solid #070C18;
  border-radius: 50%;
  box-shadow: 0 0 10px #00D2B4;
}

.launcher-status-dot::after {
  content: '';
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  border: 2px solid #00D2B4;
  animation: tutorPulseRing 2s infinite ease-in-out;
}

/* Balãozinho de Saudação (Speech Bubble Tooltip) */
.tutor-speech-bubble {
  position: absolute;
  right: 76px;
  bottom: 12px;
  background: rgba(11, 15, 25, 0.96);
  border: 1px solid rgba(0, 210, 180, 0.45);
  color: #F8FAFC;
  padding: 8px 15px;
  border-radius: 14px;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.7), 0 0 20px rgba(0, 210, 180, 0.15);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  pointer-events: none;
  opacity: 0;
  transform: translateX(10px) scale(0.95);
  transition: all 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Triângulo da Fala */
.tutor-speech-bubble::after {
  content: '';
  position: absolute;
  right: -6px;
  top: 50%;
  transform: translateY(-50%);
  width: 0;
  height: 0;
  border-top: 5px solid transparent;
  border-bottom: 5px solid transparent;
  border-left: 6px solid rgba(0, 210, 180, 0.5);
}

.synapse-tutor-launcher:hover .tutor-speech-bubble,
.tutor-speech-bubble.visible {
  opacity: 1;
  transform: translateX(0) scale(1);
}

/* --- JANELA MODAL DO CHAT FLUTUANTE (PARTE INTERNA EXPANSÍVEL) --- */
.synapse-tutor-modal {
  position: fixed;
  bottom: 104px;
  right: 26px;
  width: 450px;
  height: 650px;
  min-width: 360px;
  min-height: 440px;
  max-width: calc(100vw - 24px);
  max-height: calc(100vh - 30px);
  background: rgba(11, 15, 25, 0.96);
  border: 1px solid rgba(0, 210, 180, 0.35);
  border-radius: 24px;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.8), 0 0 50px rgba(0, 210, 180, 0.18), inset 0 1px 1px rgba(255, 255, 255, 0.1);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: 99999;
  backdrop-filter: blur(28px);
  -webkit-backdrop-filter: blur(28px);
  transform: scale(0.88) translateY(40px);
  opacity: 0;
  pointer-events: none;
  transition: width 0.3s cubic-bezier(0.16, 1, 0.3, 1), height 0.3s cubic-bezier(0.16, 1, 0.3, 1), transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.3s ease;
}

.synapse-tutor-modal.open {
  transform: scale(1) translateY(0);
  opacity: 1;
  pointer-events: auto;
}

/* Modo Expandido / Maximizado */
.synapse-tutor-modal.maximized {
  width: min(920px, calc(100vw - 36px)) !important;
  height: calc(100vh - 50px) !important;
  bottom: 24px !important;
  right: 24px !important;
  border-radius: 20px;
  box-shadow: 0 30px 90px rgba(0, 0, 0, 0.9), 0 0 60px rgba(0, 210, 180, 0.25);
}

/* Alça de Redimensionamento Customizada (Canto Superior Esquerdo) */
.tutor-resize-handle {
  position: absolute;
  top: 0;
  left: 0;
  width: 22px;
  height: 22px;
  cursor: nwse-resize;
  z-index: 100;
  user-select: none;
}

.tutor-resize-handle::before {
  content: '';
  position: absolute;
  top: 6px;
  left: 6px;
  width: 8px;
  height: 8px;
  border-top: 2px solid rgba(0, 210, 180, 0.6);
  border-left: 2px solid rgba(0, 210, 180, 0.6);
  border-top-left-radius: 3px;
  transition: border-color 0.2s ease;
}

.tutor-resize-handle:hover::before {
  border-color: #00FFCC;
}

/* Header do Chat (Arrastável) */
.tutor-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  background: linear-gradient(180deg, rgba(30, 27, 75, 0.7) 0%, rgba(15, 23, 42, 0.4) 100%);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  position: relative;
  cursor: grab;
  user-select: none;
}

.tutor-header:active {
  cursor: grabbing;
}

.tutor-header-actions,
.tutor-header-left {
  cursor: default;
}

.tutor-header-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.tutor-header-avatar-wrap {
  position: relative;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  padding: 2px;
  background: linear-gradient(135deg, #00D2B4, #EC4899);
}

.tutor-header-avatar {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  background: #0F172A;
  object-fit: cover;
}

.tutor-header-title h3 {
  margin: 0;
  font-size: 15.5px;
  font-weight: 800;
  color: #FFFFFF;
  letter-spacing: -0.01em;
  display: flex;
  align-items: center;
  gap: 8px;
}

.tutor-header-title .tutor-status-badge {
  font-size: 11px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: rgba(0, 210, 180, 0.15);
  color: #00D2B4;
  border: 1px solid rgba(0, 210, 180, 0.4);
  font-weight: 800;
  font-family: var(--font-mono, monospace);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  text-align: center;
}

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

.tutor-btn-icon {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: #94A3B8;
  width: 32px;
  height: 32px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
}

.tutor-btn-icon:hover {
  background: rgba(255, 255, 255, 0.15);
  color: #FFFFFF;
  transform: scale(1.05);
}

/* Barra de Modos de Aprendizado (Segmented Control) */
.tutor-mode-bar {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 6px 14px;
  background: rgba(6, 9, 15, 0.7);
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.tutor-mode-pill {
  flex: 1;
  padding: 6px 10px;
  font-size: 11.5px;
  font-weight: 700;
  color: #94A3B8;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 10px;
  cursor: pointer;
  text-align: center;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
}

.tutor-mode-pill:hover {
  color: #F8FAFC;
  background: rgba(255, 255, 255, 0.05);
}

.tutor-mode-pill.active {
  background: linear-gradient(135deg, rgba(0, 210, 180, 0.2), rgba(99, 102, 241, 0.2));
  color: #00FFCC;
  border-color: rgba(0, 255, 204, 0.4);
  box-shadow: 0 2px 10px rgba(0, 210, 180, 0.15);
}

/* Sugestões Rápidas (Quick Chips) */
.tutor-quick-chips {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 10px 16px;
  background: rgba(11, 15, 25, 0.5);
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}

.tutor-quick-chips::-webkit-scrollbar {
  display: none;
}

.tutor-chip-btn {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: #CBD5E1;
  padding: 6px 12px;
  border-radius: 14px;
  font-size: 11.5px;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
  transition: all 0.2s ease;
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.tutor-chip-btn:hover {
  background: rgba(0, 210, 180, 0.16);
  color: #00FFCC;
  border-color: rgba(0, 210, 180, 0.35);
  transform: translateY(-2px);
}

/* Corpo das Mensagens */
.tutor-messages-body {
  flex: 1;
  padding: 18px 16px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
  scroll-behavior: smooth;
  background: radial-gradient(circle at 50% 20%, rgba(30, 27, 75, 0.25) 0%, transparent 70%);
}

.tutor-messages-body::-webkit-scrollbar {
  width: 5px;
}
.tutor-messages-body::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.15);
  border-radius: 4px;
}

/* Bolhas de Mensagem */
.tutor-msg {
  display: flex;
  gap: 10px;
  max-width: 92%;
  animation: tutorMsgFadeIn 0.3s ease;
}

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

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

.tutor-msg.assistant {
  align-self: flex-start;
}

.tutor-msg-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  flex-shrink: 0;
  border: 1px solid rgba(0, 210, 180, 0.4);
  background: #0F172A;
}

.tutor-msg-bubble {
  padding: 12px 16px;
  border-radius: 18px;
  font-size: 13.5px;
  line-height: 1.55;
  color: #E2E8F0;
  word-break: break-word;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
}

.tutor-msg.user .tutor-msg-bubble {
  background: linear-gradient(135deg, #4F46E5 0%, #7C3AED 100%);
  color: #FFFFFF;
  border-bottom-right-radius: 4px;
  border: 1px solid rgba(255, 255, 255, 0.15);
}

.tutor-msg.assistant .tutor-msg-bubble {
  background: rgba(18, 24, 38, 0.85);
  border: 1px solid rgba(255, 255, 255, 0.09);
  border-bottom-left-radius: 4px;
}

/* Blocos de Código Formatados no Chat */
.tutor-code-card {
  margin: 10px 0;
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: #070A12;
}

.tutor-code-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 12px;
  background: rgba(255, 255, 255, 0.04);
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  font-size: 11px;
  font-family: var(--font-mono, monospace);
  color: #94A3B8;
  font-weight: 700;
  text-transform: uppercase;
}

.tutor-btn-copy-code {
  background: transparent;
  border: none;
  color: #94A3B8;
  font-size: 11px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 4px;
  transition: color 0.2s ease;
}

.tutor-btn-copy-code:hover {
  color: #00FFCC;
}

.tutor-msg pre {
  margin: 0;
  padding: 12px;
  overflow-x: auto;
  font-family: 'JetBrains Mono', 'Fira Code', monospace;
  font-size: 12px;
  color: #38BDF8;
  line-height: 1.45;
}

.tutor-msg code {
  font-family: 'JetBrains Mono', monospace;
  background: rgba(0, 0, 0, 0.35);
  padding: 2px 6px;
  border-radius: 4px;
  color: #EC4899;
  font-size: 12px;
}

/* Pílula de Timestamp Interativo (Pular no Vídeo) */
.tutor-timestamp-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: rgba(0, 210, 180, 0.15);
  color: #00FFCC;
  border: 1px solid rgba(0, 255, 204, 0.4);
  padding: 3px 10px;
  border-radius: 14px;
  font-weight: 700;
  font-family: var(--font-mono, monospace);
  font-size: 11.5px;
  cursor: pointer;
  transition: all 0.2s ease;
  margin: 2px 4px;
  box-shadow: 0 2px 8px rgba(0, 210, 180, 0.15);
}

.tutor-timestamp-btn:hover {
  background: #00FFCC;
  color: #0B0F19;
  transform: scale(1.06);
  box-shadow: 0 4px 14px rgba(0, 255, 204, 0.4);
}

/* Footer / Input Bar */
.tutor-input-container {
  padding: 12px 16px;
  background: rgba(11, 15, 25, 0.85);
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  display: flex;
  align-items: center;
  gap: 8px;
}

.tutor-input-field {
  flex: 1;
  background: rgba(6, 9, 15, 0.85);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 14px;
  padding: 10px 14px;
  font-size: 13.5px;
  color: #F8FAFC;
  outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
  resize: none;
  max-height: 80px;
  font-family: inherit;
}

.tutor-input-field:focus {
  border-color: #00FFCC;
  box-shadow: 0 0 12px rgba(0, 255, 204, 0.25);
}

.tutor-btn-voice {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: #94A3B8;
  width: 40px;
  height: 40px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
  flex-shrink: 0;
}

.tutor-btn-voice:hover {
  background: rgba(255, 255, 255, 0.15);
  color: #00FFCC;
}

.tutor-btn-voice.listening {
  background: #EC4899;
  color: #FFFFFF;
  border-color: #F472B6;
  animation: tutorWaveListen 1.5s infinite;
}

.tutor-btn-send {
  background: linear-gradient(135deg, #00D2B4, #3B82F6);
  border: none;
  color: #FFFFFF;
  width: 40px;
  height: 40px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.25s ease;
  flex-shrink: 0;
}

.tutor-btn-send:hover {
  transform: scale(1.08);
  box-shadow: 0 4px 18px rgba(0, 210, 180, 0.45);
}

.tutor-btn-send:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none;
}

/* Indicador de Digitação (Typing Dots) */
.tutor-typing-dots {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 6px 10px;
}

.tutor-typing-dots span {
  width: 7px;
  height: 7px;
  background: #00FFCC;
  border-radius: 50%;
  animation: tutorBlink 1.4s infinite both;
}

.tutor-typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.tutor-typing-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes tutorBlink {
  0%, 80%, 100% { opacity: 0.2; transform: scale(0.75); }
  40% { opacity: 1; transform: scale(1.3); }
}
