/*
 * KxDataTable 스타일 — Nifty tabulator 계보. 정본 `.kx-table`(screens/shared.css) 위에
 * 툴바(검색·CSV·외부필터)·정렬 헤더 버튼·푸터(페이지 크기·페이저)만 얹는다.
 * 색·간격·폰트는 kx 토큰만 사용(하드코딩 hex 금지) · 다크/라이트 양 테마 · 선 SVG 아이콘.
 */
@import '../screens/shared.css';

.kx-dt {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  /* 자신이 flex/grid 자식일 때 부모 폭 초과로 셸을 밀지 않도록 축소 허용. */
  min-width: 0;
  max-width: 100%;
}

/* ── 툴바(검색 · 외부 필터 · CSV) ── */
.kx-dt__toolbar {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  flex-wrap: wrap;
}
.kx-dt__toolbar-end {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.kx-dt__search {
  position: relative;
  display: inline-flex;
  align-items: center;
  min-width: 200px;
  max-width: 320px;
  flex: 1 1 220px;
}
.kx-dt__search-ic {
  position: absolute;
  left: 10px;
  color: var(--color-neutral-500);
  pointer-events: none;
}
.kx-dt__search-input {
  width: 100%;
  height: 36px;
  padding: 0 var(--space-3) 0 34px;
  border: var(--border-card);
  border-radius: var(--radius-sm);
  background: var(--color-white);
  font-size: var(--fs-body);
  color: var(--color-neutral-900);
}
.kx-dt__search-input::placeholder {
  color: var(--color-neutral-500);
}
.kx-dt__search-input:focus-visible {
  outline: none;
  border-color: var(--color-primary-600);
  box-shadow: 0 0 0 3px var(--color-primary-050);
}

/* CSV 내보내기 버튼(secondary 아웃라인 톤) */
.kx-dt__csv {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 36px;
  padding: 0 var(--space-3);
  border: var(--border-card);
  border-radius: var(--radius-sm);
  background: var(--color-white);
  color: var(--color-neutral-700);
  font-size: var(--fs-body);
  font-weight: var(--fw-semibold);
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
  white-space: nowrap;
}
.kx-dt__csv:hover:not(:disabled) {
  background: var(--color-neutral-050);
  border-color: var(--color-neutral-500);
  color: var(--color-neutral-900);
}
.kx-dt__csv:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
.kx-dt__csv:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px var(--color-primary-050);
}

/* ── 정렬 헤더 버튼 ── */
.kx-dt__sort-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  width: 100%;
  padding: 0;
  border: none;
  background: transparent;
  font: inherit;
  letter-spacing: inherit;
  color: inherit;
  text-align: left;
  cursor: pointer;
}
.kx-dt__sort-btn--num {
  justify-content: flex-end;
}
.kx-dt__sort-btn:hover {
  color: var(--color-primary-700);
}
.kx-dt__sort-btn:focus-visible {
  outline: none;
  color: var(--color-primary-700);
  box-shadow: 0 0 0 3px var(--color-primary-050);
  border-radius: var(--radius-sm);
}
.kx-dt__sort-ic {
  flex: none;
  color: var(--color-neutral-500);
}
/* 방향에 따라 활성 셰브런만 강조(기본은 둘 다 흐리게) */
.kx-dt__sort-btn .kx-sort-up,
.kx-dt__sort-btn .kx-sort-down {
  opacity: 0.32;
  transition: opacity 0.12s ease;
}
.kx-dt__sort-btn[data-dir='asc'] .kx-sort-up,
.kx-dt__sort-btn[data-dir='desc'] .kx-sort-down {
  opacity: 1;
}
.kx-dt__sort-btn[data-dir='asc'] .kx-dt__sort-ic,
.kx-dt__sort-btn[data-dir='desc'] .kx-dt__sort-ic {
  color: var(--color-primary-600);
}

/* 클릭 가능 행 */
.kx-dt__row--click {
  cursor: pointer;
}
.kx-table tbody tr.is-selected {
  background: var(--color-primary-100);
}
.kx-dt__empty-cell {
  padding: 0 !important;
}
.kx-dt__empty-cell:hover {
  background: transparent;
}

/* ── 푸터(건수 · 페이지 크기 · 페이저) ── */
.kx-dt__footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  flex-wrap: wrap;
}
.kx-dt__count {
  font-size: var(--fs-caption);
  color: var(--color-neutral-500);
}
.kx-dt__pager {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  flex-wrap: wrap;
}
.kx-dt__pagesize {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
}
.kx-dt__pagesize-label {
  font-size: var(--fs-caption);
  color: var(--color-neutral-500);
}
.kx-dt__pagesize-select {
  height: 32px;
  padding: 0 var(--space-2);
}
.kx-dt__pagenav {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
}
.kx-dt__page-btn {
  height: 32px;
  padding: 0 var(--space-3);
  border: var(--border-card);
  border-radius: var(--radius-sm);
  background: var(--color-white);
  color: var(--color-neutral-700);
  font-size: var(--fs-caption);
  font-weight: var(--fw-semibold);
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
}
.kx-dt__page-btn:hover:not(:disabled) {
  background: var(--color-neutral-050);
  border-color: var(--color-neutral-500);
}
.kx-dt__page-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}
.kx-dt__page-btn:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px var(--color-primary-050);
}
.kx-dt__pageinfo {
  font-size: var(--fs-caption);
  color: var(--color-neutral-700);
  min-width: 96px;
  text-align: center;
}

@media (max-width: 640px) {
  .kx-dt__toolbar-end {
    margin-left: 0;
  }
  .kx-dt__search {
    max-width: none;
  }
  .kx-dt__footer {
    justify-content: flex-start;
  }
}
