/* ==========================================================================
   ChronoBot — Widget de Asesor Laboral Inteligente & Chatbot Comercial
   Desarrollado por Informática Ducal - 2026
   ========================================================================== */

/* 1. Botón Flotante / Launcher */
.chronobot-launcher {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9999;
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  user-select: none;
  font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

.chronobot-pill-badge {
  background: rgba(15, 23, 42, 0.92);
  backdrop-filter: blur(12px);
  border: 1px solid rgba(56, 189, 248, 0.4);
  color: #ffffff;
  padding: 8px 14px;
  border-radius: 9999px;
  font-size: 0.84rem;
  font-weight: 700;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.4);
  display: flex;
  align-items: center;
  gap: 8px;
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.3s ease;
  animation: chronobotFloat 4s ease-in-out infinite;
}

.chronobot-pill-badge:hover {
  transform: translateY(-3px) scale(1.03);
  box-shadow: 0 14px 30px rgba(56, 189, 248, 0.35);
  border-color: #38bdf8;
}

.chronobot-status-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #10b981;
  box-shadow: 0 0 10px #10b981;
  display: inline-block;
  animation: chronobotPulse 2s infinite;
}

.chronobot-btn-circle {
  width: 58px;
  height: 58px;
  border-radius: 50%;
  background: linear-gradient(135deg, #4f46e5 0%, #06b6d4 100%);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.45rem;
  box-shadow: 0 10px 25px rgba(79, 70, 229, 0.5);
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.3s ease;
  border: 2px solid rgba(255, 255, 255, 0.25);
  position: relative;
}

.chronobot-launcher:hover .chronobot-btn-circle {
  transform: scale(1.08) rotate(5deg);
  box-shadow: 0 15px 35px rgba(6, 182, 212, 0.6);
}

.chronobot-unread-count {
  position: absolute;
  top: -4px;
  right: -4px;
  background: #ef4444;
  color: #fff;
  font-size: 0.7rem;
  font-weight: 800;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid #0f172a;
  box-shadow: 0 2px 8px rgba(239, 68, 68, 0.5);
}

/* 2. Ventana Principal del Chat */
.chronobot-window {
  position: fixed;
  bottom: 94px;
  right: 24px;
  width: 400px;
  max-width: calc(100vw - 32px);
  height: 600px;
  max-height: calc(100vh - 120px);
  background: #0f172a;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 20px;
  box-shadow: 0 25px 60px rgba(0, 0, 0, 0.65), 0 0 40px rgba(79, 70, 229, 0.15);
  z-index: 10000;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  opacity: 0;
  transform: translateY(20px) scale(0.95);
  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);
}

.chronobot-window.open {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

/* Cabecera */
.chronobot-header {
  background: linear-gradient(135deg, #1e1b4b 0%, #0f172a 100%);
  padding: 16px 18px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.chronobot-header-info {
  display: flex;
  align-items: center;
  gap: 12px;
}

.chronobot-avatar {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background: linear-gradient(135deg, #4f46e5 0%, #06b6d4 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #ffffff;
  font-size: 1.25rem;
  box-shadow: 0 4px 12px rgba(79, 70, 229, 0.4);
  position: relative;
}

.chronobot-avatar-dot {
  position: absolute;
  bottom: -2px;
  right: -2px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #10b981;
  border: 2px solid #0f172a;
}

.chronobot-header-text h4 {
  margin: 0;
  font-size: 0.98rem;
  font-weight: 800;
  color: #ffffff;
  display: flex;
  align-items: center;
  gap: 6px;
}

.chronobot-header-text span {
  font-size: 0.74rem;
  color: #94a3b8;
  display: block;
  margin-top: 2px;
}

.chronobot-header-actions {
  display: flex;
  align-items: center;
  gap: 4px;
}

.chronobot-header-btn {
  background: rgba(255, 255, 255, 0.08);
  border: none;
  color: #94a3b8;
  width: 30px;
  height: 30px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 0.85rem;
  transition: all 0.2s ease;
}

.chronobot-header-btn:hover {
  background: rgba(255, 255, 255, 0.16);
  color: #ffffff;
}

/* Área de Mensajes */
.chronobot-body {
  flex: 1;
  padding: 16px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
  background: radial-gradient(circle at top right, rgba(79, 70, 229, 0.08) 0%, transparent 60%), #0f172a;
  scroll-behavior: smooth;
}

.chronobot-body::-webkit-scrollbar {
  width: 5px;
}

.chronobot-body::-webkit-scrollbar-track {
  background: transparent;
}

.chronobot-body::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.15);
  border-radius: 10px;
}

/* Mensajes */
.chronobot-msg {
  display: flex;
  flex-direction: column;
  max-width: 88%;
  animation: chronobotFadeIn 0.25s ease-out;
}

.chronobot-msg.bot {
  align-self: flex-start;
}

.chronobot-msg.user {
  align-self: flex-end;
}

.chronobot-bubble {
  padding: 12px 16px;
  border-radius: 16px;
  font-size: 0.88rem;
  line-height: 1.5;
  color: #f8fafc;
  word-break: break-word;
}

.chronobot-msg.bot .chronobot-bubble {
  background: #1e293b;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-bottom-left-radius: 4px;
}

.chronobot-msg.user .chronobot-bubble {
  background: linear-gradient(135deg, #4f46e5 0%, #3730a3 100%);
  color: #ffffff;
  border-bottom-right-radius: 4px;
  box-shadow: 0 4px 14px rgba(79, 70, 229, 0.35);
}

.chronobot-msg-time {
  font-size: 0.68rem;
  color: #64748b;
  margin-top: 4px;
  padding: 0 4px;
}

.chronobot-msg.user .chronobot-msg-time {
  text-align: right;
}

/* Opciones / Quick Chips */
.chronobot-chips-container {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}

.chronobot-chip {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(56, 189, 248, 0.3);
  color: #38bdf8;
  padding: 7px 12px;
  border-radius: 9999px;
  font-size: 0.78rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s ease;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  text-align: left;
}

.chronobot-chip:hover {
  background: rgba(56, 189, 248, 0.15);
  border-color: #38bdf8;
  color: #ffffff;
  transform: translateY(-1px);
}

.chronobot-chip.primary {
  background: linear-gradient(135deg, rgba(79, 70, 229, 0.35) 0%, rgba(6, 182, 212, 0.35) 100%);
  border-color: rgba(99, 102, 241, 0.6);
  color: #ffffff;
}

.chronobot-chip.primary:hover {
  background: linear-gradient(135deg, #4f46e5 0%, #06b6d4 100%);
  box-shadow: 0 4px 12px rgba(79, 70, 229, 0.4);
}

/* Tarjetas Informativas dentro del Chat */
.chronobot-card {
  background: rgba(15, 23, 42, 0.8);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  padding: 12px 14px;
  margin-top: 10px;
}

.chronobot-card-title {
  font-weight: 800;
  font-size: 0.88rem;
  color: #38bdf8;
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.chronobot-card-price {
  font-family: 'JetBrains Mono', monospace;
  font-size: 1.25rem;
  font-weight: 800;
  color: #34d399;
  margin: 6px 0;
}

.chronobot-card-list {
  font-size: 0.78rem;
  color: #cbd5e1;
  padding-left: 18px;
  margin: 6px 0 10px 0;
}

.chronobot-card-list li {
  margin-bottom: 3px;
}

/* Formulario Embebido de Lead */
.chronobot-lead-form {
  background: rgba(30, 41, 59, 0.9);
  border: 1px solid rgba(79, 70, 229, 0.4);
  border-radius: 14px;
  padding: 14px;
  margin-top: 10px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.chronobot-lead-form input,
.chronobot-lead-form select {
  width: 100%;
  background: #0f172a;
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: #ffffff;
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 0.82rem;
  outline: none;
  box-sizing: border-box;
}

.chronobot-lead-form input:focus,
.chronobot-lead-form select:focus {
  border-color: #38bdf8;
  box-shadow: 0 0 0 2px rgba(56, 189, 248, 0.2);
}

.chronobot-lead-form button {
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
  color: #ffffff;
  border: none;
  padding: 10px;
  border-radius: 8px;
  font-weight: 800;
  font-size: 0.84rem;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.chronobot-lead-form button:hover {
  box-shadow: 0 4px 14px rgba(16, 185, 129, 0.5);
  transform: translateY(-1px);
}

/* Indicador de Escritura (Typing) */
.chronobot-typing {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 10px 14px;
  background: #1e293b;
  border-radius: 16px;
  border-bottom-left-radius: 4px;
  width: fit-content;
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.chronobot-typing-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #94a3b8;
  animation: chronobotBounce 1.4s infinite ease-in-out both;
}

.chronobot-typing-dot:nth-child(1) { animation-delay: -0.32s; }
.chronobot-typing-dot:nth-child(2) { animation-delay: -0.16s; }

/* Pie / Input de Texto */
.chronobot-footer {
  padding: 12px 16px;
  background: #0b1120;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.chronobot-input-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  background: #1e293b;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 12px;
  padding: 4px 8px 4px 14px;
  transition: border-color 0.2s ease;
}

.chronobot-input-wrap:focus-within {
  border-color: #38bdf8;
  box-shadow: 0 0 0 2px rgba(56, 189, 248, 0.2);
}

.chronobot-input {
  flex: 1;
  background: transparent;
  border: none;
  color: #ffffff;
  font-size: 0.88rem;
  outline: none;
  padding: 6px 0;
  font-family: inherit;
}

.chronobot-input::placeholder {
  color: #64748b;
  font-size: 0.82rem;
}

.chronobot-send-btn {
  background: linear-gradient(135deg, #4f46e5 0%, #06b6d4 100%);
  border: none;
  color: #ffffff;
  width: 34px;
  height: 34px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 0.9rem;
  transition: all 0.2s ease;
  flex-shrink: 0;
}

.chronobot-send-btn:hover {
  transform: scale(1.05);
  box-shadow: 0 2px 10px rgba(6, 182, 212, 0.4);
}

.chronobot-send-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none;
}

/* Animaciones */
@keyframes chronobotFadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes chronobotPulse {
  0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7); }
  70% { transform: scale(1); box-shadow: 0 0 0 8px rgba(16, 185, 129, 0); }
  100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}

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

@keyframes chronobotBounce {
  0%, 80%, 100% { transform: scale(0); }
  40% { transform: scale(1); }
}

/* Responsividad en móviles */
@media (max-width: 480px) {
  .chronobot-window {
    bottom: 0;
    right: 0;
    width: 100vw;
    height: 100vh;
    max-height: 100vh;
    border-radius: 0;
    border: none;
  }
  .chronobot-launcher {
    bottom: 16px;
    right: 16px;
  }
  .chronobot-pill-badge span:first-child {
    display: none;
  }
}
