/* ===== JARVIS AI ASSISTANT ===== */

:root {
  --jarvis-primary: #00d4ff;
  --jarvis-secondary: #7b2ff7;
  --jarvis-dark: #0a0e1a;
  --jarvis-dark2: #111827;
  --jarvis-border: rgba(0, 212, 255, 0.25);
  --jarvis-glow: rgba(0, 212, 255, 0.4);
  --jarvis-radius: 20px;
}

/* ---- Bubble ---- */
#jarvis-bubble {
  position: fixed;
  bottom: 30px;
  right: 30px;
  z-index: 99999;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 12px;
}

#jarvis-toggle {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: linear-gradient(135deg, #7b2ff7, #00d4ff);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 0 0 var(--jarvis-glow), 0 8px 32px rgba(0,0,0,0.4);
  animation: jarvis-pulse 2.5s infinite;
  transition: transform 0.2s ease;
  position: relative;
}

#jarvis-toggle:hover { transform: scale(1.08); }

#jarvis-toggle .jarvis-icon-open,
#jarvis-toggle .jarvis-icon-close { transition: opacity 0.2s ease, transform 0.2s ease; }
#jarvis-toggle .jarvis-icon-close { display: none; }

#jarvis-bubble.open #jarvis-toggle .jarvis-icon-open { display: none; }
#jarvis-bubble.open #jarvis-toggle .jarvis-icon-close { display: flex; }
#jarvis-bubble.open #jarvis-toggle { animation: none; box-shadow: 0 0 20px var(--jarvis-glow), 0 8px 32px rgba(0,0,0,0.4); }

@keyframes jarvis-pulse {
  0%   { box-shadow: 0 0 0 0 var(--jarvis-glow), 0 8px 32px rgba(0,0,0,0.4); }
  70%  { box-shadow: 0 0 0 14px transparent, 0 8px 32px rgba(0,0,0,0.4); }
  100% { box-shadow: 0 0 0 0 transparent, 0 8px 32px rgba(0,0,0,0.4); }
}

/* ---- Label flotante ---- */
#jarvis-label {
  background: linear-gradient(135deg, #7b2ff7, #00d4ff);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 1.5px;
  padding: 4px 10px;
  border-radius: 20px;
  pointer-events: none;
  opacity: 1;
  transition: opacity 0.3s;
  white-space: nowrap;
}
#jarvis-bubble.open #jarvis-label { opacity: 0; }

/* ---- Ventana de chat ---- */
#jarvis-window {
  position: fixed;
  bottom: 110px;
  right: 30px;
  width: 370px;
  max-height: 560px;
  background: var(--jarvis-dark);
  border: 1px solid var(--jarvis-border);
  border-radius: var(--jarvis-radius);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: 99998;
  box-shadow: 0 20px 60px rgba(0,0,0,0.6), 0 0 40px rgba(0,212,255,0.08);
  transform: translateY(20px) scale(0.95);
  opacity: 0;
  pointer-events: none;
  transition: transform 0.3s cubic-bezier(.4,0,.2,1), opacity 0.3s ease;
}

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

/* ---- Header ---- */
#jarvis-header {
  background: linear-gradient(90deg, #0d1120, #141c2e);
  border-bottom: 1px solid var(--jarvis-border);
  padding: 14px 18px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}

.jarvis-avatar {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: linear-gradient(135deg, #7b2ff7, #00d4ff);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  position: relative;
}

.jarvis-avatar::after {
  content: '';
  position: absolute;
  width: 10px;
  height: 10px;
  background: #22c55e;
  border-radius: 50%;
  bottom: 1px;
  right: 1px;
  border: 2px solid var(--jarvis-dark);
  animation: jarvis-blink 2s infinite;
}

@keyframes jarvis-blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

.jarvis-info h4 {
  color: #fff;
  font-size: 15px;
  font-weight: 700;
  margin: 0;
  line-height: 1.2;
  letter-spacing: 0.5px;
}

.jarvis-info span {
  color: var(--jarvis-primary);
  font-size: 11px;
  font-weight: 500;
  opacity: 0.8;
}

#jarvis-close-btn {
  margin-left: auto;
  background: none;
  border: none;
  color: rgba(255,255,255,0.4);
  cursor: pointer;
  padding: 4px;
  display: flex;
  align-items: center;
  transition: color 0.2s;
}
#jarvis-close-btn:hover { color: #fff; }

/* ---- Mensajes ---- */
#jarvis-messages {
  flex: 1;
  overflow-y: auto;
  padding: 18px 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  scrollbar-width: thin;
  scrollbar-color: rgba(0,212,255,0.2) transparent;
}

#jarvis-messages::-webkit-scrollbar { width: 4px; }
#jarvis-messages::-webkit-scrollbar-thumb { background: rgba(0,212,255,0.2); border-radius: 4px; }

.jarvis-msg {
  display: flex;
  flex-direction: column;
  max-width: 85%;
  animation: jarvis-msg-in 0.25s ease;
}

@keyframes jarvis-msg-in {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

.jarvis-msg.bot  { align-self: flex-start; }
.jarvis-msg.user { align-self: flex-end; }

.jarvis-msg-bubble {
  padding: 10px 14px;
  border-radius: 16px;
  font-size: 13.5px;
  line-height: 1.55;
  word-break: break-word;
}

.jarvis-msg.bot .jarvis-msg-bubble {
  background: rgba(0,212,255,0.08);
  border: 1px solid rgba(0,212,255,0.15);
  color: #e2e8f0;
  border-top-left-radius: 4px;
}

.jarvis-msg.user .jarvis-msg-bubble {
  background: linear-gradient(135deg, #7b2ff7, #00d4ff);
  color: #fff;
  border-top-right-radius: 4px;
}

.jarvis-msg-time {
  font-size: 10px;
  color: rgba(255,255,255,0.25);
  margin-top: 4px;
  padding: 0 4px;
}
.jarvis-msg.user .jarvis-msg-time { text-align: right; }

/* ---- Typing indicator ---- */
#jarvis-typing {
  display: none;
  align-self: flex-start;
  align-items: center;
  gap: 5px;
  padding: 10px 14px;
  background: rgba(0,212,255,0.08);
  border: 1px solid rgba(0,212,255,0.15);
  border-radius: 16px;
  border-top-left-radius: 4px;
}
#jarvis-typing.visible { display: flex; }
#jarvis-typing span {
  width: 7px; height: 7px;
  background: var(--jarvis-primary);
  border-radius: 50%;
  opacity: 0.4;
  animation: jarvis-dot 1.2s infinite;
}
#jarvis-typing span:nth-child(2) { animation-delay: 0.2s; }
#jarvis-typing span:nth-child(3) { animation-delay: 0.4s; }

@keyframes jarvis-dot {
  0%, 80%, 100% { opacity: 0.4; transform: scale(1); }
  40% { opacity: 1; transform: scale(1.3); }
}

/* ---- Input area ---- */
#jarvis-input-area {
  padding: 14px 16px;
  border-top: 1px solid var(--jarvis-border);
  background: var(--jarvis-dark2);
  display: flex;
  align-items: flex-end;
  gap: 10px;
  flex-shrink: 0;
}

#jarvis-input {
  flex: 1;
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 12px;
  color: #fff;
  font-size: 13.5px;
  padding: 10px 14px;
  resize: none;
  min-height: 42px;
  max-height: 120px;
  outline: none;
  font-family: inherit;
  transition: border-color 0.2s;
  scrollbar-width: none;
}
#jarvis-input::-webkit-scrollbar { display: none; }
#jarvis-input:focus { border-color: var(--jarvis-primary); }
#jarvis-input::placeholder { color: rgba(255,255,255,0.3); }

#jarvis-send {
  width: 42px;
  height: 42px;
  background: linear-gradient(135deg, #7b2ff7, #00d4ff);
  border: none;
  border-radius: 12px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: opacity 0.2s, transform 0.2s;
}
#jarvis-send:hover { opacity: 0.9; transform: scale(1.05); }
#jarvis-send:disabled { opacity: 0.4; cursor: not-allowed; transform: none; }

/* ---- Footer del chat ---- */
#jarvis-footer {
  text-align: center;
  padding: 8px;
  font-size: 10px;
  color: rgba(255,255,255,0.15);
  background: var(--jarvis-dark2);
  letter-spacing: 0.5px;
}

/* ---- Responsive ---- */
@media (max-width: 480px) {
  #jarvis-window {
    right: 10px;
    bottom: 100px;
    width: calc(100vw - 20px);
  }
  #jarvis-bubble {
    right: 16px;
    bottom: 20px;
  }
}
