/* ========================================
   CHATBOT WIDGET - STYLES
   ======================================== */

:root {
  /* Colores principales - Paleta Negro con Rojo */
  --chatbot-primary: #b52a31;
  --chatbot-primary-dark: #8f2128;
  --chatbot-primary-light: #d43c44;
  --chatbot-secondary: #b52a31;
  --chatbot-accent: #ff4d4d;
  
  /* Colores de fondo - Tonos negros */
  --chatbot-bg-dark: #0a0a0a;
  --chatbot-bg-medium: #141414;
  --chatbot-bg-light: #1f1f1f;
  --chatbot-bg-message: #f5f5f5;
  
  /* Colores de texto */
  --chatbot-text-primary: #f5f5f5;
  --chatbot-text-secondary: #9ca3af;
  --chatbot-text-dark: #0a0a0a;
  
  /* Sombras y efectos */
  --chatbot-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.6);
  --chatbot-shadow-sm: 0 4px 6px -1px rgba(0, 0, 0, 0.2);
  --chatbot-glow: 0 0 40px rgba(181, 42, 49, 0.4);
  
  /* Dimensiones */
  --chatbot-width: 400px;
  --chatbot-height: 600px;
  --chatbot-toggle-size: 64px;
  --chatbot-border-radius: 20px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  background: linear-gradient(135deg, #1a1a1a 0%, #2d1215 50%, #0a0a0a 100%);
  min-height: 100vh;
}

/* ========================================
   DEMO PAGE STYLES
   ======================================== */

.demo-page {
  max-width: 1200px;
  margin: 0 auto;
  padding: 20px;
}

.demo-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 40px;
  background: rgba(181, 42, 49, 0.15);
  backdrop-filter: blur(10px);
  border-radius: 16px;
  margin-bottom: 40px;
  border: 1px solid rgba(181, 42, 49, 0.3);
}

.demo-header h1 {
  color: white;
  margin: 0;
  font-size: 1.5rem;
}

.demo-header nav {
  display: flex;
  gap: 24px;
}

.demo-header nav a {
  color: rgba(255, 255, 255, 0.8);
  text-decoration: none;
  font-weight: 500;
  transition: color 0.2s;
}

.demo-header nav a:hover {
  color: white;
}

.demo-content {
  padding: 40px;
  background: rgba(255, 255, 255, 0.95);
  border-radius: 24px;
  box-shadow: var(--chatbot-shadow);
}

.hero {
  text-align: center;
  margin-bottom: 40px;
}

.hero h2 {
  color: var(--chatbot-bg-dark);
  font-size: 2rem;
  margin-bottom: 16px;
}

.hero p {
  color: var(--chatbot-text-secondary);
  font-size: 1.1rem;
  max-width: 600px;
  margin: 0 auto;
}

.info-section h3 {
  color: var(--chatbot-bg-dark);
  margin-bottom: 16px;
}

.info-section p {
  color: var(--chatbot-text-secondary);
}

.config-area {
  margin-top: 20px;
}

.config-area label {
  display: block;
  color: var(--chatbot-bg-dark);
  font-weight: 500;
  margin-bottom: 8px;
}

.config-area textarea {
  width: 100%;
  height: 120px;
  padding: 16px;
  border: 2px solid #e2e8f0;
  border-radius: 12px;
  font-family: 'Fira Code', monospace;
  font-size: 0.85rem;
  resize: vertical;
  transition: border-color 0.2s;
}

.config-area textarea:focus {
  outline: none;
  border-color: var(--chatbot-primary);
}

.config-area .btn-load,
.config-area .btn-demo {
  margin-top: 12px;
  padding: 12px 24px;
  border: none;
  border-radius: 10px;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  margin-right: 12px;
}

.config-area .btn-load {
  background: var(--chatbot-primary);
  color: white;
}

.config-area .btn-load:hover {
  background: var(--chatbot-primary-dark);
  transform: translateY(-2px);
}

.config-area .btn-demo {
  background: var(--chatbot-bg-light);
  color: white;
  border: 1px solid var(--chatbot-primary);
}

.config-area .btn-demo:hover {
  background: var(--chatbot-primary-dark);
  transform: translateY(-2px);
}

/* Sección de Endpoint */
.endpoint-section {
  margin-top: 30px;
  padding-top: 30px;
  border-top: 2px solid #e2e8f0;
}

.endpoint-row {
  margin-bottom: 12px;
}

.endpoint-row label {
  display: block;
  color: var(--chatbot-bg-dark);
  font-weight: 500;
  margin-bottom: 6px;
}

.endpoint-row input[type="url"] {
  width: 100%;
  padding: 12px 16px;
  border: 2px solid #e2e8f0;
  border-radius: 10px;
  font-size: 0.95rem;
  transition: border-color 0.2s;
}

.endpoint-row input[type="url"]:focus {
  outline: none;
  border-color: var(--chatbot-primary);
}

.endpoint-row input[type="checkbox"] {
  margin-right: 8px;
  width: 18px;
  height: 18px;
  vertical-align: middle;
}

.btn-endpoint,
.btn-test {
  margin-top: 12px;
  padding: 12px 24px;
  border: none;
  border-radius: 10px;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  margin-right: 12px;
}

.btn-endpoint {
  background: var(--chatbot-primary);
  color: white;
}

.btn-endpoint:hover {
  background: var(--chatbot-primary-dark);
  transform: translateY(-2px);
}

.btn-test {
  background: var(--chatbot-accent);
  color: white;
}

.btn-test:hover {
  background: var(--chatbot-primary);
  transform: translateY(-2px);
}

.api-docs {
  margin-top: 24px;
  padding: 16px;
  background: var(--chatbot-bg-dark);
  border-radius: 12px;
}

.api-docs h4 {
  color: var(--chatbot-text-primary);
  margin: 0 0 12px 0;
  font-size: 0.95rem;
}

.api-docs pre {
  margin: 0;
  padding: 16px;
  background: #0f172a;
  border-radius: 8px;
  overflow-x: auto;
}

.api-docs code {
  color: #a5f3fc;
  font-family: 'Fira Code', 'Consolas', monospace;
  font-size: 0.85rem;
  line-height: 1.6;
}

/* ========================================
   CHATBOT WIDGET
   ======================================== */

.chatbot-widget {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9999;
  font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, sans-serif;
}

/* ========================================
   TOGGLE BUTTON
   ======================================== */

.chatbot-toggle {
  width: var(--chatbot-toggle-size);
  height: var(--chatbot-toggle-size);
  border-radius: 50%;
  border: none;
  background: linear-gradient(135deg, var(--chatbot-primary) 0%, var(--chatbot-primary-dark) 100%);
  color: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--chatbot-shadow), var(--chatbot-glow);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  overflow: hidden;
}

.chatbot-toggle::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(135deg, rgba(255,255,255,0.2) 0%, transparent 50%);
  border-radius: 50%;
}

.chatbot-toggle:hover {
  transform: scale(1.1);
  box-shadow: var(--chatbot-shadow), 0 0 60px rgba(181, 42, 49, 0.6);
}

.chatbot-toggle:active {
  transform: scale(0.95);
}

.toggle-icon {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s;
}

.toggle-icon svg {
  width: 100%;
  height: 100%;
}

.chatbot-toggle .close-icon {
  position: absolute;
  opacity: 0;
  transform: rotate(-90deg) scale(0.5);
}

.chatbot-toggle.active .chat-icon {
  opacity: 0;
  transform: rotate(90deg) scale(0.5);
}

.chatbot-toggle.active .close-icon {
  opacity: 1;
  transform: rotate(0) scale(1);
}

.notification-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  width: 24px;
  height: 24px;
  background: #ef4444;
  border-radius: 50%;
  color: white;
  font-size: 0.75rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 3px solid white;
  animation: pulse-badge 2s infinite;
}

.notification-badge.hidden {
  display: none;
}

@keyframes pulse-badge {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.1); }
}

/* ========================================
   CHAT WINDOW
   ======================================== */

.chatbot-window {
  position: absolute;
  bottom: calc(var(--chatbot-toggle-size) + 16px);
  right: 0;
  width: var(--chatbot-width);
  height: var(--chatbot-height);
  background: var(--chatbot-bg-dark);
  border-radius: var(--chatbot-border-radius);
  box-shadow: var(--chatbot-shadow);
  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);
}

/* ========================================
   CHAT HEADER
   ======================================== */

.chatbot-header {
  padding: 16px 20px;
  background: linear-gradient(135deg, var(--chatbot-bg-medium) 0%, var(--chatbot-bg-dark) 100%);
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.header-avatar {
  display: flex;
  align-items: center;
  gap: 12px;
}

.avatar-circle {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--chatbot-primary) 0%, var(--chatbot-primary-dark) 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
}

.avatar-circle svg {
  width: 24px;
  height: 24px;
}

.header-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.header-title {
  color: var(--chatbot-text-primary);
  font-weight: 600;
  font-size: 1rem;
}

.header-status {
  color: var(--chatbot-text-secondary);
  font-size: 0.8rem;
  display: flex;
  align-items: center;
  gap: 6px;
}

.status-dot {
  width: 8px;
  height: 8px;
  background: #4ade80;
  border-radius: 50%;
  animation: pulse-dot 2s infinite;
}

@keyframes pulse-dot {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

.header-actions {
  display: flex;
  gap: 8px;
}

.header-btn {
  width: 36px;
  height: 36px;
  border: none;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 10px;
  color: var(--chatbot-text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.header-btn svg {
  width: 18px;
  height: 18px;
}

.header-btn:hover {
  background: rgba(255, 255, 255, 0.2);
  color: var(--chatbot-text-primary);
}

/* ========================================
   CHAT BODY
   ======================================== */

.chatbot-body {
  flex: 1;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  scroll-behavior: smooth;
}

.chat-messages::-webkit-scrollbar {
  width: 6px;
}

.chat-messages::-webkit-scrollbar-track {
  background: transparent;
}

.chat-messages::-webkit-scrollbar-thumb {
  background: var(--chatbot-bg-light);
  border-radius: 3px;
}

/* ========================================
   MESSAGE BUBBLES
   ======================================== */

.message {
  display: flex;
  flex-direction: column;
  max-width: 85%;
  animation: message-in 0.3s ease-out;
}

@keyframes message-in {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.message.bot {
  align-self: flex-start;
}

.message.user {
  align-self: flex-end;
}

.message-bubble {
  padding: 14px 18px;
  border-radius: 18px;
  line-height: 1.5;
  font-size: 0.95rem;
  word-wrap: break-word;
}

.message.bot .message-bubble {
  background: var(--chatbot-bg-medium);
  color: var(--chatbot-text-primary);
  border-bottom-left-radius: 6px;
}

.message.user .message-bubble {
  background: linear-gradient(135deg, var(--chatbot-primary) 0%, var(--chatbot-primary-dark) 100%);
  color: white;
  border-bottom-right-radius: 6px;
}

.message-time {
  font-size: 0.7rem;
  color: var(--chatbot-text-secondary);
  margin-top: 4px;
  padding: 0 4px;
}

.message.user .message-time {
  text-align: right;
}

/* ========================================
   IMAGE MESSAGES
   ======================================== */

.message-images {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.message-image {
  border-radius: 12px;
  overflow: hidden;
  max-width: 100%;
  box-shadow: var(--chatbot-shadow-sm);
}

.message-image img {
  width: 100%;
  max-width: 250px;
  height: auto;
  display: block;
  transition: transform 0.3s;
  cursor: pointer;
}

.message-image img:hover {
  transform: scale(1.02);
}

.message-image.single img {
  max-width: 100%;
}

/* ========================================
   IMAGE CAROUSEL
   ======================================== */

.image-carousel {
  position: relative;
  width: 100%;
  margin-top: 10px;
  border-radius: 12px;
  overflow: hidden;
  background: var(--chatbot-bg-light);
}

.carousel-container {
  position: relative;
  width: 100%;
  overflow: hidden;
}

.carousel-track {
  display: flex;
  transition: transform 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.carousel-slide {
  min-width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px;
}

.carousel-slide img {
  max-width: 100%;
  max-height: 200px;
  border-radius: 8px;
  cursor: pointer;
  transition: transform 0.3s;
  object-fit: contain;
}

.carousel-slide img:hover {
  transform: scale(1.02);
}

.carousel-btn {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 36px;
  height: 36px;
  border: none;
  background: rgba(0, 0, 0, 0.5);
  color: white;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  z-index: 2;
  backdrop-filter: blur(4px);
}

.carousel-btn:hover {
  background: rgba(0, 0, 0, 0.7);
  transform: translateY(-50%) scale(1.1);
}

.carousel-btn:disabled {
  opacity: 0.3;
  cursor: not-allowed;
  transform: translateY(-50%);
}

.carousel-btn svg {
  width: 20px;
  height: 20px;
}

.carousel-btn.prev {
  left: 8px;
}

.carousel-btn.next {
  right: 8px;
}

.carousel-indicators {
  display: flex;
  justify-content: center;
  gap: 6px;
  padding: 10px;
  background: rgba(0, 0, 0, 0.2);
}

.carousel-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.4);
  border: none;
  cursor: pointer;
  transition: all 0.2s;
  padding: 0;
}

.carousel-dot:hover {
  background: rgba(255, 255, 255, 0.6);
}

.carousel-dot.active {
  background: var(--chatbot-primary-light);
  transform: scale(1.2);
}

.carousel-counter {
  position: absolute;
  top: 8px;
  right: 8px;
  background: rgba(0, 0, 0, 0.6);
  color: white;
  padding: 4px 10px;
  border-radius: 12px;
  font-size: 0.75rem;
  font-weight: 500;
  backdrop-filter: blur(4px);
}

/* ========================================
   OPTIONS BUTTONS
   ======================================== */

.message-options {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 12px;
}

.option-btn {
  padding: 12px 18px;
  background: rgba(181, 42, 49, 0.15);
  border: 1px solid rgba(181, 42, 49, 0.3);
  border-radius: 12px;
  color: var(--chatbot-primary-light);
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  text-align: left;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.option-btn:hover {
  background: rgba(181, 42, 49, 0.3);
  border-color: var(--chatbot-primary);
  transform: translateX(4px);
}

.option-btn:active {
  transform: translateX(2px);
}

.option-btn .option-icon {
  width: 16px;
  height: 16px;
  opacity: 0.7;
}

.option-btn.url-option {
  background: rgba(255, 77, 77, 0.15);
  border-color: rgba(255, 77, 77, 0.3);
  color: var(--chatbot-accent);
}

.option-btn.url-option:hover {
  background: rgba(255, 77, 77, 0.25);
  border-color: var(--chatbot-accent);
}

.option-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none !important;
}

/* ========================================
   TYPING INDICATOR
   ======================================== */

.typing-indicator {
  padding: 12px 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--chatbot-bg-medium);
  border-top: 1px solid rgba(255, 255, 255, 0.05);
}

.typing-indicator.hidden {
  display: none;
}

.typing-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--chatbot-primary) 0%, var(--chatbot-primary-dark) 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
}

.typing-avatar svg {
  width: 18px;
  height: 18px;
}

.typing-dots {
  display: flex;
  gap: 4px;
}

.typing-dots span {
  width: 8px;
  height: 8px;
  background: var(--chatbot-text-secondary);
  border-radius: 50%;
  animation: typing-bounce 1.4s infinite ease-in-out;
}

.typing-dots span:nth-child(1) {
  animation-delay: 0s;
}

.typing-dots span:nth-child(2) {
  animation-delay: 0.2s;
}

.typing-dots span:nth-child(3) {
  animation-delay: 0.4s;
}

@keyframes typing-bounce {
  0%, 60%, 100% {
    transform: translateY(0);
    opacity: 0.5;
  }
  30% {
    transform: translateY(-8px);
    opacity: 1;
  }
}

/* ========================================
   CHAT FOOTER (INPUT)
   ======================================== */

.chatbot-footer {
  padding: 16px 20px;
  background: var(--chatbot-bg-medium);
  border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.chatbot-footer.hidden {
  display: none;
}

.input-container {
  display: flex;
  gap: 10px;
  align-items: center;
}

.input-container input {
  flex: 1;
  padding: 14px 18px;
  background: var(--chatbot-bg-dark);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 14px;
  color: var(--chatbot-text-primary);
  font-size: 0.95rem;
  font-family: inherit;
  transition: all 0.2s;
}

.input-container input::placeholder {
  color: var(--chatbot-text-secondary);
}

.input-container input:focus {
  outline: none;
  border-color: var(--chatbot-primary);
  box-shadow: 0 0 0 3px rgba(181, 42, 49, 0.25);
}

.send-btn {
  width: 48px;
  height: 48px;
  border: none;
  background: linear-gradient(135deg, var(--chatbot-primary) 0%, var(--chatbot-primary-dark) 100%);
  border-radius: 14px;
  color: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.send-btn svg {
  width: 20px;
  height: 20px;
}

.send-btn:hover:not(:disabled) {
  transform: scale(1.05);
  box-shadow: 0 4px 12px rgba(181, 42, 49, 0.5);
}

.send-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ========================================
   CHAT ENDED
   ======================================== */

.chat-ended {
  padding: 20px;
  text-align: center;
  background: var(--chatbot-bg-medium);
  border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.chat-ended.hidden {
  display: none;
}

.chat-ended p {
  color: var(--chatbot-text-secondary);
  margin: 0 0 12px 0;
  font-size: 0.9rem;
}

.chat-ended-actions {
  display: flex;
  gap: 10px;
  justify-content: center;
  flex-wrap: wrap;
}

.restart-btn,
.view-responses-btn {
  padding: 10px 18px;
  border: none;
  border-radius: 10px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.restart-btn {
  background: linear-gradient(135deg, var(--chatbot-primary) 0%, var(--chatbot-primary-dark) 100%);
  color: white;
}

.restart-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(181, 42, 49, 0.5);
}

.view-responses-btn {
  background: rgba(181, 42, 49, 0.15);
  color: var(--chatbot-primary-light);
  border: 1px solid rgba(181, 42, 49, 0.3);
}

.view-responses-btn:hover {
  background: rgba(181, 42, 49, 0.25);
  transform: translateY(-2px);
}

/* ========================================
   RESPONSIVE
   ======================================== */

@media (max-width: 480px) {
  .chatbot-widget {
    bottom: 16px;
    right: 16px;
  }
  
  .chatbot-window {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    height: 100%;
    border-radius: 0;
  }
  
  .chatbot-toggle {
    width: 56px;
    height: 56px;
  }
  
  :root {
    --chatbot-toggle-size: 56px;
  }
}

/* ========================================
   IMAGE LIGHTBOX (Optional)
   ======================================== */

.image-lightbox {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.9);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10001;
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s;
}

.image-lightbox.open {
  opacity: 1;
  visibility: visible;
}

.image-lightbox img {
  max-width: 90%;
  max-height: 90%;
  border-radius: 8px;
  box-shadow: 0 0 40px rgba(0, 0, 0, 0.5);
}

.lightbox-close {
  position: absolute;
  top: 20px;
  right: 20px;
  width: 44px;
  height: 44px;
  background: rgba(255, 255, 255, 0.1);
  border: none;
  border-radius: 50%;
  color: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
}

.lightbox-close:hover {
  background: rgba(255, 255, 255, 0.2);
}

