/* ========================================
   Chatbot Widget - Open Space Comarcal
   ======================================== */

/* Botón flotante */
.chatbot-trigger {
  position: fixed;
  bottom: 20px;
  right: 20px;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: linear-gradient(135deg, #006272 0%, #008b9e 100%);
  border: none;
  cursor: pointer;
  box-shadow: 0 4px 20px rgba(0, 98, 114, 0.4);
  z-index: 9998;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s ease;
}

.chatbot-trigger:hover {
  transform: scale(1.1);
  box-shadow: 0 6px 30px rgba(0, 98, 114, 0.5);
}

.chatbot-trigger i {
  font-size: 26px;
  color: #fff;
  transition: transform 0.3s ease;
}

.chatbot-trigger.active i.lni-comments-alt {
  display: none;
}

.chatbot-trigger.active i.lni-close {
  display: block;
}

.chatbot-trigger i.lni-close {
  display: none;
}

/* Tooltip de incitación (Bocadillo) */
.chatbot-tooltip {
  position: absolute;
  right: 80px;
  bottom: 8px;
  background: #fff;
  padding: 10px 16px;
  border-radius: 20px 20px 4px 20px;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.12);
  font-size: 13.5px;
  font-weight: 600;
  color: #1e293b;
  width: max-content;
  max-width: none;
  line-height: 1.4;
  opacity: 0;
  visibility: hidden;
  transform: translateY(10px) scale(0.9);
  transition: all 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
  pointer-events: none;
  border: 1px solid rgba(226, 232, 240, 0.8);
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: 8px;
}


.chatbot-tooltip::after {
  content: '';
  position: absolute;
  right: -9px;
  bottom: 11px;
  border-width: 6px 0 6px 10px;
  border-style: solid;
  border-color: transparent transparent transparent #fff;
  filter: drop-shadow(2px 0 2px rgba(0, 0, 0, 0.05));
}

.chatbot-tooltip.show {
  opacity: 1;
  visibility: visible;
  transform: translateY(0) scale(1);
  animation: tooltipBounce 2s infinite ease-in-out 0.5s;
}

@keyframes tooltipBounce {

  0%,
  100% {
    transform: translateY(0);
  }

  50% {
    transform: translateY(-5px);
  }
}

/* Badge de notificación */
.chatbot-trigger .badge {
  position: absolute;
  top: -4px;
  right: -4px;
  min-width: 22px;
  height: 22px;
  background: #ff4757;
  border-radius: 50%;
  font-size: 11px;
  font-weight: 800;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 10px rgba(255, 71, 87, 0.4);
  border: 2px solid #fff;
  opacity: 0;
  transform: scale(0);
  transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  z-index: 10;
}

.chatbot-trigger .badge.show {
  opacity: 1;
  transform: scale(1);
}

/* Ventana del chat */
.chatbot-window {
  position: fixed;
  bottom: 90px;
  right: 20px;
  width: 380px;
  max-width: calc(100vw - 40px);
  height: 520px;
  max-height: calc(100vh - 200px);
  background: #fff;
  border-radius: 20px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
  z-index: 9999;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  opacity: 0;
  visibility: hidden;
  transform: translateY(20px) scale(0.95);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.chatbot-window.open {
  opacity: 1;
  visibility: visible;
  transform: translateY(0) scale(1);
}

/* Header del chat */
.chatbot-header {
  background: linear-gradient(135deg, #006272 0%, #008b9e 100%);
  color: #fff;
  padding: 18px 20px;
  display: flex;
  align-items: center;
  gap: 14px;
  flex-shrink: 0;
}

.chatbot-avatar {
  width: 44px;
  height: 44px;
  background: #fff;
  color: #006272;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
}

.chatbot-info {
  flex: 1;
}

.chatbot-name {
  font-size: 16px;
  font-weight: 700;
  margin-bottom: 2px;
}

.chatbot-status {
  font-size: 12px;
  opacity: 0.85;
  display: flex;
  align-items: center;
  gap: 6px;
}

.chatbot-status::before {
  content: '';
  width: 8px;
  height: 8px;
  background: #4ade80;
  border-radius: 50%;
}

.chatbot-close {
  background: rgba(255, 255, 255, 0.15);
  border: none;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
}

.chatbot-close:hover {
  background: rgba(255, 255, 255, 0.25);
}

.chatbot-restart {
  border: none;
  background: none;
  color: #fff;
  font-size: 20px;
  cursor: pointer;
  opacity: 0.8;
  transition: opacity 0.2s;
  padding: 5px;
  margin-left: auto;
  margin-right: 10px;
}

.chatbot-close:hover,
.chatbot-restart:hover {
  opacity: 1;
}

/* Confirmación de reinicio personalizada */
.chatbot-confirm-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(2px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s ease;
  border-radius: 15px;
}

.chatbot-confirm-overlay.show {
  opacity: 1;
  visibility: visible;
}

.chatbot-confirm-card {
  background: #fff;
  padding: 30px 25px;
  border-radius: 20px;
  width: 85%;
  max-width: 300px;
  text-align: center;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.2);
  transform: translateY(30px) scale(0.9);
  transition: all 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
  position: relative;
  overflow: hidden;
}

.chatbot-confirm-card::before {
  content: '\eafe';
  /* lni-warning */
  font-family: 'LineIcons';
  display: block;
  font-size: 40px;
  color: #ff9800;
  margin-bottom: 15px;
}

.chatbot-confirm-overlay.show .chatbot-confirm-card {
  transform: translateY(0) scale(1);
}

.chatbot-confirm-card p {
  font-size: 16px;
  color: #1e293b;
  margin-bottom: 25px;
  font-weight: 600;
  line-height: 1.4;
}

.chatbot-confirm-btns {
  display: flex;
  gap: 10px;
  justify-content: center;
}

.chatbot-confirm-btn {
  padding: 10px 20px;
  border-radius: 12px;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  border: none;
  transition: all 0.2s;
  flex: 1;
}

.chatbot-confirm-btn.yes {
  background: #ef4444;
  color: #fff;
}

.chatbot-confirm-btn.no {
  background: #f1f5f9;
  color: #64748b;
}

.chatbot-confirm-btn:hover {
  transform: translateY(-3px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.chatbot-confirm-btn.yes:hover {
  background: #dc2626;
  box-shadow: 0 4px 12px rgba(239, 68, 68, 0.3);
}

/* Área de mensajes */
.chatbot-messages {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: #f8fafc;
}

/* Burbujas de mensaje */
.chatbot-message {
  max-width: 85%;
  padding: 12px 16px;
  border-radius: 18px;
  font-size: 14px;
  line-height: 1.5;
  animation: messageIn 0.3s ease;
}

@keyframes messageIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.chatbot-message.bot {
  align-self: flex-start;
  background: #fff;
  color: #334155;
  border: 1px solid #e2e8f0;
  border-bottom-left-radius: 6px;
}

.chatbot-message.user {
  align-self: flex-end;
  background: linear-gradient(135deg, #006272 0%, #008b9e 100%);
  color: #fff;
  border-bottom-right-radius: 6px;
}

/* Indicador de escribiendo */
.chatbot-typing {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 12px 16px;
  background: #fff;
  border-radius: 18px;
  border-bottom-left-radius: 6px;
  border: 1px solid #e2e8f0;
  align-self: flex-start;
  max-width: 70px;
}

.chatbot-typing span {
  width: 8px;
  height: 8px;
  background: #94a3b8;
  border-radius: 50%;
  animation: typingDot 1.4s infinite ease-in-out;
}

.chatbot-typing span:nth-child(1) {
  animation-delay: 0s;
}

.chatbot-typing span:nth-child(2) {
  animation-delay: 0.2s;
}

.chatbot-typing span:nth-child(3) {
  animation-delay: 0.4s;
}

@keyframes typingDot {

  0%,
  80%,
  100% {
    transform: scale(0.6);
    opacity: 0.5;
  }

  40% {
    transform: scale(1);
    opacity: 1;
  }
}

/* Input del chat */
.chatbot-input-wrapper {
  padding: 16px;
  background: #fff;
  border-top: 1px solid #e2e8f0;
  display: flex;
  gap: 10px;
  flex-shrink: 0;
}

.chatbot-input {
  flex: 1;
  min-width: 0;
  padding: 12px 16px;
  border: 1px solid #e2e8f0;
  border-radius: 24px;
  font-size: 14px;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.chatbot-input:focus {
  border-color: #006272;
  box-shadow: 0 0 0 3px rgba(0, 98, 114, 0.1);
}

.chatbot-input::placeholder {
  color: #94a3b8;
}

.chatbot-send {
  width: 44px;
  height: 44px;
  min-width: 44px;
  min-height: 44px;
  flex-shrink: 0;
  background: linear-gradient(135deg, #006272 0%, #008b9e 100%);
  border: none;
  border-radius: 50%;
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s, box-shadow 0.2s;
}

.chatbot-send:hover {
  transform: scale(1.05);
  box-shadow: 0 4px 12px rgba(0, 98, 114, 0.3);
}

.chatbot-send:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

.chatbot-send i {
  font-size: 18px;
}

/* Responsive */
@media (max-width: 480px) {
  .chatbot-window {
    bottom: 0;
    right: 0;
    left: 0;
    width: 100%;
    max-width: 100%;
    height: 100%;
    max-height: 100%;
    border-radius: 0;
  }

  .chatbot-trigger {
    bottom: 20px;
    right: 20px;
    width: 56px;
    height: 56px;
  }
}

/* Nuevos estilos para el typing con contexto */
.chatbot-typing {
  padding: 12px 16px;
  background: white;
  border-radius: 12px 12px 12px 0;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.05);
  display: flex;
  align-items: center;
  gap: 10px;
  width: fit-content;
  margin-bottom: 15px;
  font-size: 0.9rem;
  color: #64748b;
  animation: slideIn 0.3s ease;
  max-width: none;
  /* Override previo */
}

.typing-text {
  font-weight: 600;
  color: #006272;
  font-size: 0.85rem;
}

.typing-dots {
  display: flex;
  gap: 4px;
}

.typing-dots span {
  width: 6px;
  height: 6px;
  background: #006272;
  border-radius: 50%;
  animation: bounce 1.4s infinite ease-in-out both;
  opacity: 0.6;
}

.typing-dots span:nth-child(1) {
  animation-delay: -0.32s;
}

.typing-dots span:nth-child(2) {
  animation-delay: -0.16s;
}

@keyframes slideIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes bounce {

  0%,
  80%,
  100% {
    transform: scale(0);
  }

  40% {
    transform: scale(1);
  }
}

/* ========================================
   Inline Form Styles
   ======================================== */

.chatbot-inline-form {
  background: #f8fafc;
  border-radius: 16px;
  padding: 16px;
  margin: 8px 0;
  border: 1px solid #e2e8f0;
  animation: slideIn 0.3s ease;
}

.chatbot-inline-form form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.chatbot-form-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.chatbot-form-field label {
  font-size: 12px;
  font-weight: 600;
  color: #64748b;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.chatbot-form-field input,
.chatbot-form-field select,
.chatbot-form-field textarea {
  padding: 10px 12px;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  font-size: 14px;
  font-family: inherit;
  background: #fff;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.chatbot-form-field input:focus,
.chatbot-form-field select:focus,
.chatbot-form-field textarea:focus {
  outline: none;
  border-color: #006272;
  box-shadow: 0 0 0 3px rgba(0, 98, 114, 0.1);
}

.chatbot-form-field input::placeholder,
.chatbot-form-field textarea::placeholder {
  color: #94a3b8;
}

.chatbot-form-field textarea {
  resize: vertical;
  min-height: 50px;
}

.chatbot-form-submit {
  background: linear-gradient(135deg, #006272 0%, #008b9e 100%);
  color: #fff;
  border: none;
  padding: 12px 20px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  margin-top: 4px;
}

.chatbot-form-submit:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 98, 114, 0.3);
}

.chatbot-form-submit:disabled {
  opacity: 0.7;
  cursor: not-allowed;
}

.chatbot-form-success {
  background: #f0fdf4;
  color: #166534;
  padding: 20px;
  border-radius: 12px;
  text-align: center;
  font-weight: 500;
  border: 1px solid #bbf7d0;
  animation: slideIn 0.3s ease;
  font-size: 14px;
}

.chatbot-form-sent-status {
  background: #f1f5f9;
  color: #64748b;
  padding: 12px 16px;
  border-radius: 12px;
  font-size: 13px;
  margin: 8px 0;
  display: flex;
  align-items: center;
  gap: 8px;
  border: 1px dashed #cbd5e1;
  animation: slideIn 0.3s ease;
}

.chatbot-form-sent-status i {
  color: #10b981;
  font-size: 16px;
}

.chatbot-form-expired {
  background: #fef3c7;
  color: #92400e;
  padding: 12px 16px;
  border-radius: 12px;
  font-size: 13px;
  margin: 8px 0;
  display: flex;
  align-items: center;
  gap: 8px;
  border: 1px dashed #fcd34d;
  animation: slideIn 0.3s ease;
}

.chatbot-form-expired i {
  color: #f59e0b;
  font-size: 16px;
}