/* ── Core Table — ARKAN UI core (design_handoff_arkan_ui/COMPONENTS.md #1) ──
   Scoped under .core-table*. Does not touch the legacy .table/.table-wrap
   classes used elsewhere in the portal — additive only, new screens opt in. */

.core-table-wrap {
  position: relative;
  width: 100%;
  overflow-x: auto;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-default);
  background: var(--surface-primary);
}

.core-table {
  width: auto;
  min-width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
}

/* ── Header ── */
.core-table thead {
  background: var(--surface-raised, var(--bg-secondary));
}

.core-table th {
  height: 34px;
  padding: 0 24px;
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border-default);
  white-space: nowrap;
  user-select: none;
}

.core-table__sortable {
  cursor: pointer;
}
.core-table__sortable:hover {
  color: var(--text-primary);
}
.core-table__sortable[aria-sort="ascending"]::after  { content: ' ↑'; opacity: 0.7; }
.core-table__sortable[aria-sort="descending"]::after { content: ' ↓'; opacity: 0.7; }

/* ── Cells ── */
.core-table td {
  height: 44px;
  padding: 0 24px;
  font-size: 13.5px;
  color: var(--text-primary);
  border-bottom: 1px solid var(--border-subtle);
  vertical-align: middle;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.core-table tbody tr:last-child td {
  border-bottom: none;
}

.core-table__cell--right  { text-align: right; }
.core-table__cell--center { text-align: center; }

/* Row-card cell — the whole ticket rendered as one compact card (subject +
   date on top, ticket number/status/priority/company/requester as inline
   badges below) instead of spreading across separate grid columns. Opts out
   of the single-line ellipsis rule above; each inner piece manages its own
   truncation/wrapping. See COLUMNS in pages/tickets.js for why. */
.core-table__cell--row {
  height: auto;
  white-space: normal;
  overflow: visible;
  text-overflow: clip;
  padding-top: 9px;
  padding-bottom: 9px;
}
.core-table__rowcard {
  display: flex;
  flex-direction: column;
  gap: 5px;
  min-width: 0;
}
.core-table__rowcard-top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}
.core-table__rowcard-top .core-table__primary { flex: 1; min-width: 0; }
.core-table__row-date {
  flex-shrink: 0;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-muted);
}
.core-table__rowcard-bottom {
  display: flex;
  align-items: center;
  gap: 7px;
  flex-wrap: wrap;
}
.core-table__meta {
  font-size: 11.5px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}

/* Utility classes for cell content (used inside column render()) */
.core-table__primary {
  font-size: 14px;
  display: block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.core-table__mono {
  font-family: var(--font-mono);
  font-size: 12.5px;
  color: var(--text-secondary);
}

.core-table__dot {
  display: inline-block;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  margin-right: 6px;
  vertical-align: middle;
}
.core-table__dot--status { width: 6px; height: 6px; }

/* ── Row states ── */
.core-table__row {
  cursor: pointer;
  transition: background var(--transition-fast);
}
.core-table__row:hover td {
  background: color-mix(in srgb, var(--accent-primary) 5%, transparent);
}
.core-table__row--selected td {
  background: color-mix(in srgb, var(--accent-primary) 5%, transparent);
}

/* ── Checkbox column ── */
.core-table__check-cell {
  width: 40px;
  text-align: center;
  padding: 0 8px;
}
.core-table__checkbox {
  width: 15px;
  height: 15px;
  border-radius: 4px;
  border: 1.5px solid var(--border-default);
  accent-color: var(--accent-primary);
  cursor: pointer;
}

/* ── Loading skeleton (8 rows, not a spinner) ── */
.core-table__skeleton-bar {
  display: block;
  height: 12px;
  width: 70%;
  border-radius: 4px;
  background: var(--border-subtle);
  animation: core-table-pulse 1.3s ease-in-out infinite;
}
@keyframes core-table-pulse {
  0%, 100% { opacity: 0.5; }
  50%      { opacity: 1; }
}
@media (prefers-reduced-motion: reduce) {
  .core-table__skeleton-bar { animation: none; opacity: 0.7; }
}

/* ── Empty / error states ── */
.core-table__empty,
.core-table__error {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 48px 24px;
  color: var(--text-muted);
  font-size: 13.5px;
  text-align: center;
}
.core-table__empty-icon {
  font-size: 20px;
  color: var(--text-disabled);
}

/* ── Bulk action bar (floats above the table on selection) ── */
.core-table-bulk {
  position: sticky;
  bottom: 64px;
  left: 0;
  right: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  gap: 12px;
  height: 46px;
  padding: 0 16px;
  margin: 12px auto 0;
  width: fit-content;
  border-radius: 11px;
  background: var(--surface-elevated);
  box-shadow: var(--shadow-lg);
  font-size: 13px;
  color: var(--text-primary);
}
.core-table-bulk__count { font-weight: 600; white-space: nowrap; }
.core-table-bulk__sep {
  width: 1px;
  height: 18px;
  background: var(--border-default);
}
.core-table-bulk__action {
  background: transparent;
  border: none;
  color: var(--accent-primary);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  padding: 4px 6px;
  white-space: nowrap;
}
.core-table-bulk__action:hover { color: var(--accent-hover); }
.core-table-bulk__clear {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 13px;
  cursor: pointer;
  padding: 4px 6px;
  white-space: nowrap;
}
.core-table-bulk__clear:hover { color: var(--text-primary); }
