/* DataTable — mejoras unificadas de tabla (Coquitos Wear).
   Progresivo: solo afecta a <table class="dt">. Edición en línea,
   reordenar columnas (arrastrar cabecera) y ancho (tirador). El
   mostrar/ocultar columnas y la paginación los sigue gestionando el
   servidor + el JS de base.html. */

/* --- Edición en línea --------------------------------------------------- */
.dt .dt-edit {
  cursor: text;
  border-bottom: 1px dashed rgba(128,128,128,.5);
  padding-bottom: 1px;
  transition: background-color .15s ease;
}
.dt .dt-edit[data-type="select"] { cursor: pointer; }
.dt .dt-edit:hover { background: rgba(128,128,128,.12); border-radius: 4px; }
.dt .dt-edit::after {
  content: "✎";
  font-size: .78em;
  opacity: 0;
  margin-left: 4px;
  transition: opacity .15s ease;
  color: var(--accent, #3a4db0);
}
.dt .dt-edit:hover::after { opacity: .65; }
.dt .dt-edit-box {
  width: 100%;
  min-width: 70px;
  box-sizing: border-box;
  font: inherit;
  padding: 3px 5px;
  border: 1.5px solid var(--accent, #3a4db0);
  border-radius: 5px;
  background: Canvas;
  color: CanvasText;
}
.dt td.dt-saving { opacity: .55; }
@keyframes dtSavedFlash {
  0%   { background: rgba(31,122,84,.38); }
  100% { background: transparent; }
}
.dt td.dt-saved { animation: dtSavedFlash 1s ease; }
.dt td.dt-error { animation: dtSavedFlash 1s ease; }
.dt td.dt-error { animation-name: dtErrFlash; }
@keyframes dtErrFlash {
  0%   { background: rgba(190,60,60,.4); }
  100% { background: transparent; }
}

/* --- Reordenar columnas (arrastrar cabecera) ---------------------------- */
.dt thead th[draggable="true"] { cursor: grab; }
.dt thead th.dt-dragging { opacity: .4; }
.dt thead th.dt-drop-before { box-shadow: inset 3px 0 0 var(--accent, #3a4db0); }
.dt thead th.dt-drop-after  { box-shadow: inset -3px 0 0 var(--accent, #3a4db0); }

/* --- Ancho de columna (tirador) ----------------------------------------- */
.dt thead th { position: relative; }
.dt .dt-resizer {
  position: absolute;
  top: 0; right: 0;
  width: 8px; height: 100%;
  cursor: col-resize;
  user-select: none;
  touch-action: none;
}
.dt .dt-resizer::before {
  content: "";
  position: absolute;
  top: 25%; right: 3px;
  height: 50%; width: 2px;
  background: rgba(128,128,128,.35);
  opacity: 0;
  transition: opacity .15s ease;
}
.dt thead th:hover .dt-resizer::before { opacity: 1; }
.dt.dt-resizing { user-select: none; cursor: col-resize; }
/* celdas de una columna con ancho fijado: recortan con … en vez de desbordar */
.dt td.dt-clip, .dt th.dt-clip {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* --- Barra de herramientas del datatable (reset layout) ----------------- */
.dt-reset-btn {
  font: inherit;
  font-size: 13px;
  cursor: pointer;
  border: 1px solid rgba(128,128,128,.4);
  background: transparent;
  color: inherit;
  padding: 4px 10px;
  border-radius: 999px;
}
.dt-reset-btn:hover { background: rgba(128,128,128,.12); }

/* --- Badges de aviso compactos: solo el icono, el texto en el tooltip ---- */
.dt-aviso { cursor: pointer; }
.dt-aviso svg, .dt-aviso img { vertical-align: middle; pointer-events: none; }
.dt-aviso:focus-visible { outline: 2px solid var(--accent, #3a4db0); outline-offset: 2px; border-radius: 4px; }

/* Tooltip propio (el title nativo es lento y no sale en táctil) */
.dt-tip {
  position: fixed;
  z-index: 10000;
  max-width: 280px;
  background: #23242b;
  color: #f3f3f5;
  font: 12.5px/1.45 system-ui, -apple-system, sans-serif;
  padding: 7px 10px;
  border-radius: 7px;
  box-shadow: 0 6px 20px rgba(0,0,0,.3);
  pointer-events: none;
  opacity: 0;
  transform: translateY(3px);
  transition: opacity .12s ease, transform .12s ease;
}
.dt-tip.show { opacity: 1; transform: translateY(0); }
@media (prefers-color-scheme: light) {
  .dt-tip { background: #23242b; color: #f3f3f5; }
}

/* Avisos en una SEGUNDA línea, bajo el valor — así no ensanchan la columna */
.dt .dt-avisos { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 3px; }

/* Columnas de dinero alineadas a la izquierda (coste, precio, beneficio) */
.dt th[data-col="coste"], .dt td[data-col="coste"],
.dt th[data-col="precio"], .dt td[data-col="precio"],
.dt th[data-col="beneficio"], .dt td[data-col="beneficio"] { text-align: left !important; }
