/* ── Smart Data Table v6.4 — Subgrid + acciones adaptativas ── */

.sdt-viewport {
  width: 100%;
  min-width: 0;
  overflow-x: hidden;
}

.sdt--table { display: block; width: 100%; min-width: 0; }
.sdt--cards { display: none; }

.sdt-table {
  display: grid;
  grid-template-columns: var(--sdt-grid-template);
  width: 100%;
  min-width: 0;
  max-width: 100%;
  font-size: 14px;
}

.sdt-thead,
.sdt-tbody {
  display: grid;
  grid-template-columns: subgrid;
  grid-column: 1 / -1;
}

/* Fila = subgrid alineado con el encabezado */
.sdt-tr {
  display: grid;
  grid-template-columns: subgrid;
  grid-column: 1 / -1;
  align-items: center;
  width: 100%;
  min-width: 0;
  min-height: 48px;
  border-bottom: 1px solid var(--admin-border);
  background: #fff;
  transition: background 0.1s ease;
}

.sdt-tr:hover {
  background: oklch(98.5% 0.003 250);
}

.sdt-tr--head {
  min-height: 40px;
  background: oklch(98% 0.003 250);
}

.sdt-tr--head:hover {
  background: oklch(98% 0.003 250);
}

.sdt-thead {
  position: sticky;
  top: 0;
  z-index: 3;
}

/* Celdas base */
.sdt-td {
  padding: 8px 10px;
  min-width: 0;
  box-sizing: border-box;
}

.sdt-td--check {
  display: flex;
  align-items: center;
  justify-content: center;
  padding-left: 12px;
  padding-right: 4px;
}

.sdt-td--flex,
.sdt-td--shrink {
  min-width: 0;
  max-width: none;
}

/* Acciones — columna final del grid */
.sdt-td--actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding-right: 8px;
  padding-left: 4px;
  overflow: hidden;
  background: inherit;
}

.sdt-td--spacer {
  padding: 0;
  min-width: 0;
}

/* Encabezados */
.sdt-td--head {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: oklch(50% 0.01 250);
}

.sdt-td--head[data-crud-sort] {
  cursor: pointer;
  user-select: none;
}

.sdt-td--head[data-crud-sort]:hover {
  color: oklch(30% 0.015 250);
}

.sdt-td--align-right { text-align: right; }
.sdt-td--align-center { text-align: center; }

.sdt-head__label {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sdt-head__label--sr {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Texto */
.sdt-td__text {
  display: block;
  min-width: 0;
}

.sdt-td__text--clip {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sdt-td__text--mono {
  font-family: ui-monospace, 'JetBrains Mono', Menlo, monospace;
  font-size: 13px;
  letter-spacing: 0.01em;
}

.sdt-td--sku .sdt-td__text,
.sdt-td--code .sdt-td__text,
.sdt-td--phone .sdt-td__text,
.sdt-td--money .sdt-td__text,
.sdt-td--date .sdt-td__text,
.sdt-td--quantity .sdt-td__text,
.sdt-td--number .sdt-td__text {
  word-break: keep-all;
  overflow-wrap: normal;
}

.sdt-td__rich {
  min-width: 0;
  overflow: hidden;
}

.sdt-td__rich .admin-product-cell {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  width: 100%;
}

.sdt-td__rich .admin-product-cell__thumb {
  width: 36px;
  height: 36px;
  border-radius: 6px;
  object-fit: cover;
  flex-shrink: 0;
  background: oklch(96% 0.004 80);
}

.sdt-td__rich .admin-product-cell > div {
  min-width: 0;
  flex: 1;
}

.sdt-td__rich .admin-product-cell strong {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 14px;
}

.sdt-td__rich .admin-cell-muted {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12px;
}

.sdt-td__rich .admin-badge {
  display: inline-flex;
  max-width: none;
  white-space: nowrap;
  flex-shrink: 0;
}

.sdt-td--status.sdt-td--align-center .sdt-td__rich,
.sdt-td--badge.sdt-td--align-center .sdt-td__rich {
  display: flex;
  justify-content: center;
}

/* Estado vacío */
.sdt-tr--empty {
  display: grid;
  grid-column: 1 / -1;
  grid-template-columns: 1fr;
  border-bottom: 0;
}

.sdt-td--empty {
  grid-column: 1 / -1;
  padding: 32px 20px;
  text-align: center;
}

/* Botones de acción visibles */
.sdt-row-actions {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: flex-end;
  gap: 4px;
  flex-wrap: nowrap;
  flex-shrink: 0;
  width: 100%;
  min-width: 0;
}

.sdt-row-actions__inline {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  gap: 4px;
  flex-wrap: nowrap;
  min-width: 0;
}

.sdt-row-actions__inline[hidden] {
  display: none !important;
}

.sdt-row-actions--menu .sdt-actions {
  display: inline-flex;
}

[data-sdt-actions-overflow][hidden] {
  display: none !important;
}

.sdt-act {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 5px 10px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.02em;
  line-height: 1.2;
  white-space: nowrap;
  border: 1px solid var(--admin-border);
  background: #fff;
  color: oklch(25% 0.015 250);
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s, color 0.12s;
  flex-shrink: 0;
}

.sdt-act--icon {
  width: 30px;
  height: 30px;
  padding: 0;
  border-radius: 7px;
}

.sdt-act__icon {
  width: 16px;
  height: 16px;
  display: block;
  flex-shrink: 0;
}

.sdt-row-actions--icons .sdt-row-actions__inline {
  gap: 3px;
}

.sdt-act:hover {
  background: oklch(97% 0.004 250);
}

.sdt-act--edit {
  border-color: oklch(88% 0.02 250);
}

.sdt-act--view {
  border-color: oklch(88% 0.02 250);
  color: oklch(38% 0.04 250);
}

.sdt-act--status {
  border-color: oklch(86% 0.04 230);
  color: oklch(38% 0.06 230);
}

.sdt-act--status:hover {
  background: oklch(97% 0.02 230);
}

.sdt-act--cancel {
  color: var(--admin-danger, oklch(48% 0.14 25));
  border-color: oklch(88% 0.06 25);
}

.sdt-act--cancel:hover:not(:disabled) {
  background: oklch(97% 0.02 25);
}

.sdt-act--delete {
  color: var(--admin-danger, oklch(48% 0.14 25));
  border-color: oklch(88% 0.06 25);
}

.sdt-act--delete:hover {
  background: oklch(97% 0.02 25);
}

.sdt-act--disabled,
.sdt-act:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  pointer-events: none;
}

.sdt-menu__item--disabled,
.sdt-menu__item:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.sdt-actions {
  position: relative;
  display: inline-flex;
  flex-shrink: 0;
}

.sdt-actions__btn {
  width: 32px;
  height: 32px;
  border: 1px solid transparent;
  border-radius: 7px;
  background: transparent;
  color: oklch(40% 0.01 250);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: background 0.12s, border-color 0.12s;
}

.sdt-actions__btn:hover,
.sdt-actions__btn[aria-expanded="true"] {
  background: oklch(96% 0.004 250);
  border-color: var(--admin-border);
}

.sdt-actions__menu {
  position: absolute;
  top: calc(100% + 4px);
  right: 0;
  z-index: 500;
  min-width: 168px;
  padding: 6px;
  background: #fff;
  border: 1px solid var(--admin-border);
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.12);
}

.sdt-actions__menu[hidden] { display: none !important; }

.sdt-menu__item {
  display: flex;
  align-items: center;
  width: 100%;
  padding: 8px 12px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  font-size: 13px;
  font-weight: 500;
  color: oklch(25% 0.015 250);
  text-align: left;
  cursor: pointer;
}

.sdt-menu__item:hover {
  background: oklch(97% 0.004 250);
}

.sdt-menu__item--danger {
  color: var(--admin-danger, oklch(48% 0.14 25));
}

.sdt-menu__item--danger:hover {
  background: oklch(97% 0.02 25);
}

.sdt-empty {
  padding: 32px 20px;
  text-align: center;
}

@media (max-width: 1100px) {
  .sdt-td--priority-low {
    visibility: hidden;
    padding-top: 0;
    padding-bottom: 0;
    overflow: hidden;
    pointer-events: none;
  }

  .sdt-td--priority-low > * {
    display: none;
  }
}

@media (max-width: 767px) {
  .sdt--table { display: none; }
  .sdt--cards { display: block; }

  .sdt-card {
    background: #fff;
    border: 1px solid var(--admin-border);
    border-radius: 12px;
    padding: 14px 16px;
    margin-bottom: 10px;
  }

  .sdt-card__head {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    margin-bottom: 12px;
    flex-wrap: wrap;
  }

  .sdt-card__head .sdt-row-actions {
    margin-left: auto;
  }

  .sdt-card__check { flex-shrink: 0; padding-top: 2px; }

  .sdt-card__title {
    flex: 1;
    min-width: 0;
    font-size: 15px;
    font-weight: 600;
    margin: 0;
    line-height: 1.3;
  }

  .sdt-card__body {
    display: grid;
    gap: 8px;
  }

  .sdt-card__field {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
    font-size: 13px;
  }

  .sdt-card__label {
    color: oklch(50% 0.01 250);
    flex-shrink: 0;
  }

  .sdt-card__value {
    text-align: right;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
  }
}

@media (prefers-reduced-motion: reduce) {
  .sdt-tr,
  .sdt-actions__btn,
  .sdt-menu__item { transition: none; }
}
