/* tutor.css */
:root {
  --tutor-bg: #1e1e2f;
  --tutor-card: #2a2a40;
  --tutor-border: rgba(255, 255, 255, 0.1);
  --tutor-primary: #6366f1;
  --tutor-user-msg: #3b82f6;
  --tutor-bot-msg: #374151;
  --tutor-text: #f8fafc;
  --tutor-muted: #94a3b8;
}

#tutor-fab {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 60px;
  height: 60px;
  background: linear-gradient(135deg, var(--tutor-primary), #8b5cf6);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 10px 25px rgba(99, 102, 241, 0.4);
  z-index: 10001;  /* Por encima del menú hamburguesa (9999) */
  transition: transform 0.2s, box-shadow 0.2s;
  font-size: 28px;
  touch-action: manipulation;  /* Evita delay de 300ms en iOS */
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
}

#tutor-fab:hover {
  transform: scale(1.05) translateY(-5px);
  box-shadow: 0 15px 35px rgba(99, 102, 241, 0.6);
}

#tutor-window {
  position: fixed;
  bottom: 100px;
  right: 24px;
  width: 380px;
  height: 550px;
  max-height: 80vh;
  background: var(--tutor-bg);
  border: 1px solid var(--tutor-border);
  border-radius: 20px;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
  display: flex;
  flex-direction: column;
  z-index: 10000;  /* Por encima del hamburguesa */
  overflow: hidden;
  opacity: 0;
  pointer-events: none;
  transform: translateY(20px) scale(0.95);
  transition: opacity 0.3s ease, transform 0.3s ease;
  font-family: 'Inter', sans-serif;
}

/* ── RESPONSIVE MÓVIL ── */
@media (max-width: 500px) {
  #tutor-fab {
    bottom: 82px;
    left: 50%;
    right: auto;
    transform: translateX(-50%);
    width: 54px;
    height: 54px;
    font-size: 24px;
  }
  #tutor-window {
    bottom: 0;
    right: 0;
    left: 0;
    width: 100%;
    height: 90vh;
    max-height: 90vh;
    border-radius: 20px 20px 0 0;
    border-bottom: none;
  }
}

#tutor-window.active {
  opacity: 1;
  pointer-events: all;
  transform: translateY(0) scale(1);
}

.tutor-header {
  background: var(--tutor-card);
  padding: 16px 20px;
  border-bottom: 1px solid var(--tutor-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

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

.tutor-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: linear-gradient(135deg, #10b981, #059669);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  box-shadow: 0 0 15px rgba(16, 185, 129, 0.3);
}

.tutor-title {
  color: var(--tutor-text);
  font-weight: 800;
  font-size: 16px;
  margin: 0;
  line-height: 1.2;
}

.tutor-status {
  color: #10b981;
  font-size: 11px;
  font-weight: 600;
}

.tutor-close {
  background: transparent;
  border: none;
  color: var(--tutor-muted);
  font-size: 24px;
  cursor: pointer;
  transition: color 0.2s;
}

.tutor-close:hover {
  color: var(--tutor-text);
}

.tutor-body {
  flex: 1;
  padding: 16px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
  background: linear-gradient(to bottom, var(--tutor-bg), #13131f);
}

.tutor-msg {
  max-width: 85%;
  padding: 12px 16px;
  border-radius: 18px;
  font-size: 14px;
  line-height: 1.5;
  color: var(--tutor-text);
  word-wrap: break-word;
  animation: popIn 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes popIn {
  from { opacity: 0; transform: translateY(10px) scale(0.95); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.tutor-msg.bot {
  background: var(--tutor-bot-msg);
  align-self: flex-start;
  border-bottom-left-radius: 4px;
  border: 1px solid var(--tutor-border);
}

.tutor-msg.user {
  background: var(--tutor-user-msg);
  align-self: flex-end;
  border-bottom-right-radius: 4px;
}

.tutor-msg .context-chip {
  display: block;
  font-size: 11px;
  color: rgba(255,255,255,0.7);
  background: rgba(0,0,0,0.2);
  padding: 4px 8px;
  border-radius: 6px;
  margin-bottom: 6px;
  border: 1px dashed rgba(255,255,255,0.3);
}

.tutor-input-area {
  padding: 16px;
  background: var(--tutor-card);
  border-top: 1px solid var(--tutor-border);
  display: flex;
  gap: 10px;
}

.tutor-input {
  flex: 1;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--tutor-border);
  border-radius: 20px;
  padding: 12px 16px;
  color: var(--tutor-text);
  font-size: 14px;
  outline: none;
  transition: border-color 0.2s;
  font-family: inherit;
}

.tutor-input:focus {
  border-color: var(--tutor-primary);
}

.tutor-send {
  background: var(--tutor-primary);
  color: white;
  border: none;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform 0.2s, background 0.2s;
}

.tutor-send:hover {
  transform: scale(1.05);
  background: #4f46e5;
}

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

.typing-indicator {
  display: flex;
  gap: 4px;
  padding: 12px 16px;
  background: var(--tutor-bot-msg);
  border-radius: 18px;
  border-bottom-left-radius: 4px;
  align-self: flex-start;
  width: fit-content;
}

.typing-dot {
  width: 6px;
  height: 6px;
  background: var(--tutor-muted);
  border-radius: 50%;
  animation: typing 1.4s infinite ease-in-out both;
}

.typing-dot:nth-child(1) { animation-delay: -0.32s; }
.typing-dot:nth-child(2) { animation-delay: -0.16s; }

@keyframes typing {
  0%, 80%, 100% { transform: scale(0); }
  40% { transform: scale(1); }
}
