/* v2-tables.css — tablas V2, alias .table-v2, acciones, DataTable skin (extraído Fase 5.2) */
/* =============================================
   TABLAS V2 CANÓNICAS — Contrato DataTable V2
   ============================================= */

/* === Wrapper engine V2: scroll horizontal cuando la tabla excede; tabla siempre 100% ancho === */
.v2-table-wrapper,
.v2-table-wrap,
.table-container {
  display: block;
  width: 100%;
  overflow-x: auto;
  overflow-y: hidden;
  margin-bottom: 1rem;
}

/* === .v2-table — Tabla canónica V2 (100% ancho; auto-layout por contenido; mínimos en ch) === */
.v2-table {
  width: 100%;
  table-layout: auto;
  border-collapse: collapse;
  font-size: var(--v2-font-size-sm);
  background: var(--v2-bg);
  border: 1px solid var(--v2-border);
  border-radius: var(--v2-radius-md);
  overflow: hidden;
}
/* Si la suma de anchos de colgroup excede 100%, la tabla crece y el wrapper hace scroll */

/* Por defecto: nowrap + ellipsis; NUNCA wrap por carácter (word-break/overflow-wrap explícitos) */
.v2-table th,
.v2-table td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--v2-border);
  border-right: 1px solid var(--v2-border);
  vertical-align: middle;
  text-align: left;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  word-break: normal;
  overflow-wrap: normal;
}
.v2-table th:last-child,
.v2-table td:last-child { border-right: none; }

/* Cabecera: centrado canónico; NUNCA display -webkit-box (mantener table-cell) */
.v2-table thead th {
  background: var(--sigma-surface-section, var(--sigma-surface-base, var(--v2-bg-subtle)));
  color: var(--sigma-text-primary, var(--v2-text));
  font-weight: 600;
  border-bottom: var(--sigma-border-width-hairline, 1px) solid var(--sigma-border-strong, var(--v2-border));
  text-align: center;
  vertical-align: middle;
  word-break: normal;
  overflow-wrap: normal;
}
.v2-table thead th.v2-td--num { text-align: center; }

/* Body: una sola línea con ellipsis por defecto; sin romper por carácter */
.v2-table tbody td {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  word-break: normal;
  overflow-wrap: normal;
}

/* Celdas texto (Descripción/Proyecto): clamp 2 líneas; break-word sin romper por carácter */
.v2-table tbody td.v2-td--text-clamp {
  white-space: normal;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-overflow: ellipsis;
  word-break: normal;
  overflow-wrap: break-word;
  hyphens: auto;
}

/* Header que puede partir en 2 líneas (wrap_header). NUNCA -webkit-box en th (rompe layout). */
.v2-table thead th.v2-th--wrap {
  display: table-cell;
  white-space: normal;
  word-break: normal;
  overflow-wrap: break-word;
  hyphens: auto;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.2;
  max-height: 2.4em;
}

/* === Colgroup + celdas: SOLO mínimos en ch (auto-layout; contenido influye) === */
.v2-table .v2-col--date,
.v2-table th.v2-col--date, .v2-table td.v2-col--date { min-width: 10ch; }
.v2-table .v2-col--datetime,
.v2-table th.v2-col--datetime, .v2-table td.v2-col--datetime { min-width: 16ch; }
.v2-table .v2-col--code,
.v2-table th.v2-col--code, .v2-table td.v2-col--code { min-width: 9ch; }
.v2-table .v2-col--reg,
.v2-table th.v2-col--reg, .v2-table td.v2-col--reg { min-width: 6ch; }
.v2-table .v2-col--type,
.v2-table th.v2-col--type, .v2-table td.v2-col--type { min-width: 8ch; }
.v2-table .v2-col--user,
.v2-table th.v2-col--user, .v2-table td.v2-col--user { min-width: 10ch; }
.v2-table .v2-col--user-sm,
.v2-table th.v2-col--user-sm, .v2-table td.v2-col--user-sm { min-width: 10ch; }
.v2-table .v2-col--num-sm,
.v2-table th.v2-col--num-sm, .v2-table td.v2-col--num-sm { min-width: 8ch; }
.v2-table .v2-col--num,
.v2-table th.v2-col--num, .v2-table td.v2-col--num { min-width: 10ch; }
.v2-table .v2-col--unit,
.v2-table th.v2-col--unit, .v2-table td.v2-col--unit { min-width: 6ch; }
.v2-table .v2-col--unit-sm,
.v2-table th.v2-col--unit-sm, .v2-table td.v2-col--unit-sm { min-width: 6ch; }
.v2-table .v2-col--status,
.v2-table th.v2-col--status, .v2-table td.v2-col--status { min-width: 10ch; }
.v2-table .v2-col--actions,
.v2-table th.v2-col--actions, .v2-table td.v2-col--actions { min-width: 10ch; }
.v2-table .v2-col--text-sm,
.v2-table th.v2-col--text-sm, .v2-table td.v2-col--text-sm { min-width: 14ch; }
.v2-table .v2-col--text-md,
.v2-table th.v2-col--text-md, .v2-table td.v2-col--text-md { min-width: 20ch; }
.v2-table .v2-col--text-lg,
.v2-table th.v2-col--text-lg, .v2-table td.v2-col--text-lg { min-width: 28ch; }
.v2-table .v2-col--text,
.v2-table th.v2-col--text, .v2-table td.v2-col--text { min-width: 20ch; }
.v2-table .v2-col--text-priority,
.v2-table th.v2-col--text-priority, .v2-table td.v2-col--text-priority { min-width: 28ch; }
.v2-table .v2-col--entity-code,
.v2-table th.v2-col--entity-code, .v2-table td.v2-col--entity-code { min-width: 9ch; }
.v2-table .v2-col--entity-name,
.v2-table th.v2-col--entity-name, .v2-table td.v2-col--entity-name { min-width: 20ch; }
.v2-table .v2-col--entity-both,
.v2-table th.v2-col--entity-both, .v2-table td.v2-col--entity-both { min-width: 28ch; }

.v2-table tbody tr { background: var(--v2-bg); }
.v2-table tbody tr:nth-child(even) { background: var(--v2-bg-subtle); }
.v2-table tbody tr:hover { background: var(--v2-primary-light); }

/* td transparente para que el fondo del tr sea visible */
.v2-table td { background: transparent !important; }

/* Celdas que permiten wrap (legacy): break-word sin romper por carácter */
.v2-table .v2-td--wrap {
  white-space: normal;
  word-break: normal;
  overflow-wrap: break-word;
  overflow: visible;
  text-overflow: clip;
}

/* Nowrap obligatorio para columnas fijas (Fecha/Código/Num/Tipo/Usuario/Reg/Unidad/Estado) */
.v2-table .v2-td--nowrap { white-space: nowrap; }
.v2-table th.v2-td--nowrap { white-space: nowrap; }
/* Reg.: alineación derecha */
.v2-table .v2-td--reg { text-align: right; }
.v2-table th.v2-td--reg { text-align: right; }
/* Alineación semántica */
.v2-table .v2-td--num { text-align: right; }
.v2-table .v2-td--center { text-align: center; }
.v2-table th.v2-td--num { text-align: right; }
.v2-table th.v2-td--center { text-align: center; }

/* Columna Acciones: botones inline sin wrap, compactos */
.v2-actions {
  display: inline-flex;
  flex-wrap: nowrap;
  gap: 6px;
  align-items: center;
  justify-content: center;
  white-space: nowrap;
}
.v2-table td .v2-actions .v2-btn,
.v2-table td .v2-actions .btn {
  padding: 4px 10px;
  font-size: 0.8rem;
  flex-shrink: 0;
}

/* Modificador denso: muchas columnas, headers y botones en una fila */
.v2-table--dense {
  font-size: 0.8rem;
}
.v2-table--dense th,
.v2-table--dense td {
  padding: 6px 10px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.v2-table--dense thead th { white-space: nowrap; }
.v2-table--dense td .v2-actions .v2-btn,
.v2-table--dense td .v2-actions .btn {
  padding: 2px 6px;
  font-size: 0.75rem;
}

/* Variantes */
.v2-table--bordered { border: 1px solid var(--v2-border); }
.v2-table--bordered th, .v2-table--bordered td { border: 1px solid var(--v2-border); }
.v2-table--bordered thead th { border-bottom: 2px solid var(--v2-border); }

.v2-table--compact { font-size: 0.85em; }
.v2-table--compact th, .v2-table--compact td { padding: 0.4rem 0.5rem; vertical-align: middle; }
.v2-table--compact th { font-weight: 600; white-space: nowrap; }

.v2-table-scroll-x { overflow-x: auto; margin-bottom: 1rem; }
.v2-table-fixed { table-layout: fixed; width: 100%; }

.v2-table-section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 15px;
}

/* Footer de tabla */
.v2-table-footer { background-color: var(--v2-bg-subtle); font-weight: 600; }
.v2-table-footer td { border-top: 2px solid var(--v2-border); }

/* Input integrado en tablas */
.v2-table-input {
  border: 0; outline: none; background: transparent; width: 100%;
  padding: 0.25rem 0.5rem; text-align: center;
}
.v2-table-input:focus { outline: 2px solid rgba(102, 126, 234, 0.5); outline-offset: 2px; background: rgba(255, 255, 255, 0.9); }

/* Inputs de cantidad */
.v2-input-cantidad { width: 120px; text-align: right; display: inline-block; }
.v2-input-cantidad-recepcion { width: 120px; text-align: right; display: inline-block; font-size: 0.9em; padding: 6px 10px; }

/* Transferencias anchos */
.v2-table-transferencias { width: 100%; }
.v2-table-transferencias th:nth-child(1) { width: 10%; }
.v2-table-transferencias th:nth-child(2) { width: 15%; }
.v2-table-transferencias th:nth-child(3) { width: 8%; }
.v2-table-transferencias th:nth-child(4) { width: 10%; }
.v2-table-transferencias th:nth-child(5) { width: 12%; }
.v2-table-transferencias th:nth-child(6) { width: 12%; }
.v2-table-transferencias th:nth-child(7) { width: 12%; }
.v2-table-transferencias th:nth-child(8) { width: 12%; }
.v2-table-transferencias th:nth-child(9) { width: 9%; }

/* Requisición items columns */
.v2-table-requisicion-items td.v2-table-stock { color: var(--v2-text-muted); font-size: 0.9em; }
.v2-table-requisicion-items .v2-table-cantidad { font-weight: 600; }
.v2-table-requisicion-items .v2-col-codigo { width: 100px; max-width: 110px; white-space: nowrap; text-align: center; }
.v2-table-requisicion-items .v2-col-desc { min-width: 220px; white-space: normal; word-break: break-word; }
.v2-table-requisicion-items .v2-col-unidad { width: 56px; max-width: 70px; white-space: nowrap; text-align: center; }
.v2-table-requisicion-items .v2-col-stock { width: 7%; min-width: 52px; max-width: 72px; white-space: nowrap; text-align: center; }
.v2-table-requisicion-items .v2-col-cant { width: 80px; max-width: 95px; white-space: nowrap; text-align: center; }
.v2-table-requisicion-items .v2-col-fecha { width: 120px; max-width: 130px; white-space: nowrap; text-align: center; }
.v2-table-requisicion-items .v2-col-frentecc { width: 110px; max-width: 130px; white-space: nowrap; text-align: center; }
.v2-table-requisicion-items .v2-col-obs { min-width: 120px; max-width: 260px; white-space: normal; word-break: break-word; }
.v2-table-requisicion-items .v2-col-actions { min-width: 200px; width: 200px; white-space: nowrap; text-align: center; }
.v2-table-requisicion-items .v2-table-actions-wrap { display: flex; gap: 8px; justify-content: center; flex-wrap: nowrap; }
.v2-table-requisicion-items .v2-table-actions-wrap .btn,
.v2-table-requisicion-items .v2-table-actions-wrap .v2-btn { padding: 4px 10px; font-size: 0.8rem; }

/* === .table-v2 — Alias (usado por templates migrados en paso anterior) === */
.table-v2 {
  width: 100%; border-collapse: collapse; font-size: var(--v2-font-size-sm);
  background: var(--v2-bg); border: 1px solid var(--v2-border); border-radius: var(--v2-radius-md);
  overflow: hidden;
}
.table-v2 th, .table-v2 td {
  padding: 12px 14px; border-bottom: 1px solid var(--v2-border);
  border-right: 1px solid var(--v2-border); text-align: left;
}
.table-v2 th:last-child, .table-v2 td:last-child { border-right: none; }
.table-v2 thead th {
  background: var(--sigma-surface-section, var(--sigma-surface-base, var(--v2-bg-subtle)));
  color: var(--sigma-text-primary, var(--v2-text));
  font-weight: 600;
}
.table-v2 tbody tr:nth-child(even) { background: var(--v2-bg-subtle); }
.table-v2 tbody tr:hover { background: var(--v2-primary-light); }
.v2-flete-create-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-bottom: 12px; }
.v2-list-compact { margin: 0; padding-left: 1.25rem; font-size: 13px; line-height: 1.5; }
.v2-list-summary { margin: 0; padding-left: 1.2rem; font-size: 14px; line-height: 1.6; }
.v2-list-small { font-size: 13px; }
.v2-panel--import-hint { margin-bottom: 20px; padding: 14px 16px; border-radius: 8px; border: 1px solid #e2e8f0; background: #f8fafc; }
.v2-panel--import-resumen { padding: 16px; border-radius: 8px; }
.v2-panel--import-ok { border: 1px solid #bbf7d0; background: #f0fdf4; }
.v2-panel--import-error { border: 1px solid #fecaca; background: #fef2f2; }
.v2-resumen-title { margin: 0 0 12px; font-size: 16px; }
.v2-resumen-subtitle { margin: 12px 0 6px; font-weight: 600; }
.v2-dist-origen-inline { min-width: 12rem; max-width: 18rem; }

/* Table action cells — auto-center when containing btns */
.v2-table td:has(.v2-btn),
.v2-table td:has(.acciones-botones) {
  white-space: nowrap; text-align: center !important; vertical-align: middle !important; padding: 8px 4px !important;
}

/* =============================================
   DataTableV2 (Motor Informes v1 — solo skin)
   ============================================= */
