body {
  font-family: 'Inter', 'Helvetica Neue', Arial, sans-serif;
  color: #e0e0e0;
  line-height: 1.6;
  margin: 0;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

.coments {
  background: #1c1c1c;
  display: flex;
  justify-content: center;
  align-items: center;
  /* centra verticalmente */
  min-height: 300px;
  /* o la altura que quieras */
  width: 100%;
}


/* ==================== Contenedor principal ==================== */
.comentarios-container {
  max-width: 1260px;
  box-sizing: border-box;
  justify-content: center;
  align-items: center;
  /* centra verticalmente */
  min-height: 300px;
  /* o la altura que quieras */
  width: 100%;
  margin-top: 20px;
}

.comentarios-header {
  color: #e0e0e0;
  font-size: 22px;
  margin-bottom: 18px;
  border-bottom: 1px solid #2d2d2d;
  padding-bottom: 12px;
  font-weight: 600;
}

/* ==================== Form principal ==================== */
#comentario-form {
  background: #242424;
  padding: 20px;
  border-radius: 12px;
  margin-bottom: 28px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  border: 1px solid #313131;
  box-shadow: 0 2px 8px rgba(0, 0, 0, .35);
}

#comentario-form input[type="text"],
#comentario-form textarea {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid #3f3f3f;
  border-radius: 8px;
  background: #333333;
  color: #e0e0e0;
  font-size: 15px;
  outline: none;
  resize: vertical;
  min-height: 72px;
  box-sizing: border-box;
  /* Evitar desbordes de texto */
  overflow-wrap: anywhere;
  /* moderno */
  word-break: break-word;
  /* cadenas largas */
  hyphens: auto;
  /* guiones si el idioma lo permite */
}

#comentario-form input[type="text"] {
  min-height: auto;
}

#comentario-form input[type="text"]::placeholder,
#comentario-form textarea::placeholder {
  color: #9a9a9a;
}

#comentario-form input[type="text"]:focus,
#comentario-form textarea:focus {
  border-color: #ff6b6b;
  background: #3a3a3a;
  box-shadow: 0 0 0 2px rgba(255, 107, 107, .28);
}

#comentario-form input[type="file"] {
  color: #bbb;
  background: none;
  border: none;
  padding: 4px 0;
  font-size: 14px;
  cursor: pointer;
  align-self: flex-start;
}

#comentario-form input[type="file"]::-webkit-file-upload-button {
  background: #555;
  color: #fff;
  padding: 8px 14px;
  border-radius: 6px;
  border: none;
  cursor: pointer;
  transition: background-color .2s;
}

#comentario-form input[type="file"]::-webkit-file-upload-button:hover {
  background: #666;
}

#comentario-form button[type="submit"] {
  background: #ff4d4d;
  color: #fff;
  border: none;
  padding: 10px 18px;
  border-radius: 8px;
  cursor: pointer;
  transition: background-color .2s ease, box-shadow .2s ease;
  align-self: flex-end;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: .2px;
  text-transform: uppercase;
}

#comentario-form button[type="submit"]:hover {
  background: #ff3434;
  box-shadow: 0 4px 12px rgba(255, 77, 77, .36);
}

#comentario-form button[type="submit"]:active {
  box-shadow: none;
}

#imagen-error {
  font-size: .9em;
  color: #ff6b6b;
  margin-top: -6px;
  margin-bottom: 2px;
  padding-left: 2px;
  display: block;
}

/* ==================== Lista y tarjetas ==================== */
#lista-comentarios {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.comentario-item {
  display: flex;
  gap: 14px;
  background: #222;
  /* más compacto */
  padding: 16px;
  border-radius: 12px;
  border: 1px solid #2d2d2d;
  box-shadow: 0 1px 6px rgba(0, 0, 0, .30);
  position: relative;
  /* IMPIDE que las tarjetas individuales se muevan a la derecha solas */
  margin-left: 0 !important;
}

/* Avatar */
.comentario-avatar {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid #444;
  flex-shrink: 0;
  align-self: flex-start;
}

/* Contenido */
.comentario-contenido {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-width: 0;
}

.comentario-contenido strong {
  font-size: 16px;
  color: #ff6b6b;
  font-weight: 700;
  margin-bottom: 2px;
  display: block;
}

.comentario-contenido p {
  margin: 4px 0 8px 0;
  color: #e0e0e0;
  line-height: 1.55;
  /* Evitar desbordes de texto */
  overflow-wrap: anywhere;
  word-break: break-word;
  hyphens: auto;
  white-space: pre-wrap;
}

.comentario-uploaded-image {
  display: block;
  margin-top: 10px;
  margin-bottom: 8px;
  max-width: 100%;
  height: auto;
  max-height: 420px;
  /* limita altura */
  border-radius: 10px;
  border: 1px solid #3a3a3a;
  box-shadow: 0 3px 10px rgba(0, 0, 0, .28);
  object-fit: contain;
  /* por si se define altura en el futuro */
}

.comentario-contenido small {
  color: #a3a3a3;
  font-size: 12px;
  margin-top: auto;
}

/* ==================== Hilos / hijos ==================== */

/* 1. El contenedor '.children' es el único encargado de empujar hacia la derecha */
.children,
.respuestas-anidadas {
  display: flex;
  flex-direction: column;
  gap: 3px;
  margin-top: 5px;
  position: relative;
  /* Margen global para empujar hacia la derecha */
  margin-left: 16px;
  padding-left: 14px;
}

/* Línea guía vertical para hilos */
.children::before,
.respuestas-anidadas::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 2px;
  background: #2f2f2f;
  border-radius: 2px;
}

.children[data-depth="5"] {
  margin-left: 0 !important;
  padding-left: 0 !important;
}

/* Ocultamos las líneas guía extras a partir del tope para que no se encimen y se vea limpio */
.children[data-depth="5"]::before {
  display: none !important;
}

/* ==================== Botón Responder ==================== */
.reply-button {
  background: none;
  border: none;
  color: #88bbff;
  font-size: 13px;
  cursor: pointer;
  padding: 0;
  margin: 0;
  /* Quitado el margin-top viejo */
  text-align: left;
  font-weight: 600;
}

.delete-comment-button {
  background: none;
  border: none;
  color: #9088ff;
  font-size: 13px;
  cursor: pointer;
  padding: 2px 4px;
  margin: 0;
  /* Quitado el margin-top viejo */
  text-align: left;
  font-weight: 600;
}

.reply-button:hover {
  color: #cde6ff;
  text-decoration: underline;
}

/* ==================== Formulario de respuesta ==================== */
.reply-form-container {
  margin-left: 42px;
  /* Alineado con el avatar del comentario */
  margin-top: 10px;
  background: #242424;
  border: 1px solid #313131;
  border-radius: 12px;
  padding: 16px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, .28);
}

.reply-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.reply-form input[type="text"],
.reply-form textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid #3f3f3f;
  border-radius: 8px;
  background: #333333;
  color: #e0e0e0;
  font-size: 15px;
  outline: none;
  resize: vertical;
  min-height: 68px;
  overflow-wrap: anywhere;
  word-break: break-word;
  hyphens: auto;
  white-space: pre-wrap;
}

.reply-form input[type="text"] {
  min-height: auto;
}

.reply-form input[type="text"]:focus,
.reply-form textarea:focus {
  border-color: #ff6b6b;
  background: #3a3a3a;
  box-shadow: 0 0 0 2px rgba(255, 107, 107, .22);
}

.reply-form input[type="file"] {
  color: #bbb;
  background: none;
  border: none;
  padding: 4px 0;
  font-size: 14px;
  cursor: pointer;
  align-self: flex-start;
}

.reply-form input[type="file"]::-webkit-file-upload-button {
  background: #555;
  color: #fff;
  padding: 8px 14px;
  border-radius: 6px;
  border: none;
  cursor: pointer;
  transition: background-color .2s;
}

.reply-form input[type="file"]::-webkit-file-upload-button:hover {
  background: #666;
}

.reply-imagen-error {
  font-size: .9em;
  color: #ff6b6b;
  margin-top: -4px;
  margin-bottom: 2px;
  padding-left: 2px;
}

.reply-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.reply-actions button[type="submit"] {
  background: #ff4d4d;
  color: #fff;
  border: none;
  padding: 9px 16px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  transition: background-color .2s, box-shadow .2s;
}

.reply-actions button[type="submit"]:hover {
  background: #ff3434;
  box-shadow: 0 3px 10px rgba(255, 77, 77, .30);
}

.reply-actions .cancel-reply-btn {
  background: none;
  border: 1px solid #444;
  color: #cfcfcf;
  padding: 8px 14px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
}

.reply-actions .cancel-reply-btn:hover {
  background: #333;
}

.image-preview {
  margin-top: 8px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.image-preview-img {
  max-width: 100%;
  height: auto;
  max-height: 300px;
  /* limita altura de la captura */
  border-radius: 10px;
  border: 1px solid #3a3a3a;
  box-shadow: 0 3px 10px rgba(0, 0, 0, .28);
  object-fit: contain;
}

.image-preview-remove {
  align-self: flex-start;
  background: #444;
  color: #eaeaea;
  border: 1px solid #555;
  border-radius: 8px;
  padding: 6px 12px;
  cursor: pointer;
  font-size: 13px;
}

.image-preview-remove:hover {
  background: #505050;
}

/* Indicador visual de dragover en textarea */
textarea.dropping {
  outline: 2px dashed #88bbff;
  background: #2d2d2d;
}

/* ==================== Responsive ==================== */
@media (max-width:768px) {
  .comentarios-container {
    margin: 24px auto;
  }

  #comentario-form {
    padding: 18px;
    border-radius: 10px;
  }

  .comentario-item {
    padding: 16px;
    border-radius: 10px;
    gap: 12px;
  }

  .comentario-avatar {
    width: 40px;
    height: 40px;
  }

  .children,
  .respuestas-anidadas {
    /* Menos sangría en celulares para no robar tanta pantalla */
    margin-left: 8px;
    padding-left: 10px;
  }

  .reply-form-container {
    margin-left: 14px;
    padding: 14px;
    border-radius: 10px;
  }

  .comentario-uploaded-image {
    max-height: 360px;
  }
}

@media (max-width:480px) {
  .comentarios-container {
    margin: 20px auto;
  }

  .comentario-item {
    padding: 14px;
    border-radius: 10px;
  }

  .comentario-avatar {
    width: 36px;
    height: 36px;
  }

  .comentario-uploaded-image {
    max-height: 300px;
  }
}

/* ==================== File input custom (Imagen) ==================== */
.file-field {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.file-input-hidden {
  position: absolute;
  left: -9999px;
  width: 1px;
  height: 1px;
  overflow: hidden;
}

.file-btn {
  background: #555;
  color: #fff;
  padding: 8px 14px;
  border-radius: 6px;
  border: none;
  cursor: pointer;
  transition: background-color .2s;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.file-btn:hover {
  background: #666;
}

.file-name {
  color: #bbb;
  font-size: 14px;
}

#load-more-comments {
  display: block;
  width: 100%;
  background: #ff5722;
  color: #e0e0e0;
  border: 1px solid #3f3f3f;
  padding: 12px 20px;
  margin: 16px 0 8px 0;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  text-align: center;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  cursor: pointer;
  transition: all 0.2s ease;
  font-family: inherit;
  box-sizing: border-box;
}

#load-more-comments:hover {
  border-color: #ff6b6b;
}

#load-more-comments:active {
  transform: translateY(1px);
}

/* ==================== Estados del JS (Cargando / Error) ==================== */
.loading-comments,
.error-comments {
  text-align: center;
  padding: 24px 20px;
  color: #a3a3a3;
  font-size: 15px;
  font-weight: 500;
  background: #222;
  border-radius: 12px;
  border: 1px dashed #3f3f3f;
  margin: 10px 0;
}

.error-comments {
  color: #ff6b6b;
  border-color: rgba(255, 107, 107, 0.4);
  background: rgba(255, 107, 107, 0.05);
}

.comment-actions {
  display: flex;
  flex-direction: column;
  /* Apila los elementos (Reacciones arriba, botones abajo) */
  align-items: flex-start;
  gap: 1px;
  /* Espacio vertical entre reacciones y los botones */
  margin-top: 1px;
}

/* Contenedor que agrupa Responder y Eliminar para que estén uno al lado del otro */
.action-buttons-row {
  display: flex;
  align-items: center;
  gap: 15px;
  /* Espacio entre Responder y Eliminar */
}

.reactions-fb-wrapper {
  position: relative;
  display: flex;
  align-items: center;
  gap: 6px;
}

/* El popover oculto que aparece con hover */
.reactions-popover {
  position: absolute;
  bottom: 110%;
  /* Aparece arriba del botón */
  left: 0;
  background: #2a2a2a;
  border: 1px solid #3f3f3f;
  border-radius: 30px;
  padding: 6px 10px;
  display: flex;
  gap: 8px;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.5);

  /* Animación oculta por defecto */
  opacity: 0;
  visibility: hidden;
  transform: translateY(10px) scale(0.95);
  transition: all 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  z-index: 100;
}

/* Aparece cuando haces hover sobre el contenedor */
.reactions-fb-wrapper:hover .reactions-popover {
  opacity: 1;
  visibility: visible;
  transform: translateY(0) scale(1);
}

/* Emojis individuales dentro del popover */
.btn-react {
  background: none;
  border: none;
  font-size: 24px;
  cursor: pointer;
  padding: 0;
  margin: 0;
  transition: transform 0.2s ease;
  line-height: 1;
}

.btn-react:hover {
  transform: scale(1.35) translateY(-4px);
}

/* Botón principal (El texto abajo) */
.main-react-btn {
  background: none;
  border: none;
  color: #a3a3a3;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 0;
  transition: color 0.2s;
}

.main-react-btn:hover {
  color: #d1d1d1;
}

.main-react-btn.reacted {
  /* Si ya reaccionó, lo ponemos más oscuro por defecto, JS cambiará el color exacto */
  font-weight: 700;
}

/* El contador siempre visible */
.reaction-count-display {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 13px;
  color: #a3a3a3;
  background: #333;
  padding: 2px 8px;
  border-radius: 11px;
}

.reaction-count-display span {
  font-weight: bold;
}

.reaction-icons {
  font-size: 14px;
  letter-spacing: -3px;
  /* Junta los emojis */
  margin-right: 4px;
  display: inline-block;
}

.user-header {
  display: flex;
  align-items: center;
  gap: 8px;
  /* Espacio entre el nombre, el nivel y el rango */
  margin-bottom: 2px;
  flex-wrap: wrap;
  /* Si la pantalla es muy pequeña, los baja a otra línea */
}

/* Sobrescribimos el display: block que tenía antes el 'strong' */
.user-header strong {
  display: inline-block;
  margin-bottom: 0;
}

.user-level {
  background: #ffb142;
  /* Un tono dorado anaranjado que queda bien con modo oscuro */
  color: #1c1c1c;
  /* Letra oscura para contrastar con el fondo dorado */
  font-size: 11px;
  font-weight: 800;
  padding: 2px 6px;
  border-radius: 6px;
  letter-spacing: 0.5px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.4);
  user-select: none;
}

.user-rank {
  font-size: 12px;
  color: #a3a3a3;
  font-style: italic;
  font-weight: 500;
}