/* ==========================================================================
   Estilos específicos para el Pulidor de Texto y Popovers interactivos (MINJUS)
   ========================================================================== */

/* Contenedor interactivo de palabra con sugerencia */
.palabra-interactiva {
  position: relative;
  display: inline-block;
  cursor: pointer;
  padding: 1px 6px;
  border-radius: 4px;
  margin: 0 1px;
  transition: all 0.15s ease-in-out;
  user-select: none;
}

.palabra-interactiva.aplicada {
  background-color: #d1e7dd;
  color: #0f5132;
  font-weight: 600;
  border-bottom: 2px solid #198754;
}

.palabra-interactiva.aplicada:hover {
  background-color: #badbcc;
  box-shadow: 0 0 0 2px rgba(25, 135, 84, 0.3);
}

.palabra-interactiva.descartada {
  background-color: #f8f9fa;
  color: #6c757d;
  text-decoration: line-through;
  opacity: 0.75;
  border-bottom: 2px dashed #dc3545;
}

.palabra-interactiva.descartada:hover {
  opacity: 1;
  background-color: #e9ecef;
  box-shadow: 0 0 0 2px rgba(220, 53, 69, 0.3);
}

/* Popover flotante interactivo en Hover */
.popover-cambio-card {
  position: absolute;
  bottom: calc(100% + 10px);
  left: 50%;
  transform: translateX(-50%);
  background-color: #ffffff;
  color: #212529;
  border: 1px solid #ced4da;
  border-radius: 6px;
  padding: 8px 12px;
  font-size: 0.82rem;
  line-height: 1.35;
  white-space: nowrap;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.2) !important;
  z-index: 1050;
  display: none;
  pointer-events: auto;
  min-width: 180px;
  text-align: left;
  cursor: default;
}

/* Flecha del popover */
.popover-cambio-card::after {
  content: "";
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  border-width: 6px;
  border-style: solid;
  border-color: #ffffff transparent transparent transparent;
}

.popover-cambio-card::before {
  content: "";
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  border-width: 7px;
  border-style: solid;
  border-color: #ced4da transparent transparent transparent;
}

/* Área de holgura para evitar parpadeos al mover el mouse al popover */
.palabra-interactiva::before {
  content: "";
  position: absolute;
  top: -14px;
  left: -8px;
  right: -8px;
  bottom: -4px;
  display: none;
  z-index: 1040;
}

.palabra-interactiva:hover::before {
  display: block;
}

.palabra-interactiva:hover .popover-cambio-card,
.palabra-interactiva:focus-within .popover-cambio-card {
  display: block;
  animation: fadeInPopover 0.15s ease-in-out;
}

@keyframes fadeInPopover {
  from {
    opacity: 0;
    transform: translate(-50%, 4px);
  }
  to {
    opacity: 1;
    transform: translate(-50%, 0);
  }
}

/* ==========================================================================
   Estilos para Autocompletado de Delitos Sugeridos (MINJUS)
   ========================================================================== */
.delito-autocomplete-list {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  z-index: 1060;
  max-height: 290px;
  overflow-y: auto;
  background-color: #ffffff;
  border: 1px solid #ced4da;
  border-top: none;
  border-radius: 0 0 6px 6px;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.15) !important;
}

.delito-sugerencia-item {
  padding: 8px 12px;
  cursor: pointer;
  border-bottom: 1px solid #f1f3f5;
  transition: background-color 0.12s ease-in-out;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.delito-sugerencia-item:last-child {
  border-bottom: none;
}

.delito-sugerencia-item:hover,
.delito-sugerencia-item.active {
  background-color: #e9ecef;
}

.delito-sugerencia-item.active {
  border-left: 3px solid #007bff;
}

.delito-sugerencia-item .item-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.88rem;
  font-weight: 600;
  color: #212529;
}

.delito-sugerencia-item .item-title {
  flex: 1;
  word-break: break-word;
}

.delito-sugerencia-item .item-match-highlight {
  color: #0056b3;
  font-weight: 700;
  text-decoration: underline;
}

.delito-sugerencia-item .item-categoria {
  font-size: 0.72rem;
  font-weight: 500;
  background-color: #e3f2fd;
  color: #0d47a1;
  padding: 2px 7px;
  border-radius: 4px;
  white-space: nowrap;
  margin-left: 8px;
}

.delito-sugerencia-item .item-keywords {
  font-size: 0.75rem;
  color: #6c757d;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.delito-sugerencia-empty {
  padding: 12px 14px;
  font-size: 0.85rem;
  color: #6c757d;
  font-style: italic;
  text-align: center;
}

