:root {
  --bg: #f5f6fa;
  --card-bg: #ffffff;
  --border: #e1e4ea;
  --primary: #2563eb;
  --primary-soft: #e0edff;
  --text-main: #111827;
  --text-sub: #6b7280;
  --danger: #dc2626;

  /* ✅ 사이드바용 색 */
  --sidebar-bg: #eef2ff;      /* 연보라/연파랑 느낌 */
  --sidebar-border: #c7d2fe;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: system-ui, -apple-system, BlinkMacSystemFont,
    "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text-main);
}

.admin-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

header.admin-header {
  padding: 0.9rem 1.5rem;
  border-bottom: 1px solid var(--border);
  background: #ffffff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 10;
}

.admin-logo {
  font-weight: 700;
  font-size: 1.1rem;
}
.admin-logo span {
  font-weight: 400;
  font-size: 0.9rem;
  color: var(--text-sub);
  margin-left: 0.4rem;
}

.admin-badge {
  font-size: 0.8rem;
  padding: 0.12rem 0.5rem;
  border-radius: 999px;
  border: 1px solid var(--primary-soft);
  background: var(--primary-soft);
  color: var(--primary);
}

.admin-main {
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
  gap: 1.5rem;
  padding: 1.5rem;
}

/* 사이드 메뉴 */
.admin-nav {
  align-self: flex-start;
  position: sticky;
  top: 4rem;

  /* ✅ 사이드바 전체 박스 스타일 */
  padding: 0.75rem;
  border-radius: 0.9rem;
  background: var(--sidebar-bg);
  border: 1px solid var(--sidebar-border);
}

.admin-nav-group-title {
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-sub);
  margin-bottom: 0.4rem;
}

/* 리스트 자체는 배경/테두리 제거해서 사이드바 배경이 보이게 */
.admin-nav-list {
  list-style: none;
  margin: 0;
  padding: 0;
  border-radius: 0;
  border: none;
  background: transparent;
}

/* 항목 간 구분은 살짝만 */
.admin-nav-item + .admin-nav-item {
  margin-top: 0.25rem;
  border-top: none;
}


.admin-nav-item {
  border-top: 1px solid var(--border);
}
.admin-nav-item:first-child {
  border-top: none;
}

.admin-nav-button {
  display: flex;
  width: 100%;
  padding: 0.7rem 0.9rem;
  background: transparent;
  border: none;
  text-align: left;
  font-size: 0.9rem;
  cursor: pointer;
  color: var(--text-sub);
  align-items: center;
  gap: 0.4rem;
  border-radius: 0.7rem;          /* 둥글게 */
}

.admin-nav-button span.icon {
  font-size: 1rem;
  width: 1.4rem;
  text-align: center;
}

.admin-nav-button.active {
  background: var(--primary-soft); /* 선택된 메뉴 배경 */
  color: var(--primary);
  font-weight: 600;
}

/* 메인 컨텐츠 카드 */
.admin-section {
  display: none;
}
.admin-section.active {
  display: block;
}

.card {
  background: var(--card-bg);
  border-radius: 0.9rem;
  border: 1px solid var(--border);
  padding: 1.2rem 1.3rem;
  margin-bottom: 1rem;
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.8rem;
  gap: 0.75rem;
}

.card-title {
  font-size: 1rem;
  font-weight: 600;
}
.card-subtitle {
  font-size: 0.84rem;
  color: var(--text-sub);
  margin-top: 0.1rem;
}

.pill {
  display: inline-flex;
  align-items: center;
  padding: 0.15rem 0.55rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  font-size: 0.75rem;
  color: var(--text-sub);
  gap: 0.25rem;
}

.pill-dot {
  width: 0.35rem;
  height: 0.35rem;
  border-radius: 999px;
  background: #10b981;
}

/* 대시보드 위젯 */
.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 0.8rem;
  margin-bottom: 0.3rem;
}

.dashboard-stat {
  background: #f9fafb;
  border-radius: 0.75rem;
  padding: 0.8rem 0.9rem;
  border: 1px solid #e5e7eb;
}

.dashboard-stat-label {
  font-size: 0.8rem;
  color: var(--text-sub);
  margin-bottom: 0.25rem;
}

.dashboard-stat-value {
  font-size: 1.05rem;
  font-weight: 600;
}

.dashboard-stat-note {
  font-size: 0.75rem;
  color: var(--text-sub);
  margin-top: 0.2rem;
}

/* 테이블 */
.table-wrapper {
  width: 100%;
  overflow-x: auto;
  border-radius: 0.75rem;
  border: 1px solid var(--border);
}

table.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
  background: #ffffff;
}

.admin-table thead {
  background: #f9fafb;
}

.admin-table th,
.admin-table td {
  padding: 0.55rem 0.75rem;
  border-bottom: 1px solid var(--border);
  text-align: left;
  white-space: nowrap;
}

.admin-table th {
  font-weight: 600;
  color: var(--text-sub);
  font-size: 0.8rem;
}

.admin-table tbody tr:hover {
  background: #f5f7ff;
}

.badge-key {
  display: inline-flex;
  padding: 0.1rem 0.4rem;
  border-radius: 999px;
  background: #eff6ff;
  color: #1d4ed8;
  font-size: 0.75rem;
}

.text-muted {
  color: var(--text-sub);
  font-size: 0.8rem;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.35rem 0.7rem;
  border-radius: 999px;
  font-size: 0.8rem;
  border: 1px solid var(--border);
  background: #fff;
  cursor: pointer;
}

.btn-primary {
  border-color: var(--primary);
  background: var(--primary);
  color: #fff;
}

.btn-ghost {
  background: transparent;
}

.btn:disabled {
  opacity: 0.6;
  cursor: default;
}

.field-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin-bottom: 0.6rem;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  flex: 1 1 180px;
  min-width: 0;
}

.field label {
  font-size: 0.78rem;
  color: var(--text-sub);
}

.field input,
.field select,
.field textarea {
  border-radius: 0.55rem;
  border: 1px solid var(--border);
  padding: 0.4rem 0.5rem;
  font-size: 0.84rem;
  font-family: inherit;
}

.field textarea {
  min-height: 70px;
  resize: vertical;
}

.small-help {
  font-size: 0.75rem;
  color: var(--text-sub);
}

.danger-text {
  color: var(--danger);
  font-size: 0.8rem;
}
.admin-form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 0.75rem 1rem;
  margin-bottom: 1rem;
}

.admin-field-full {
  grid-column: 1 / -1;
}

.admin-code-preview {
  margin-top: 0.5rem;
  padding: 0.75rem 1rem;
  border-radius: 0.75rem;
  background: #0f172a;
  color: #e5e7eb;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  font-size: 0.85rem;
  max-height: 260px;
  overflow: auto;
  white-space: pre-wrap;
}

@media (max-width: 840px) {
  .admin-main {
    grid-template-columns: 1fr;
  }

  .admin-nav {
    position: static;
  }
}

/* ============================
   문제 관리 페이지 레이아웃
   (questions.html 용)
   ============================ */

.questions-page {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(0, 1.6fr);
  gap: 1rem;
}

/* 왼쪽: 문제 목록 카드 */
.questions-list {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

/* 필터 영역 */
.questions-filters {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 0.5rem 0.75rem;
  margin-bottom: 0.5rem;
}

/* 테이블 래퍼 – 가로/세로 스크롤 */
.questions-table-wrapper {
  width: 100%;
  max-height: none;  /* ★ 내부 세로 스크롤 없애기 */
  overflow-y: visible;
  overflow-x: auto;   /* 데스크톱에서 컬럼이 너무 많을 때만 가로 스크롤 */
  border-radius: 0.75rem;
  border: 1px solid var(--border);
  background: #ffffff;
}


/* 문제 목록 테이블 */
.questions-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

.questions-table th,
.questions-table td {
  padding: 0.55rem 0.7rem;
  white-space: nowrap;
}

.questions-table thead {
  position: sticky;
  top: 0;
  background: #f9fafb;
  z-index: 1;
}

/* 한 행 선택되었을 때 강조 */
.questions-table tr.is-selected {
  background: #eef2ff;
}

/* 페이지네이션 */
.questions-pagination {
  margin-top: 0.6rem;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.8rem;
}

.questions-pagination button {
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: #fff;
  cursor: pointer;
}

.questions-pagination button:disabled {
  opacity: 0.5;
  cursor: default;
}

/* 오른쪽: 상세 패널 */
.questions-detail {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.questions-detail-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
}

.questions-detail-body {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

/* ============================
   반응형(모바일)
   ============================ */

/* 태블릿 ~ 작은 화면: 좌우 2단 -> 위아래 1단 */
@media (max-width: 960px) {
  .questions-page {
    grid-template-columns: 1fr;
  }

  /* 모바일에서 상세가 위에 오게 하고 싶으면 순서만 바꾸기 */
  .questions-detail {
    order: -1;
  }
}

@media (max-width: 640px) {
  .questions-page .card {
    padding: 0.9rem 0.8rem;
  }

  .questions-filters {
    grid-template-columns: 1fr;
  }

  .questions-table-wrapper {
    margin: 0 -0.5rem;           /* 살짝 넓게 */
    border-radius: 0.5rem;
    -webkit-overflow-scrolling: touch;

    /* ★ 모바일에서는 내부 스크롤 완전히 없애기 */
    max-height: none;
    overflow-x: hidden;
    overflow-y: visible;
  }

  .questions-table th,
  .questions-table td {
    padding: 0.4rem 0.5rem;
    font-size: 0.78rem;
    /* ★ 긴 질문 줄바꿈 허용 */
    white-space: normal;
  }
}

/* 아주 작은 화면: 덜 중요한 컬럼은 숨김(예: ID, 난이도 등) */
@media (max-width: 480px) {
  /* 1열: ID 컬럼 숨김 */
  .questions-table th:nth-child(1),
  .questions-table td:nth-child(1),
  /* 4열: 난이도 컬럼 (추측입니다 – 실제 열 순서에 맞게 조정 필요) */
  .questions-table th:nth-child(4),
  .questions-table td:nth-child(4),
  /* 6열: 수정일/등록일 컬럼 (추측입니다 – 실제 열 순서에 맞게 조정 필요) */
  .questions-table th:nth-child(6),
  .questions-table td:nth-child(6) {
    display: none;
  }
}

/* =========================================
   📱 모바일에서 문제 목록 보기 최적화(강제 덮어쓰기)
   ========================================= */
@media (max-width: 640px) {
  .questions-table-wrapper {
    max-height: none !important;
    overflow-x: hidden !important;
    overflow-y: visible !important;
    -webkit-overflow-scrolling: touch;
    margin: 0 -0.5rem;
    border-radius: 0.5rem;
  }

  .questions-table th,
  .questions-table td {
    padding: 0.4rem 0.5rem;
    font-size: 0.78rem;
    /* 긴 질문 줄바꿈 허용 */
    white-space: normal !important;
    word-break: keep-all;
  }
}

@media (max-width: 480px) {
  /* 아주 작은 화면에서는 ID 컬럼 숨기기 */
  .questions-table th:nth-child(1),
  .questions-table td:nth-child(1) {
    display: none !important;
  }
}

