@import url('https://fonts.googleapis.com/css2?family=Noto+Sans+KR:wght@300;400;500;700&display=swap');

:root {
  /* 민트-티얼 메인 팔레트 */
  --g50:  #f0fdfb;
  --g100: #caf5ef;
  --g200: #8de6dc;
  --g300: #4ecdc4;
  --g400: #2bb8ae;
  --g500: #1a8a82;
  /* 복숭아 / 크리미 옐로우 */
  --y50:  #fffef6;
  --y100: #fff0e6;
  --y200: #ffc8a0;
  --y300: #ff9e70;
  /* 텍스트 */
  --text: #1b4a47;
  --text-muted: #5a8a85;
  --radius: 18px;
  --shadow: 0 4px 20px rgba(40, 170, 160, 0.13);
  --shadow-hover: 0 8px 28px rgba(40, 170, 160, 0.22);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'Noto Sans KR', -apple-system, sans-serif;
  background: linear-gradient(150deg, #f0fdfb 0%, #fff5ee 55%, #fff 100%);
  min-height: 100vh;
  color: var(--text);
}

/* ─── Header ─── */
.site-header {
  background: rgba(255, 255, 255, 0.88);
  backdrop-filter: blur(14px);
  border-bottom: 2px solid var(--g100);
  position: sticky;
  top: 0;
  z-index: 200;
}

.header-inner {
  max-width: 960px;
  margin: 0 auto;
  padding: 14px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
}

.logo-icon {
  font-size: 26px;
  display: inline-block;
  animation: sway 4s ease-in-out infinite;
}

@keyframes sway {
  0%, 100% { transform: rotate(-6deg); }
  50%       { transform: rotate(6deg); }
}

.logo-text {
  font-size: 19px;
  font-weight: 700;
  color: var(--g500);
  letter-spacing: -0.3px;
}

.admin-badge {
  font-size: 11px;
  background: var(--y200);
  color: #7a3200;
  padding: 2px 8px;
  border-radius: 20px;
  margin-left: 6px;
  font-weight: 600;
  vertical-align: middle;
}

.header-actions { display: flex; align-items: center; gap: 8px; }

.text-link, .admin-link {
  font-size: 13px;
  color: var(--text-muted);
  text-decoration: none;
  padding: 7px 14px;
  border-radius: 20px;
  transition: background 0.18s;
  font-weight: 500;
}
.text-link:hover, .admin-link:hover { background: var(--g100); }

/* ─── Main ─── */
.main-content {
  max-width: 960px;
  margin: 0 auto;
  padding: 36px 24px 80px;
}

/* ─── Loading ─── */
.loading-wrapper {
  text-align: center;
  padding: 100px 20px;
  color: var(--text-muted);
}
.loading-wrapper p { margin-top: 14px; font-size: 15px; }

.spinner {
  width: 44px; height: 44px;
  border: 3px solid var(--g100);
  border-top-color: var(--g400);
  border-radius: 50%;
  animation: spin 0.75s linear infinite;
  margin: 0 auto;
}

.spinner-sm {
  width: 18px; height: 18px;
  border: 2px solid var(--g100);
  border-top-color: var(--g400);
  border-radius: 50%;
  animation: spin 0.75s linear infinite;
  display: inline-block;
  vertical-align: middle;
  margin-right: 6px;
}

@keyframes spin { to { transform: rotate(360deg); } }

.loading-inline {
  text-align: center;
  padding: 48px;
  color: var(--text-muted);
  font-size: 14px;
}

/* ─── Empty ─── */
.empty-state { text-align: center; padding: 100px 24px; }
.empty-icon { font-size: 64px; margin-bottom: 20px; }
.empty-state h2 { font-size: 22px; font-weight: 700; margin-bottom: 10px; color: var(--g500); }
.empty-state p { color: var(--text-muted); font-size: 15px; }
.empty-results { text-align: center; padding: 30px; color: var(--text-muted); font-size: 14px; }

/* ─── Tabs ─── */
.tabs-wrapper { overflow-x: auto; margin-bottom: 28px; scrollbar-width: none; }
.tabs-wrapper::-webkit-scrollbar { display: none; }

.tabs {
  display: flex;
  gap: 6px;
  padding: 5px;
  background: var(--g100);
  border-radius: 50px;
  width: fit-content;
  min-width: 100%;
}

.tab-btn {
  padding: 10px 22px;
  border: none;
  border-radius: 50px;
  background: transparent;
  cursor: pointer;
  font-family: inherit;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-muted);
  transition: all 0.2s;
  white-space: nowrap;
}
.tab-btn:hover { background: rgba(255,255,255,0.55); }
.tab-btn.active {
  background: white;
  color: var(--g500);
  box-shadow: var(--shadow);
  font-weight: 700;
}

/* ─── Exam Card ─── */
.exam-card {
  background: white;
  border-radius: var(--radius);
  padding: 32px;
  box-shadow: var(--shadow);
  border: 2px solid var(--g100);
  border-top: 4px solid var(--g300);
  margin-bottom: 22px;
}

/* ─── Progress ─── */
.progress-section {
  background: var(--g50);
  border-radius: 14px;
  padding: 18px 22px;
  margin-bottom: 30px;
  border: 1.5px solid var(--g100);
}

.progress-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}

.progress-label { font-size: 14px; font-weight: 500; color: var(--text-muted); }
.progress-count { font-size: 15px; font-weight: 700; color: var(--g500); }

.progress-bar {
  height: 13px;
  background: var(--g100);
  border-radius: 99px;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--g300), var(--y300));
  border-radius: 99px;
  transition: width 0.6s cubic-bezier(.4,0,.2,1);
}

/* ─── Form ─── */
.form-title {
  font-size: 19px;
  font-weight: 700;
  margin-bottom: 22px;
  color: var(--text);
}

.form-group { margin-bottom: 18px; }

.form-group label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 7px;
  color: var(--text-muted);
}

.form-group input[type=text],
.form-group input[type=password] {
  width: 100%;
  padding: 13px 18px;
  border: 2px solid var(--g100);
  border-radius: 13px;
  font-family: inherit;
  font-size: 15px;
  color: var(--text);
  background: var(--g50);
  transition: border-color 0.2s, box-shadow 0.2s, background 0.2s;
  outline: none;
}
.form-group input:focus {
  border-color: var(--g300);
  box-shadow: 0 0 0 4px rgba(78, 205, 196, 0.18);
  background: white;
}

.input-hint {
  display: block;
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 6px;
  line-height: 1.5;
}

.form-error {
  background: #fff0f0;
  border: 1.5px solid #ffc8c8;
  color: #b83232;
  border-radius: 12px;
  padding: 11px 16px;
  font-size: 13px;
  margin-bottom: 14px;
  white-space: pre-line;
  line-height: 1.5;
}

.form-success {
  background: var(--g50);
  border: 1.5px solid var(--g200);
  color: var(--g500);
  border-radius: 12px;
  padding: 11px 16px;
  font-size: 13px;
  margin-bottom: 14px;
}

/* ─── Buttons ─── */
.btn-primary {
  display: inline-block;
  padding: 13px 32px;
  background: linear-gradient(135deg, var(--g300), var(--g400));
  color: white;
  border: none;
  border-radius: 50px;
  font-family: inherit;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.22s;
  box-shadow: 0 4px 14px rgba(43, 184, 174, 0.34);
  letter-spacing: -0.2px;
}
.btn-primary:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 7px 20px rgba(43, 184, 174, 0.44);
}
.btn-primary:active:not(:disabled) { transform: translateY(0); }
.btn-primary:disabled { opacity: 0.55; cursor: not-allowed; }

.btn-ghost {
  background: none;
  border: 2px solid var(--g200);
  padding: 8px 18px;
  border-radius: 20px;
  font-family: inherit;
  font-size: 13px;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.2s;
  font-weight: 500;
}
.btn-ghost:hover { background: var(--g100); border-color: var(--g300); }

.btn-danger-sm {
  background: none;
  border: 1.5px solid #ffb8b8;
  color: #c02020;
  padding: 6px 13px;
  border-radius: 9px;
  font-family: inherit;
  font-size: 12px;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
  font-weight: 500;
}
.btn-danger-sm:hover { background: #fff0f0; }

.btn-sm {
  background: var(--g50);
  border: 1.5px solid var(--g200);
  color: var(--text-muted);
  padding: 5px 12px;
  border-radius: 8px;
  font-family: inherit;
  font-size: 12px;
  cursor: pointer;
  transition: all 0.2s;
  font-weight: 500;
}
.btn-sm:hover { background: var(--g100); }

/* ─── Results ─── */
.results-wrapper { display: flex; flex-direction: column; gap: 22px; }

.stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
}

.stat-card {
  background: white;
  border-radius: 16px;
  padding: 22px 16px;
  text-align: center;
  box-shadow: var(--shadow);
  border: 2px solid var(--g100);
  transition: transform 0.2s, box-shadow 0.2s;
}
.stat-card:hover { transform: translateY(-4px); box-shadow: var(--shadow-hover); }
.stat-max { border-color: var(--y200); background: linear-gradient(145deg, #fff, var(--y50)); }
.stat-avg { border-color: var(--g200); background: linear-gradient(145deg, #fff, var(--g50)); }
.stat-min { border-color: #e0e0e0; }

.stat-icon { font-size: 30px; margin-bottom: 8px; }
.stat-label { font-size: 12px; color: var(--text-muted); font-weight: 600; margin-bottom: 6px; letter-spacing: 0.2px; }
.stat-value { font-size: 26px; font-weight: 700; color: var(--text); }

.chart-section,
.ranking-section {
  background: white;
  border-radius: var(--radius);
  padding: 26px 28px;
  box-shadow: var(--shadow);
  border: 2px solid var(--g100);
}

.section-title { font-size: 16px; font-weight: 700; margin-bottom: 18px; color: var(--text); }

.chart-container { position: relative; height: 220px; }

.table-wrapper { overflow-x: auto; }

.ranking-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
.ranking-table th {
  text-align: left;
  padding: 10px 16px;
  background: var(--g50);
  color: var(--text-muted);
  font-weight: 600;
  font-size: 12px;
  border-bottom: 2px solid var(--g100);
}
.ranking-table td {
  padding: 13px 16px;
  border-bottom: 1px solid var(--g50);
}
.ranking-table tr:last-child td { border-bottom: none; }
.ranking-table tr.my-row {
  background: linear-gradient(90deg, var(--y50), var(--g50));
}

.rank-cell { font-size: 19px; width: 56px; }
.nickname-cell { font-weight: 500; }
.score-cell { font-weight: 700; color: var(--g500); font-size: 15px; }

.me-badge {
  display: inline-block;
  background: var(--y200);
  color: #7a3200;
  font-size: 10px;
  padding: 1px 7px;
  border-radius: 10px;
  font-weight: 700;
  margin-left: 6px;
  vertical-align: middle;
}

.no-nickname { color: var(--text-muted); font-size: 12px; font-style: italic; }

.error-msg {
  background: #fff0f0;
  border: 1.5px solid #ffc8c8;
  color: #b83232;
  border-radius: 14px;
  padding: 18px;
  text-align: center;
  font-size: 14px;
  white-space: pre-line;
  line-height: 1.6;
}

/* ─── Admin ─── */
.login-card {
  max-width: 420px;
  margin: 70px auto 0;
  background: white;
  border-radius: var(--radius);
  padding: 44px 36px;
  box-shadow: var(--shadow);
  border: 2px solid var(--g100);
  border-top: 4px solid var(--g300);
  text-align: center;
}
.login-icon { font-size: 52px; margin-bottom: 16px; }
.login-card h2 { font-size: 23px; font-weight: 700; margin-bottom: 28px; color: var(--text); }
.login-card .form-group { text-align: left; }
.login-card .btn-primary { width: 100%; margin-top: 4px; }

.admin-card {
  background: white;
  border-radius: var(--radius);
  padding: 30px 32px;
  box-shadow: var(--shadow);
  border: 2px solid var(--g100);
  border-top: 4px solid var(--g300);
  margin-bottom: 24px;
}
.card-title { font-size: 17px; font-weight: 700; margin-bottom: 22px; color: var(--text); }

.file-drop-zone {
  border: 2.5px dashed var(--g200);
  border-radius: 14px;
  padding: 36px 20px;
  text-align: center;
  cursor: pointer;
  background: var(--g50);
  transition: all 0.2s;
  color: var(--text-muted);
  font-size: 14px;
  line-height: 1.6;
  user-select: none;
}
.file-drop-zone:hover, .file-drop-zone.drag-over { border-color: var(--g400); background: var(--g100); }
.file-drop-zone.has-file { border-style: solid; border-color: var(--g300); }
.file-drop-icon { font-size: 38px; margin-bottom: 8px; }

.exam-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 15px 0;
  border-bottom: 1px solid var(--g50);
}
.exam-item:last-child { border-bottom: none; }
.exam-info { flex: 1; min-width: 0; }
.exam-name {
  display: block;
  font-weight: 700;
  font-size: 15px;
  margin-bottom: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.exam-meta { font-size: 12px; color: var(--text-muted); }
.exam-actions { display: flex; gap: 6px; flex-shrink: 0; }

.badge { font-size: 12px; padding: 4px 11px; border-radius: 20px; font-weight: 600; white-space: nowrap; }
.badge-green { background: var(--g100); color: var(--g500); }
.badge-yellow { background: var(--y100); color: #7a3200; }

.empty-list { text-align: center; color: var(--text-muted); padding: 28px; font-size: 14px; }

.student-detail {
  margin-top: 16px;
  border-top: 1px solid var(--g100);
  padding-top: 14px;
}
.student-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.student-table th {
  text-align: left;
  padding: 8px 12px;
  background: var(--g50);
  color: var(--text-muted);
  font-weight: 600;
  font-size: 11px;
  border-bottom: 1.5px solid var(--g100);
}
.student-table td { padding: 10px 12px; border-bottom: 1px solid var(--g50); }
.student-table tr:last-child td { border-bottom: none; }

.nickname-done { color: var(--g500); font-weight: 600; }
.nickname-pending { color: #bbb; font-style: italic; }

/* ─── 신원 확인 / 닉네임 관리 ─── */
.required { color: #e53e3e; font-size: 12px; }

.form-sub {
  font-size: 13px;
  color: var(--text-muted);
  margin: -10px 0 18px;
  line-height: 1.6;
}

.verified-badge {
  display: inline-block;
  background: var(--g100);
  color: var(--g500);
  font-size: 13px;
  padding: 6px 14px;
  border-radius: 20px;
  margin-bottom: 16px;
}

.nickname-status {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--g50);
  border: 1.5px solid var(--g100);
  border-radius: 14px;
  padding: 14px 18px;
  margin-bottom: 14px;
}
.nick-label { font-size: 12px; color: var(--text-muted); white-space: nowrap; }
.nick-value { font-size: 18px; font-weight: 700; color: var(--g500); }

.nick-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }

.form-row { display: flex; gap: 10px; align-items: center; margin-top: 12px; }
.form-row .btn-primary { flex: 1; margin: 0; }

.btn-sm-outline {
  padding: 7px 14px;
  font-size: 13px;
  border-radius: 10px;
  border: 1.5px solid var(--g300);
  background: white;
  color: var(--g500);
  cursor: pointer;
  font-weight: 600;
  transition: all 0.15s;
}
.btn-sm-outline:hover { background: var(--g50); }

.btn-danger-outline { border-color: #fca5a5; color: #dc2626; }
.btn-danger-outline:hover { background: #fff5f5; }

.btn-report {
  font-size: 12px;
  padding: 7px 14px;
  border-radius: 10px;
  border: 1.5px dashed #fca5a5;
  background: #fff5f5;
  color: #dc2626;
  cursor: pointer;
  font-weight: 600;
  transition: all 0.15s;
}
.btn-report:hover { background: #fee2e2; }

.report-sent {
  background: #fff7ed;
  border: 1.5px solid #fed7aa;
  color: #c2410c;
  border-radius: 12px;
  padding: 12px 16px;
  font-size: 13px;
  margin-bottom: 12px;
}

/* ─── AI 닉네임 추천 ─── */
.ai-suggest-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 9px 18px;
  background: linear-gradient(135deg, #a78bfa, #f0abfc);
  color: white;
  border: none;
  border-radius: 50px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s;
  box-shadow: 0 3px 12px rgba(167, 139, 250, 0.35);
  margin-top: 10px;
  width: 100%;
  justify-content: center;
}
.ai-suggest-btn:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 6px 18px rgba(167, 139, 250, 0.48);
}
.ai-suggest-btn:disabled { opacity: 0.6; cursor: not-allowed; }

.ai-suggest-area {
  margin-top: 14px;
  padding: 16px;
  background: linear-gradient(135deg, #faf5ff, #fce7f3);
  border: 1.5px solid #e9d5ff;
  border-radius: 14px;
  animation: fadeIn 0.3s ease;
}
@keyframes fadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }

.ai-suggest-label {
  font-size: 11px;
  font-weight: 700;
  color: #7c3aed;
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 5px;
}

.ai-chips { display: flex; flex-wrap: wrap; gap: 7px; }

.ai-chip {
  padding: 7px 16px;
  background: white;
  border: 1.5px solid #ddd6fe;
  border-radius: 50px;
  font-size: 13px;
  font-weight: 600;
  color: #5b21b6;
  cursor: pointer;
  transition: all 0.15s;
}
.ai-chip:hover {
  background: #f5f3ff;
  border-color: #a78bfa;
  transform: translateY(-1px);
  box-shadow: 0 3px 8px rgba(167, 139, 250, 0.25);
}

/* ─── 신고 관리 ─── */
.report-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 0;
  border-bottom: 1px solid var(--g50);
}
.report-item:last-child { border-bottom: none; }
.report-info { flex: 1; font-size: 13px; display: flex; flex-direction: column; gap: 3px; }
.report-exam { color: var(--text-muted); font-size: 12px; }
.report-nick em { color: #e53e3e; font-style: normal; font-weight: 600; }
.report-time { color: var(--text-muted); font-size: 11px; }
.report-actions { display: flex; gap: 6px; flex-shrink: 0; flex-wrap: wrap; }
.report-badge {
  display: inline-block;
  background: #fff5f5;
  color: #dc2626;
  font-size: 10px;
  padding: 1px 6px;
  border-radius: 8px;
  margin-left: 4px;
  font-weight: 700;
}
.row-reported td { background: #fff9f9; }

/* ─── Responsive ─── */
@media (max-width: 620px) {
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .stat-card:nth-child(3) { grid-column: 1 / -1; }
  .exam-card { padding: 20px; }
  .main-content { padding: 22px 16px 60px; }
  .chart-container { height: 170px; }
  .chart-section, .ranking-section { padding: 20px 16px; }
  .stat-value { font-size: 22px; }
  .ranking-table td, .ranking-table th { padding: 10px 10px; }
}
