* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

.body-desk {
  background: #9b9a9a;
  padding: 3px;
  transition: background 0.4s;
  border-radius: 28px;
}

.chat-container {
  /* height: 100%; 
  display: flex; 
  flex-direction: column;*/
  background: #ece5dd;
  border-radius: 28px;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
  overflow: hidden;
  transition: background 0.4s;
}

/* ==================== MODO OSCURO ==================== */
body.dark .chat-container {
  background: #0b141a;
}

body.dark .chat-header {
  background: #202c33;
  border-bottom: 1px solid #2a3942;
}

body.dark .chat-messages {
  background: #0b141a;
}

body.dark .bottom-bar {
  background: #202c33;
  border-top: 1px solid #2a3942;
}

body.dark .message.assistant .message-content {
  background: #202c33;
  color: #e9edf0;
}

body.dark .message.user .message-content {
  background: #005c4b;
  color: #e9edf0;
}

body.dark #pregunta {
  background: #2a3942;
  border-color: #3b4a54;
  color: #e9edf0;
}

body.dark #pregunta::placeholder {
  color: #8696a0;
}

body.dark .modal-content {
  background: #202c33;
  color: #e9edf0;
}

body.dark .modal-header {
  border-bottom-color: #2a3942;
  background: #202c33;
}

body.dark .modal-footer {
  border-top-color: #2a3942;
  background: #202c33;
}

body.dark .form-label {
  color: #e9edf0;
}

body.dark .form-control,
body.dark .form-select {
  background: #2a3942;
  border-color: #3b4a54;
  color: #e9edf0;
}

body.dark .form-control:focus,
body.dark .form-select:focus {
  border-color: #25d366;
  box-shadow: 0 0 0 3px rgba(37, 211, 102, 0.2);
}

body.dark .btn-close {
  filter: invert(1);
}

body.dark .text-muted {
  color: #8696a0 !important;
}

/* ============================================ */
/* ============================================ */
/* Header estilo WhatsApp                       */
/* ============================================ */
/* ============================================ */

.chat-header {
  background: #075e54;
  color: white;
  padding: 18px 24px;
  flex-shrink: 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.chat-header h3 {
  font-weight: 600;
  font-size: 1.25rem;
  margin: 0;
  color: white;
}

.chat-header h3 i {
  margin-right: 8px;
  color: #25d366;
}

/* ============================================ */
/* ESTILOS BASE DE BOTONES                      */
/* ============================================ */

/* Base para todos los botones del header */
.chat-header .btn-light {
  transition: all 0.3s ease;
  position: relative;
  overflow: hidden;
}

/* Hover amarillo para desktop CON RESPLANDOR */
.chat-header .btn-light:hover i {
  color: var(--fondo-botones-hoover) !important;
  transform: scale(1.1);
  transition: all 0.2s ease;
}

/* Resplandor al hacer hover en el botón */
.chat-header .btn-light:hover {
  box-shadow: 0px 0px 8px var(--fondo-botones-hoover);
  border-color: var(--fondo-botones-hoover);
}

.chat-header .btn-light i {
  transition: all 0.2s ease;
}

/* ============================================ */
/* MÓVIL (menos de 576px) -                     */
/* ============================================ */

@media (max-width: 576px) {
  /* Ajustes del header */
  .chat-header {
    padding: 12px 16px;
    gap: 12px;
  }

  .chat-header h3 {
    font-size: 0.95rem;
    margin: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
    min-width: 0;
  }

  .chat-header div {
    display: flex;
    flex-direction: row;
    gap: 8px;
    flex-shrink: 0;
  }

  /* Área táctil más grande */
  .chat-header .btn {
    min-width: 44px;
    min-height: 44px;
    padding: 10px 12px;
    margin: 0 !important;
  }

  .chat-header .btn i {
    font-size: 1.1rem;
  }

  /* Estilo visible de botones en móvil */
  .chat-header .btn-light {
    background-color: rgba(255, 255, 255, 0.2) !important;
    border: 1px solid rgba(255, 255, 255, 0.4) !important;
  }

  /* Sugerencia 3: Efecto scale al tocar */
  .chat-header .btn-light:active {
    transform: scale(0.95);
  }

  /* Efecto ripple */
  .chat-header .btn-light::after {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(255, 193, 7, 0.5);
    transform: translate(-50%, -50%);
    transition:
      width 0.3s,
      height 0.3s;
    pointer-events: none;
  }

  .chat-header .btn-light:active::after {
    width: 120px;
    height: 120px;
  }

  /* Color amarillo al tocar en móvil */
  .chat-header .btn-light:active i {
    color: #ffc107 !important;
  }
}

/* ============================================ */
/* MÓVIL EXTREMO (menos de 380px) -             */
/* ============================================ */

@media (max-width: 380px) {
  .chat-header {
    padding: 10px 12px;
    gap: 8px;
  }

  .chat-header h3 {
    font-size: 0.85rem;
  }

  /* Oculta "con Pachito" en pantallas muy pequeñas */
  .chat-header h3 i + span {
    display: none;
  }

  .chat-header h3 {
    display: flex;
    align-items: center;
    gap: 4px;
  }

  /* Botones un poco más compactos */
  .chat-header .btn {
    min-width: 40px;
    min-height: 40px;
    padding: 8px 10px;
  }

  .chat-header .btn i {
    font-size: 1rem;
  }

  .chat-header div {
    gap: 6px;
  }
}

/* ============================================ */
/* ============================================ */
/* Mensajes                                     */
/* ============================================ */
/* ============================================ */

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
  background: #ece5dd;
  min-height: 0;
  background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="100" height="100" viewBox="0 0 100 100" opacity="0.03"><path fill="none" d="M0 0h100v100H0z"/><path fill="%23000" d="M20 20 L30 20 L30 30 L20 30 Z M40 40 L50 40 L50 50 L40 50 Z M60 60 L70 60 L70 70 L60 70 Z M80 80 L90 80 L90 90 L80 90 Z"/></svg>');
  background-repeat: repeat;
}

/* Bottom bar estilo WhatsApp */
.bottom-bar {
  flex-shrink: 0;
  background: #f0f2f5;
  border-top: 1px solid #e0e0e0;
  padding: 12px 20px;
}

#pregunta {
  resize: none;
  overflow-y: hidden;
  min-height: 42px;
  max-height: 120px;
  line-height: 1.5;
  border-radius: 20px;
  padding: 10px 16px;
  font-size: 0.95rem;
  border: none;
  background: white;
  transition: all 0.2s ease;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

#pregunta:focus {
  outline: none;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
  color: #000;
}

/* Botón estilo WhatsApp */
.btn-primary {
  background: #25d366;
  background: green;
  border: none;
  border-radius: 50px;
  padding: 8px 24px;
  font-weight: 600;
  transition: all 0.2s ease;
  color: white;
  margin-left: 8px;
}

.btn-primary:hover {
  background: #128c7e;
  transform: scale(1.02);
}

/* Mensajes estilo burbujas WhatsApp */
.message {
  margin-bottom: 12px;
  display: flex;
  animation: fadeIn 0.2s ease-out;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.message.user {
  justify-content: flex-end;
}

.message.assistant {
  justify-content: flex-start;
}

.message-content {
  max-width: 90%;
  padding: 8px 12px;
  border-radius: 18px;
  word-wrap: break-word;
  line-height: 1.4;
  font-size: 0.9rem;
  position: relative;
  box-shadow: 0 1px 1px rgba(0, 0, 0, 0.1);
}

/* Mensaje propio (usuario) */
.message.user .message-content {
  background: #dcf8c6;
  color: #303030;
  color: #000;
  border-bottom-right-radius: 4px;
}

/* Mensaje del asistente */
.message.assistant .message-content {
  background: white;
  color: #303030;
  color: #000;
  border-bottom-left-radius: 4px;
}

/* Botones de header estilo WhatsApp */
#themeToggle,
.btn-light {
  background: rgba(255, 255, 255, 0.2);
  border: none;
  color: white;
  border-radius: 30px;
  padding: 8px 14px;
  transition: all 0.2s;
}

#themeToggle:hover,
.btn-light:hover {
  background: rgba(255, 255, 255, 0.3);
}

/* Scrollbar estilo WhatsApp */
.chat-messages::-webkit-scrollbar {
  width: 6px;
}

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

.chat-messages::-webkit-scrollbar-thumb {
  background: #bdc1c6;
  border-radius: 10px;
}

.chat-messages::-webkit-scrollbar-thumb:hover {
  background: #9aa0a6;
}

body.dark .chat-messages::-webkit-scrollbar-track {
  background: #2a3942;
}

body.dark .chat-messages::-webkit-scrollbar-thumb {
  background: #3b4a54;
}

/* Modal estilo WhatsApp */
.modal-content {
  border-radius: 20px;
  border: none;
  overflow: hidden;
}

.modal-header {
  background: #075e54;
  color: white;
  border-bottom: none;
  padding: 1rem 1.5rem;
}

.modal-header .modal-title {
  color: white;
}

.modal-header .btn-close {
  filter: brightness(0) invert(1);
}

.modal-footer {
  background: #f0f2f5;
  border-top: 1px solid #e0e0e0;
}

.btn-danger {
  background: #dc3545;
  border: none;
  border-radius: 20px;
  padding: 8px 18px;
  font-weight: 500;
  transition: all 0.2s;
}

.btn-danger:hover {
  background: #c82333;
  transform: scale(1.02);
}

.btn-secondary {
  background: #25d366;
  border: none;
  border-radius: 20px;
  padding: 8px 20px;
  font-weight: 500;
  color: white;
  transition: all 0.2s;
}

.btn-secondary:hover {
  background: #128c7e;
  transform: scale(1.02);
}

.form-range::-webkit-slider-thumb {
  background: #25d366;
}

.form-range::-webkit-slider-thumb:hover {
  background: #128c7e;
}

.form-range:focus::-webkit-slider-thumb {
  box-shadow: 0 0 0 3px rgba(37, 211, 102, 0.2);
}

/* Estilos para bloques del typing */
.typing-indicator {
  display: flex;
  gap: 4px;
  padding: 12px 16px;
  background: #f1f3f4;
  border-radius: 18px;
  width: fit-content;
}

.typing-indicator span {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #667eea;
  animation: typing 1.4s infinite;
}

@keyframes typing {
  0%,
  60%,
  100% {
    transform: translateY(0);
    opacity: 0.4;
  }
  30% {
    transform: translateY(-10px);
    opacity: 1;
  }
}

/* ==================== ESTILOS PARA TABLAS ==================== */

/* Contenedor responsive para tablas */
.message-content .table-responsive {
  overflow-x: auto;
  margin: 0.75rem 0;
  border-radius: 12px;
}

/* Estilos base para tablas */
.message-content .table {
  width: 100%;
  margin-bottom: 0;
  background-color: transparent;
  border-collapse: collapse;
  font-size: 0.85rem;
  border-radius: 12px;
  overflow: hidden;
}

.message-content .table th,
.message-content .table td {
  padding: 0.6rem 0.8rem;
  vertical-align: top;
  border: 1px solid #dee2e6;
  text-align: left;
}

.message-content .table thead th {
  vertical-align: bottom;
  border-bottom: 2px solid #dee2e6;
  background-color: #075e54;
  color: white;
  font-weight: 600;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.message-content .table-striped tbody tr:nth-of-type(odd) {
  background-color: rgba(0, 0, 0, 0.03);
}

.message-content .table-hover tbody tr:hover {
  background-color: rgba(0, 0, 0, 0.05);
  transition: background-color 0.2s ease;
}

.message-content .table-bordered {
  border: 1px solid #dee2e6;
}

/* Modo oscuro para tablas */
body.dark .message-content .table {
  color: #e9edf0;
}

body.dark .message-content .table th,
body.dark .message-content .table td {
  border-color: #3b4a54;
}

body.dark .message-content .table-striped tbody tr:nth-of-type(odd) {
  background-color: rgba(255, 255, 255, 0.03);
}

body.dark .message-content .table-hover tbody tr:hover {
  background-color: rgba(255, 255, 255, 0.05);
}

body.dark .message-content .table thead th {
  background-color: #202c33;
  color: #e9edf0;
  border-bottom-color: #3b4a54;
}

body.dark .message-content .table-bordered {
  border-color: #3b4a54;
}

/* Estilos para listas dentro de tablas o mensajes */
.message-content ul,
.message-content ol {
  margin: 0.5rem 0;
  padding-left: 1.5rem;
}

.message-content li {
  margin: 0.25rem 0;
  line-height: 1.4;
}

.message-content p {
  margin: 0.5rem 0;
}

.message-content p:first-child {
  margin-top: 0;
}

.message-content p:last-child {
  margin-bottom: 0;
}

/* Estilos para código inline */
.message-content code {
  background: rgba(0, 0, 0, 0.05);
  padding: 0.2rem 0.3rem;
  border-radius: 4px;
  font-family: monospace;
  font-size: 0.85em;
}

body.dark .message-content code {
  background: rgba(255, 255, 255, 0.1);
}

/* Estilos para bloques de código */
.message-content pre {
  background: rgba(0, 0, 0, 0.05);
  padding: 0.75rem;
  border-radius: 8px;
  overflow-x: auto;
  margin: 0.5rem 0;
}

body.dark .message-content pre {
  background: rgba(255, 255, 255, 0.05);
}

.message-content pre code {
  background: transparent;
  padding: 0;
}
