/* ════════════════════════════════════════════════════════════════════
   PEUNEX — Listados de Clientes y Proveedores.
   Aditivo a panel-pages.css: reutiliza .page-head, .kpi-row/.kpi-tile,
   .btn-act y .status-pill. Sólo se agrega lo que falta para el formato
   de tabla compacta y su versión en tarjetas para celular.
   Colores: exclusivamente los tokens existentes (--primary,
   --primary-light, --surface, --surface-hover, --border, --text,
   --text-muted, --success, --danger, --warning); las mezclas usan
   color-mix(in srgb, … N%, transparent) o con --surface/--border.
   Responsive: 360, 768, 1024 y 1440 px. Sin scroll horizontal ≥1024 px.
   ════════════════════════════════════════════════════════════════════ */

/* ── Encabezado y KPIs ────────────────────────────────────────────── */
.list-page-head {
  margin-bottom: 1rem;
}

.list-kpis {
  margin-bottom: 1rem;
}

/* El KPI enlazado (Compras) conserva el aspecto de tarjeta. */
a.kpi-tile--link {
  color: inherit;
  text-decoration: none;
}

a.kpi-tile--link:hover {
  border-color: color-mix(in srgb, var(--primary) 45%, var(--border));
}

a.kpi-tile--link:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

/* ── Botón secundario dentro de .page-head__actions ───────────────── */
.btn-act--quiet {
  border-color: var(--border);
  background-color: var(--surface);
  color: var(--text-muted);
}

.btn-act--quiet:hover {
  border-color: color-mix(in srgb, var(--primary) 40%, var(--border));
  background-color: var(--surface-hover);
  color: var(--text);
}

/* ── Barra de filtros ─────────────────────────────────────────────── */
.list-filters-card {
  padding: .85rem 1rem;
  margin-bottom: 1rem;
}

.list-filters {
  display: grid;
  grid-template-columns: minmax(14rem, 2.2fr) repeat(3, minmax(8rem, 1fr)) auto;
  gap: .625rem;
  align-items: end;
  min-width: 0;
}

.list-filters--single {
  grid-template-columns: minmax(0, 1fr) auto;
}

.list-filters__field {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.list-filters__field .form-label {
  margin-bottom: .25rem;
  color: var(--text-muted);
  font-size: .72rem;
  font-weight: 650;
  letter-spacing: .02em;
}

.list-filters__field .form-input {
  width: 100%;
  min-width: 0;
  height: 2.4rem;
  padding: .4rem .65rem;
  font-size: .8125rem;
}

.list-search {
  position: relative;
  min-width: 0;
}

.list-search > .bi {
  position: absolute;
  top: 50%;
  left: .65rem;
  transform: translateY(-50%);
  color: var(--text-muted);
  font-size: .8125rem;
  pointer-events: none;
}

.list-search .form-input {
  padding-left: 2rem;
}

.list-filters__actions {
  display: flex;
  align-items: center;
  gap: .375rem;
}

.list-filters__actions .btn-act {
  white-space: nowrap;
}

/* ── Cabecera de la tarjeta con el listado ────────────────────────── */
.list-card-head {
  flex-wrap: wrap;
  gap: .5rem .75rem;
  margin-bottom: 0;
  padding: .7rem .9rem;
  border-bottom: 1px solid var(--border);
  background: var(--surface-hover);
}

.list-card-heading {
  display: flex;
  align-items: center;
  gap: .55rem;
  min-width: 0;
}

.list-card-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  width: 2rem;
  height: 2rem;
  border-radius: .5rem;
  background: var(--primary-light);
  color: var(--primary);
  font-size: .95rem;
  line-height: 1;
}

.list-card-title {
  margin: 0;
  color: var(--text);
  font-size: .95rem;
  font-weight: 650;
  line-height: 1.25;
}

.list-card-count {
  color: var(--text-muted);
  font-size: .78rem;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* ── Tabla compacta ───────────────────────────────────────────────── */
.list-table {
  width: 100%;
  min-width: 0;
  table-layout: fixed;
  font-size: .8rem;
}

.list-table th,
.list-table td {
  box-sizing: border-box;
}

.list-table thead th {
  padding: .5rem .55rem;
  font-size: .66rem;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.list-table tbody td {
  height: 3rem;
  padding: .4rem .55rem;
  vertical-align: middle;
}

.list-table .list-col--avatar {
  width: 5%;
}

.list-table--clientes .list-col--name {
  width: 24%;
}

.list-table--clientes .list-col--doc {
  width: 11%;
}

.list-table--clientes .list-col--phone {
  width: 10%;
}

.list-table--clientes .list-col--email {
  width: 14%;
}

.list-table--clientes .list-col--meta {
  width: 10%;
}

.list-table--clientes .list-col--amount {
  width: 8%;
}

.list-table--clientes .list-col--actions {
  width: 18%;
}

.list-table--proveedores .list-col--name {
  width: 26%;
}

.list-table--proveedores .list-col--doc {
  width: 11%;
}

.list-table--proveedores .list-col--phone {
  width: 12%;
}

.list-table--proveedores .list-col--email {
  width: 20%;
}

.list-table--proveedores .list-col--meta {
  width: 12%;
}

.list-table--proveedores .list-col--status {
  width: 9%;
}

.list-table--proveedores .list-col--actions {
  width: 10%;
}

.list-table .list-col--amount,
.list-table .list-col--actions {
  text-align: right;
}

.list-table .status-pill {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ── Celdas: avatar, nombre y valores recortados ──────────────────── */
.list-avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  border-radius: 50%;
  color: #fff;
  font-size: .6875rem;
  font-weight: 700;
  line-height: 1;
  text-transform: uppercase;
  flex: 0 0 auto;
  user-select: none;
}

.list-name {
  display: flex;
  align-items: center;
  gap: .35rem;
  min-width: 0;
}

.list-name__text {
  min-width: 0;
  overflow: hidden;
  color: var(--text);
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.list-name__flag {
  flex: 0 0 auto;
  padding: .05rem .35rem;
  font-size: .62rem;
  line-height: 1.4;
}

.list-ellipsis {
  display: block;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.list-cell--doc .list-ellipsis {
  font-variant-numeric: tabular-nums;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.list-cell--email,
.list-cell--phone,
.list-cell--meta {
  color: var(--text-muted);
}

.list-amount {
  font-variant-numeric: tabular-nums;
  font-weight: 650;
  white-space: nowrap;
}

.list-amount--debt {
  color: var(--danger);
}

.list-amount--credit {
  color: var(--success);
}

.list-muted {
  color: var(--text-muted);
}

/* ── Acciones compactas: una sola fila, iconos neutros ────────────── */
.row-actions {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  justify-content: flex-end;
  gap: .2rem;
  min-width: 0;
}

.row-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  box-sizing: border-box;
  width: 2.1rem;
  height: 2.1rem;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: .55rem;
  background: var(--surface);
  color: var(--text-muted);
  font-size: .95rem;
  line-height: 1;
  text-decoration: none;
  transition: background-color .16s ease, border-color .16s ease, color .16s ease;
}

/* Ver / editar / nueva venta → color primario al interactuar. */
.row-action--view:hover,
.row-action--view:focus-visible,
.row-action--edit:hover,
.row-action--edit:focus-visible,
.row-action--sale:hover,
.row-action--sale:focus-visible {
  border-color: color-mix(in srgb, var(--primary) 45%, var(--border));
  background: color-mix(in srgb, var(--primary) 10%, var(--surface));
  color: var(--primary);
}

/* WhatsApp → verde de éxito. */
.row-action--wa:hover,
.row-action--wa:focus-visible {
  border-color: color-mix(in srgb, var(--success) 45%, var(--border));
  background: color-mix(in srgb, var(--success) 10%, var(--surface));
  color: var(--success);
}

/* Nueva reparación → ámbar de advertencia. */
.row-action--repair:hover,
.row-action--repair:focus-visible {
  border-color: color-mix(in srgb, var(--warning) 45%, var(--border));
  background: color-mix(in srgb, var(--warning) 10%, var(--surface));
  color: var(--warning);
}

.row-action:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

/* ── Tablet / escritorio angosto: la tabla sigue siendo tabla ─────── */
@media (max-width: 900px) {
  .list-filters {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .list-filters__field--search,
  .list-filters__actions {
    grid-column: 1 / -1;
  }
}

@media (max-width: 1023.98px) {
  /* Entre 700 y 1023 px la tabla conserva columnas legibles y permite
     desplazamiento horizontal; en ≥1024 px se ajusta sin scroll. */
  .list-table-wrap .list-table {
    min-width: 1000px;
  }
}

@media (min-width: 1024px) {
  /* La tabla se ajusta al ancho disponible: nada de scroll horizontal. */
  .list-table-wrap {
    overflow-x: visible;
  }

  .list-table {
    min-width: 0;
  }
}

/* ── Celular: cada fila se convierte en tarjeta apilada ───────────── */
@media (max-width: 699.98px) {
  .list-filters {
    grid-template-columns: minmax(0, 1fr);
  }

  .list-filters__field--search,
  .list-filters__actions {
    grid-column: 1 / -1;
  }

  .list-filters__actions {
    flex-wrap: wrap;
  }

  .list-filters__actions .btn-act {
    flex: 1 1 auto;
  }

  .list-card-head {
    padding: .65rem .75rem;
  }

  .list-table-wrap {
    overflow: visible;
    padding: .75rem;
  }

  .list-table-wrap .list-table,
  .list-table {
    display: block;
    width: 100%;
    min-width: 0;
  }

  .list-table thead {
    display: none;
  }

  .list-table tbody {
    display: block;
  }

  .list-table tbody tr.list-row {
    display: grid;
    grid-template-columns: 2.25rem minmax(0, 1fr) minmax(0, 1fr) auto;
    column-gap: .6rem;
    row-gap: .35rem;
    margin-bottom: .6rem;
    padding: .7rem .8rem;
    border: 1px solid var(--border);
    border-radius: .8rem;
    background: var(--surface);
  }

  .list-table tbody tr.list-row:last-child {
    margin-bottom: 0;
  }

  .list-table tbody tr.list-row:hover {
    background: var(--surface-hover);
  }

  .list-table tbody td {
    display: block;
    height: auto;
    padding: 0;
    border: 0;
  }

  .list-table--clientes .list-cell--avatar {
    grid-area: 1 / 1;
    align-self: center;
  }

  .list-table--clientes .list-cell--name {
    grid-area: 1 / 2 / 2 / 4;
    min-width: 0;
  }

  .list-table--clientes .list-cell--status {
    grid-area: 1 / 4;
    align-self: center;
    justify-self: end;
  }

  .list-table--clientes .list-cell--doc {
    grid-area: 2 / 2;
  }

  .list-table--clientes .list-cell--phone {
    grid-area: 2 / 3;
  }

  .list-table--clientes .list-cell--email {
    grid-area: 3 / 2;
  }

  .list-table--clientes .list-cell--meta {
    grid-area: 3 / 3;
  }

  .list-table--clientes .list-cell--amount {
    grid-area: 4 / 2 / 5 / 4;
  }

  .list-table--clientes .list-cell--actions {
    grid-area: 5 / 1 / 6 / -1;
    margin-top: .15rem;
    padding-top: .55rem;
    border-top: 1px solid var(--border);
  }

  /* Proveedores: sin avatar, la tarjeta usa 3 columnas. */
  .list-table--proveedores tbody tr.list-row {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto;
  }

  .list-table--proveedores .list-cell--name {
    grid-area: 1 / 1 / 2 / 3;
    min-width: 0;
  }

  .list-table--proveedores .list-cell--status {
    grid-area: 1 / 3;
    align-self: center;
    justify-self: end;
  }

  .list-table--proveedores .list-cell--doc {
    grid-area: 2 / 1;
  }

  .list-table--proveedores .list-cell--phone {
    grid-area: 2 / 2;
  }

  .list-table--proveedores .list-cell--email {
    grid-area: 3 / 1;
  }

  .list-table--proveedores .list-cell--meta {
    grid-area: 3 / 2;
  }

  .list-table--proveedores .list-cell--actions {
    grid-area: 4 / 1 / 5 / -1;
    margin-top: .15rem;
    padding-top: .55rem;
    border-top: 1px solid var(--border);
  }

  /* Pares «etiqueta: valor» en las celdas con data-label. */
  .list-table tbody td[data-label] {
    display: flex;
    align-items: baseline;
    gap: .3rem;
    min-width: 0;
  }

  .list-table tbody td[data-label]::before {
    content: attr(data-label) ":";
    flex: 0 0 auto;
    color: var(--text-muted);
    font-size: .66rem;
    font-weight: 650;
    line-height: 1.3;
  }

  .list-table tbody td[data-label] .list-ellipsis,
  .list-table tbody td[data-label] .list-amount {
    min-width: 0;
    font-size: .76rem;
  }

  .list-table .list-name__text {
    font-size: .86rem;
  }

  .list-table .row-actions {
    justify-content: flex-end;
  }

  .list-table tbody tr.list-row--empty {
    display: block;
    padding: 0;
    border: 1px solid var(--border);
    border-radius: .8rem;
  }

  .list-table tbody tr.list-row--empty td {
    display: block;
    padding: 0;
  }
}

/* En pantallas muy angostas (360 px) la etiqueta va sobre el valor
   para que el dato conserve ancho útil. */
@media (max-width: 399.98px) {
  .list-table tbody td[data-label] {
    display: block;
  }

  .list-table tbody td[data-label]::before {
    display: block;
    margin-bottom: .05rem;
  }
}

/* Área táctil de 2.75rem en dispositivos de puntero grueso. */
@media (pointer: coarse) {
  .row-action {
    width: 2.75rem;
    height: 2.75rem;
  }

  .list-table--clientes .list-col--name {
    width: 17%;
  }

  .list-table--clientes .list-col--doc {
    width: 8%;
  }

  .list-table--clientes .list-col--phone {
    width: 9%;
  }

  .list-table--clientes .list-col--email {
    width: 10%;
  }

  .list-table--clientes .list-col--meta {
    width: 8%;
  }

  .list-table--clientes .list-col--amount {
    width: 8%;
  }

  .list-table--clientes .list-col--actions {
    width: 27%;
  }

  .list-table--proveedores .list-col--name {
    width: 24%;
  }

  .list-table--proveedores .list-col--doc {
    width: 10.5%;
  }

  .list-table--proveedores .list-col--phone {
    width: 11.5%;
  }

  .list-table--proveedores .list-col--email {
    width: 19%;
  }

  .list-table--proveedores .list-col--meta {
    width: 11%;
  }

  .list-table--proveedores .list-col--actions {
    width: 15%;
  }
}

@media (prefers-reduced-motion: reduce) {
  .row-action,
  a.kpi-tile--link {
    transition: none;
  }
}

/* Ajustes tras la revisión: valores completos en las tarjetas móviles y CUIT sin recortar en escritorio */
@media (max-width: 699.98px) {
  .list-table tbody td[data-label] .list-ellipsis {
    white-space: normal;
    overflow: visible;
    text-overflow: clip;
    overflow-wrap: anywhere;
  }
}

@media (min-width: 700px) {
  .list-table--clientes .list-cell--doc {
    min-width: 7.8rem;
  }
}


/* ── Filtros compactos y no fijos (Ventas, Presupuestos, Compras, Clientes, Proveedores, Reparaciones) ── */
.uix-sticky-filters,
.list-filters-card,
.rep-filter-card {
  position: static !important;
  top: auto !important;
}

.list-filters-card,
.rep-filter-card {
  padding: .5rem .7rem;
  margin-bottom: .6rem;
}

.list-filters,
.list-filters--docs,
.rep-filter-grid {
  gap: .4rem .6rem;
}

.list-filters__field .form-label,
.rep-field .form-label {
  margin-bottom: .1rem;
  font-size: .62rem;
  font-weight: 650;
  letter-spacing: .02em;
}

.list-filters .form-input,
.list-filters select,
.list-filters input[type="date"],
.rep-filter-grid .form-input,
.rep-filter-grid select,
.rep-filter-grid input[type="date"] {
  min-height: 2rem;
  height: 2rem;
  padding: .2rem .5rem;
  font-size: .8rem;
}

.list-filters .list-search .form-input {
  padding-left: 2rem;
}

.list-filters .btn-act,
.list-filters .btn-primary,
.list-filters .btn-secondary,
.rep-filter-actions .btn-act {
  min-height: 2rem;
  height: 2rem;
  padding: 0 .75rem;
  font-size: .78rem;
}

/* El texto aclaratorio largo se muestra solo como ayuda del selector, no ocupa una fila */
.list-filters__hint {
  display: none;
}

/* Chips de estado de reparaciones: una sola fila baja */
.rep-state-filters {
  gap: .3rem;
  margin-top: .45rem;
  padding-top: .45rem;
}

/* Barra de filtros en una sola línea (Ventas/Presupuestos/Compras) */
.list-filters--docs {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
}
.list-filters--docs .list-filters__field { flex: 0 1 9.5rem; min-width: 8rem; }
.list-filters--docs .list-filters__field--search { flex: 1 1 14rem; }
.list-filters--docs .list-filters__actions { flex: 0 0 auto; margin-left: auto; }
.list-tabs__action { margin-left: auto; }
.list-filters-card .list-filters-card__body { padding: 0; }
.list-filters-card.p-0 { padding: .5rem .7rem !important; }
.list-filters--docs .list-filters__field { flex-basis: 7.5rem; min-width: 6.5rem; }
.list-filters--docs .list-filters__field--search { flex-basis: 11rem; }
.uix-sticky-filters,
[data-theme="dark"] .uix-sticky-filters {
  background: transparent !important;
  padding: 0 !important;
  margin-bottom: .6rem;
}

/* Clientes: el saldo no debe pisar los íconos de acciones */
@media (min-width: 1024px) {
  .list-table--clientes .list-col--amount { width: 9%; }
  .list-table--clientes .list-col--actions { width: 17%; }
  .list-table--clientes th.list-col--amount,
  .list-table--clientes td.list-cell--amount { text-align: center; padding-right: 1rem; padding-left: .5rem; }
  .list-table--clientes td.list-cell--actions { padding-left: 1rem; }
}
