/* ============================================================
   EMOTION DETECTION STYLES
   Estilos para el módulo de detección de emociones faciales
   ============================================================ */

/* ========= CONTENEDOR DE WEBCAM ========= */
.webcam-container {
  position: relative;
  width: 100%;
  max-width: 320px;
  margin: 1rem auto;
  border-radius: 16px;
  overflow: hidden;
  background: linear-gradient(135deg, #1e1b4b 0%, #312e81 50%, #1e1b4b 100%);
  box-shadow: 
    0 10px 40px rgba(99, 102, 241, 0.3),
    0 0 0 1px rgba(255, 255, 255, 0.1),
    inset 0 1px 0 rgba(255, 255, 255, 0.1);
  transition: all 0.3s ease;
}

.webcam-container:hover {
  transform: translateY(-2px);
  box-shadow: 
    0 15px 50px rgba(99, 102, 241, 0.4),
    0 0 0 1px rgba(255, 255, 255, 0.15),
    inset 0 1px 0 rgba(255, 255, 255, 0.15);
}

.webcam-container.is-active {
  box-shadow: 
    0 10px 40px rgba(99, 102, 241, 0.4),
    0 0 30px rgba(244, 114, 182, 0.3),
    0 0 0 2px rgba(244, 114, 182, 0.5),
    inset 0 1px 0 rgba(255, 255, 255, 0.1);
}

/* ========= HEADER DE WEBCAM ========= */
.webcam-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1rem;
  background: rgba(0, 0, 0, 0.3);
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.webcam-title {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.85rem;
  font-weight: 600;
  color: #e0e7ff;
  letter-spacing: 0.025em;
}

.webcam-title-icon {
  font-size: 1.1rem;
  animation: pulse-glow 2s ease-in-out infinite;
}

@keyframes pulse-glow {
  0%, 100% { opacity: 0.7; transform: scale(1); }
  50% { opacity: 1; transform: scale(1.1); }
}

.webcam-toggle {
  position: relative;
  width: 44px;
  height: 24px;
  background: rgba(99, 102, 241, 0.3);
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.3s ease;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.webcam-toggle:hover {
  background: rgba(99, 102, 241, 0.4);
}

.webcam-toggle.is-active {
  background: linear-gradient(135deg, #6366f1, #a855f7);
  border-color: rgba(255, 255, 255, 0.2);
}

.webcam-toggle-knob {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 18px;
  height: 18px;
  background: white;
  border-radius: 50%;
  transition: all 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.55);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.webcam-toggle.is-active .webcam-toggle-knob {
  left: calc(100% - 20px);
}

/* ========= ÁREA DE VIDEO ========= */
.webcam-video-area {
  position: relative;
  aspect-ratio: 4/3;
  background: #0f0f23;
  overflow: hidden;
}

.webcam-video,
.webcam-canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.webcam-video {
  /* Video oculto - se usa solo para procesamiento */
  opacity: 0;
  pointer-events: none;
}

.webcam-canvas {
  z-index: 1;
  /* El canvas ya dibuja el video espejado correctamente */
}

/* Placeholder cuando está desactivado */
.webcam-placeholder {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  background: linear-gradient(135deg, #1e1b4b 0%, #312e81 100%);
  z-index: 2;
  opacity: 1;
  transition: opacity 0.3s ease;
}

.webcam-container.is-active .webcam-placeholder {
  opacity: 0;
  pointer-events: none;
}

.webcam-placeholder-icon {
  font-size: 3rem;
  opacity: 0.5;
  animation: float 3s ease-in-out infinite;
}

@keyframes float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-10px); }
}

.webcam-placeholder-text {
  font-size: 0.8rem;
  color: #a5b4fc;
  text-align: center;
  padding: 0 1rem;
  opacity: 0.7;
}

/* ========= DISPLAY DE EMOCIÓN ========= */
.emotion-display {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  background: rgba(0, 0, 0, 0.4);
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  transition: all 0.3s ease;
}

.emotion-indicator {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #6b7280;
  transition: all 0.3s ease;
  box-shadow: 0 0 10px currentColor;
}

.emotion-emoji {
  font-size: 1.5rem;
  transition: transform 0.3s ease;
}

.emotion-display:hover .emotion-emoji {
  transform: scale(1.2);
}

.emotion-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.emotion-label {
  font-size: 0.9rem;
  font-weight: 600;
  color: #f1f5f9;
  transition: color 0.3s ease;
}

.emotion-confidence {
  font-size: 0.75rem;
  color: #94a3b8;
}

/* ========= ESTADOS DE EMOCIÓN ========= */
.emotion-display.emotion-happy .emotion-indicator {
  background: #22c55e;
  box-shadow: 0 0 15px rgba(34, 197, 94, 0.5);
}

.emotion-display.emotion-sad .emotion-indicator {
  background: #3b82f6;
  box-shadow: 0 0 15px rgba(59, 130, 246, 0.5);
}

.emotion-display.emotion-angry .emotion-indicator {
  background: #ef4444;
  box-shadow: 0 0 15px rgba(239, 68, 68, 0.5);
}

.emotion-display.emotion-surprised .emotion-indicator {
  background: #f59e0b;
  box-shadow: 0 0 15px rgba(245, 158, 11, 0.5);
}

.emotion-display.emotion-neutral .emotion-indicator {
  background: #6b7280;
  box-shadow: 0 0 15px rgba(107, 114, 128, 0.5);
}

.emotion-display.emotion-fearful .emotion-indicator {
  background: #8b5cf6;
  box-shadow: 0 0 15px rgba(139, 92, 246, 0.5);
}

.emotion-display.emotion-disgusted .emotion-indicator {
  background: #84cc16;
  box-shadow: 0 0 15px rgba(132, 204, 22, 0.5);
}

/* ========= BARRA DE ESTADO ========= */
.emotion-status-bar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  background: rgba(0, 0, 0, 0.2);
  font-size: 0.7rem;
  color: #94a3b8;
}

.emotion-status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #6b7280;
  transition: all 0.3s ease;
}

.emotion-status-dot.is-active {
  background: #22c55e;
  animation: blink 1s ease-in-out infinite;
}

@keyframes blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

.emotion-status-text {
  flex: 1;
}

.emotion-last-sent {
  opacity: 0.7;
}

/* ========= ANIMACIONES DE TRANSICIÓN ========= */
.emotion-display {
  position: relative;
  overflow: hidden;
}

.emotion-display::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.1), transparent);
  transition: left 0.5s ease;
}

.emotion-display.emotion-changed::before {
  left: 100%;
}

/* ========= RESPONSIVE ========= */
@media (max-width: 768px) {
  .webcam-container {
    max-width: 280px;
  }
  
  .emotion-display {
    padding: 0.6rem 0.8rem;
  }
  
  .emotion-emoji {
    font-size: 1.3rem;
  }
  
  .emotion-label {
    font-size: 0.85rem;
  }
}

/* ========= TEMA OSCURO MEJORADO ========= */
@media (prefers-color-scheme: dark) {
  .webcam-container {
    background: linear-gradient(135deg, #0c0a1d 0%, #1a1744 50%, #0c0a1d 100%);
  }
  
  .webcam-video-area {
    background: #050510;
  }
}

/* ========= ACCESIBILIDAD ========= */
@media (prefers-reduced-motion: reduce) {
  .webcam-placeholder-icon,
  .webcam-toggle-knob,
  .emotion-emoji,
  .emotion-indicator {
    animation: none;
    transition: none;
  }
}

/* ========= INDICADOR DE PROCESAMIENTO ========= */
.emotion-processing {
  position: absolute;
  bottom: 8px;
  right: 8px;
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px 8px;
  background: rgba(0, 0, 0, 0.7);
  border-radius: 4px;
  font-size: 0.65rem;
  color: #a5b4fc;
  z-index: 3;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.webcam-container.is-active .emotion-processing {
  opacity: 1;
}

.emotion-processing-dot {
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: #a5b4fc;
  animation: processing-pulse 1.4s ease-in-out infinite;
}

.emotion-processing-dot:nth-child(2) {
  animation-delay: 0.2s;
}

.emotion-processing-dot:nth-child(3) {
  animation-delay: 0.4s;
}

@keyframes processing-pulse {
  0%, 80%, 100% { transform: scale(0.6); opacity: 0.5; }
  40% { transform: scale(1); opacity: 1; }
}

/* ========= TOOLTIP DE AYUDA ========= */
.webcam-help {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  padding: 1rem 1.5rem;
  background: rgba(0, 0, 0, 0.9);
  border-radius: 12px;
  text-align: center;
  z-index: 10;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.webcam-container.show-help .webcam-help {
  opacity: 1;
  pointer-events: auto;
}

.webcam-help-title {
  font-size: 0.9rem;
  font-weight: 600;
  color: #f1f5f9;
  margin-bottom: 0.5rem;
}

.webcam-help-text {
  font-size: 0.75rem;
  color: #94a3b8;
  line-height: 1.5;
}