/* hotfix17 + hotfix17.5: 와이드 테이블 반응형 — 단계별 컬럼 숨김 + 카드 모드.
 *
 *  컬럼 우선순위 (절대 노출):
 *    이름 (.col-name) · 상태 (.col-status) · 관리 (.col-actions)
 *
 *  숨김 단계 (좁아질수록):
 *    < 1280px : 담당 학생, 근무 시작
 *    < 1100px : 연락처, 예상 퇴직금
 *    <  980px : 급여
 *    <  860px : 역할
 *    <  720px : 테이블 → 카드 모드 (thead 숨김, tr 카드 그리드)
 *
 *  hotfix17 잘못잡힌 룰 교정: 이름이 압축돼 잘리는 문제 → 이름은 어떤 단계에서도 절대 숨기지 않음.
 *  역할은 마지막 단계에서만 숨김.
 *
 *  ⋯ expand row: 숨겨진 컬럼이 1개 이상이면 토글 노출. 카드 모드에선 토글 숨김 (정보가 카드 안에 다 노출).
 *  가로 스크롤: ::-webkit-scrollbar 항상 노출 (드래그 안 해도 사용자 인지 가능).
 */

/* ─────────── ⋯ 토글 버튼 ─────────── */
.staff-table .col-detail-toggle {
  width: 32px;
  text-align: center;
  padding: 0 4px;
}
.staff-table .row-expand-toggle {
  display: none;          /* 기본 (와이드) 숨김 */
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  padding: 0;
  background: transparent;
  border: 1px solid var(--border, #E5E7EB);
  border-radius: 4px;
  cursor: pointer;
  color: var(--fg-secondary, #6B7280);
  font-size: 14px;
  font-family: inherit;
  transition: background 0.12s ease, border-color 0.12s ease;
}
.staff-table .row-expand-toggle:hover {
  background: var(--color-bg-subtle, #F9FAFB);
  border-color: var(--accent, #0D9488);
  color: var(--accent, #0D9488);
}
.staff-table .row-expand-toggle.is-open {
  background: var(--color-bg-brand-subtle, #E3F3F3);
  border-color: var(--accent, #0D9488);
  color: var(--accent, #0D9488);
}

/* ─────────── expand-row 그리드 ─────────── */
.staff-table tr.staff-row-detail > td {
  padding: 12px 16px 16px;
  background: var(--color-bg-subtle, #F9FAFB);
  border-top: 1px dashed var(--border, #E5E7EB);
}
.staff-table .row-detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 8px 24px;
}
.staff-table .row-detail-grid .rd-pair {
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-size: 12.5px;
}
.staff-table .row-detail-grid .rd-label {
  font-size: 11px;
  color: var(--fg-muted, #6B7280);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.staff-table .row-detail-grid .rd-value {
  color: var(--fg-primary, #1F2937);
  font-variant-numeric: tabular-nums;
}
/* 와이드: expand-row 자체 숨김 (이미 컬럼으로 다 보임) */
.staff-table tr.staff-row-detail { display: none; }
/* expand-row 의 detail pair — 와이드에선 모두 숨김 */
.staff-table .row-detail-grid .rd-pair { display: none; }

/* ─────────── 가로 스크롤바 항상 노출 ─────────── */
.staff-table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;                                /* Firefox */
  scrollbar-color: rgba(100, 116, 139, 0.5) transparent;
}
.staff-table-wrap::-webkit-scrollbar {
  height: 8px;
  -webkit-appearance: none;
}
.staff-table-wrap::-webkit-scrollbar-thumb {
  background: rgba(100, 116, 139, 0.5);
  border-radius: 4px;
}
.staff-table-wrap::-webkit-scrollbar-thumb:hover {
  background: rgba(100, 116, 139, 0.7);
}
.staff-table-wrap::-webkit-scrollbar-track {
  background: transparent;
}

/* ─────────── 단계 1: < 1280px ─────────── */
@media (max-width: 1279px) {
  .staff-table .col-students,
  .staff-table .col-start-date {
    display: none;
  }
  .staff-table .row-expand-toggle { display: inline-flex; }
  .staff-table tr.staff-row-detail { display: table-row; }
  .staff-table .row-detail-grid .col-students-detail,
  .staff-table .row-detail-grid .col-start-date-detail {
    display: flex;
  }
}

/* ─────────── 단계 2: < 1100px ─────────── */
@media (max-width: 1099px) {
  .staff-table .col-phone,
  .staff-table .col-retirement-pay {
    display: none;
  }
  .staff-table .row-detail-grid .col-phone-detail,
  .staff-table .row-detail-grid .col-retirement-pay-detail {
    display: flex;
  }
}

/* ─────────── 단계 3: < 980px ─────────── */
@media (max-width: 979px) {
  .staff-table .col-salary {
    display: none;
  }
  .staff-table .row-detail-grid .col-salary-detail {
    display: flex;
  }
}

/* ─────────── 단계 4: < 860px ─────────── */
@media (max-width: 859px) {
  .staff-table .col-role {
    display: none;
  }
  .staff-table .row-detail-grid .col-role-detail {
    display: flex;
  }
}

/* ─────────── 단계 5: < 720px — 카드 모드 ─────────── */
@media (max-width: 719px) {
  /* 가로 스크롤 비활성 */
  .staff-table-wrap { overflow-x: visible; }
  /* 테이블 → 카드 그리드 변환 */
  .staff-table {
    min-width: 0 !important;
    width: 100%;
    border: 0;
  }
  .staff-table thead { display: none; }
  .staff-table tbody { display: flex; flex-direction: column; gap: 12px; }
  .staff-table tr.staff-row {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 4px 10px;
    align-items: center;
    padding: 14px 16px;
    border: 1px solid var(--border, #E5E7EB);
    border-radius: 12px;
    background: #fff;
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
  }
  .staff-table tr.staff-row > td {
    display: block;
    border: 0;
    padding: 0;
    line-height: 1.5;
  }
  /* 카드 헤더 — 이름 (좌상) + 상태 (우상) */
  .staff-table tr.staff-row > td.col-name {
    grid-column: 1;
    grid-row: 1;
    font-size: 15px;
    font-weight: 700;
  }
  .staff-table tr.staff-row > td.col-status {
    grid-column: 2;
    grid-row: 1;
    text-align: right;
  }
  /* 카드 본문 — 역할/연락처/담당/근무시작/급여/예상 퇴직금 inline 라벨 */
  .staff-table tr.staff-row > td.col-role,
  .staff-table tr.staff-row > td.col-phone,
  .staff-table tr.staff-row > td.col-students,
  .staff-table tr.staff-row > td.col-start-date,
  .staff-table tr.staff-row > td.col-salary,
  .staff-table tr.staff-row > td.col-retirement-pay {
    grid-column: 1 / -1;
    display: flex !important;
    gap: 6px;
    font-size: 12.5px;
    color: var(--fg-secondary, #374151);
  }
  .staff-table tr.staff-row > td.col-role::before     { content: '역할 '; color: var(--fg-muted, #6B7280); font-weight: 600; min-width: 64px; }
  .staff-table tr.staff-row > td.col-phone::before    { content: '연락처 '; color: var(--fg-muted, #6B7280); font-weight: 600; min-width: 64px; }
  .staff-table tr.staff-row > td.col-students::before { content: '담당 학생 '; color: var(--fg-muted, #6B7280); font-weight: 600; min-width: 64px; }
  .staff-table tr.staff-row > td.col-start-date::before { content: '근무 시작 '; color: var(--fg-muted, #6B7280); font-weight: 600; min-width: 64px; }
  .staff-table tr.staff-row > td.col-salary::before   { content: '급여 '; color: var(--fg-muted, #6B7280); font-weight: 600; min-width: 64px; }
  .staff-table tr.staff-row > td.col-retirement-pay::before { content: '예상 퇴직금 '; color: var(--fg-muted, #6B7280); font-weight: 600; min-width: 64px; }
  /* 카드 푸터 — 액션 우측 정렬 */
  .staff-table tr.staff-row > td.col-actions {
    grid-column: 1 / -1;
    grid-row: auto;
    text-align: right;
    margin-top: 6px;
    border-top: 1px dashed var(--border, #E5E7EB);
    padding-top: 8px !important;
  }
  /* 카드 모드 — ⋯ 토글 / expand row 모두 숨김 (정보가 카드 안에 다 들어있음) */
  .staff-table tr.staff-row > td.col-detail-toggle { display: none !important; }
  .staff-table tr.staff-row-detail { display: none !important; }
}
