/* ============================================================
   投票排行榜系统 - 前台样式
   ============================================================ */

:root {
  --bg: #f0f2f5;
  --surface: #ffffff;
  --surface-muted: #f7f8fa;
  --text: #1a1a2e;
  --text-muted: #8a8a9a;
  --border: #e8e8ee;
  --brand: #6c5ce7;
  --brand-soft: #f0edff;
  --brand-on: #ffffff;
  --gold: #f1c40f;
  --gold-soft: #fff8e1;
  --silver: #bdc3c7;
  --silver-soft: #f5f6f7;
  --bronze: #e67e22;
  --bronze-soft: #fdf0e6;
  --accent: #00b894;
  --accent-soft: #e0f7f4;
  --danger: #e74c3c;
  --radius: 10px;
  --radius-card: 16px;
  --radius-full: 999px;
  --shadow-sm: 0 1px 3px rgba(0,0,0,.06);
  --shadow-md: 0 4px 16px rgba(0,0,0,.08);
  --shadow-lg: 0 8px 32px rgba(0,0,0,.12);
  --max-width: 1200px;
  --font: "PingFang SC", "Noto Sans CJK SC", "WenQuanYi Micro Hei", "Microsoft YaHei", system-ui, -apple-system, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f0f1a;
    --surface: #1a1a2e;
    --surface-muted: #232340;
    --text: #e8e8f0;
    --text-muted: #9999b0;
    --border: #2a2a45;
    --brand-soft: #2a2a50;
    --gold-soft: #3a3520;
    --silver-soft: #2a2a35;
    --bronze-soft: #3a2a20;
    --accent-soft: #1a3a35;
    --shadow-sm: 0 1px 3px rgba(0,0,0,.3);
    --shadow-md: 0 4px 16px rgba(0,0,0,.4);
    --shadow-lg: 0 8px 32px rgba(0,0,0,.5);
  }
}

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

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
  padding-bottom: 80px;
}

a { color: var(--brand); text-decoration: none; }
img { display: block; max-width: 100%; }

/* ============================================================
   顶部导航
   ============================================================ */
.navbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 20px;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow-sm);
}
.navbar-inner {
  max-width: var(--max-width);
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 56px;
}
.navbar h1 {
  font-size: 18px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
}
.navbar h1 .logo { font-size: 22px; }
.navbar .nav-info {
  font-size: 13px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 16px;
}
.vote-pill {
  background: var(--brand-soft);
  color: var(--brand);
  padding: 4px 12px;
  border-radius: var(--radius-full);
  font-size: 13px;
  font-weight: 500;
}
.admin-link {
  color: var(--text-muted);
  font-size: 13px;
}

/* ============================================================
   容器
   ============================================================ */
.container {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 24px 20px;
}

.section-title {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.section-title .line {
  flex: 1;
  height: 1px;
  background: var(--border);
}

/* ============================================================
   前三名领奖台 Podium
   ============================================================ */
.podium {
  display: grid;
  grid-template-columns: 1fr 1.15fr 1fr;
  align-items: end;
  gap: 16px;
  margin-bottom: 32px;
}
.podium-card {
  background: var(--surface);
  border-radius: var(--radius-card);
  padding: 24px 16px 20px;
  text-align: center;
  position: relative;
  box-shadow: var(--shadow-md);
  transition: transform .2s, box-shadow .2s;
}
.podium-card:hover { transform: translateY(-4px); box-shadow: var(--shadow-lg); }

.podium-card .rank-medal {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  font-weight: 700;
  margin: 0 auto 12px;
  color: #fff;
}
.podium-card.rank-1 { border: 2px solid var(--gold); }
.podium-card.rank-1 .rank-medal { background: linear-gradient(135deg, #f1c40f, #f39c12); }
.podium-card.rank-2 { border: 2px solid var(--silver); }
.podium-card.rank-2 .rank-medal { background: linear-gradient(135deg, #bdc3c7, #95a5a6); }
.podium-card.rank-3 { border: 2px solid var(--bronze); }
.podium-card.rank-3 .rank-medal { background: linear-gradient(135deg, #e67e22, #d35400); }

.podium-card.rank-1 { padding-top: 32px; }
.podium-card.rank-2 { padding-top: 24px; }
.podium-card.rank-3 { padding-top: 20px; }

.podium-card .avatar {
  width: 72px;
  height: 72px;
  border-radius: var(--radius-full);
  margin: 0 auto 12px;
  border: 3px solid var(--border);
  object-fit: cover;
  background: var(--surface-muted);
}
.podium-card.rank-1 .avatar { width: 88px; height: 88px; }

.podium-card .name {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 4px;
}
.podium-card .signature {
  font-size: 12px;
  color: var(--text-muted);
  margin: 0 auto 12px;
  max-width: 160px;
  line-height: 1.4;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  word-break: break-word;
}
.podium-card .signature:empty::before {
  content: '这个人很懒，什么都没写';
  opacity: .5;
}
.podium-card .vote-num {
  font-size: 22px;
  font-weight: 700;
  color: var(--brand);
  margin-bottom: 12px;
}
.podium-card .vote-num small {
  font-size: 12px;
  font-weight: 400;
  color: var(--text-muted);
  margin-left: 2px;
}

/* ============================================================
   卡片网格
   ============================================================ */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 16px;
}
.candidate-card {
  background: var(--surface);
  border-radius: var(--radius-card);
  padding: 20px 16px;
  text-align: center;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
  transition: transform .2s, box-shadow .2s, border-color .2s;
  display: flex;
  flex-direction: column;
  align-items: center;
}
.candidate-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-md);
  border-color: var(--brand);
}
.candidate-card .card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  margin-bottom: 12px;
}
.candidate-card .rank-num {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-muted);
}
.candidate-card .tg-tag {
  font-size: 11px;
  color: var(--accent);
  background: var(--accent-soft);
  padding: 2px 8px;
  border-radius: var(--radius-full);
  max-width: 100px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.candidate-card .avatar {
  width: 56px;
  height: 56px;
  border-radius: var(--radius-full);
  border: 2px solid var(--border);
  object-fit: cover;
  margin-bottom: 10px;
  background: var(--surface-muted);
}
.candidate-card .avatar-placeholder {
  width: 56px;
  height: 56px;
  border-radius: var(--radius-full);
  background: var(--surface-muted);
  border: 2px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  font-size: 20px;
  margin-bottom: 10px;
}
.candidate-card .name {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 4px;
}
.candidate-card .signature {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 14px;
  min-height: 36px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.candidate-card .vote-num {
  font-size: 18px;
  font-weight: 700;
  color: var(--brand);
  margin-bottom: 12px;
}
.candidate-card .vote-num small {
  font-size: 12px;
  font-weight: 400;
  color: var(--text-muted);
}
.candidate-card .btn-row {
  display: flex;
  gap: 8px;
  width: 100%;
}

/* ============================================================
   按钮
   ============================================================ */
.btn {
  border: none;
  border-radius: var(--radius);
  padding: 8px 16px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: opacity .2s, transform .1s;
  font-family: inherit;
  flex: 1;
}
.btn:active { transform: scale(.96); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-vote {
  background: var(--brand);
  color: var(--brand-on);
}
.btn-vote:hover:not(:disabled) { opacity: .88; }
.btn-share {
  background: var(--accent-soft);
  color: var(--accent);
  border: 1px solid var(--accent);
  flex: 0 0 auto;
  padding: 8px 14px;
}
.btn-primary {
  background: var(--brand);
  color: var(--brand-on);
  width: 100%;
  padding: 12px;
  font-size: 15px;
}
.btn-outline {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
}

/* ============================================================
   悬浮提交按钮
   ============================================================ */
.fab {
  position: fixed;
  right: 24px;
  bottom: 24px;
  width: 56px;
  height: 56px;
  border-radius: var(--radius-full);
  background: var(--brand);
  color: #fff;
  border: none;
  font-size: 28px;
  cursor: pointer;
  box-shadow: 0 4px 20px rgba(108,92,231,.4);
  z-index: 90;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform .2s, box-shadow .2s;
}
.fab:hover { transform: scale(1.08); box-shadow: 0 6px 28px rgba(108,92,231,.5); }
.fab:active { transform: scale(.95); }
.fab-label {
  position: absolute;
  right: 70px;
  background: var(--surface);
  color: var(--text);
  padding: 6px 14px;
  border-radius: var(--radius);
  font-size: 13px;
  white-space: nowrap;
  box-shadow: var(--shadow-md);
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s;
}
.fab:hover .fab-label { opacity: 1; }

/* ============================================================
   弹窗 Modal
   ============================================================ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.5);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 200;
  padding: 20px;
}
.modal-overlay.active { display: flex; }
.modal {
  background: var(--surface);
  border-radius: var(--radius-card);
  padding: 28px 24px;
  width: 100%;
  max-width: 420px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  animation: modalIn .25s ease;
}
@keyframes modalIn {
  from { opacity: 0; transform: scale(.95) translateY(10px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}
.modal-header h2 { font-size: 18px; font-weight: 600; }
.modal-close {
  background: none;
  border: none;
  font-size: 24px;
  color: var(--text-muted);
  cursor: pointer;
  line-height: 1;
  padding: 4px;
}
.modal-close:hover { color: var(--text); }

/* ============================================================
   表单
   ============================================================ */
.form-group { margin-bottom: 16px; }
.form-group label {
  display: block;
  font-size: 14px;
  font-weight: 500;
  margin-bottom: 6px;
}
.form-group label .req { color: var(--danger); }
.form-group input,
.form-group textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 14px;
  font-family: inherit;
  background: var(--surface);
  color: var(--text);
  transition: border-color .2s;
}
.form-group input:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--brand);
}
.form-group .hint { font-size: 12px; color: var(--text-muted); margin-top: 4px; }
.form-group .error-msg { font-size: 12px; color: var(--danger); margin-top: 4px; }

/* 头像预览 */
.avatar-preview {
  width: 64px;
  height: 64px;
  border-radius: var(--radius-full);
  border: 2px solid var(--border);
  background: var(--surface-muted);
  object-fit: cover;
  margin-top: 8px;
  display: none;
}
.avatar-preview.show { display: block; }
.avatar-placeholder-sm {
  width: 64px;
  height: 64px;
  border-radius: var(--radius-full);
  border: 2px solid var(--border);
  background: var(--surface-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  font-size: 24px;
  margin-top: 8px;
}

/* ============================================================
   分页
   ============================================================ */
.pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 6px;
  margin-top: 32px;
  flex-wrap: wrap;
}
.pagination a, .pagination span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 36px;
  height: 36px;
  padding: 0 10px;
  border-radius: var(--radius);
  font-size: 14px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  text-decoration: none;
}
.pagination a:hover { border-color: var(--brand); color: var(--brand); }
.pagination .current {
  background: var(--brand);
  color: #fff;
  border-color: var(--brand);
}
.pagination .disabled { opacity: .4; pointer-events: none; }

/* ============================================================
   消息提示
   ============================================================ */
.toast {
  position: fixed;
  top: 70px;
  left: 50%;
  transform: translateX(-50%) translateY(-100px);
  background: var(--surface);
  color: var(--text);
  padding: 12px 24px;
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  z-index: 300;
  font-size: 14px;
  font-weight: 500;
  transition: transform .3s ease;
  border: 1px solid var(--border);
  max-width: 90%;
}
.toast.show { transform: translateX(-50%) translateY(0); }
.toast.success { border-left: 4px solid var(--accent); }
.toast.error { border-left: 4px solid var(--danger); }

/* ============================================================
   空状态
   ============================================================ */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
}
.empty-state .icon { font-size: 48px; margin-bottom: 16px; }
.empty-state p { font-size: 14px; }

/* ============================================================
   响应式
   ============================================================ */
@media (max-width: 768px) {
  .podium {
    gap: 8px;
    align-items: end;
    margin-bottom: 20px;
  }
  .podium-card { padding: 14px 6px 12px; }
  .podium-card.rank-1 { padding-top: 28px; }
  .podium-card.rank-2 { padding-top: 20px; }
  .podium-card.rank-3 { padding-top: 14px; }
  .podium-card .rank-medal { width: 28px; height: 28px; font-size: 14px; margin-bottom: 8px; }
  .podium-card .avatar { width: 52px; height: 52px; border-width: 2px; margin-bottom: 8px; }
  .podium-card.rank-1 .avatar { width: 60px; height: 60px; }
  .podium-card .signature {
    display: -webkit-box;
    font-size: 11px;
    min-height: 14px;
    -webkit-line-clamp: 1;
    margin: 0 auto 8px;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: normal;
    word-break: break-word;
  }
  .podium-card .name { font-size: 13px; margin-bottom: 2px; }
  .podium-card .vote-num { font-size: 18px; margin-bottom: 8px; }
  .podium-card .btn-row { gap: 6px; }

  .tier-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .tier-card { padding: 10px 8px; }
  .tier-card .avatar, .tier-card .avatar-placeholder { width: 44px; height: 44px; }
  .tier-card .signature {
    display: -webkit-box;
    min-height: 14px;
    font-size: 11px;
    -webkit-line-clamp: 1;
    max-width: 100%;
    margin: 0 auto 6px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: normal;
    word-break: break-word;
  }
  .tier-card .vote-num { font-size: 14px; margin-bottom: 6px; }
  .tier-card .btn { padding: 5px 0; font-size: 12px; }
  .tier-card .btn-share { padding: 5px 8px; }
  .tier-card .rank-label { margin-bottom: 6px; font-size: 11px; }

  .fab { right: 16px; bottom: 16px; width: 50px; height: 50px; font-size: 24px; }
}

@media (max-width: 480px) {
  .podium { gap: 6px; }
  .podium-card { padding: 12px 4px 10px; }
  .podium-card .avatar { width: 46px; height: 46px; }
  .podium-card.rank-1 .avatar { width: 54px; height: 54px; }
  .podium-card .vote-num { font-size: 16px; }
  .navbar h1 { font-size: 15px; }
  .navbar .nav-info { gap: 10px; }
  .vote-pill { font-size: 12px; padding: 3px 10px; }
  .tier-grid { grid-template-columns: repeat(2, 1fr); gap: 8px; }
  .tier-header { gap: 8px; }
  .tier-badge { min-width: 32px; height: 20px; font-size: 11px; }
}

/* ============================================================
   分类区块 T0 - T5
   ============================================================ */
.tier-section { margin-bottom: 32px; }
.tier-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
  padding-bottom: 10px;
  border-bottom: 2px solid var(--border);
}
.tier-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 40px;
  height: 26px;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 700;
  color: #fff;
  padding: 0 8px;
}
.tier-badge.t0 { background: linear-gradient(135deg, #e74c3c, #c0392b); }
.tier-badge.t1 { background: linear-gradient(135deg, #e67e22, #d35400); }
.tier-badge.t2 { background: linear-gradient(135deg, #f1c40f, #f39c12); }
.tier-badge.t3 { background: linear-gradient(135deg, #2ecc71, #27ae60); }
.tier-badge.t4 { background: linear-gradient(135deg, #3498db, #2980b9); }
.tier-badge.t5 { background: linear-gradient(135deg, #9b59b6, #8e44ad); }

.tier-header .tier-desc {
  font-size: 13px;
  color: var(--text-muted);
}
.tier-header .tier-count {
  margin-left: auto;
  font-size: 13px;
  color: var(--text-muted);
  background: var(--surface-muted);
  padding: 2px 10px;
  border-radius: var(--radius-full);
}

/* 分类卡片网格 */
.tier-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 14px;
}
.tier-card {
  background: var(--surface);
  border-radius: var(--radius-card);
  padding: 16px;
  text-align: center;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
  transition: transform .2s, box-shadow .2s, border-color .2s;
  display: flex;
  flex-direction: column;
  align-items: center;
}
.tier-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-md);
  border-color: var(--brand);
}
.tier-card .rank-label {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-muted);
  margin-bottom: 8px;
  background: var(--surface-muted);
  padding: 2px 10px;
  border-radius: var(--radius-full);
}
.tier-card .avatar {
  width: 52px;
  height: 52px;
  border-radius: var(--radius-full);
  border: 2px solid var(--border);
  object-fit: cover;
  margin-bottom: 8px;
  background: var(--surface-muted);
}
.tier-card .avatar-placeholder {
  width: 52px;
  height: 52px;
  border-radius: var(--radius-full);
  background: var(--surface-muted);
  border: 2px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  font-size: 18px;
  margin-bottom: 8px;
}
.tier-card .name {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 3px;
}
.tier-card .signature {
  font-size: 12px;
  color: var(--text-muted);
  margin: 0 auto 10px;
  max-width: 180px;
  line-height: 1.4;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  word-break: break-word;
}
.tier-card .signature:empty::before {
  content: '这个人很懒，什么都没写';
  opacity: .5;
}
.tier-card .vote-num {
  font-size: 16px;
  font-weight: 700;
  color: var(--brand);
  margin-bottom: 10px;
}
.tier-card .vote-num small {
  font-size: 12px;
  font-weight: 400;
  color: var(--text-muted);
}
.tier-card .btn-row {
  display: flex;
  gap: 6px;
  width: 100%;
}
.tier-card .btn { padding: 6px 10px; font-size: 13px; }
.tier-card .btn-share { padding: 6px 10px; }

@media (max-width: 480px) {
  .tier-grid { grid-template-columns: repeat(2, 1fr); }
  .tier-header { gap: 8px; }
  .tier-badge { min-width: 32px; height: 20px; font-size: 11px; }
  .tier-card { padding: 8px 6px; }
  .tier-card .name { font-size: 13px; }
}
