/* ================================================================
   morIsApp mind · Chatbot widget compartido entre las 3 webs
   ================================================================ */

#mj-widget {
  position: fixed;
  bottom: 24px; right: 24px;
  z-index: 9500;
  width: 64px; height: 64px;
  cursor: grab;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
}
#mj-widget.dragging { cursor: grabbing; transition: none; }
#mj-widget.dragged { transition: none; }

.mj-nexus-label {
  position: absolute;
  top: -22px; left: 50%;
  transform: translateX(-50%);
  font-family: 'DM Sans', 'Inter', sans-serif;
  font-size: 0.55rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: rgba(245,242,236,0.55);
  white-space: nowrap;
  pointer-events: none;
}
.mj-nexus-label span { color: #C9A56B; font-weight: 600; }

.mj-bubble {
  position: absolute;
  bottom: 78px; right: 0;
  max-width: 240px;
  background: rgba(10,10,10,0.92);
  border: 1px solid rgba(201,165,107,0.25);
  color: #f4ede0;
  padding: 0.7rem 1rem;
  font-size: 0.78rem;
  line-height: 1.45;
  border-radius: 2px;
  backdrop-filter: blur(10px);
  pointer-events: none;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.3s, transform 0.3s;
  display: none;
}
.mj-bubble::after {
  content: '';
  position: absolute;
  bottom: -6px; right: 22px;
  width: 10px; height: 10px;
  background: rgba(10,10,10,0.92);
  border-right: 1px solid rgba(201,165,107,0.25);
  border-bottom: 1px solid rgba(201,165,107,0.25);
  transform: rotate(45deg);
}

.mj-btn {
  width: 64px; height: 64px;
  border-radius: 50%;
  background: radial-gradient(circle at 30% 30%, #1a1410 0%, #0a0a0a 100%);
  border: 1.5px solid #C9A56B;
  display: flex; align-items: center; justify-content: center;
  position: relative;
  box-shadow: 0 8px 28px rgba(0,0,0,0.5), 0 0 14px rgba(201,165,107,0.2);
  cursor: grab;
  transition: transform 0.25s, box-shadow 0.25s;
}
#mj-widget:not(.dragging) .mj-btn:hover {
  transform: scale(1.06);
  box-shadow: 0 10px 36px rgba(0,0,0,0.6), 0 0 22px rgba(201,165,107,0.4);
}
#mj-widget.dragging .mj-btn { cursor: grabbing; transform: scale(1.1); }

.mj-btn-orb {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #e8c97a 0%, #C9A56B 40%, #8a6f3a 100%);
  position: relative;
  box-shadow: inset 0 0 12px rgba(0,0,0,0.3), 0 0 14px rgba(201,165,107,0.3);
}
.mj-btn-orb::before {
  content: '';
  position: absolute;
  top: 6px; left: 8px;
  width: 10px; height: 6px;
  background: rgba(255,255,255,0.4);
  border-radius: 50%;
  filter: blur(2px);
}

/* Robot SVG · ojos que parpadean, antena que pulsa */
.mj-robot-svg .mj-eye {
  animation: mjBlink 3.8s ease-in-out infinite;
  transform-origin: center 19px;
}
.mj-robot-svg .mj-eye-r { animation-delay: 0.15s; }
@keyframes mjBlink {
  0%, 90%, 100% { transform: scaleY(1); }
  93% { transform: scaleY(0.05); }
  96% { transform: scaleY(1); }
}
.mj-robot-svg .mj-ant-dot {
  animation: mjAnt 1.8s ease-in-out infinite;
  transform-origin: center;
}
@keyframes mjAnt {
  0%, 100% { opacity: 0.6; transform: scale(0.9); }
  50%      { opacity: 1;   transform: scale(1.15); }
}
.mj-head-avatar .mj-robot-svg {
  width: 28px; height: 28px;
  filter: drop-shadow(0 0 6px rgba(201,165,107,0.4));
}
.mj-head-avatar {
  background: radial-gradient(circle at 30% 30%, rgba(232,201,138,0.25) 0%, rgba(201,165,107,0.12) 100%);
  border: 1px solid rgba(201,165,107,0.3);
  display: flex; align-items: center; justify-content: center;
}

@keyframes mjBreath {
  0%, 100% { box-shadow: 0 8px 28px rgba(0,0,0,0.5), 0 0 14px rgba(201,165,107,0.2); }
  50%     { box-shadow: 0 8px 28px rgba(0,0,0,0.5), 0 0 28px rgba(201,165,107,0.5); }
}
#mj-widget:not(.dragging):not(.open) .mj-btn { animation: mjBreath 3s ease-in-out infinite; }

.mj-orbit-ring {
  position: absolute;
  border: 1px solid rgba(201,165,107,0.2);
  border-radius: 50%;
  pointer-events: none;
}
.mj-orbit-ring-1 {
  inset: -8px;
  animation: mjOrbit1 14s linear infinite;
}
.mj-orbit-ring-2 {
  inset: -16px;
  border-style: dashed;
  animation: mjOrbit1 22s linear infinite reverse;
  opacity: 0.5;
}
@keyframes mjOrbit1 { to { transform: rotate(360deg); } }

/* ========== PANEL ========== */
.mj-panel {
  position: fixed;
  bottom: 100px; right: 24px;
  width: 380px;
  max-width: calc(100vw - 32px);
  max-height: calc(100vh - 140px);
  background: rgba(14,14,14,0.96);
  backdrop-filter: blur(24px);
  border: 1px solid rgba(201,165,107,0.25);
  z-index: 9499;
  display: flex; flex-direction: column;
  border-radius: 4px;
  opacity: 0;
  transform: translateY(20px) scale(0.96);
  pointer-events: none;
  transition: opacity 0.35s, transform 0.35s cubic-bezier(0.65,0,0.35,1);
  box-shadow: 0 25px 70px rgba(0,0,0,0.6);
}
.mj-panel.open {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: all;
}

.mj-panel-head {
  display: flex; align-items: center; gap: 0.8rem;
  padding: 1rem 1.2rem;
  border-bottom: 1px solid rgba(201,165,107,0.15);
}
.mj-head-avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: radial-gradient(circle at 30% 30%, #e8c97a 0%, #C9A56B 50%, #8a6f3a 100%);
  flex-shrink: 0;
}
.mj-head-title { flex: 1; min-width: 0; }
.mj-head-name {
  display: block;
  font-size: 0.78rem;
  color: #C9A56B;
  letter-spacing: 0.06em;
  font-weight: 500;
}
.mj-head-sub {
  display: block;
  font-size: 0.65rem;
  color: rgba(245,242,236,0.45);
  letter-spacing: 0.04em;
}
.mj-online {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: #5fc97a;
  box-shadow: 0 0 8px #5fc97a;
  animation: mjPulse 2s ease-in-out infinite;
  flex-shrink: 0;
}
@keyframes mjPulse { 50% { opacity: 0.5; } }
.mj-head-close {
  width: 28px; height: 28px;
  border-radius: 50%;
  border: 1px solid rgba(201,165,107,0.2);
  background: transparent;
  color: rgba(245,242,236,0.6);
  font-size: 0.9rem;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.mj-head-close:hover { color: #C9A56B; border-color: #C9A56B; }

.mj-msgs {
  flex: 1;
  overflow-y: auto;
  padding: 1rem 1.2rem;
  display: flex; flex-direction: column; gap: 0.8rem;
  min-height: 200px; max-height: 360px;
}
.mj-msgs::-webkit-scrollbar { width: 3px; }
.mj-msgs::-webkit-scrollbar-thumb { background: rgba(201,165,107,0.4); border-radius: 2px; }

.mj-msg {
  max-width: 88%;
  padding: 0.7rem 0.95rem;
  font-size: 0.85rem;
  line-height: 1.55;
  border-radius: 4px;
  animation: mjFade 0.4s ease-out;
}
@keyframes mjFade {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}
.mj-msg.bot {
  background: rgba(201,165,107,0.08);
  border: 1px solid rgba(201,165,107,0.15);
  color: rgba(245,242,236,0.9);
  align-self: flex-start;
}
.mj-msg.bot a { color: #C9A56B; text-decoration: underline; }
.mj-msg.bot strong { color: #f4ede0; }
.mj-msg.user {
  background: rgba(201,165,107,0.18);
  border: 1px solid rgba(201,165,107,0.3);
  color: #f4ede0;
  align-self: flex-end;
}

.mj-typing {
  align-self: flex-start;
  display: flex; gap: 4px;
  padding: 0.7rem 0.95rem;
  background: rgba(201,165,107,0.08);
  border: 1px solid rgba(201,165,107,0.15);
  border-radius: 4px;
}
.mj-typing span {
  width: 6px; height: 6px;
  background: #C9A56B;
  border-radius: 50%;
  animation: mjType 1.2s ease-in-out infinite;
}
.mj-typing span:nth-child(2) { animation-delay: 0.2s; }
.mj-typing span:nth-child(3) { animation-delay: 0.4s; }
@keyframes mjType {
  0%, 60%, 100% { transform: scale(0.7); opacity: 0.4; }
  30% { transform: scale(1); opacity: 1; }
}

.mj-chips {
  display: flex; flex-wrap: wrap; gap: 0.35rem;
  padding: 0.8rem 1.2rem;
  border-top: 1px solid rgba(201,165,107,0.1);
}
.mj-chip {
  font-family: inherit;
  font-size: 0.7rem;
  padding: 0.4rem 0.7rem;
  background: rgba(201,165,107,0.05);
  border: 1px solid rgba(201,165,107,0.2);
  color: rgba(245,242,236,0.7);
  cursor: pointer;
  transition: all 0.2s;
  border-radius: 2px;
}
.mj-chip:hover {
  background: rgba(201,165,107,0.15);
  color: #C9A56B;
  border-color: #C9A56B;
}

.mj-input-row {
  display: flex; gap: 0.5rem;
  padding: 0.8rem 1.2rem;
  border-top: 1px solid rgba(201,165,107,0.1);
}
.mj-input {
  flex: 1;
  background: rgba(0,0,0,0.3);
  border: 1px solid rgba(201,165,107,0.2);
  color: #f4ede0;
  font-family: inherit;
  font-size: 0.85rem;
  padding: 0.65rem 0.85rem;
  border-radius: 2px;
}
.mj-input:focus {
  outline: none;
  border-color: #C9A56B;
  background: rgba(0,0,0,0.5);
}
.mj-send {
  width: 40px; height: 40px;
  background: #C9A56B;
  color: #0a0a0a;
  border: none; border-radius: 2px;
  font-weight: 700; font-size: 1rem;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background 0.2s;
}
.mj-send:hover { background: #e8c97a; }

.mj-panel-foot {
  font-size: 0.65rem;
  color: rgba(245,242,236,0.4);
  text-align: center;
  padding: 0.55rem;
  border-top: 1px solid rgba(201,165,107,0.08);
  letter-spacing: 0.05em;
}
.mj-panel-foot a { color: #C9A56B; }

@media (max-width: 600px) {
  #mj-widget { bottom: 16px; right: 16px; }
  .mj-panel {
    bottom: 90px; right: 16px; left: 16px;
    width: auto; max-width: none;
  }
  .mj-bubble { display: none !important; }
}

/* ================================================================
   Selector de idiomas (lang.js)
   ================================================================ */
.lang-selector {
  position: relative;
  display: inline-block;
}
.lang-btn {
  display: flex; align-items: center; gap: 0.5rem;
  padding: 0.5rem 0.9rem;
  background: transparent;
  border: 1px solid rgba(201,165,107,0.25);
  color: rgba(245,242,236,0.7);
  font-family: inherit; font-size: 0.7rem;
  letter-spacing: 0.12em; text-transform: uppercase;
  cursor: pointer;
  transition: all 0.25s;
  border-radius: 2px;
}
.lang-btn:hover { border-color: #C9A56B; color: #C9A56B; }
.lang-btn svg { color: #C9A56B; flex-shrink: 0; }
.lang-btn-current { font-weight: 600; }
.lang-drop {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  min-width: 200px;
  background: rgba(14,14,14,0.96);
  backdrop-filter: blur(20px);
  border: 1px solid rgba(201,165,107,0.25);
  border-radius: 2px;
  padding: 0.5rem;
  display: none;
  z-index: 9300;
  max-height: 480px;
  overflow-y: auto;
  box-shadow: 0 18px 50px rgba(0,0,0,0.5);
}
.lang-drop.open { display: block; }
.lang-grp {
  font-size: 0.58rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: rgba(201,165,107,0.6);
  padding: 0.6rem 0.7rem 0.3rem;
  font-weight: 500;
}
.lang-item {
  width: 100%;
  display: flex; align-items: center; gap: 0.6rem;
  padding: 0.55rem 0.7rem;
  background: transparent;
  border: none;
  color: rgba(245,242,236,0.75);
  font-family: inherit; font-size: 0.82rem;
  text-align: left;
  cursor: pointer;
  border-radius: 2px;
  transition: all 0.2s;
}
.lang-item:hover { background: rgba(201,165,107,0.1); color: #f4ede0; }
.lang-item.active { background: rgba(201,165,107,0.15); color: #C9A56B; }
.lang-item .lang-code {
  font-size: 0.62rem;
  letter-spacing: 0.12em;
  color: #C9A56B;
  font-weight: 600;
  min-width: 24px;
}

/* Theme-aware overrides para webs claras (markia tiene modo claro/oscuro) */
html[data-theme="light"] .mj-btn { background: radial-gradient(circle at 30% 30%, #fff8e0 0%, #f5e6c0 100%); }
html[data-theme="light"] .mj-panel { background: rgba(245,242,236,0.97); color: #0E0E0E; }
html[data-theme="light"] .mj-msg.bot { background: rgba(184,146,78,0.1); color: rgba(14,14,14,0.85); border-color: rgba(184,146,78,0.2); }
html[data-theme="light"] .mj-msg.user { background: rgba(184,146,78,0.2); color: #0E0E0E; }
html[data-theme="light"] .mj-input { background: rgba(255,253,247,0.8); color: #0E0E0E; }
html[data-theme="light"] .lang-drop { background: rgba(245,242,236,0.97); color: #0E0E0E; }
html[data-theme="light"] .lang-item { color: rgba(14,14,14,0.75); }
html[data-theme="light"] .lang-btn { color: rgba(14,14,14,0.7); }

@media (prefers-reduced-motion: reduce) {
  #mj-widget .mj-btn { animation: none !important; }
  .mj-orbit-ring { animation: none !important; }
}
