/* ═══════════════════════════════════════════════════════════════
   JOSHUA AI - CHAT INTEGRADO EN HERO
   Chat limpio y minimalista al lado del icono
   ═══════════════════════════════════════════════════════════════ */

/* ─────────────────────────────────────────────────────────────────
   WRAPPER PARA ICONO + CHAT
   ───────────────────────────────────────────────────────────────── */
.hero-icon-chat-wrapper {
  display: flex;
  gap: 32px;
  align-items: center;
  width: 100%;
  justify-content: center;
}

/* ─────────────────────────────────────────────────────────────────
   PANEL DE CHAT - LIMPIO Y MINIMALISTA
   ───────────────────────────────────────────────────────────────── */
.joshua-chat-panel {
  width: 320px;
  background: rgba(22, 22, 35, 0.9);
  backdrop-filter: blur(40px);
  -webkit-backdrop-filter: blur(40px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 24px;
  box-shadow:
    0 20px 50px rgba(0, 0, 0, 0.4),
    0 0 0 1px rgba(255, 255, 255, 0.05) inset;
  overflow: hidden;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'SF Pro Display', sans-serif;
  animation: chatSlideIn 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
  animation-delay: 0.3s;
  opacity: 0;
}

@keyframes chatSlideIn {
  from {
    opacity: 0;
    transform: translateX(30px) scale(0.95);
  }
  to {
    opacity: 1;
    transform: translateX(0) scale(1);
  }
}

/* Header */
.joshua-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 20px;
  background: linear-gradient(180deg, rgba(255,255,255,0.06) 0%, rgba(255,255,255,0) 100%);
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.joshua-avatar {
  width: 48px;
  height: 48px;
  border-radius: 14px;
  background: linear-gradient(135deg, #5AC8FA 0%, #007AFF 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 6px 20px rgba(0, 122, 255, 0.35);
  flex-shrink: 0;
}

.joshua-avatar svg {
  width: 26px;
  height: 26px;
  color: white;
}

.joshua-info {
  flex: 1;
}

.joshua-info h4 {
  margin: 0 0 2px;
  font-size: 16px;
  font-weight: 600;
  color: white;
}

.joshua-info p {
  margin: 0;
  font-size: 12px;
  color: rgba(255, 255, 255, 0.5);
}

.joshua-status {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: #4CD964;
  font-weight: 500;
}

.joshua-status-dot {
  width: 8px;
  height: 8px;
  background: #4CD964;
  border-radius: 50%;
  animation: pulse 2s ease-in-out infinite;
}

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

/* ─────────────────────────────────────────────────────────────────
   CONTENEDOR DE MENSAJES
   ───────────────────────────────────────────────────────────────── */
.joshua-messages {
  max-height: 220px;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.2) transparent;
}

.joshua-messages::-webkit-scrollbar {
  width: 6px;
}

.joshua-messages::-webkit-scrollbar-track {
  background: transparent;
}

.joshua-messages::-webkit-scrollbar-thumb {
  background: rgba(255,255,255,0.2);
  border-radius: 3px;
}

.joshua-messages::-webkit-scrollbar-thumb:hover {
  background: rgba(255,255,255,0.3);
}

/* Mensajes */
.joshua-message {
  display: flex;
  gap: 10px;
  animation: messageIn 0.3s ease-out;
}

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

.joshua-message-bot {
  align-items: flex-start;
}

.joshua-message-user {
  justify-content: flex-end;
}

.joshua-message-avatar {
  width: 32px;
  height: 32px;
  border-radius: 10px;
  background: linear-gradient(135deg, #5AC8FA 0%, #007AFF 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.joshua-message-avatar svg {
  width: 18px;
  height: 18px;
  color: white;
}

.joshua-message-content {
  max-width: 80%;
  padding: 12px 16px;
  border-radius: 16px;
  font-size: 14px;
  line-height: 1.5;
}

.joshua-message-bot .joshua-message-content {
  background: rgba(255, 255, 255, 0.08);
  color: rgba(255, 255, 255, 0.9);
  border-bottom-left-radius: 6px;
}

.joshua-message-user .joshua-message-content {
  background: linear-gradient(135deg, #5AC8FA 0%, #007AFF 100%);
  color: white;
  border-bottom-right-radius: 6px;
}

.joshua-message-content p {
  margin: 0;
}

.joshua-message-content strong {
  color: #5AC8FA;
}

.joshua-message-user .joshua-message-content strong {
  color: white;
}

/* Indicador de escritura */
.joshua-typing-dots {
  display: flex;
  gap: 4px;
  align-items: center;
  height: 20px;
}

.joshua-typing-dots span {
  width: 8px;
  height: 8px;
  background: rgba(255, 255, 255, 0.5);
  border-radius: 50%;
  animation: typingBounce 1.4s infinite ease-in-out both;
}

.joshua-typing-dots span:nth-child(1) {
  animation-delay: -0.32s;
}

.joshua-typing-dots span:nth-child(2) {
  animation-delay: -0.16s;
}

@keyframes typingBounce {
  0%, 80%, 100% {
    transform: scale(0.6);
    opacity: 0.5;
  }
  40% {
    transform: scale(1);
    opacity: 1;
  }
}

/* ─────────────────────────────────────────────────────────────────
   INPUT DE TEXTO
   ───────────────────────────────────────────────────────────────── */
.joshua-input-section {
  padding: 0 20px;
}

.joshua-input-wrapper {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 16px;
  padding: 6px 8px 6px 16px;
  transition: all 0.2s ease;
}

.joshua-input-wrapper:focus-within {
  border-color: #5AC8FA;
  background: rgba(90, 200, 250, 0.08);
}

.joshua-text-input {
  flex: 1;
  background: none;
  border: none;
  color: white;
  font-size: 14px;
  font-family: inherit;
  outline: none;
  min-width: 0;
  padding: 10px 0;
}

.joshua-text-input::placeholder {
  color: rgba(255, 255, 255, 0.4);
}

.joshua-input-btn {
  width: 38px;
  height: 38px;
  border-radius: 12px;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  flex-shrink: 0;
}

.joshua-input-btn svg {
  width: 18px;
  height: 18px;
}

.joshua-send-btn {
  background: rgba(255, 255, 255, 0.1);
  color: rgba(255, 255, 255, 0.6);
}

.joshua-send-btn:hover {
  background: linear-gradient(135deg, #5AC8FA 0%, #007AFF 100%);
  color: white;
}

.joshua-mic-btn {
  background: linear-gradient(135deg, #5AC8FA 0%, #007AFF 100%);
  color: white;
}

.joshua-mic-btn:hover {
  transform: scale(1.05);
  box-shadow: 0 4px 12px rgba(0, 122, 255, 0.4);
}

/* Divider */
.joshua-divider {
  display: flex;
  align-items: center;
  padding: 16px 20px;
}

.joshua-divider::before,
.joshua-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: rgba(255, 255, 255, 0.1);
}

.joshua-divider span {
  padding: 0 12px;
  font-size: 12px;
  color: rgba(255, 255, 255, 0.4);
  text-transform: uppercase;
}

/* ─────────────────────────────────────────────────────────────────
   BOTONES DE ACCIÓN
   ───────────────────────────────────────────────────────────────── */
.joshua-actions {
  padding: 0 20px 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.joshua-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 16px 24px;
  border-radius: 16px;
  font-size: 15px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  border: none;
}

.joshua-btn svg {
  width: 22px;
  height: 22px;
  flex-shrink: 0;
}

/* Botón de llamada */
.joshua-btn-call {
  background: rgba(76, 217, 100, 0.12);
  border: 1px solid rgba(76, 217, 100, 0.25);
  color: #4CD964;
}

.joshua-btn-call:hover {
  background: linear-gradient(135deg, #4CD964 0%, #248A3D 100%);
  color: white;
  border-color: transparent;
  transform: translateY(-3px);
  box-shadow: 0 8px 24px rgba(76, 217, 100, 0.35);
}

/* ─────────────────────────────────────────────────────────────────
   MODAL DE LLAMADA
   ───────────────────────────────────────────────────────────────── */
.joshua-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s ease;
}

.joshua-modal-overlay.visible {
  opacity: 1;
  visibility: visible;
}

.joshua-modal {
  width: 100%;
  max-width: 420px;
  background: linear-gradient(180deg, #1e1e2e 0%, #16162a 100%);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 28px;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.6);
  transform: translateY(30px) scale(0.9);
  transition: all 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
  overflow: hidden;
}

.joshua-modal-overlay.visible .joshua-modal {
  transform: translateY(0) scale(1);
}

.joshua-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 24px 28px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.joshua-modal-header h3 {
  margin: 0;
  font-size: 20px;
  font-weight: 600;
  color: white;
}

.joshua-modal-close {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.08);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  color: rgba(255, 255, 255, 0.5);
}

.joshua-modal-close:hover {
  background: rgba(255, 255, 255, 0.15);
  color: white;
}

.joshua-modal-close svg {
  width: 20px;
  height: 20px;
}

.joshua-modal-body {
  padding: 28px;
}

.joshua-modal-intro {
  text-align: center;
  margin-bottom: 28px;
}

.joshua-modal-icon {
  width: 72px;
  height: 72px;
  margin: 0 auto 20px;
  border-radius: 20px;
  background: linear-gradient(135deg, #4CD964 0%, #248A3D 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 12px 32px rgba(76, 217, 100, 0.35);
}

.joshua-modal-icon svg {
  width: 36px;
  height: 36px;
  color: white;
}

.joshua-modal-intro p {
  margin: 0;
  font-size: 15px;
  color: rgba(255, 255, 255, 0.6);
  line-height: 1.6;
}

/* Form */
.joshua-form {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.joshua-form-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.joshua-form-group label {
  font-size: 13px;
  font-weight: 500;
  color: rgba(255, 255, 255, 0.7);
}

.joshua-form-group input {
  padding: 16px 18px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 14px;
  color: white;
  font-size: 16px;
  font-family: inherit;
  transition: all 0.2s ease;
}

.joshua-form-group input:focus {
  outline: none;
  border-color: #5AC8FA;
  background: rgba(90, 200, 250, 0.08);
  box-shadow: 0 0 0 4px rgba(90, 200, 250, 0.1);
}

.joshua-form-group input::placeholder {
  color: rgba(255, 255, 255, 0.3);
}

.joshua-phone-row {
  display: flex;
  gap: 10px;
}

.joshua-country-select {
  width: 115px;
  padding: 16px 14px;
  background: #1e1e2e;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 14px;
  color: white;
  font-size: 15px;
  font-family: inherit;
  cursor: pointer;
  flex-shrink: 0;
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23ffffff' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 32px;
}

.joshua-country-select:focus {
  outline: none;
  border-color: #5AC8FA;
}

.joshua-country-select option {
  background: #1e1e2e;
  color: white;
  padding: 12px;
}

.joshua-phone-row input {
  flex: 1;
  min-width: 0;
}

.joshua-submit-btn {
  margin-top: 10px;
  padding: 18px 28px;
  background: linear-gradient(135deg, #4CD964 0%, #248A3D 100%);
  border: none;
  border-radius: 16px;
  color: white;
  font-size: 17px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  transition: all 0.3s ease;
  box-shadow: 0 8px 24px rgba(76, 217, 100, 0.3);
}

.joshua-submit-btn:hover {
  transform: translateY(-3px);
  box-shadow: 0 12px 32px rgba(76, 217, 100, 0.4);
}

.joshua-submit-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

.joshua-submit-btn.loading svg {
  animation: spin 1s linear infinite;
}

@keyframes spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

.joshua-submit-btn svg {
  width: 22px;
  height: 22px;
}

/* Success */
.joshua-success {
  display: none;
  text-align: center;
  padding: 20px 0;
}

.joshua-success.visible {
  display: block;
}

.joshua-success-icon {
  width: 80px;
  height: 80px;
  margin: 0 auto 24px;
  border-radius: 50%;
  background: linear-gradient(135deg, #4CD964 0%, #248A3D 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  animation: successBounce 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes successBounce {
  0% { transform: scale(0); }
  60% { transform: scale(1.1); }
  100% { transform: scale(1); }
}

.joshua-success-icon svg {
  width: 40px;
  height: 40px;
  color: white;
}

.joshua-success h4 {
  margin: 0 0 12px;
  font-size: 22px;
  font-weight: 600;
  color: white;
}

.joshua-success p {
  margin: 0;
  font-size: 15px;
  color: rgba(255, 255, 255, 0.6);
  line-height: 1.6;
}

/* Error */
.joshua-error {
  display: none;
  padding: 14px 18px;
  background: rgba(255, 59, 48, 0.12);
  border: 1px solid rgba(255, 59, 48, 0.25);
  border-radius: 12px;
  color: #FF6961;
  font-size: 14px;
  text-align: center;
}

.joshua-error.visible {
  display: block;
}

/* ─────────────────────────────────────────────────────────────────
   RESPONSIVE
   ───────────────────────────────────────────────────────────────── */
@media (max-width: 900px) {
  .hero-icon-chat-wrapper {
    flex-direction: column;
    gap: 24px;
  }

  .joshua-chat-panel {
    width: 100%;
    max-width: 340px;
  }

  .module-icon-large {
    width: 160px !important;
    height: 160px !important;
  }
}

@media (max-width: 480px) {
  .joshua-chat-panel {
    border-radius: 20px;
    max-width: 100%;
  }

  .joshua-header {
    padding: 16px;
  }

  .joshua-welcome {
    padding: 16px;
  }

  .joshua-actions {
    padding: 0 16px 16px;
  }

  .joshua-modal {
    border-radius: 24px;
    margin: 16px;
  }

  .joshua-modal-body {
    padding: 24px;
  }
}

/* ─────────────────────────────────────────────────────────────────
   MODAL DE VOZ CON ELEVENLABS
   ───────────────────────────────────────────────────────────────── */
.joshua-voice-modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.85);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  z-index: 10001;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s ease;
}

.joshua-voice-modal.visible {
  opacity: 1;
  visibility: visible;
}

.joshua-voice-container {
  width: 100%;
  max-width: 400px;
  background: linear-gradient(180deg, #1e1e2e 0%, #16162a 100%);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 28px;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.6);
  transform: translateY(30px) scale(0.9);
  transition: all 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
  overflow: hidden;
}

.joshua-voice-modal.visible .joshua-voice-container {
  transform: translateY(0) scale(1);
}

.joshua-voice-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.joshua-voice-header h3 {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
  color: white;
  display: flex;
  align-items: center;
  gap: 10px;
}

.joshua-voice-header h3 svg {
  width: 22px;
  height: 22px;
  color: #5AC8FA;
}

.joshua-voice-close {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.08);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  color: rgba(255, 255, 255, 0.5);
}

.joshua-voice-close:hover {
  background: rgba(255, 255, 255, 0.15);
  color: white;
}

.joshua-voice-close svg {
  width: 20px;
  height: 20px;
}

.joshua-voice-body {
  padding: 24px;
  min-height: 350px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.joshua-voice-body elevenlabs-convai {
  width: 100% !important;
  max-width: 350px !important;
}

/* Ocultar widget flotante default de ElevenLabs */
body > elevenlabs-convai:not(.joshua-voice-body elevenlabs-convai) {
  display: none !important;
}
