/* ============================================================
   components.css — 可复用组件：导航项 / 状态点 / 按钮 /
                   面板 / 指标卡 / 表格 / 空状态 / 上传槽
   ============================================================ */

/* ---------- 导航项 ---------- */

.nav-item {
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  color: var(--text-dim);
  white-space: nowrap;
  transition: color 0.15s, background 0.15s;
}

.nav-item:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.04);
}

.nav-item.active {
  color: var(--gold-bright);
  background: var(--gold-soft);
}

/* ---------- 连接状态灯 ---------- */

.status {
  display: flex;
  align-items: center;
  gap: var(--gap-2);
  margin-left: auto;
  flex-shrink: 0;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-faint);
  transition: background 0.2s, box-shadow 0.2s;
}

.status-dot[data-state="online"] {
  background: var(--green);
  box-shadow: 0 0 8px rgba(56, 211, 159, 0.85);
}

.status-dot[data-state="offline"] {
  background: var(--red);
  box-shadow: 0 0 8px rgba(240, 82, 95, 0.85);
}

.status-text {
  font-size: 12px;
  color: var(--text-faint);
  white-space: nowrap;
}

/* ---------- 按钮 ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 36px;
  padding: 0 var(--gap-4);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--bg-elevated);
  font-size: 14px;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.btn:hover:not(:disabled) {
  border-color: var(--gold-line);
  color: var(--gold-bright);
}

.btn-primary {
  border-color: var(--gold);
  background: var(--gold);
  color: #17120a;
  font-weight: 600;
}

.btn-primary:hover:not(:disabled) {
  background: var(--gold-bright);
  border-color: var(--gold-bright);
  color: #17120a;
}

.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* ---------- 页头 ---------- */

.page-head {
  margin-bottom: var(--gap-5);
}

.page-title {
  font-size: 20px;
  font-weight: 600;
  letter-spacing: 0.01em;
}

.page-sub {
  margin-top: 6px;
  font-size: 13px;
  color: var(--text-dim);
}

/* ---------- 区块标题 ---------- */

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: var(--gap-6) 0 var(--gap-3);
}

.section-title {
  font-size: 14px;
  font-weight: 600;
}

/* ---------- 面板 ---------- */

.panel {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

/* ---------- 指标卡 ---------- */

.stat-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: var(--gap-4);
}

.stat {
  padding: 18px 20px;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.stat-label {
  font-size: 12px;
  color: var(--text-dim);
  letter-spacing: 0.04em;
}

.stat-value {
  margin-top: 6px;
  font-size: 28px;
  font-weight: 600;
  line-height: 1.2;
  font-variant-numeric: tabular-nums;
}

.stat-value.gold {
  color: var(--gold-bright);
}

/* ---------- 表格 ---------- */

.table-wrap {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.table th {
  padding: 12px var(--gap-4);
  background: rgba(255, 255, 255, 0.02);
  border-bottom: 1px solid var(--border);
  font-size: 12px;
  font-weight: 500;
  color: var(--text-dim);
  letter-spacing: 0.04em;
  text-align: left;
}

.table td {
  padding: 14px var(--gap-4);
  border-bottom: 1px solid var(--border);
  font-size: 14px;
}

.table tbody tr:last-child td {
  border-bottom: 0;
}

/* 文件名过长时截断，不撑破表格 */
.cell-name {
  max-width: 380px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.table-empty {
  padding: 32px var(--gap-4);
  text-align: center;
  font-size: 13px;
  color: var(--text-faint);
}

/* ---------- 空状态 ---------- */

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--gap-2);
  padding: 64px var(--gap-5);
  text-align: center;
}

.empty-title {
  font-size: 15px;
}

.empty-desc {
  max-width: 420px;
  font-size: 13px;
  line-height: 1.7;
  color: var(--text-faint);
}

/* ---------- 上传槽 ---------- */

.dropzone {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin-bottom: var(--gap-5);
  padding: 40px var(--gap-5);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius);
  background: var(--bg-panel);
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}

.dropzone:hover,
.dropzone.is-dragging {
  border-color: var(--gold);
  background: rgba(212, 175, 55, 0.05);
}

.dropzone:focus-visible {
  border-color: var(--gold);
}

.dropzone-title {
  font-size: 14px;
}

.dropzone-hint {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-faint);
}

/* ---------- 工具栏与提示 ---------- */

.quiz-toolbar {
  display: flex;
  align-items: center;
  gap: var(--gap-3);
  margin-bottom: var(--gap-5);
}

.hint {
  font-size: 12px;
  color: var(--text-faint);
}

/* ---------- 登录 ---------- */

.auth-gate {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--gap-4);
  background: var(--bg);
}

.auth-gate[hidden] {
  display: none;
}

.auth-card {
  display: flex;
  flex-direction: column;
  gap: var(--gap-3);
  width: 100%;
  max-width: 340px;
  padding: var(--gap-6) var(--gap-5);
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.auth-brand {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--gap-2);
  margin-bottom: var(--gap-2);
  font-size: 15px;
  font-weight: 600;
}

.auth-input {
  height: 40px;
  padding: 0 var(--gap-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-input);
  font-size: 14px;
  transition: border-color 0.15s;
}

.auth-input:focus {
  border-color: var(--gold-line);
}

.auth-input::placeholder {
  color: var(--text-faint);
}

.nav-logout {
  flex-shrink: 0;
  margin-left: var(--gap-3);
  padding: 4px 10px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  font-size: 12px;
  color: var(--text-dim);
  transition: color 0.15s, border-color 0.15s;
}

.nav-logout:hover {
  color: var(--gold-bright);
  border-color: var(--gold-line);
}

.nav-logout[hidden] {
  display: none;
}

/* ---------- 状态徽标 ---------- */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  white-space: nowrap;
}

.badge::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}

.badge-parsing { color: var(--gold-bright); }
.badge-success { color: var(--green); }
.badge-failed  { color: var(--red); }

/* ---------- 行内小按钮 ---------- */

.cell-actions {
  width: 132px;
  text-align: right;
  white-space: nowrap;
}

.cell-actions .btn-mini + .btn-mini {
  margin-left: var(--gap-2);
}

.btn-mini {
  height: 26px;
  padding: 0 10px;
  border: 1px solid var(--border-strong);
  border-radius: 5px;
  font-size: 12px;
  color: var(--text-dim);
  transition: color 0.15s, border-color 0.15s;
}

.btn-mini:hover {
  color: var(--gold-bright);
  border-color: var(--gold-line);
}

.btn-mini.danger:hover {
  color: var(--red);
  border-color: rgba(240, 82, 95, 0.5);
}

/* ---------- 浮动提示 ---------- */

.toast-stack {
  position: fixed;
  top: calc(var(--topbar-h) + var(--gap-4));
  right: var(--gap-5);
  z-index: 50;
  display: flex;
  flex-direction: column;
  gap: var(--gap-2);
  pointer-events: none;
}

.toast {
  min-width: 220px;
  max-width: 340px;
  padding: 10px 14px;
  border: 1px solid var(--border-strong);
  border-left-width: 2px;
  border-radius: var(--radius-sm);
  background: var(--bg-elevated);
  box-shadow: var(--shadow-panel);
  font-size: 13px;
  line-height: 1.5;
  animation: toast-in 0.2s ease-out;
}

.toast-success { border-left-color: var(--green); }
.toast-error   { border-left-color: var(--red); }

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateX(8px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

/* ---------- 下拉选择 ---------- */

.select-wrap {
  position: relative;
  flex: 1;
  max-width: 380px;
}

/* 自绘箭头，遮住原生箭头保证暗色一致 */
.select-wrap::after {
  content: "";
  position: absolute;
  top: 50%;
  right: 14px;
  width: 6px;
  height: 6px;
  border-right: 1.5px solid var(--text-dim);
  border-bottom: 1.5px solid var(--text-dim);
  transform: translateY(-70%) rotate(45deg);
  pointer-events: none;
}

.select {
  width: 100%;
  height: 36px;
  padding: 0 32px 0 var(--gap-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-input);
  color: var(--text);
  font-size: 13px;
  cursor: pointer;
  appearance: none;
  transition: border-color 0.15s;
}

.select:hover {
  border-color: var(--border-strong);
}

.select:focus {
  border-color: var(--gold-line);
}

.select option {
  background: var(--bg-elevated);
  color: var(--text);
}

/* ---------- 响应式 ---------- */

@media (max-width: 720px) {
  .stat-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}
