/* ============================================
   CHAT WIDGET - Amazon GreenLine Perú
   Estilo WhatsApp Elegante
   ============================================ */

:root {
  --chat-primary: #25D366;
  --chat-primary-dark: #128C7E;
  --chat-secondary: #075E54;
  --chat-bg: #0a1628;
  --chat-bubble-user: #005c4b;
  --chat-bubble-bot: #1f2c3d;
  --chat-text: #ffffff;
  --chat-text-muted: #8696a0;
  --chat-border: rgba(255, 255, 255, 0.1);
  --chat-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
}

/* Botón Flotante Rectangular */
.chat-widget-btn {
  position: fixed;
  bottom: 24px;
  right: 24px;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 24px;
  border-radius: 50px;
  background: linear-gradient(135deg, #25D366 0%, #128C7E 100%);
  border: none;
  cursor: pointer;
  box-shadow: 0 4px 20px rgba(37, 211, 102, 0.4);
  z-index: 9999;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  animation: pulse-glow 2s infinite;
}

.chat-widget-btn:hover {
  transform: translateY(-3px) scale(1.02);
  box-shadow: 0 8px 30px rgba(37, 211, 102, 0.6);
}

.chat-widget-btn svg {
  width: 28px;
  height: 28px;
  fill: white;
  flex-shrink: 0;
}

.chat-widget-btn-text {
  color: white;
  text-align: left;
  line-height: 1.3;
}

.chat-widget-btn-text strong {
  display: block;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.3px;
}

.chat-widget-btn-text small {
  font-size: 11px;
  opacity: 0.9;
  font-weight: 400;
}

/* Ocultar label antiguo */
.chat-widget-btn-label {
  display: none;
}

@keyframes pulse-glow {

  0%,
  100% {
    box-shadow: 0 4px 20px rgba(37, 211, 102, 0.4);
  }

  50% {
    box-shadow: 0 4px 30px rgba(37, 211, 102, 0.7);
  }
}

/* Ocultar botón cuando el chat está abierto */
.chat-widget-container.active~.chat-widget-btn,
.chat-widget-btn.hidden {
  opacity: 0;
  pointer-events: none;
  transform: scale(0.8);
}

/* Contenedor Principal del Chat */
.chat-widget-container {
  position: fixed;
  bottom: 100px;
  right: 24px;
  width: 380px;
  max-width: calc(100vw - 48px);
  height: 550px;
  max-height: calc(100vh - 140px);
  background: var(--chat-bg);
  border-radius: 20px;
  box-shadow: var(--chat-shadow);
  z-index: 9998;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  opacity: 0;
  transform: translateY(20px) scale(0.95);
  pointer-events: none;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  border: 1px solid var(--chat-border);
}

.chat-widget-container.active {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: all;
}

/* Header del Chat */
.chat-header {
  background: linear-gradient(135deg, var(--chat-secondary) 0%, var(--chat-primary-dark) 100%);
  padding: 16px 20px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.chat-header-avatar {
  width: 45px;
  height: 45px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.15);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
}

.chat-header-info h3 {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
  color: white;
}

.chat-header-info p {
  margin: 2px 0 0;
  font-size: 12px;
  color: rgba(255, 255, 255, 0.7);
}

.chat-header-close {
  margin-left: auto;
  background: none;
  border: none;
  color: white;
  cursor: pointer;
  padding: 8px;
  border-radius: 50%;
  transition: background 0.2s;
}

.chat-header-close:hover {
  background: rgba(255, 255, 255, 0.1);
}

/* Área de Mensajes */
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: linear-gradient(180deg, rgba(10, 22, 40, 0.95) 0%, rgba(10, 22, 40, 1) 100%);
}

.chat-messages::-webkit-scrollbar {
  width: 6px;
}

.chat-messages::-webkit-scrollbar-track {
  background: transparent;
}

.chat-messages::-webkit-scrollbar-thumb {
  background: var(--chat-border);
  border-radius: 3px;
}

/* Burbujas de Chat */
.chat-bubble {
  max-width: 85%;
  padding: 12px 16px;
  border-radius: 18px;
  font-size: 14px;
  line-height: 1.5;
  animation: bubble-in 0.3s ease;
}

@keyframes bubble-in {
  from {
    opacity: 0;
    transform: translateY(10px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.chat-bubble.bot {
  background: var(--chat-bubble-bot);
  color: var(--chat-text);
  border-bottom-left-radius: 4px;
  align-self: flex-start;
}

.chat-bubble p {
  color: inherit;
  margin: 0 0 8px;
}

.chat-bubble p:last-child {
  margin-bottom: 0;
}

.chat-bubble.user {
  background: var(--chat-bubble-user);
  color: var(--chat-text);
  border-bottom-right-radius: 4px;
  align-self: flex-end;
}

.chat-bubble.bot::before {
  content: '🤖';
  display: block;
  margin-bottom: 6px;
  font-size: 16px;
}

/* Indicador de Escribiendo */
.typing-indicator {
  display: flex;
  gap: 4px;
  padding: 16px;
  align-self: flex-start;
}

.typing-indicator span {
  width: 8px;
  height: 8px;
  background: var(--chat-text-muted);
  border-radius: 50%;
  animation: typing-bounce 1.4s infinite ease-in-out;
}

.typing-indicator span:nth-child(1) {
  animation-delay: 0s;
}

.typing-indicator span:nth-child(2) {
  animation-delay: 0.2s;
}

.typing-indicator span:nth-child(3) {
  animation-delay: 0.4s;
}

@keyframes typing-bounce {

  0%,
  60%,
  100% {
    transform: translateY(0);
    opacity: 0.4;
  }

  30% {
    transform: translateY(-8px);
    opacity: 1;
  }
}

/* Botones de Opciones */
.chat-options {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 12px;
}

.chat-option-btn {
  background: linear-gradient(135deg, var(--chat-primary) 0%, var(--chat-primary-dark) 100%);
  color: white;
  border: none;
  padding: 12px 20px;
  border-radius: 12px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.chat-option-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 15px rgba(37, 211, 102, 0.4);
}

.chat-option-btn.secondary {
  background: var(--chat-bubble-bot);
  border: 1px solid var(--chat-border);
}

.chat-option-btn.whatsapp {
  background: linear-gradient(135deg, #25D366 0%, #128C7E 100%);
}

.chat-option-btn.youtube {
  background: linear-gradient(135deg, #FF0000 0%, #CC0000 100%);
}

/* Input del Chat */
.chat-input-container {
  padding: 12px 16px;
  background: rgba(0, 0, 0, 0.2);
  border-top: 1px solid var(--chat-border);
}

.chat-input-wrapper {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--chat-bubble-bot);
  border-radius: 25px;
  padding: 8px 16px;
}

.chat-input {
  flex: 1;
  background: none;
  border: none;
  color: var(--chat-text);
  font-size: 14px;
  outline: none;
}

.chat-input::placeholder {
  color: var(--chat-text-muted);
}

.chat-send-btn {
  background: var(--chat-primary);
  border: none;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.chat-send-btn:hover {
  background: var(--chat-primary-dark);
  transform: scale(1.1);
}

.chat-send-btn svg {
  width: 18px;
  height: 18px;
  fill: white;
}

/* Contador de Consultas */
.chat-counter {
  text-align: center;
  padding: 8px;
  font-size: 12px;
  color: var(--chat-text-muted);
  background: rgba(0, 0, 0, 0.3);
}

.chat-counter strong {
  color: var(--chat-primary);
}

/* Modal de Licencia */
.license-modal {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.9);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px;
  z-index: 10;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s;
}

.license-modal.active {
  opacity: 1;
  pointer-events: all;
}

.license-modal h3 {
  color: var(--chat-text);
  margin-bottom: 16px;
  text-align: center;
}

.license-modal p {
  color: var(--chat-text-muted);
  font-size: 14px;
  text-align: center;
  margin-bottom: 20px;
}

.license-input-group {
  display: flex;
  gap: 8px;
  width: 100%;
  margin-bottom: 16px;
}

.license-input {
  flex: 1;
  padding: 12px 16px;
  border-radius: 12px;
  border: 1px solid var(--chat-border);
  background: var(--chat-bubble-bot);
  color: var(--chat-text);
  font-size: 14px;
  outline: none;
}

.license-input:focus {
  border-color: var(--chat-primary);
}

.license-activate-btn {
  background: var(--chat-primary);
  color: white;
  border: none;
  padding: 12px 20px;
  border-radius: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.license-activate-btn:hover {
  background: var(--chat-primary-dark);
}

.license-prices {
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 100%;
  margin-top: 16px;
}

.license-price-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px;
  background: var(--chat-bubble-bot);
  border-radius: 10px;
  font-size: 13px;
  color: var(--chat-text);
}

/* Secciones Especiales */
.diagnosis-section {
  background: rgba(37, 211, 102, 0.1);
  border-left: 3px solid var(--chat-primary);
  padding: 12px;
  border-radius: 0 8px 8px 0;
  margin: 8px 0;
}

.diagnosis-section h4 {
  margin: 0 0 8px;
  font-size: 13px;
  color: var(--chat-primary);
}

.diagnosis-section ul {
  margin: 0;
  padding-left: 20px;
  font-size: 13px;
}

.diagnosis-section li {
  margin: 4px 0;
}

/* Links de proyectos */
.project-link {
  display: block;
  color: var(--chat-primary);
  text-decoration: none;
  padding: 8px 0;
  font-size: 13px;
  transition: color 0.2s;
}

.project-link:hover {
  color: var(--chat-primary-dark);
  text-decoration: underline;
}

/* Responsive */
@media (max-width: 480px) {
  .chat-widget-container {
    bottom: 0;
    right: 0;
    width: 100%;
    max-width: 100%;
    height: 100%;
    max-height: 100%;
    border-radius: 0;
  }

  .chat-widget-btn {
    bottom: 16px;
    right: 16px;
    padding: 10px 16px;
    gap: 8px;
  }

  .chat-widget-btn-text strong {
    font-size: 10px;
  }

  .chat-widget-btn-text small {
    font-size: 9px;
  }

  .chat-widget-btn svg {
    width: 22px;
    height: 22px;
  }
}