/* ============================================================
   CSS Variables
   ============================================================ */
:root {
  --bg: #f0f2f5;
  --surface: #ffffff;
  --ink: #1a1a2e;
  --muted: #8892a0;
  --rule: #e4e7ed;
  --accent: #4361ee;
  --accent2: #7209b7;
  --success: #06d6a0;
  --success-bg: #d1f7e4;
  --success-ink: #0a6b50;
  --info: #118ab2;
  --info-bg: #d1ecf1;
  --info-ink: #0c5460;
  --danger: #ef476f;
  --danger-bg: #fde0e6;
  --danger-ink: #9d174d;
  --warning-bg: #fff3cd;
  --warning-ink: #856404;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 2px 12px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.1);
  --transition: 0.2s ease;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Noto Sans CJK SC", "PingFang SC", "Microsoft YaHei", "Helvetica Neue", sans-serif;
  --mono: "SF Mono", "Fira Code", "Consolas", monospace;
}

/* ============================================================
   Reset & Base
   ============================================================ */
*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--ink);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

.app {
  max-width: 960px;
  margin: 0 auto;
  padding: 1.5rem;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

/* ============================================================
   Header
   ============================================================ */
.app-header {
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent2) 100%);
  color: #fff;
  padding: 2rem 2rem 1.5rem;
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
}

.app-header h1 {
  font-size: 1.75rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  margin-bottom: 0.25rem;
}

.subtitle {
  font-size: 0.875rem;
  opacity: 0.85;
  margin-bottom: 1.25rem;
}

/* Stats Bar */
.stats-bar {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.stat-card {
  background: rgba(255, 255, 255, 0.15);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: var(--radius-sm);
  padding: 0.625rem 1.25rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 90px;
  flex: 1;
}

.stat-label {
  font-size: 0.75rem;
  opacity: 0.85;
  margin-bottom: 0.125rem;
}

.stat-value {
  font-size: 1.5rem;
  font-weight: 700;
  line-height: 1.2;
}

.stat-admitted { border-color: rgba(6, 214, 160, 0.4); }
.stat-not-admitted { border-color: rgba(239, 71, 111, 0.4); }
.stat-class8 { border-color: rgba(17, 138, 178, 0.4); }

/* ============================================================
   Search Section
   ============================================================ */
.search-section {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 1.25rem;
  box-shadow: var(--shadow);
}

.search-box {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  background: var(--bg);
  border: 2px solid var(--rule);
  border-radius: var(--radius-sm);
  padding: 0 0.875rem;
  transition: border-color var(--transition), box-shadow var(--transition);
}

.search-box:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(67, 97, 238, 0.12);
}

.search-icon {
  color: var(--muted);
  flex-shrink: 0;
}

#search-input {
  flex: 1;
  border: none;
  outline: none;
  background: transparent;
  font-size: 0.95rem;
  font-family: var(--font);
  color: var(--ink);
  padding: 0.75rem 0;
}

#search-input::placeholder {
  color: var(--muted);
}

.clear-btn {
  border: none;
  background: var(--rule);
  color: var(--muted);
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 1.1rem;
  line-height: 1;
  transition: background var(--transition), color var(--transition);
  flex-shrink: 0;
}

.clear-btn:hover {
  background: var(--danger);
  color: #fff;
}

/* Filter Buttons */
.filter-buttons {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.875rem;
  flex-wrap: wrap;
}

.filter-btn {
  padding: 0.4rem 1rem;
  border: 2px solid var(--rule);
  background: var(--surface);
  color: var(--ink);
  border-radius: 24px;
  cursor: pointer;
  font-size: 0.85rem;
  font-family: var(--font);
  font-weight: 500;
  transition: all var(--transition);
  display: flex;
  align-items: center;
  gap: 0.375rem;
}

.filter-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.filter-btn.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.filter-btn.active:hover {
  color: #fff;
}

.filter-count {
  font-size: 0.75rem;
  opacity: 0.7;
  font-weight: 600;
}

.filter-btn.active .filter-count {
  opacity: 0.85;
}

/* ============================================================
   Results Section
   ============================================================ */
.results-section {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  flex: 1;
  display: flex;
  flex-direction: column;
}

.results-header {
  padding: 0.875rem 1.25rem;
  border-bottom: 1px solid var(--rule);
  font-size: 0.85rem;
  color: var(--muted);
}

.results-count strong {
  color: var(--accent);
  font-size: 1rem;
}

.table-wrap {
  overflow-x: auto;
  overflow-y: auto;
  max-height: 600px;
}

/* Scrollbar */
.table-wrap::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
.table-wrap::-webkit-scrollbar-track {
  background: transparent;
}
.table-wrap::-webkit-scrollbar-thumb {
  background: #c8ccd4;
  border-radius: 3px;
}
.table-wrap::-webkit-scrollbar-thumb:hover {
  background: var(--muted);
}

/* Table */
.results-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.results-table thead {
  position: sticky;
  top: 0;
  z-index: 10;
}

.results-table th {
  background: #f8f9fb;
  color: var(--muted);
  font-weight: 600;
  text-align: left;
  padding: 0.75rem 1rem;
  border-bottom: 2px solid var(--rule);
  white-space: nowrap;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.results-table td {
  padding: 0.625rem 1rem;
  border-bottom: 1px solid #f0f1f3;
  vertical-align: middle;
}

.results-table tbody tr {
  transition: background var(--transition);
}

.results-table tbody tr:hover {
  background: #f8f9fb;
}

.col-num {
  width: 50px;
  text-align: center;
  color: var(--muted);
  font-size: 0.8rem;
  font-family: var(--mono);
}

.col-name {
  font-weight: 500;
  min-width: 100px;
}

.col-id {
  font-family: var(--mono);
  font-size: 0.85rem;
  color: var(--muted);
  min-width: 120px;
  letter-spacing: 0.02em;
}

.col-status {
  white-space: nowrap;
  min-width: 120px;
}

.no-id {
  color: var(--muted);
  font-style: italic;
  opacity: 0.6;
}

/* Pinyin Hint */
.pinyin-hint {
  display: block;
  font-size: 0.7rem;
  color: var(--muted);
  font-family: var(--mono);
  margin-top: 1px;
  letter-spacing: 0.5px;
  opacity: 0.7;
}

/* Status Badges */
.badge {
  display: inline-block;
  padding: 0.2rem 0.625rem;
  border-radius: 12px;
  font-size: 0.75rem;
  font-weight: 600;
  margin-right: 0.25rem;
  line-height: 1.4;
}

.badge-admitted {
  background: var(--success-bg);
  color: var(--success-ink);
}

.badge-not-admitted {
  background: var(--danger-bg);
  color: var(--danger-ink);
}

.badge-class8 {
  background: var(--info-bg);
  color: var(--info-ink);
}

/* Highlight */
mark {
  background: var(--warning-bg);
  color: var(--warning-ink);
  padding: 1px 3px;
  border-radius: 3px;
  font-weight: 600;
}

/* Empty State */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 3rem 1rem;
  color: var(--muted);
  text-align: center;
}

.empty-state svg {
  color: #c8ccd4;
  margin-bottom: 0.75rem;
}

.empty-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--ink);
  margin-bottom: 0.25rem;
}

.empty-hint {
  font-size: 0.85rem;
}

/* ============================================================
   Footer
   ============================================================ */
.app-footer {
  text-align: center;
  font-size: 0.8rem;
  color: var(--muted);
  padding: 0.5rem;
}

.app-footer kbd {
  display: inline-block;
  padding: 1px 6px;
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: 4px;
  font-family: var(--mono);
  font-size: 0.75rem;
  box-shadow: 0 1px 0 var(--rule);
}

/* ============================================================
   Responsive
   ============================================================ */
@media (max-width: 640px) {
  .app {
    padding: 0.75rem;
    gap: 0.875rem;
  }

  .app-header {
    padding: 1.5rem 1.25rem 1.25rem;
  }

  .app-header h1 {
    font-size: 1.35rem;
  }

  .stats-bar {
    gap: 0.5rem;
  }

  .stat-card {
    padding: 0.5rem 0.625rem;
    min-width: 70px;
  }

  .stat-value {
    font-size: 1.2rem;
  }

  .search-section {
    padding: 1rem;
  }

  #search-input {
    font-size: 0.875rem;
  }

  .filter-btn {
    padding: 0.35rem 0.75rem;
    font-size: 0.8rem;
  }

  .results-table {
    min-width: 500px;
  }

  .results-table th,
  .results-table td {
    padding: 0.5rem 0.625rem;
  }
}
