/* ==========================================================
   admin.css — 어드민 페이지 전용 스타일
   Precision Cycling Design System 준수
   네임스페이스: admin- 접두사
   ========================================================== */

/* ==========================================================
   1. 페이지 타이틀
   ========================================================== */
.admin-page-title {
  font: var(--text-display);
  color: var(--color-text-primary);
  margin: 0 0 24px 0;
  letter-spacing: -0.02em;
}

/* ==========================================================
   2. 탭 네비게이션
   ========================================================== */
.admin-tabs {
  display: flex;
  gap: 0;
  border-bottom: 2px solid var(--color-border);
  margin-bottom: 24px;
}

.admin-tab {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 24px;
  border: none;
  background: none;
  font: var(--text-body);
  font-weight: 600;
  color: var(--color-text-secondary);
  cursor: pointer;
  position: relative;
  transition: color 0.15s ease;
}

.admin-tab::after {
  content: '';
  position: absolute;
  bottom: -2px;
  left: 0;
  right: 0;
  height: 2px;
  background: transparent;
  transition: background 0.15s ease;
}

.admin-tab:hover {
  color: var(--color-primary);
}

.admin-tab.active {
  color: var(--color-primary);
}

.admin-tab.active::after {
  background: var(--color-primary);
}

.admin-tab svg {
  flex-shrink: 0;
}

/* ==========================================================
   3. 패널 공통
   ========================================================== */
.admin-panel {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-left: 3px solid var(--color-primary);
  padding: 24px;
  box-shadow: var(--shadow-1);
  margin-bottom: 32px;
}

/* ==========================================================
   4. 검색 바 (회원 관리)
   ========================================================== */
.admin-search-bar {
  display: flex;
  align-items: flex-end;
  gap: 12px;
  margin-bottom: 20px;
}

.admin-search-field {
  flex: 1;
}

.admin-search-label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-text-secondary);
  margin-bottom: 6px;
}

.admin-search-input {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  font: var(--text-body);
  color: var(--color-text-primary);
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.admin-search-input:focus {
  border-color: var(--color-primary);
  box-shadow: inset 0 -2px 0 0 var(--color-primary);
}

.admin-search-input::placeholder {
  color: var(--color-text-tertiary);
}

.admin-search-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 20px;
  background: var(--color-primary);
  color: #fff;
  border: none;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s ease;
}

.admin-search-btn:hover {
  background: var(--color-primary-hover);
}

/* ==========================================================
   5. 요약 영역
   ========================================================== */
.admin-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 20px;
}

.admin-summary-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  background: var(--color-surface-alt);
  border: 1px solid var(--color-border-light);
  font-size: 13px;
  color: var(--color-text-secondary);
}

.admin-summary-item strong {
  color: var(--color-text-primary);
  font-weight: 700;
}

/* ==========================================================
   6. 회원 테이블
   ========================================================== */
.admin-table-wrap {
  overflow-x: auto;
}

.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.admin-table thead th {
  padding: 12px 14px;
  text-align: left;
  font-weight: 700;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--color-text-primary);
  background: #F0F0F3;
  border-bottom: 2px solid var(--color-primary);
  white-space: nowrap;
}

.admin-table tbody tr {
  border-bottom: 1px solid var(--color-border);
  transition: background 0.12s ease, border-color 0.12s ease;
}

.admin-table tbody tr:nth-child(even) {
  background: var(--color-surface-alt);
}

.admin-table tbody tr:hover {
  background: #FFF7F3;
  border-left: 3px solid var(--color-primary);
}

.admin-table tbody td {
  padding: 12px 14px;
  color: var(--color-text-primary);
  vertical-align: middle;
}

.admin-table td.admin-td-email {
  color: var(--color-text-secondary);
  font-size: 12px;
}

.admin-table td.admin-td-date {
  color: var(--color-text-secondary);
  font-size: 12px;
  white-space: nowrap;
}

/* ==========================================================
   7. 등급 뱃지
   ========================================================== */
.admin-role-badge {
  display: inline-block;
  padding: 3px 10px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  white-space: nowrap;
}

.admin-role-admin {
  background: var(--color-primary);
  color: #fff;
}

.admin-role-manager {
  background: var(--color-blue);
  color: #fff;
}

.admin-role-member {
  background: var(--color-green);
  color: #fff;
}

.admin-role-viewer {
  background: #6B6B76;
  color: #fff;
}

/* ==========================================================
   8. 등급 변경 셀렉트
   ========================================================== */
.admin-role-select {
  padding: 6px 10px;
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  font-size: 12px;
  font-weight: 500;
  color: var(--color-text-primary);
  cursor: pointer;
  outline: none;
  transition: border-color 0.15s ease;
}

.admin-role-select:focus {
  border-color: var(--color-primary);
}

/* 본인 행 비활성화 (등급 변경 불가) */
.admin-row-self {
  opacity: 0.6;
}

.admin-row-self .admin-role-select {
  pointer-events: none;
  opacity: 0.5;
}

/* ==========================================================
   9. Provider 뱃지 (가입 방식)
   ========================================================== */
.admin-provider-badge {
  display: inline-block;
  padding: 2px 8px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.admin-provider-email {
  background: #E8E8ED;
  color: var(--color-text-primary);
}

.admin-provider-google {
  background: #E8F0FE;
  color: #1967D2;
}

.admin-provider-kakao {
  background: #FEE500;
  color: #3C1E1E;
}

.admin-provider-naver {
  background: #03C75A;
  color: #fff;
}

/* ==========================================================
   10. 로딩 / 빈 상태
   ========================================================== */
.admin-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 40px 0;
  color: var(--color-text-secondary);
  font-size: 14px;
}

.admin-empty {
  text-align: center;
  padding: 40px 0;
  color: var(--color-text-tertiary);
  font-size: 14px;
}

/* ==========================================================
   11. 권한 매트릭스 테이블
   ========================================================== */
.admin-perm-desc {
  color: var(--color-text-secondary);
  font-size: 14px;
  margin-bottom: 20px;
  line-height: 1.5;
}

.admin-perm-table-wrap {
  overflow-x: auto;
}

.admin-perm-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

/* 2단 헤더 */
.admin-perm-table thead th {
  padding: 10px 8px;
  text-align: center;
  font-weight: 700;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--color-text-primary);
  background: #F0F0F3;
  border-bottom: 2px solid var(--color-primary);
  white-space: nowrap;
}

.admin-perm-table thead th.admin-perm-th-menu {
  text-align: left;
  width: 140px;
}

/* 등급 그룹 세로 구분선 */
.admin-perm-table thead th.admin-perm-th-grade {
  border-left: 2px solid var(--color-border-strong);
}

.admin-perm-table thead th.admin-perm-th-op {
  font-size: 10px;
  padding: 6px 4px;
  color: var(--color-text-secondary);
  background: #F5F5F7;
  min-width: 36px;
}

/* 등급 그룹 첫 번째 컬럼에 세로 구분선 */
.admin-perm-table td.admin-perm-td-grade-first {
  border-left: 2px solid var(--color-border-strong);
}

.admin-perm-table tbody tr {
  border-bottom: 1px solid var(--color-border);
}

.admin-perm-table tbody tr:nth-child(even) {
  background: var(--color-surface-alt);
}

.admin-perm-table tbody tr:hover {
  background: #FFF7F3;
}

.admin-perm-table tbody td {
  padding: 10px 8px;
  text-align: center;
  vertical-align: middle;
}

.admin-perm-table tbody td.admin-perm-td-menu {
  text-align: left;
  font-weight: 600;
  color: var(--color-text-primary);
  padding-left: 14px;
}

/* 체크박스 스타일 */
.admin-perm-table input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--color-primary);
  cursor: pointer;
}

/* 잠긴 체크박스 (admin의 admin 메뉴 권한) */
.admin-perm-table input[type="checkbox"].admin-perm-locked {
  pointer-events: none;
  opacity: 0.4;
}

/* ==========================================================
   12. 권한 저장 버튼
   ========================================================== */
.admin-perm-actions {
  margin-top: 20px;
  text-align: right;
}

.admin-perm-save-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 28px;
  background: var(--color-primary);
  color: #fff;
  border: none;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s ease, box-shadow 0.15s ease;
}

.admin-perm-save-btn:hover {
  background: var(--color-primary-hover);
  box-shadow: var(--shadow-2);
}

.admin-perm-save-btn:disabled {
  background: var(--color-text-disabled);
  cursor: not-allowed;
  box-shadow: none;
}

/* ==========================================================
   13. 토스트 메시지 (settings.css 패턴 재사용)
   ========================================================== */
.save-toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: var(--color-text-primary);
  color: #fff;
  padding: 14px 28px;
  font-size: 14px;
  font-weight: 600;
  box-shadow: var(--shadow-3);
  opacity: 0;
  transition: transform 0.3s ease, opacity 0.3s ease;
  z-index: 9999;
  pointer-events: none;
}

.save-toast.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

/* ==========================================================
   14. 메뉴 라벨 한국어 매핑 (CSS content 사용 안 함 — JS에서 처리)
   ========================================================== */

/* ==========================================================
   15. 반응형: 태블릿 (768px)
   ========================================================== */
@media (max-width: 768px) {
  .admin-page-title {
    font-size: 22px;
    margin-bottom: 16px;
  }

  .admin-panel {
    padding: 16px;
  }

  .admin-search-bar {
    flex-direction: column;
    align-items: stretch;
  }

  .admin-search-btn {
    width: 100%;
    justify-content: center;
  }

  .admin-table thead th,
  .admin-table tbody td {
    padding: 10px 8px;
    font-size: 12px;
  }

  /* 가입 방식, 가입일 숨기기 */
  .admin-table th:nth-child(3),
  .admin-table td:nth-child(3),
  .admin-table th:nth-child(4),
  .admin-table td:nth-child(4) {
    display: none;
  }
}

/* ==========================================================
   16. 반응형: 모바일 카드 레이아웃 (480px)
   ========================================================== */
@media (max-width: 480px) {
  .admin-tabs {
    gap: 0;
  }

  .admin-tab {
    flex: 1;
    justify-content: center;
    padding: 10px 12px;
    font-size: 13px;
  }

  .admin-panel {
    padding: 12px;
  }

  /* ---- 회원 테이블 → 카드 전환 ---- */
  .admin-table,
  .admin-table thead,
  .admin-table tbody,
  .admin-table th,
  .admin-table td,
  .admin-table tr {
    display: block;
  }

  .admin-table thead {
    display: none;
  }

  .admin-table tbody tr {
    margin-bottom: 12px;
    padding: 14px;
    border: 1px solid var(--color-border);
    border-left: 3px solid var(--color-primary);
    box-shadow: var(--shadow-1);
    background: var(--color-surface);
  }

  .admin-table tbody tr:nth-child(even) {
    background: var(--color-surface);
  }

  .admin-table tbody tr:hover {
    border-left: 3px solid var(--color-primary);
  }

  .admin-table tbody td {
    padding: 6px 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border: none;
  }

  .admin-table tbody td::before {
    content: attr(data-label);
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--color-text-secondary);
    flex-shrink: 0;
    margin-right: 12px;
  }

  /* 이름 셀 — 카드 상단 강조 */
  .admin-table tbody td:first-child {
    font-weight: 700;
    font-size: 14px;
    padding-bottom: 8px;
    margin-bottom: 6px;
    border-bottom: 1px solid var(--color-border-light);
  }

  /* 변경 셀 — 카드 하단 분리 */
  .admin-table tbody td:last-child {
    padding-top: 10px;
    margin-top: 6px;
    border-top: 1px solid var(--color-border-light);
    justify-content: flex-end;
  }

  /* 숨겨진 컬럼 복원 */
  .admin-table th:nth-child(3),
  .admin-table td:nth-child(3),
  .admin-table th:nth-child(4),
  .admin-table td:nth-child(4) {
    display: flex;
  }

  /* ---- 권한 테이블: 가로 스크롤 ---- */
  .admin-perm-table-wrap {
    -webkit-overflow-scrolling: touch;
  }

  .admin-perm-table {
    min-width: 600px;
  }
}
