/* Estilos propios de Vecindeo (encima de Bootstrap 5) */

:root {
  --verde-vecindeo: #2c6e49;
  --verde-claro: #4c956c;
}

.bg-primary-green {
  background-color: var(--verde-vecindeo);
}

.btn-success {
  background-color: var(--verde-claro);
  border-color: var(--verde-claro);
}

/* Cards de anuncios */
.ad-card {
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  cursor: pointer;
}
.ad-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.12);
}
.ad-card .card-img-top {
  aspect-ratio: 4 / 3;
  object-fit: cover;
  background-color: #eee;
}

/* Niveles destacados (bronce / plata / oro) */
.ad-card.nivel-oro    { border: 2px solid #d4af37; }
.ad-card.nivel-plata  { border: 2px solid #a8a9ad; }
.ad-card.nivel-plata .card-title { font-weight: 700; }
.ad-card.nivel-bronce { border: 2px solid #cd7f32; }

/* Insignia "Vecino verificado" */
.badge-verificado {
  color: #fff;
  background-color: #1d9bf0;
}
.badge-tienda {
  color: #3e3049;
  background: linear-gradient(135deg, #f6e27a, #d4af37);
  font-weight: 700;
}

/* Insignia sobre la miniatura de las cards del grid (post-box) */
.post-box .thumbnail-holder {
  position: relative;
}
.post-box .thumbnail-holder .badge-verificado,
.post-box .thumbnail-holder .badge-tienda {
  position: absolute;
  top: 8px;
  right: 8px;
  font-size: 0.72rem;
  padding: 4px 8px;
  border-radius: 20px;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.25);
}
.post-box .thumbnail-holder .badge-verificado .fa,
.post-box .thumbnail-holder .badge-tienda .fa {
  margin-right: 3px;
}

/* Skeleton loaders del grid mientras cargan los anuncios (Etapa 5) */
@keyframes skeleton-pulse {
  0%   { background-position: -200px 0; }
  100% { background-position: calc(200px + 100%) 0; }
}
.img-skeleton {
  position: absolute;
  inset: 0;
  aspect-ratio: 4 / 3;
  background: #eee linear-gradient(
    90deg, #eee 0px, #e2e2e2 40px, #eee 80px
  );
  background-size: 200px 100%;
  animation: skeleton-pulse 1.2s ease-in-out infinite;
}
.post-box-skeleton {
  cursor: default;
  pointer-events: none;
}
.post-box-skeleton .thumbnail-holder {
  aspect-ratio: 4 / 3;
}
.skeleton-line {
  height: 12px;
  border-radius: 4px;
  margin-bottom: 8px;
  background: #eee linear-gradient(
    90deg, #eee 0px, #e2e2e2 40px, #eee 80px
  );
  background-size: 200px 100%;
  animation: skeleton-pulse 1.2s ease-in-out infinite;
}
.skeleton-line-title { width: 70%; height: 14px; }
.skeleton-line-sub   { width: 45%; }

/* Chat privado comprador↔vendedor, estilo WhatsApp (Etapa 5 "Plus") */
.chat-modal-header {
  background-color: var(--verde-vecindeo);
  color: #fff;
}
.chat-modal-header .chat-subtitulo {
  color: rgba(255, 255, 255, .8);
}
.chat-modal-body {
  background-color: #ece5dd;
  min-height: 320px;
  max-height: 55vh;
}
.chat-fila {
  display: flex;
  margin-bottom: 10px;
}
.chat-fila-mia  { justify-content: flex-end; }
.chat-fila-otro { justify-content: flex-start; }
.chat-burbuja {
  max-width: 75%;
  padding: 8px 12px;
  border-radius: 14px;
  box-shadow: 0 1px 1px rgba(0, 0, 0, .1);
}
.chat-burbuja-otro {
  background-color: #fff;
  border-bottom-left-radius: 3px;
}
.chat-burbuja-mia {
  background-color: #d9fdd3;
  border-bottom-right-radius: 3px;
}
.chat-texto {
  white-space: pre-wrap;
  word-break: break-word;
  font-size: .92rem;
}
.chat-hora {
  font-size: .7rem;
  color: #667781;
  text-align: right;
  margin-top: 2px;
}

/* Bandeja "Mis mensajes" */
.conv-thumb {
  width: 52px;
  height: 52px;
  object-fit: cover;
  border-radius: 6px;
  flex-shrink: 0;
}

/* Ícono de mensajes del navbar, desplegable estilo AdminLTE (globo con
   número + lista de conversaciones recientes, foto del anuncio en vez de
   foto de persona: no manejamos avatares de usuario). */
#mensajes-dropdown-toggle {
  position: relative;
}
.navbar-badge {
  position: absolute;
  top: 2px;
  right: -4px;
  font-size: .6rem;
  padding: 2px 5px;
}
.mensajes-dropdown-menu {
  width: 320px;
  max-width: 90vw;
  padding: 0;
  border: none;
  box-shadow: 0 3px 14px rgba(0, 0, 0, .18);
  overflow: hidden;
}
.mensajes-dropdown-menu .dropdown-header {
  background-color: #f8f9fa;
  padding: .6rem 1rem;
  font-size: .8rem;
  color: #6c757d;
  border-bottom: 1px solid #e9ecef;
}
#mensajes-dropdown-lista {
  max-height: 320px;
  overflow-y: auto;
}
.mensajes-drop-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: .6rem 1rem;
  border-bottom: 1px solid #f1f1f1;
  white-space: normal;
}
.mensajes-drop-item:last-child { border-bottom: none; }
.mensajes-drop-texto { flex: 1; min-width: 0; }
.mensajes-drop-hora {
  font-size: .7rem;
  color: #adb5bd;
}
.conv-thumb-sm {
  width: 40px;
  height: 40px;
  object-fit: cover;
  border-radius: 6px;
  flex-shrink: 0;
}
.mensajes-dropdown-menu .dropdown-footer {
  padding: .6rem 1rem;
  font-size: .85rem;
  text-align: center;
  border-top: 1px solid #e9ecef;
  color: var(--verde-vecindeo);
  font-weight: 500;
}
.mensajes-dropdown-menu .dropdown-footer:hover {
  background-color: #f8f9fa;
}

/* Botón/desplegable "N preguntas" por anuncio en "Mis anuncios" */
.preguntas-drop-item {
  white-space: normal;
  max-width: 280px;
}
.preguntas-drop-item .small { display: block; }

/* Dropzone de fotos (publicar) */
.dropzone {
  border: 2px dashed #c4c9cf;
  background-color: #fafbfc;
  cursor: pointer;
  transition: border-color 0.15s ease, background-color 0.15s ease;
}
.dropzone.dragover {
  border-color: var(--verde-claro);
  background-color: #eef7f1;
}

/* Miniaturas reordenables */
.pub-thumb {
  position: relative;
  width: 90px;
  height: 90px;
  cursor: grab;
}
.pub-thumb:active { cursor: grabbing; }
.pub-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 0.375rem;
  border: 1px solid #dee2e6;
  pointer-events: none;   /* el drag lo maneja el contenedor */
}
.pub-thumb.drag-over {
  outline: 3px dashed var(--verde-claro);
  outline-offset: 2px;
}
.pub-thumb.dragging { opacity: 0.4; }
.pub-thumb-x {
  position: absolute;
  top: -8px;
  right: -8px;
  width: 22px;
  height: 22px;
  line-height: 1;
  border: none;
  border-radius: 50%;
  background-color: #dc3545;
  color: #fff;
  font-weight: bold;
}
.pub-thumb-badge {
  position: absolute;
  bottom: 3px;
  left: 3px;
  font-size: 0.62rem;
}

/* File picker: NO usar attribute `hidden` ni display:none — en Firefox/Linux
   (y a veces Chrome) el diálogo no abre con input.click() si el input está
   display:none. Este clip lo deja “invisible” pero clickeable. */
.file-picker-input {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

/* Editor TinyMCE en /publicar — alto ≈ 40vh (JS fija el valor exacto al init) */
.tox-tinymce {
  border-radius: 0.375rem !important;
  min-height: 40vh !important;
}

/* Descripción enriquecida en el detalle del anuncio */
.ad-descripcion {
  line-height: 1.55;
  word-wrap: break-word;
  overflow-wrap: anywhere;
}
.ad-descripcion img {
  max-width: 100%;
  height: auto;
  border-radius: 0.375rem;
  margin: 0.5rem 0;
  display: block;
}
.ad-descripcion table {
  max-width: 100%;
  width: auto !important;
  margin: 0.75rem 0;
}
.ad-descripcion p { margin-bottom: 0.6rem; }
.ad-descripcion ul, .ad-descripcion ol { padding-left: 1.25rem; }
.ad-descripcion h1, .ad-descripcion h2, .ad-descripcion h3, .ad-descripcion h4 {
  margin: 0.8rem 0 0.4rem;
  font-weight: 600;
}

.post-vistas {
  margin-top: 0.35rem;
}

/* Moderación: mostrar/ocultar mensaje en el anuncio (solo vendedor) */
.chat-moderar-btn {
  display: inline-block;
  margin-top: 0.35rem;
  padding: 0.15rem 0.45rem;
  font-size: 0.7rem;
  border: 1px solid rgba(0, 0, 0, 0.15);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.85);
  color: #333;
  cursor: pointer;
}
.chat-burbuja-mia .chat-moderar-btn {
  background: #fff;
  border-color: #555;
  color: #333;          /* gris oscuro: el blanco se perdía sobre el verde */
}
.chat-moderar-btn:hover { opacity: 0.9; }
.chat-publico-badge {
  display: inline-block;
  margin-top: 0.35rem;
  font-size: 0.7rem;
  opacity: 0.85;
}

/* Q&A públicas: bloque completo a la derecha (~50% en escritorio) */
#preguntas-publicas-section {
  max-width: 50%;
  min-width: 16rem;
  margin-left: auto;
  padding: 1rem 1.15rem;
  background: #f8f9fa;
  border: 1px solid #e9ecef;
  border-radius: 0.5rem;
}
@media (max-width: 767.98px) {
  #preguntas-publicas-section {
    max-width: 100%;
    margin-left: 0;
  }
}
.qa-par {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  margin-bottom: 1.1rem;
}
.qa-par:last-child {
  margin-bottom: 0;
}
.qa-item {
  padding: 0.65rem 0.9rem;
  max-width: 92%;
  border-radius: 0.5rem;
}
.qa-item-comprador {
  align-self: flex-start;
  text-align: left;
  border: 1px solid #e5e7eb;
  border-left: 3px solid #adb5bd;
  background: #fff;
}
.qa-item-vendedor {
  align-self: flex-end;
  text-align: right;
  border: 1px solid #b7e4c7;
  border-right: 3px solid #198754;
  background: #eaf8ef;
}
.qa-item-vendedor .qa-meta {
  color: #198754;
}
.qa-meta {
  font-size: 0.78rem;
  color: #6c757d;
  margin-bottom: 0.2rem;
}
.qa-texto {
  white-space: pre-wrap;
  word-break: break-word;
}

/* Plus #6: historial público de ventas del vendedor */
.vendedor-reputacion {
  display: inline-block;
  margin-left: 0.35rem;
  color: #c27c0e;
  font-size: 0.95rem;
  font-weight: 600;
}
.vendedor-venta-item {
  display: block;
  color: inherit;
}
.vendedor-venta-item:hover .vendedor-venta-titulo {
  color: #0d6efd;
}
.vendedor-venta-thumb {
  position: relative;
  aspect-ratio: 1;
  overflow: hidden;
  border-radius: 0.35rem;
  background: #f1f3f5;
  margin-bottom: 0.35rem;
}
.vendedor-venta-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  filter: saturate(0.92);
}
.vendedor-venta-sold {
  position: absolute;
  left: 0.35rem;
  bottom: 0.35rem;
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  color: #fff;
  background: rgba(33, 37, 41, 0.72);
  padding: 0.1rem 0.35rem;
}
.vendedor-venta-titulo {
  font-size: 0.85rem;
  font-weight: 600;
  line-height: 1.25;
  color: #212529;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.vendedor-venta-meta {
  font-size: 0.75rem;
  color: #6c757d;
}

/* Feedback post-venta: estrellas con media estrella (mouse / touch) */
.star-rating {
  display: flex;
  gap: 0.2rem;
  user-select: none;
  outline: none;
}
.star-wrap {
  position: relative;
  display: inline-block;
  width: 2rem;
  height: 2rem;
  font-size: 1.85rem;
  line-height: 2rem;
  color: #ced4da;
}
.star-wrap .star-icon {
  pointer-events: none;
}
.star-wrap .star-icon.star-on {
  color: #f0ad4e;
}
.star-half {
  position: absolute;
  top: 0;
  width: 50%;
  height: 100%;
  padding: 0;
  margin: 0;
  border: 0;
  background: transparent;
  cursor: pointer;
}
.star-half-left { left: 0; }
.star-half-right { right: 0; }
.star-half:focus-visible {
  outline: 2px solid #0d6efd;
  outline-offset: 2px;
}

/* Referencia de pago: tiene que saltar a la vista y leerse sin dudas */
.alert-referencia {
  background: #fff5f7;
  border: 1px solid #f1aeb5;
  border-radius: .5rem;
}
.alert-referencia strong {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  letter-spacing: .08em;
  color: #b02a37;
}
.pago-cuenta-box {
  background: #e7f1ff;
  border: 1px solid #b6d4fe;
}
/* Aviso de referencia: mismo “tono suave” que alert-warning, pero en rojo */
.pago-aviso-ref {
  background: rgba(220, 53, 69, 0.12);
  border: 1px solid rgba(220, 53, 69, 0.28);
  color: #842029;
}
.pago-aviso-ref .fa {
  color: #dc3545;
}
.pago-comprobante-box {
  background: #e8f5e9;
  border: 1px solid #a5d6a7;
}
