/* Chat Widget Styles */

:root {
  --chat-primary: #0756c8;
  --chat-primary-dark: #063b86;
  --chat-navy: #071a36;
  --chat-yellow: #ffc928;
  --chat-bg: #ffffff;
  --chat-text: #172033;
  --chat-border: #dce5f0;
  --chat-light: #f4f7fb;
  --chat-muted: #596579;
  --bot-bg: #eef5ff;
  --user-bg: #0756c8;
  --user-text: #ffffff;
  --chat-accent: #ffc928;
}

/* Widget Container */
#chat-widget {
  --z-index: 9999;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
}

/* Botón flotante */
.chat-toggle-btn {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: var(--z-index);
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--chat-primary) 0%, var(--chat-primary-dark) 100%);
  color: white;
  border: 2px solid white;
  cursor: pointer;
  box-shadow: 0 6px 20px rgba(7, 26, 54, 0.25);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s ease;
  font-size: 24px;
}

.chat-toggle-btn:hover {
  transform: scale(1.1);
  box-shadow: 0 6px 16px rgba(0, 123, 255, 0.6);
}

.chat-toggle-btn:active {
  transform: scale(0.95);
}

.chat-toggle-btn svg {
  width: 28px;
  height: 28px;
  stroke-width: 2;
}

/* Contenedor del chat */
.chat-container {
  position: fixed;
  bottom: 90px;
  right: 20px;
  z-index: var(--z-index);
  width: 380px;
  max-width: 90vw;
  height: 600px;
  max-height: 80vh;
  background: var(--chat-bg);
  border-radius: 12px;
  box-shadow: 0 5px 40px rgba(0, 0, 0, 0.16);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  opacity: 1;
  transform: translateY(0);
  transition: all 0.3s ease;
}

.chat-container.hidden {
  opacity: 0;
  transform: translateY(20px);
  pointer-events: none;
  visibility: hidden;
}

/* Header */
.chat-header {
  background: linear-gradient(135deg, var(--chat-primary) 0%, var(--chat-primary-dark) 100%);
  color: white;
  padding: 16px;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  min-height: 60px;
}

.chat-header-content h3 {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
}

.chat-header-content p {
  margin: 4px 0 0 0;
  font-size: 12px;
  opacity: 0.9;
}

.chat-status {
  font-size: 12px !important;
}

.chat-header-actions {
  display: flex;
  align-items: center;
  gap: 5px;
}

.chat-toggle-btn.whatsapp-button {
  width: auto;
  min-width: 154px;
  padding: 0 20px;
  border-radius: 999px;
  gap: 9px;
  background: #25d366;
  box-shadow: 0 6px 20px rgba(18, 140, 69, 0.35);
  font-size: 16px;
  font-weight: 700;
}

.chat-toggle-btn.whatsapp-button:hover {
  background: #1ebe5d;
  box-shadow: 0 8px 24px rgba(18, 140, 69, 0.45);
}

.chat-toggle-btn.whatsapp-button svg {
  width: 30px;
  height: 30px;
}

.chat-close-btn,
.chat-clear-btn {
  background: transparent;
  border: none;
  color: white;
  cursor: pointer;
  font-size: 20px;
  padding: 0;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.2s;
}

.chat-close-btn:hover,
.chat-clear-btn:hover {
  opacity: 0.8;
}

.chat-clear-btn {
  font-size: 22px;
}

/* Mensajes */
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: white;
}

.chat-message {
  display: flex;
  gap: 8px;
  animation: slideIn 0.3s ease;
}

@keyframes slideIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.bot-message {
  justify-content: flex-start;
}

.user-message {
  justify-content: flex-end;
  flex-direction: row-reverse;
}

.message-content {
  max-width: 75%;
  padding: 12px 14px;
  border-radius: 12px;
  word-wrap: break-word;
  font-size: 14px;
  line-height: 1.4;
}

.bot-message .message-content {
  background: var(--bot-bg);
  color: var(--chat-text);
  border: 1px solid var(--chat-border);
}

.user-message .message-content {
  background: var(--user-bg);
  color: var(--user-text);
}

.message-content p {
  margin: 0;
}

.message-content ul {
  margin: 8px 0 0 0;
  padding-left: 20px;
  list-style: none;
}

.message-content ul li {
  margin: 4px 0;
  padding-left: 8px;
}

.message-time {
  font-size: 11px;
  color: var(--chat-muted);
  padding: 0 4px;
  white-space: nowrap;
}

.quick-options {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 8px;
}

.quick-options li {
  padding: 4px 0;
  font-size: 13px;
}

/* Typing indicator */
.typing-indicator {
  display: flex;
  gap: 4px;
  padding: 12px 14px;
  background: var(--bot-bg);
  border-radius: 12px;
  width: fit-content;
}

.typing-indicator span {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #999;
  animation: typing 1.4s infinite;
}

.typing-indicator span:nth-child(2) {
  animation-delay: 0.2s;
}

.typing-indicator span:nth-child(3) {
  animation-delay: 0.4s;
}

@keyframes typing {
  0%, 60%, 100% {
    opacity: 0.5;
    transform: translateY(0);
  }
  30% {
    opacity: 1;
    transform: translateY(-10px);
  }
}

/* Input area */
.chat-input-area {
  padding: 12px;
  background: var(--chat-light);
  border-top: 1px solid var(--chat-border);
}

.quick-replies {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 12px;
}

.quick-replies.hidden {
  display: none;
}

.quick-reply-btn {
  padding: 8px 12px;
  background: white;
  border: 1px solid var(--chat-border);
  border-radius: 8px;
  cursor: pointer;
  font-size: 13px;
  transition: all 0.2s;
  text-align: left;
  color: var(--chat-text);
}

.quick-reply-btn:hover {
  background: var(--chat-primary);
  color: white;
  border-color: var(--chat-primary);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(7, 86, 200, 0.15);
}

.chat-input-wrapper {
  display: flex;
  gap: 8px;
  align-items: center;
}

#chat-input {
  flex: 1;
  padding: 10px 12px;
  border: 1px solid var(--chat-border);
  border-radius: 20px;
  font-size: 14px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.2s;
}

#chat-input:focus {
  border-color: var(--chat-primary);
}

#chat-input::placeholder {
  color: #999;
}

.chat-send-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--chat-primary);
  color: white;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  flex-shrink: 0;
}

.chat-send-btn:hover {
  background: var(--chat-primary-dark);
  transform: scale(1.05);
}

.chat-send-btn:active {
  transform: scale(0.95);
}

.chat-send-btn svg {
  width: 18px;
  height: 18px;
}

/* Footer */
.chat-footer {
  padding: 8px 12px;
  background: var(--chat-light);
  border-top: 1px solid var(--chat-border);
  font-size: 11px;
  color: #666;
  text-align: center;
}

.operator-online {
  color: #28a745;
  font-weight: 600;
}

.operator-offline {
  color: #dc3545;
}

.chat-conversion-link {
  display: block;
  margin-top: 10px;
  padding: 10px 12px;
  border-radius: 9px;
  background: var(--chat-primary);
  color: #fff;
  font-weight: 700;
  text-align: center;
  text-decoration: none;
}

.chat-conversion-link:hover,
.chat-conversion-link:focus-visible {
  background: var(--chat-primary-dark);
}

.operator-actions {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}

.operator-actions .quick-reply-btn {
  flex: 1;
  margin: 0;
}

/* Responsive */
@media (max-width: 480px) {
  .chat-container {
    width: calc(100vw - 40px);
    height: calc(100vh - 100px);
    right: 20px;
    bottom: 90px;
  }

  .message-content {
    max-width: 85%;
  }
}

/* Scrollbar personalizado */
.chat-messages::-webkit-scrollbar {
  width: 6px;
}

.chat-messages::-webkit-scrollbar-track {
  background: transparent;
}

.chat-messages::-webkit-scrollbar-thumb {
  background: #ccc;
  border-radius: 3px;
}

.chat-messages::-webkit-scrollbar-thumb:hover {
  background: #999;
}
