/* ==========================================================================
   HOLOCRON WEB — 3D LIQUID ORB & JUANA VOICE AGENT WIDGET
   ========================================================================== */

#holocron-orb-widget {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  font-family: inherit;
  pointer-events: none;
}

#holocron-orb-widget * {
  box-sizing: border-box;
}

/* Tooltip Incitador / Typewriter Badge */
.orb-badge {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 7px 12px 7px 10px;
  background: rgba(18, 18, 18, 0.92);
  color: var(--text, #f5f5f4);
  border: 1px solid rgba(45, 212, 191, 0.35);
  border-radius: 24px;
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.01em;
  box-shadow: 0 8px 26px rgba(0, 0, 0, 0.45), 0 0 14px rgba(45, 212, 191, 0.2);
  margin-bottom: 8px;
  cursor: pointer;
  pointer-events: auto;
  transition: opacity 0.25s ease, transform 0.25s cubic-bezier(0.16, 1, 0.3, 1), max-height 0.25s ease, margin 0.25s ease;
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  user-select: none;
  min-width: 140px;
}

.orb-badge:hover {
  transform: translateY(-2px) scale(1.02);
  border-color: var(--accent, #2dd4bf);
  background: var(--bg, #121212);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.55), 0 0 18px rgba(45, 212, 191, 0.3);
}

.orb-badge-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent, #2dd4bf);
  box-shadow: 0 0 8px var(--accent, #2dd4bf);
  animation: orb-heartbeat 1.8s infinite ease-in-out;
  flex-shrink: 0;
}

.orb-badge-prefix {
  color: var(--accent, #2dd4bf);
  font-size: 13px;
  line-height: 1;
}

.orb-badge-text {
  font-weight: 500;
  color: var(--text, #f5f5f4);
  white-space: nowrap;
}

.orb-typewriter-cursor {
  color: var(--accent, #2dd4bf);
  font-weight: 700;
  font-size: 13px;
  letter-spacing: 1.5px;
  margin-left: 2px;
  animation: typewriter-dots 1.1s infinite ease-in-out;
}

@keyframes typewriter-dots {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.2; }
}

.orb-badge-close {
  background: none;
  border: none;
  color: var(--text-muted, #a3a3a3);
  font-size: 11px;
  cursor: pointer;
  padding: 2px 4px;
  margin-left: auto;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.15s, background 0.15s;
}

.orb-badge-close:hover {
  color: #f87171;
  background: rgba(255, 255, 255, 0.1);
}

/* Ocultar badge cuando el panel está abierto o cuando se cerró */
#holocron-orb-widget.is-panel-open .orb-badge,
.orb-badge.is-hidden {
  opacity: 0 !important;
  pointer-events: none !important;
  transform: translateY(8px) scale(0.9);
  max-height: 0;
  margin-bottom: 0;
  padding-top: 0;
  padding-bottom: 0;
  overflow: hidden;
}

/* Panel Principal del Orb */
.orb-container {
  position: relative;
  width: 140px;
  height: 140px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  user-select: none;
  pointer-events: auto;
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  outline: none;
}

.orb-container:hover {
  transform: scale(1.08);
}

/* Latido del Orb (Heartbeat) */
.orb-container.is-idle .orb-aura {
  animation: orb-heartbeat 2.2s infinite ease-in-out;
}

@keyframes orb-heartbeat {
  0% {
    transform: translate(-50%, -50%) scale(1);
    opacity: 0.28;
  }
  14% {
    transform: translate(-50%, -50%) scale(1.22);
    opacity: 0.55;
  }
  28% {
    transform: translate(-50%, -50%) scale(1.06);
    opacity: 0.35;
  }
  42% {
    transform: translate(-50%, -50%) scale(1.28);
    opacity: 0.65;
  }
  70% {
    transform: translate(-50%, -50%) scale(1);
    opacity: 0.28;
  }
  100% {
    transform: translate(-50%, -50%) scale(1);
    opacity: 0.28;
  }
}

/* Canvas WebGL de 3D Orb */
#orb-canvas {
  width: 100%;
  height: 100%;
  display: block;
  filter: drop-shadow(0 12px 35px rgba(13, 148, 136, 0.45));
}

/* Glow Aura en el fondo */
.orb-aura {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 110px;
  height: 110px;
  border-radius: 50%;
  background: radial-gradient(circle, var(--accent, #2dd4bf) 0%, rgba(13, 148, 136, 0.4) 40%, rgba(13, 148, 136, 0) 72%);
  opacity: 0.35;
  pointer-events: none;
  transition: opacity 0.4s ease, transform 0.4s ease, background 0.4s ease;
  z-index: -1;
}

.orb-container.is-active .orb-aura {
  opacity: 0.65;
  transform: translate(-50%, -50%) scale(1.35);
  background: radial-gradient(circle, #5eead4 0%, rgba(45, 212, 191, 0.5) 45%, rgba(13, 148, 136, 0) 75%);
}

.orb-container.is-listening .orb-aura {
  animation: orb-pulse-listening 1.2s infinite ease-in-out;
}

@keyframes orb-pulse-listening {
  0%, 100% { transform: translate(-50%, -50%) scale(1.1); opacity: 0.4; }
  50% { transform: translate(-50%, -50%) scale(1.4); opacity: 0.75; }
}

/* Compact Voice HUD Card */
.orb-transcript-panel {
  position: absolute;
  bottom: 160px;
  right: 0;
  width: 290px;
  background: rgba(18, 18, 18, 0.92);
  color: var(--text, #f5f5f4);
  border: 1px solid var(--border, #2a2a2a);
  border-radius: 20px;
  padding: 16px;
  box-shadow: 0 16px 44px rgba(0, 0, 0, 0.6), 0 0 24px rgba(45, 212, 191, 0.15);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  display: flex;
  flex-direction: column;
  gap: 12px;
  opacity: 0;
  transform: translateY(16px) scale(0.94);
  pointer-events: none;
  transition: opacity 0.3s cubic-bezier(0.16, 1, 0.3, 1), transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.orb-transcript-panel.is-open {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

.orb-transcript-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  padding-bottom: 10px;
}

.orb-agent-identity {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  color: var(--text, #f5f5f4);
}

.orb-avatar-mini {
  color: var(--accent, #2dd4bf);
  font-size: 16px;
}

.orb-tag {
  font-size: 10px;
  background: rgba(45, 212, 191, 0.15);
  color: var(--accent, #2dd4bf);
  padding: 2px 6px;
  border-radius: 10px;
  border: 1px solid rgba(45, 212, 191, 0.3);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.orb-status-badge {
  display: flex;
  align-items: center;
  gap: 6px;
}

.orb-status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #a3a3a3;
  transition: background 0.3s ease, box-shadow 0.3s ease;
}

.orb-status-dot.is-live {
  background: #2dd4bf;
  box-shadow: 0 0 8px #2dd4bf;
}

.orb-status-dot.is-thinking {
  background: #fbbf24;
  box-shadow: 0 0 8px #fbbf24;
}

.orb-status-dot.is-error {
  background: #f87171;
  box-shadow: 0 0 8px #f87171;
}

.orb-transcript-status {
  font-size: 11px;
  color: var(--text-muted, #a3a3a3);
  letter-spacing: 0.02em;
}

/* Indicador de Estado y Ondas de Audio */
.orb-status-indicator {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: rgba(255, 255, 255, 0.04);
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.06);
}

.orb-state-message {
  font-size: 12px;
  color: var(--text, #f5f5f4);
  font-weight: 500;
  flex: 1;
}

.orb-mic-container {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 4px;
}

.orb-mic-label {
  font-size: 10px;
  font-weight: 600;
  color: var(--text-muted, #a3a3a3);
  letter-spacing: 0.05em;
}

.orb-mic-meter {
  flex: 1;
  height: 5px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 3px;
  overflow: hidden;
  position: relative;
}

.orb-mic-meter-fill {
  width: 0%;
  height: 100%;
  background: linear-gradient(90deg, #2dd4bf, #4ade80);
  border-radius: 3px;
  transition: width 0.08s ease-out;
}

.orb-wave-bars {
  display: flex;
  align-items: center;
  gap: 3px;
  height: 16px;
}

.orb-wave-bars span {
  width: 3px;
  height: 4px;
  background: var(--accent, #2dd4bf);
  border-radius: 2px;
  transition: height 0.15s ease;
}

.orb-wave-bars.is-active span:nth-child(1) { animation: wave-anim 0.8s infinite ease-in-out 0.1s; }
.orb-wave-bars.is-active span:nth-child(2) { animation: wave-anim 0.8s infinite ease-in-out 0.3s; }
.orb-wave-bars.is-active span:nth-child(3) { animation: wave-anim 0.8s infinite ease-in-out 0.2s; }
.orb-wave-bars.is-active span:nth-child(4) { animation: wave-anim 0.8s infinite ease-in-out 0.4s; }
.orb-wave-bars.is-active span:nth-child(5) { animation: wave-anim 0.8s infinite ease-in-out 0.15s; }

@keyframes wave-anim {
  0%, 100% { height: 4px; }
  50% { height: 16px; }
}

/* Controles de Voz (Mic mute, Disconnect) */
.orb-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 2px;
  padding-top: 10px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.orb-btn {
  background: var(--bg-subtle, #1c1c1c);
  color: var(--text, #f5f5f4);
  border: 1px solid var(--border, #2a2a2a);
  border-radius: 20px;
  padding: 8px 14px;
  font-size: 12px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: background 0.2s, border-color 0.2s, transform 0.1s;
}

.orb-btn:hover {
  background: rgba(45, 212, 191, 0.15);
  border-color: var(--accent, #2dd4bf);
}

.orb-btn.is-danger {
  color: #f87171;
  border-color: rgba(248, 113, 113, 0.3);
}

.orb-btn.is-danger:hover {
  background: rgba(248, 113, 113, 0.15);
  border-color: #f87171;
}

/* Responsividad */
@media (max-width: 640px) {
  #holocron-orb-widget {
    bottom: 16px;
    right: 16px;
  }
  .orb-container {
    width: 110px;
    height: 110px;
  }
  .orb-transcript-panel {
    width: calc(100vw - 32px);
    right: 0;
  }
  .orb-badge {
    max-width: calc(100vw - 32px);
  }
}
