:root {
  --background: #1a1a1a;
  --paragraphs: #b0b0b0;
  --heading: #ffffff;
  --accent-1: #dc2626;
  --light: #ffffff;
  --shadow: rgba(0, 0, 0, 0.3);
  --accent-2: #dc2626;
  --accent-3: #ef4444;
  --border: #333333;
  --chat-bg: #0a0a0a;
  --chat-secondary: #1f1f1f;
}

.body-5 {
  background-color: #fff;
  margin: 0;
  padding: 0;
  font-family: Arial, sans-serif;
}

/* ========== CONTENEDOR PADRE PRINCIPAL ========== */
.chatbot-widget {
  position: fixed;
  bottom: 0;
  right: 0;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 10px;
  padding: 20px;
  z-index: 1000;
  font-family: Poppins, sans-serif;
}

/* ========== GLOBO DE AYUDA ========== */
.help-bubble {
  background: #ffffffe8;
  border: 1px solid #dc2626;
  border-radius: 20px 20px 4px 20px;
  box-shadow: 0 4px 20px rgb(255 46 46 / 40%), 0 0 30px rgba(220, 38, 38, 0.2);
  padding: 8px 15px;
  color: #0a0a0a;
  font-weight: bold;
  font-size: 14px;
  white-space: nowrap;
  animation: bounce 6s infinite;
}

@keyframes bounce {

  0%,
  20%,
  50%,
  80%,
  100% {
    transform: translateY(0);
  }

  40% {
    transform: translateY(-3px);
  }

  60% {
    transform: translateY(-3px);
  }
}

/* ========== BOTÓN PRINCIPAL DEL CHATBOT ========== */
.chat-button {
  background: linear-gradient(135deg, #dc2626 0%, #b91c1c 100%);
  border: 3px solid #ffffff;
  box-shadow: 0 4px 25px rgba(220, 38, 38, 0.6), 0 0 40px rgba(220, 38, 38, 0.3);
  border-radius: 50%;
  width: 60px;
  height: 60px;
  display: flex;
  justify-content: center;
  align-items: center;
  cursor: pointer;
  transition: all 0.3s ease;
}

.chat-button:hover {
  transform: scale(1.1);
  box-shadow: 0 6px 35px rgba(220, 38, 38, 0.8), 0 0 50px rgba(220, 38, 38, 0.4);
  border-color: #ffffff;
}

.chat-button:active {
  transform: scale(0.95);
}

.button-icon {
  width: 30px;
  height: 30px;
  object-fit: contain;
}

/* ========== VENTANA PRINCIPAL DEL CHAT ========== */
.chat-window {
  background: linear-gradient(180deg, #1a1a1a 0%, #0a0a0a 100%);
  border-radius: 8px;
  box-shadow: 0 10px 50px rgb(213 0 0 / 80%), 0 0 30px rgba(220, 38, 38, 0.2);
  border: 2px solid #dc2626;
  width: 400px;
  height: 500px;
  display: none;
  flex-direction: column;
  opacity: 0;
  transform: translateY(20px) scale(0.95);
  transition: all 0.3s ease;
  margin-bottom: 20px;
  visibility: hidden;
}

.chat-window.show {
  opacity: 1;
  transform: translateY(0) scale(1);
  visibility: visible;
  display: flex;
}

/* ========== HEADER DEL CHAT ========== */
.chat-header {
  background: linear-gradient(135deg, #dc2626, #b91c1c);
  color: #ffffff;
  padding: 15px 20px;
  border-radius: 5px 5px 0 0;
  font-weight: 700;
  font-size: 15px;
  text-align: center;
  box-shadow: 0 4px 15px rgba(220, 38, 38, 0.4);
  border-bottom: 2px solid rgba(220, 38, 38, 0.3);
}

/* ========== ÁREA DE CONVERSACIÓN ========== */
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 15px;
  scroll-behavior: smooth;
  background: #393939;
}

.chat-messages::-webkit-scrollbar {
  width: 6px;
}

.chat-messages::-webkit-scrollbar-track {
  background: #1a1a1a;
  border-radius: 10px;
}

.chat-messages::-webkit-scrollbar-thumb {
  background: linear-gradient(180deg, #dc2626, #b91c1c);
  border-radius: 10px;
  box-shadow: 0 0 10px rgba(220, 38, 38, 0.5);
}

.chat-messages::-webkit-scrollbar-thumb:hover {
  background: linear-gradient(180deg, #ef4444, #dc2626);
}

/* ========== BURBUJAS DE MENSAJES ========== */
.message-bubble {
  border-radius: 18px 18px 18px 4px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  margin-bottom: 12px;
  max-width: 85%;
  position: relative;
  width: fit-content;
  min-height: 40px;
  padding: 12px 18px;
  display: flex;
  align-items: center;
  animation: slideIn 0.3s ease-out;
  box-shadow: rgba(0, 0, 0, 0.24) 0px 3px 8px;
}

/* Mensajes del bot */
.message-bubble.bot {
  background: linear-gradient(135deg, #1f1f1f, #2a2a2a);
  border-radius: 4px 18px 18px 18px;
  margin-left: 0;
  margin-right: auto;
  border: 1px solid #333333;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.5);
}

.message-bubble.bot::before {
  position: absolute;
  left: -25px;
  top: 8px;
  background: linear-gradient(135deg, #dc2626, #b91c1c);
  border-radius: 50%;
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  box-shadow: 0 2px 8px rgba(220, 38, 38, 0.6);
}

/* Mensajes del usuario */
.message-bubble:not(.bot):not(.error) {
  background: linear-gradient(135deg, #dc2626, #b91c1c);
  color: #ffffff;
  margin-left: auto;
  margin-right: 0;
  border-radius: 18px 4px 18px 18px;
  box-shadow: 0 2px 10px rgba(220, 38, 38, 0.4);
  border: 1px solid rgba(220, 38, 38, 0.3);
}

/* Primer mensaje especial */
.message-bubble.first {
  margin-top: 5px;
}

/* ========== TEXTO DE MENSAJES ========== */
.message-text {
  color: #ffffff;
  word-break: break-word;
  overflow-wrap: break-word;
  margin: 0;
  line-height: 1.5;
  font-weight: 400;
}

.message-bubble:not(.bot) .message-text {
  color: #ffffff;
}

/* ========== BURBUJA DE PENSAMIENTO ========== */
.thinking-bubble {
  background: linear-gradient(135deg, #1f1f1f, #2a2a2a);
  border-radius: 4px 18px 18px 18px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.5);
  margin-bottom: 12px;
  max-width: 85%;
  position: relative;
  width: fit-content;
  min-height: 40px;
  padding: 15px 20px;
  display: flex;
  align-items: center;
  margin-left: 0;
  margin-right: auto;
  animation: slideIn 0.3s ease-out;
  border: 1px solid #333333;
}

.thinking-bubble::before {
  position: absolute;
  left: -25px;
  top: 8px;
  background: white;
  border-radius: 50%;
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
}

.thinking-dots {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
}

.thinking-dot {
  width: 8px;
  height: 8px;
  background: white;
  border-radius: 50%;
  animation: thinkingPulse 1.4s infinite ease-in-out;
}

.thinking-dot:nth-child(1) {
  animation-delay: 0ms;
}

.thinking-dot:nth-child(2) {
  animation-delay: 200ms;
}

.thinking-dot:nth-child(3) {
  animation-delay: 400ms;
}

@keyframes thinkingPulse {

  0%,
  60%,
  100% {
    transform: scale(1);
    opacity: 0.7;
  }

  30% {
    transform: scale(1.3);
    opacity: 1;
  }
}

/* ========== FORMULARIO DE ENTRADA ========== */
.chat-input-container {
  padding: 15px;
  background: #1a1a1a;
  border-radius: 0 0 8px 8px;
  border-top: 2px solid rgba(220, 38, 38, 0.3);
}

.input-form {
  display: flex;
  gap: 8px;
  align-items: center;  

}

.message-input {
  flex: 1;
  border: 2px solid #333333;
  border-radius: 25px;
  padding: 12px 15px;
  transition: all 0.3s ease;
  background: #0a0a0a;
  color: #ffffff;
  outline: none;
}

.message-input::placeholder {
  color: #666666;
}

.message-input:focus {
  border-color: #dc2626;
  box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.2);
  background: #1a1a1a;
}

.send-button {
  background: linear-gradient(135deg, #dc2626, #b91c1c);
  border-radius: 25px;
  color: #ffffff;
  border: none;
  transition: all 0.3s ease;
  font-weight: 600;
  cursor: pointer;
  width: 50px;
  height: 50px;
  font-size: 18px;
  box-shadow: 0 2px 10px rgba(220, 38, 38, 0.4);
  text-align: center;
}

.send-button:hover:not(.disabled-button) {
  background: linear-gradient(135deg, #ef4444, #dc2626);
  transform: translateY(-2px);
  box-shadow: 0 4px 20px rgba(220, 38, 38, 0.6);
}

/* ========== ESTADOS ESPECIALES ========== */
.disabled-button {
  background: #ccc !important;
  opacity: 0.6 !important;
  cursor: not-allowed !important;
  pointer-events: none !important;
}

.send-button.disabled-button {
  position: relative;
}

.send-button.disabled-button::after {
  content: "";
  width: 16px;
  height: 16px;
  border: 2px solid #fff;
  border-top: 2px solid transparent;
  border-radius: 50%;
  animation: spin 1s linear infinite;
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
}

/* ========== ANIMACIONES ========== */
@keyframes slideIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes spin {
  to {
    transform: translate(-50%, -50%) rotate(360deg);
  }
}

.chatbot-controls {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 15px;
  height: 60px;
}

/* ========== SECCIÓN DE ESTILOS PARA HISTORIAL ========== */

/* ========== BOTÓN DE HISTORIAL ========== */
.history-button {
  background: white;
  border: 3px solid white;
  box-shadow: 0 4px 20px rgba(108, 117, 125, 0.4);
  border-radius: 50%;
  width: 50px;
  height: 50px;
  display: none;
  justify-content: center;
  align-items: center;
  cursor: pointer;
  transition: all 0.3s ease;
  color: gray;
  font-size: 20px;
  border: 2px solid gray;
  visibility: hidden;
}

.history-button.authorized {
  display: flex;
  visibility: visible;
}

.history-button:hover {
  transform: scale(1.1);
  box-shadow: 0 6px 25px rgba(108, 117, 125, 0.6);
  border-color: #fffefe;
}

.history-button:active {
  transform: scale(0.95);
}

/* ========== VENTANA DEL HISTORIAL ========== */
.history-window {
  background: #fff5f5;
  border-radius: 20px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
  border: 1px solid #3c3b3b80;
  width: 500px;
  height: 600px;
  position: absolute;
  bottom: 80px;
  right: 0;
  display: none;
  flex-direction: column;
  opacity: 0;
  transform: translateY(20px) scale(0.95);
  transition: all 0.3s ease;
  visibility: hidden;
  z-index: 999;
  margin-right: 1rem;
}

.history-window.show {
  display: flex;
  opacity: 1;
  transform: translateY(0) scale(1);
  visibility: visible;
  margin-bottom: 2rem;
}

/* ========== RESTO DE ESTILOS SIN CAMBIOS ========== */
.history-header {
  background: linear-gradient(135deg, #3e9ef3, #005b9f);
  color: white;
  padding: 15px 20px;
  border-radius: 20px 20px 0 0;
  font-weight: 600;
  font-size: 14px;
  display: flex;
  align-items: center;
  gap: 15px;
}

.history-back-btn {
  background: none;
  border: none;
  color: white;
  font-size: 16px;
  cursor: pointer;
  padding: 5px;
  border-radius: 50%;
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background-color 0.3s ease;
}

.history-back-btn:hover {
  background: rgba(255, 255, 255, 0.2);
}

.history-title {
  flex: 1;
  text-align: center;
  font-weight: bold;
  font-size: 18px;
}

/* Vista de lista de chats */
.history-list-view {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}

.history-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex: 1;
  gap: 15px;
  color: var(--paragraphs);
}

.loading-spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--border);
  border-top: 3px solid #6c757d;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

.history-list {
  flex: 1;
  overflow-y: auto;
  padding: 10px;
}

.history-list::-webkit-scrollbar {
  width: 5px;
}

.history-list::-webkit-scrollbar-track {
  background: none;
}

.history-list::-webkit-scrollbar-thumb {
  background: linear-gradient(45deg, #6c757d, #5a6268);
  border-radius: 10px;
}

/* Item de chat en la lista */
.history-chat-item {
  padding: 15px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background-color 0.2s ease;
  display: flex;
  flex-direction: column;
  background: #fbfbfb;
  border-radius: 10px;
  margin-bottom: 10px;
  box-shadow: rgba(0, 0, 0, 0.24) 0px 2px 2px;
}

.history-chat-item:hover {
  background-color: rgba(108, 117, 125, 0.1);
}

.history-chat-item:last-child {
  border-bottom: none;
}

.history-chat-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12px;
  color: #535353;
  margin-bottom: 5px;
}

.history-chat-id {
  font-weight: 600;
}

.history-chat-date {
  font-size: 11px;
}

.history-chat-preview {
  font-size: 14px;
  color: #474747;
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.history-chat-email {
  font-size: 11px;
  color: #007bff;
  font-style: italic;
  margin-top: 3px;
}

/* Estado vacío */
.history-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex: 1;
  gap: 15px;
  color: var(--paragraphs);
}

.history-empty i {
  font-size: 48px;
  opacity: 0.5;
}

/* Vista de conversación individual */
.history-conversation-view {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

.history-conversation-messages {
  flex: 1;
  overflow-y: auto;
  padding: 15px;
  scroll-behavior: smooth;
  background: #f4e1e1;
}

.history-conversation-messages::-webkit-scrollbar {
  width: 5px;
}

.history-conversation-messages::-webkit-scrollbar-track {
  background: none;
}

.history-conversation-messages::-webkit-scrollbar-thumb {
  background: linear-gradient(45deg, #6c757d, #5a6268);
  border-radius: 10px;
}

/* Mensajes en el historial */
.history-message-bubble {
  border-radius: 18px 18px 18px 4px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  margin-bottom: 12px;
  max-width: 85%;
  position: relative;
  width: fit-content;
  min-height: 40px;
  padding: 12px 18px;
  display: block;
  align-items: center;
}

.history-message-bubble.user {
  background: #9c9b9b;
  color: var(--heading);
  margin-left: 0;
  margin-right: auto;
  border-radius: 4px 18px 18px 18px;
  gap: 10px;
  color: var(--heading);
  margin-left: 0;
  margin-right: auto;
  border-radius: 4px 18px 18px 18px;
  gap: 10px;
}

.history-message-bubble.bot {
  background: linear-gradient(355deg, #232c34, #5a6268);
  color: white;
  margin-left: auto;
  margin-right: 0;
  border-radius: 18px 4px 18px 18px;
}

.history-message-text {
  word-break: break-word;
  overflow-wrap: break-word;
  margin: 0;
  line-height: 1.4;
  font-size: 14px;
}

.history-message-time {
  font-size: 10px;
  opacity: 0.7;
  margin-top: 5px;
  text-align: right;
}

.history-message-bubble.user .history-message-time {
  text-align: right;
}

/* ========== ESTILOS PARA INTERFACE DE AGENTES ========== */

.agent-interface {
  border-top: 2px solid #e0e0e0;
  padding: 15px;
  background: #f8f9fa;
  border-radius: 0px 0px 20px 20px;
}

.agent-controls {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.agent-take-control {
  background: linear-gradient(135deg, #ff5722, #e64a19);
  color: white;
  border: none;
  padding: 12px 20px;
  border-radius: 25px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
}

.agent-take-control:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 15px rgba(255, 87, 34, 0.3);
}

.agent-input-form {
  display: flex;
  gap: 8px;
}

.agent-message-input {
  flex: 1;
  border: 2px solid #ddd;
  border-radius: 20px;
  padding: 10px 15px;
  font-size: 14px;
  outline: none;
  transition: border-color 0.3s ease;
}

.agent-message-input:focus {
  border-color: #4caf50;
  box-shadow: 0 0 0 3px rgba(76, 175, 80, 0.1);
}

.agent-send-btn {
  background: #4caf50;
  color: white;
  border: none;
  padding: 10px 20px;
  border-radius: 20px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
}

.agent-send-btn:hover {
  background: #45a049;
  transform: translateY(-1px);
}

.history-chat-item.waiting-agent {
  border-left: 4px solid #ff5722;
  background: rgb(255 61 0 / 18%);
}

.history-chat-item.agent-active {
  border-left: 4px solid #4caf50;
  background: rgb(76 175 80 / 11%);
}

.chat-status {
  font-size: 11px;
  margin: 5px 0;
  font-weight: bold;
}

.history-message-bubble.agent {
  background: linear-gradient(360deg, #45b80c, #4db352);
  color: white;
  margin-left: auto;
  margin-right: 0;
  border-radius: 18px 18px 4px 18px;
  gap: 10px;
  color: white;
  margin-left: auto;
  margin-right: 0;
  border-radius: 18px 4px 18px 18px;
  gap: 10px;
}

/* ========== RESPONSIVE DESIGN ========== */
@media screen and (max-width: 768px) {
  .history-window {
    width: calc(100vw - 40px);
    max-width: 400px;
    height: 550px;
    right: 20px;
    bottom: 70px;
  }

  .history-button {
    width: 45px;
    height: 45px;
    font-size: 16px;
  }
}

@media screen and (max-width: 480px) {
  .history-window {
    width: calc(100vw - 30px);
    height: 500px;
    right: 15px;
    bottom: 60px;
  }

  .history-button {
    width: 40px;
    height: 40px;
    font-size: 14px;
  }
}



/* ========== MODAL DE IDENTIFICACIÓN DE AGENTE ========== */
.agent-modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.7);
  display: none;
  justify-content: center;
  align-items: center;
  z-index: 10000;
  animation: fadeIn 0.3s ease;
}

.agent-modal-overlay.show {
  display: flex;
}

.agent-modal {
  background: white;
  border-radius: 15px;
  padding: 30px;
  max-width: 400px;
  width: 90%;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
  animation: slideUp 0.3s ease;
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}

@keyframes slideUp {
  from {
    transform: translateY(30px);
    opacity: 0;
  }

  to {
    transform: translateY(0);
    opacity: 1;
  }
}

.agent-modal-header {
  margin-bottom: 20px;
}

.agent-modal-title {
  font-size: 20px;
  font-weight: 600;
  color: #565252;
  margin: 0 0 10px 0;
}

.agent-modal-description {
  font-size: 14px;
  color: #575757;
  margin: 0;
  line-height: 1.5;
}

.agent-modal-body {
  margin-bottom: 20px;
}

.agent-name-input {
  width: 100%;
  padding: 12px 15px;
  border: 2px solid var(--border);
  border-radius: 10px;
  font-size: 16px;
  transition: border-color 0.3s ease;
  box-sizing: border-box;
}

.agent-name-input:focus {
  outline: none;
  border-color: #4caf50;
  box-shadow: 0 0 0 3px rgba(76, 175, 80, 0.1);
}

.agent-name-input.error {
  border-color: #f44336;
  animation: shake 0.3s ease;
}

@keyframes shake {

  0%,
  100% {
    transform: translateX(0);
  }

  25% {
    transform: translateX(-5px);
  }

  75% {
    transform: translateX(5px);
  }
}

.agent-modal-error {
  color: #f44336;
  font-size: 12px;
  margin-top: 5px;
  display: none;
}

.agent-modal-error.show {
  display: block;
}

.agent-modal-footer {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}

.agent-modal-btn {
  padding: 10px 20px;
  border: none;
  border-radius: 8px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
  font-size: 14px;
}

.agent-modal-btn-cancel {
  background: #999999;
  color: var(--heading);
}

.agent-modal-btn-cancel:hover {
  background: #d0d0d0;
}

.agent-modal-btn-confirm {
  background: linear-gradient(135deg, #4caf50, #45a049);
  color: white;
}

.agent-modal-btn-confirm:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 15px rgba(76, 175, 80, 0.3);
}

.agent-modal-btn-confirm:disabled {
  background: #ccc;
  cursor: not-allowed;
  transform: none;
}


/* ========== INDICADOR DE CHATS EN ESPERA ========== */
.history-button-badge {
  position: absolute;
  top: -5px;
  right: -5px;
  background: linear-gradient(135deg, #ff4444, #cc0000);
  color: white;
  border-radius: 50%;
  width: 22px;
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: bold;
  box-shadow: 0 2px 8px rgba(255, 68, 68, 0.4);
  animation: badgePulse 2s ease-in-out infinite;
  border: 2px solid white;
}

@keyframes badgePulse {

  0%,
  100% {
    transform: scale(1);
  }

  50% {
    transform: scale(1.15);
  }
}

.history-button {
  position: relative;
  /* Necesario para posicionar el badge */
}

/* ========== ESTILOS PARA ACCIONES DE AGENTE ========== */
.agent-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

.agent-send-btn {
  background: #4caf50;
  color: white;
  border: none;
  padding: 10px 20px;
  border-radius: 20px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
  flex: 1;
}

.agent-send-btn:hover {
  background: #45a049;
  transform: translateY(-1px);
}

.agent-end-btn {
  background: linear-gradient(135deg, #f44336, #d32f2f);
  color: white;
  border: none;
  padding: 10px 15px;
  border-radius: 20px;
  cursor: pointer;
  transition: all 0.3s ease;
  font-size: 16px;
  min-width: 45px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.agent-end-btn:hover {
  background: linear-gradient(135deg, #d32f2f, #c62828);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(244, 67, 54, 0.3);
}

.agent-end-btn:active {
  transform: translateY(0);
}

/* ========== MODAL DE FINALIZACIÓN DE CHAT ========== */
.agent-end-dialog-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 10002;
  transition: background 0.3s ease;
}

.agent-end-dialog-overlay.show {
  background: rgba(0, 0, 0, 0.7);
}

.agent-end-dialog {
  background: white;
  border-radius: 20px;
  padding: 30px;
  max-width: 450px;
  width: 90%;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  transform: scale(0.9) translateY(20px);
  opacity: 0;
  transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.agent-end-dialog-overlay.show .agent-end-dialog {
  transform: scale(1) translateY(0);
  opacity: 1;
}

.agent-end-dialog-header {
  text-align: center;
  margin-bottom: 20px;
}

.agent-end-dialog-header h3 {
  font-size: 22px;
  font-weight: 700;
  color: #424242;
  margin: 10px 0;
}

.agent-end-dialog-header p {
  font-size: 14px;
  color: #4a4a4a;
  margin: 5px 0 0 0;
  line-height: 1.5;
}

.agent-farewell-input {
  width: 100%;
  min-height: 100px;
  padding: 12px 15px;
  border: 2px solid var(--border);
  border-radius: 12px;
  margin: 10px 0;
  font-family: inherit;
  font-size: 14px;
  resize: vertical;
  transition: border-color 0.3s ease;
  box-sizing: border-box;
}

.agent-farewell-input:focus {
  outline: none;
  border-color: #f44336;
  box-shadow: 0 0 0 3px rgba(244, 67, 54, 0.1);
}

.char-counter {
  text-align: right;
  font-size: 12px;
  color: var(--paragraphs);
  margin-top: -5px;
  margin-bottom: 15px;
}

.agent-end-dialog-actions {
  display: flex;
  gap: 12px;
  justify-content: flex-end;
  margin-top: 20px;
}

.agent-end-cancel,
.agent-end-confirm {
  padding: 12px 24px;
  border: none;
  border-radius: 25px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
  font-size: 14px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.agent-end-cancel {
  background: #e0e0e0;
  color: #2d2d2d;
}

.agent-end-cancel:hover {
  background: #d0d0d0;
  transform: translateY(-1px);
}

.agent-end-confirm {
  background: linear-gradient(135deg, #f44336, #d32f2f);
  color: white;
}

.agent-end-confirm:hover:not(:disabled) {
  background: linear-gradient(135deg, #d32f2f, #c62828);
  transform: translateY(-1px);
  box-shadow: 0 4px 15px rgba(244, 67, 54, 0.4);
}

.agent-end-confirm:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.agent-end-confirm:active:not(:disabled) {
  transform: translateY(0);
}

/* ========== ESTILOS PARA CHATS COMPLETADOS ========== */
.history-chat-item.completed {
  opacity: 0.75;
  border-left: 4px solid #9e9e9e;
  background: linear-gradient(90deg, #f5f5f5, #fafafa);
  position: relative;
}

.history-chat-item.completed:hover {
  background: linear-gradient(90deg, #eeeeee, #f5f5f5);
  opacity: 0.85;
}

.history-chat-item.completed::after {
  content: '✓';
  position: absolute;
  top: 35px;
  right: 15px;
  background: #66bb6a;
  color: white;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: bold;
  box-shadow: 0 2px 6px rgba(102, 187, 106, 0.3);
}

.history-chat-item.completed .history-chat-preview {
  opacity: 0.7;
}

.history-chat-item.completed .chat-status {
  color: #66bb6a !important;
}

/* ========== MENSAJES DE SISTEMA EN HISTORIAL ========== */
.history-message-bubble.system {
  background: linear-gradient(135deg, #e3f2fd, #bbdefb);
  color: #1565c0;
  margin: 15px auto;
  max-width: 90%;
  border-radius: 12px;
  border-left: 4px solid #2196f3;
  text-align: center;
  box-shadow: 0 2px 8px rgba(33, 150, 243, 0.15);
}

.history-message-bubble.system .history-message-text {
  font-weight: 500;
  font-size: 13px;
}

.history-message-bubble.system .history-message-time {
  text-align: center;
  color: #1565c0;
  opacity: 0.7;
}