/* ===== CONTENEDOR PRINCIPAL ===== */
.avatar-widget {
  position: fixed !important;
  bottom: 20px !important;
  right: 20px !important;
  z-index: 9999 !important;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

/* ===== AVATAR CIRCULAR (MINIMIZADO) ===== */
.avatar-circle {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  overflow: hidden;
  cursor: pointer;
  box-shadow: 0 8px 30px rgba(102, 126, 234, 0.4);
  border: 3px solid #667eea;
  transition: all 0.3s ease;
  position: relative;
  background: #fff;
}

.avatar-circle:hover {
  transform: scale(1.1);
  box-shadow: 0 12px 40px rgba(102, 126, 234, 0.6);
}

.avatar-circle img,
.avatar-circle video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center center;
}

/* Indicador de estado */
.avatar-pulse {
  position: absolute;
  bottom: 5px;
  right: 5px;
  width: 16px;
  height: 16px;
  background: #51CF66;
  border-radius: 50%;
  border: 2px solid #fff;
  animation: pulse-dot 2s infinite;
}

.avatar-circle.playing .avatar-pulse {
  background: #ff6b6b;
  animation: pulse-speaking 0.5s infinite;
}

.avatar-circle.listening .avatar-pulse {
  background: #667eea;
  animation: pulse-listening 0.8s infinite;
}

@keyframes pulse-dot {
  0%, 100% { 
    opacity: 1;
    transform: scale(1);
  }
  50% { 
    opacity: 0.6;
    transform: scale(1.2);
  }
}

@keyframes pulse-speaking {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.3); }
}

@keyframes pulse-listening {
  0%, 100% { 
    transform: scale(1); 
    box-shadow: 0 0 0 0 rgba(102, 126, 234, 0.4); 
  }
  50% { 
    transform: scale(1.2); 
    box-shadow: 0 0 0 8px rgba(102, 126, 234, 0); 
  }
}

/* ===== PANEL EXPANDIDO - POSICIONADO ABAJO ===== */
.avatar-panel {
  display: none;
  width: 400px;
  background: #fff;
  border-radius: 20px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
  overflow: hidden;
  flex-direction: column;
  position: fixed !important;
  bottom: 110px !important;
  right: 20px !important;
  max-width: calc(100vw - 40px);
  max-height: calc(100vh - 140px);
}

.avatar-widget.expanded .avatar-circle {
  display: none;
}

.avatar-widget.expanded .avatar-panel {
  display: flex !important;
}

/* ===== HEADER DEL PANEL ===== */
.avatar-header {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  padding: 15px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-shrink: 0;
}

.header-info h3 {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
}

.header-info p {
  margin: 4px 0 0;
  font-size: 11px;
  opacity: 0.9;
}

.close-btn {
  background: rgba(255, 255, 255, 0.2);
  border: none;
  color: white;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.3s;
  flex-shrink: 0;
}

.close-btn:hover {
  background: rgba(255, 255, 255, 0.3);
}

/* ===== CONTENEDOR DE VIDEO - IMAGEN COMPLETA ===== */
.video-container {
  background: #f5f5f5;
  height: 280px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  position: relative;
  padding: 15px;
  flex-shrink: 0;
}

/* Avatar estático - Imagen completa y centrada */
#video-avatar,
.video-container .avatar-static {
  height: 100%;
  width: auto;
  max-width: 100%;
  object-fit: contain;
  border: none;
  border-radius: 0;
  box-shadow: none;
}

/* Video principal */
#main-video,
.video-container video {
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #f5f5f5;
}

/* ===== ÁREA DE CHAT ===== */
.chat-area {
  padding: 15px;
  max-height: 100px;
  min-height: 60px;
  overflow-y: auto;
  background: #f8f9fa;
  flex-shrink: 1;
}

.chat-message {
  margin-bottom: 10px;
  padding: 10px 14px;
  border-radius: 15px;
  max-width: 85%;
  word-wrap: break-word;
  font-size: 14px;
  line-height: 1.4;
}

.chat-message.user {
  background: #e9ecef;
  color: #333;
  margin-left: auto;
  border-bottom-right-radius: 5px;
}

.chat-message.bot {
  background: #667eea;
  color: white;
  border-bottom-left-radius: 5px;
}

/* ===== BOTONES RÁPIDOS - FONDO AZUL ===== */
.quick-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 10px 15px;
  background: #fff;
  border-top: 1px solid #e9ecef;
  justify-content: center;
  flex-shrink: 0;
}

.quick-btn {
  background: #667eea !important;
  color: white !important;
  border: none !important;
  padding: 8px 14px;
  border-radius: 20px;
  font-size: 12px;
  cursor: pointer;
  transition: all 0.2s;
  font-weight: 500;
}

.quick-btn:hover {
  background: #5568d3 !important;
  transform: scale(1.05);
  box-shadow: 0 2px 8px rgba(102, 126, 234, 0.3);
}

/* ===== ÁREA DE INPUT CON MICRÓFONO ===== */
.input-area {
  display: flex !important;
  gap: 10px;
  padding: 12px 15px;
  background: #fff;
  border-top: 1px solid #e9ecef;
  align-items: center;
  flex-shrink: 0;
}

#user-input {
  flex: 1;
  border: 2px solid #e9ecef;
  border-radius: 25px;
  padding: 12px 15px;
  font-size: 14px;
  outline: none;
  transition: border-color 0.3s;
}

#user-input:focus {
  border-color: #667eea;
}

/* BOTÓN DE MICRÓFONO - VISIBLE */
.mic-btn,
button[aria-label*="micrófono"],
button[aria-label*="Micrófono"] {
  width: 45px !important;
  height: 45px !important;
  border-radius: 50% !important;
  border: none !important;
  cursor: pointer !important;
  font-size: 20px !important;
  color: white !important;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%) !important;
  transition: all 0.3s !important;
  flex-shrink: 0 !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  visibility: visible !important;
  opacity: 1 !important;
}

.mic-btn:hover {
  transform: scale(1.1);
}

.mic-btn.recording {
  background: linear-gradient(135deg, #ff6b6b 0%, #ee5a5a 100%) !important;
  animation: pulse-mic 1s infinite;
}

@keyframes pulse-mic {
  0%, 100% { box-shadow: 0 0 0 0 rgba(255,107,107,0.5); }
  50% { box-shadow: 0 0 0 12px rgba(255,107,107,0); }
}

/* Botón enviar */
.send-btn,
#send-btn {
  width: 45px !important;
  height: 45px !important;
  border-radius: 50% !important;
  border: none !important;
  cursor: pointer !important;
  font-size: 18px !important;
  color: white !important;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%) !important;
  flex-shrink: 0 !important;
  transition: transform 0.2s !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
}

.send-btn:hover,
#send-btn:hover {
  transform: scale(1.1);
}

/* ===== OVERLAY DE ESCUCHA ===== */
.listening-overlay {
  display: none;
  position: absolute;
  bottom: 10px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(102, 126, 234, 0.95);
  color: white;
  padding: 10px 20px;
  border-radius: 25px;
  font-size: 13px;
  align-items: center;
  gap: 10px;
  z-index: 10;
}

.listening-overlay.active {
  display: flex !important;
}

.listening-dots span {
  display: inline-block;
  width: 8px;
  height: 8px;
  background: white;
  border-radius: 50%;
  margin: 0 3px;
  animation: bounce 1s infinite;
}

.listening-dots span:nth-child(2) { animation-delay: 0.2s; }
.listening-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes bounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-8px); }
}

/* ===== FORMULARIO DE AGENDAMIENTO ===== */
.scheduling-form {
  display: none;
  padding: 20px;
  background: #fff;
  overflow-y: auto;
  flex: 1;
}

.scheduling-form.visible {
  display: block;
}

.scheduling-form h3 {
  color: #667eea;
  margin-bottom: 20px;
  font-size: 18px;
}

.form-group {
  margin-bottom: 14px;
}

.form-group label {
  display: block;
  margin-bottom: 6px;
  font-size: 12px;
  font-weight: 500;
  color: #495057;
}

.form-group input,
.form-group textarea,
.form-group select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid #e9ecef;
  border-radius: 8px;
  font-size: 14px;
  transition: border-color 0.3s;
  box-sizing: border-box;
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
  outline: none;
  border-color: #667eea;
}

.form-group textarea {
  resize: vertical;
  min-height: 70px;
  font-family: inherit;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.form-actions {
  display: flex;
  gap: 10px;
  margin-top: 16px;
}

.form-btn {
  flex: 1;
  padding: 12px;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s;
}

.form-btn.primary {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
}

.form-btn.primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.form-btn.secondary {
  background: #f8f9fa;
  color: #495057;
  border: 1px solid #e9ecef;
}

.form-btn.secondary:hover {
  background: #e9ecef;
}

.form-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* ===== SCROLLBAR ===== */
.chat-area::-webkit-scrollbar,
.scheduling-form::-webkit-scrollbar {
  width: 5px;
}

.chat-area::-webkit-scrollbar-track,
.scheduling-form::-webkit-scrollbar-track {
  background: #f8f9fa;
}

.chat-area::-webkit-scrollbar-thumb,
.scheduling-form::-webkit-scrollbar-thumb {
  background: #cbd5e0;
  border-radius: 3px;
}

.chat-area::-webkit-scrollbar-thumb:hover,
.scheduling-form::-webkit-scrollbar-thumb:hover {
  background: #a0aec0;
}

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
  .avatar-widget {
    bottom: 15px !important;
    right: 15px !important;
  }
  
  .avatar-panel {
    width: calc(100vw - 30px) !important;
    max-width: 400px !important;
    bottom: 85px !important;
    right: 15px !important;
  }
  
  .avatar-circle {
    width: 60px;
    height: 60px;
  }
  
  .video-container {
    height: 240px;
    padding: 12px;
  }
  
  .chat-area {
    max-height: 80px;
    min-height: 50px;
  }
  
  .mic-btn,
  .send-btn {
    width: 42px !important;
    height: 42px !important;
  }
}

@media (max-width: 480px) {
  .avatar-panel {
    width: calc(100vw - 20px) !important;
    right: 10px !important;
    bottom: 80px !important;
  }
  
  .video-container {
    height: 220px;
  }
  
  .input-area {
    padding: 10px;
    gap: 8px;
  }
  
  #user-input {
    padding: 10px 12px;
    font-size: 13px;
  }
  
  .mic-btn,
  .send-btn {
    width: 40px !important;
    height: 40px !important;
    font-size: 16px !important;
  }
}

/* ===== ANIMACIONES ===== */
@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.chat-message {
  animation: fadeIn 0.3s ease;
}

@keyframes slideUp {
  from { 
    opacity: 0; 
    transform: translateY(20px); 
  }
  to { 
    opacity: 1; 
    transform: translateY(0); 
  }
}

.avatar-panel {
  animation: slideUp 0.3s ease;
}
