/* ============================================
   高效填表 PC 管理平台 - 样式表
   ============================================ */

/* ===== Reset & Base ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --primary: #1677FF;
  --primary-light: #E6F0FF;
  --primary-dark: #0958D9;
  --success: #52C41A;
  --warning: #FA8C16;
  --danger: #FF4D4F;
  --text-primary: #1D2129;
  --text-secondary: #6B7280;
  --text-hint: #9CA3AF;
  --border: #E5E7EB;
  --bg: #F5F5F7;
  --bg-white: #FFFFFF;
  --radius: 8px;
  --radius-lg: 12px;
  --shadow: 0 2px 8px rgba(0,0,0,0.08);
  --shadow-lg: 0 8px 24px rgba(0,0,0,0.12);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Segoe UI", "Helvetica Neue", sans-serif;
  font-size: 14px;
  color: var(--text-primary);
  background: var(--bg);
  overflow: hidden;
  height: 100vh;
}

/* ===== Page Container ===== */
.page { display: none; height: 100vh; }
.page.active { display: flex; }

/* ==================== 登录页 ==================== */
#page-login {
  justify-content: center;
  align-items: center;
  background: linear-gradient(135deg, #1677FF 0%, #36AEFF 50%, #69C0FF 100%);
}

.login-container {
  width: 100%;
  max-width: 420px;
  padding: 20px;
}

.login-card {
  background: #fff;
  border-radius: var(--radius-lg);
  padding: 40px 32px;
  box-shadow: var(--shadow-lg);
  text-align: center;
}

.login-brand { margin-bottom: 32px; }
.login-logo { font-size: 48px; margin-bottom: 12px; }
.login-brand h1 { font-size: 24px; color: var(--primary); margin-bottom: 4px; }
.login-brand p { font-size: 14px; color: var(--text-hint); }

.login-qrcode-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-bottom: 20px;
}
#qrcode-container {
  width: 200px;
  height: 200px;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  background: #fff;
  margin-bottom: 12px;
}
.login-qrcode-tip {
  font-size: 14px;
  color: var(--text-secondary);
}
.login-qrcode-expired p { margin-bottom: 12px; color: var(--text-hint); }

.login-divider {
  display: flex;
  align-items: center;
  margin: 20px 0;
  color: var(--text-hint);
  font-size: 13px;
}
.login-divider::before, .login-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}
.login-divider span { padding: 0 16px; }

.login-token-area {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
}
.login-token-area .input { flex: 1; }

.login-footer { margin-top: 20px; }
.login-footer p { font-size: 12px; color: var(--text-hint); }

/* ==================== 主布局 ==================== */
#page-main { flex-direction: row; }

/* 侧边栏 */
.sidebar {
  width: 220px;
  background: #fff;
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  box-shadow: 2px 0 8px rgba(0,0,0,0.04);
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 20px 20px 16px;
  border-bottom: 1px solid var(--border);
}
.sidebar-logo { font-size: 28px; }
.sidebar-title { font-size: 18px; font-weight: 700; color: var(--primary); }

.sidebar-nav { flex: 1; padding: 12px 8px; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-radius: var(--radius);
  cursor: pointer;
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 14px;
  margin-bottom: 4px;
  transition: all 0.15s;
}
.nav-item:hover { background: var(--bg); }
.nav-item.active { background: var(--primary-light); color: var(--primary); font-weight: 600; }
.nav-icon { font-size: 18px; }

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px 16px;
  border-top: 1px solid var(--border);
}
.sidebar-user-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--primary-light);
  color: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  font-weight: 600;
  flex-shrink: 0;
}
.sidebar-user-info { flex: 1; min-width: 0; }
.sidebar-user-name { font-size: 14px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-user-plan { font-size: 12px; color: var(--text-hint); }

/* 主内容区 */
.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* 视图容器 */
.view { display: none; flex-direction: column; flex: 1; overflow: hidden; }
.view.active { display: flex; }

/* 顶栏 */
.topbar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px 24px;
  background: #fff;
  border-bottom: 1px solid var(--border);
}
.topbar-title { font-size: 20px; font-weight: 700; flex-shrink: 0; }
.topbar-count { font-size: 14px; color: var(--text-hint); }
.topbar-actions { margin-left: auto; display: flex; gap: 8px; }

/* 搜索区 */
.search-area { padding: 16px 24px; }
.search-input { width: 100%; max-width: 400px; }

/* 统计卡片 */
.stats-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; padding: 0 24px 16px; }
.stat-card {
  background: #fff;
  border-radius: var(--radius);
  padding: 20px;
  text-align: center;
  box-shadow: var(--shadow);
}
.stat-num { font-size: 32px; font-weight: 700; color: var(--primary); }
.stat-label { font-size: 13px; color: var(--text-hint); margin-top: 4px; }
.stat-active .stat-num { color: var(--success); }
.stat-ended .stat-num { color: var(--text-hint); }
.stat-replies .stat-num { color: var(--warning); }

/* 表单列表 */
.form-list { padding: 0 24px 24px; overflow-y: auto; flex: 1; }
.form-card {
  background: #fff;
  border-radius: var(--radius);
  padding: 20px 24px;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 16px;
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: all 0.15s;
}
.form-card:hover { box-shadow: var(--shadow-lg); transform: translateY(-1px); }
.form-card-icon {
  width: 44px;
  height: 44px;
  border-radius: var(--radius);
  background: var(--primary-light);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  flex-shrink: 0;
}
.form-card-info { flex: 1; min-width: 0; }
.form-card-title { font-size: 16px; font-weight: 600; margin-bottom: 4px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.form-card-meta { display: flex; align-items: center; gap: 12px; font-size: 13px; color: var(--text-secondary); }
.form-card-status {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 10px;
  font-size: 12px;
  font-weight: 500;
}
.status-active { background: #F6FFED; color: #52C41A; }
.status-ended { background: #F5F5F7; color: #8C8CA1; }
.status-draft { background: #FFF7E6; color: #FA8C16; }

.form-card-actions { display: flex; gap: 8px; flex-shrink: 0; }

/* 工具栏 */
.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 24px;
  background: #fff;
  border-bottom: 1px solid var(--border);
  gap: 12px;
  flex-wrap: wrap;
}
.toolbar-left, .toolbar-right { display: flex; align-items: center; gap: 8px; }
.toolbar-search { width: 240px; }

/* 批量操作栏 */
.batch-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 24px;
  background: var(--primary-light);
  border-bottom: 1px solid #B7D8FF;
  font-size: 14px;
}

/* ===== 数据表格 ===== */
.table-wrap { flex: 1; overflow: hidden; display: flex; flex-direction: column; position: relative; }
.loading-wrap { display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 60px 0; }
.spinner {
  width: 36px;
  height: 36px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  margin-bottom: 12px;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading-wrap p { color: var(--text-hint); }

.empty-wrap { display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 60px 0; color: var(--text-hint); }
.empty-wrap p { margin-bottom: 16px; }

.table-scroll { flex: 1; overflow: auto; }

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  white-space: nowrap;
}

.data-table thead {
  position: sticky;
  top: 0;
  z-index: 10;
}

.data-table th {
  background: #F8FAFC;
  padding: 10px 14px;
  text-align: left;
  font-weight: 600;
  color: var(--text-secondary);
  border-bottom: 2px solid var(--border);
  position: relative;
  cursor: default;
  user-select: none;
}

.data-table th .col-resize-handle {
  position: absolute;
  right: 0;
  top: 0;
  bottom: 0;
  width: 8px;
  cursor: col-resize;
}
.data-table th .col-resize-handle:hover { background: var(--primary-light); }

.data-table td {
  padding: 8px 14px;
  border-bottom: 1px solid #F3F4F6;
  max-width: 300px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.data-table tbody tr { cursor: pointer; transition: background 0.1s; }
.data-table tbody tr:hover { background: #F0F5FF; }
.data-table tbody tr.selected { background: var(--primary-light) !important; }
.data-table tbody tr.row-active { background: #E6F7FF !important; box-shadow: inset 3px 0 0 var(--primary); }
.data-table tbody tr.row-active td { padding-top: 10px; padding-bottom: 10px; }
.data-table tbody tr.row-multiline td { white-space: normal !important; word-break: break-all; padding-top: 8px; padding-bottom: 8px; line-height: 1.6; }
.data-table .td-check { width: 44px; text-align: center; }
.data-table .td-index { color: var(--text-hint); text-align: center; }
.data-table .td-time { font-size: 12px; color: var(--text-secondary); }
.data-table .td-mono { font-family: "SF Mono", monospace; font-size: 12px; color: var(--text-secondary); }
.data-table .td-user { white-space: nowrap; }
.data-table .td-user-inner { display: inline-flex; align-items: center; gap: 8px; }
.data-table .td-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  flex-shrink: 0;
  object-fit: cover;
}
.data-table .td-avatar-placeholder {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: linear-gradient(135deg, #91CAFF, #69B1FF);
  color: #fff;
  font-size: 12px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.checkbox {
  width: 18px;
  height: 18px;
  border: 2px solid #D0D5DD;
  border-radius: 4px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s;
  background: #fff;
  font-size: 12px;
}
.checkbox.checked { border-color: var(--primary); background: var(--primary); color: #fff; }
.checkbox.half { border-color: var(--primary); background: var(--primary); color: #fff; }

/* ===== 弹窗 ===== */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0,0,0,0.45);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: fadeIn 0.15s ease;
}
@keyframes fadeIn { from { opacity: 0; } }

.modal {
  background: #fff;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 640px;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  animation: slideUp 0.2s ease;
}
.modal-sm { width: 480px; }
@keyframes slideUp { from { transform: translateY(20px); opacity: 0; } }

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
  background: #F8FAFC;
}
.modal-header h3 { font-size: 18px; font-weight: 700; }
.modal-close {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: none;
  background: #F3F4F6;
  font-size: 16px;
  cursor: pointer;
  color: var(--text-hint);
  display: flex;
  align-items: center;
  justify-content: center;
}
.modal-close:hover { background: var(--border); }

.modal-body { flex: 1; padding: 20px 24px; overflow-y: auto; }

.modal-footer {
  display: flex;
  gap: 12px;
  padding: 16px 24px;
  border-top: 1px solid var(--border);
  justify-content: flex-end;
  background: #FAFBFC;
}

/* 详情字段 */
.detail-field {
  display: flex;
  flex-direction: column;
  padding: 14px 0;
  border-bottom: 1px solid #F3F4F6;
}
.detail-field:last-child { border-bottom: none; }
.detail-label { font-size: 13px; font-weight: 500; color: var(--text-hint); margin-bottom: 6px; }
.detail-value { font-size: 15px; color: var(--text-primary); word-break: break-all; }
.detail-mono { font-family: "SF Mono", monospace; font-size: 13px; background: #F8FAFC; padding: 6px 12px; border-radius: 6px; color: var(--text-secondary); word-break: break-all; }
.detail-input { width: 100%; padding: 8px 12px; border: 1px solid var(--border); border-radius: 6px; font-size: 14px; outline: none; }
.detail-input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(22,119,255,0.1); }
.detail-textarea { min-height: 100px; resize: vertical; line-height: 1.6; font-family: inherit; }
.detail-section-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-hint);
  padding-top: 20px;
  margin-top: 8px;
  border-top: 2px solid #EEF1F6;
}

/* 筛选面板 */
.filter-field-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 20px; }
.filter-field-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-radius: var(--radius);
  border: 2px solid transparent;
  background: #F8FAFC;
  cursor: pointer;
}
.filter-field-item:hover { background: var(--primary-light); }
.filter-field-item.active { border-color: var(--primary); background: var(--primary-light); }
.filter-field-count { font-size: 12px; background: #fff; padding: 2px 10px; border-radius: 10px; color: var(--text-hint); }

.filter-value-list { display: flex; flex-wrap: wrap; gap: 8px; }
.filter-value-item {
  padding: 6px 16px;
  border-radius: 16px;
  background: #F3F4F6;
  cursor: pointer;
  font-size: 13px;
  border: 2px solid transparent;
}
.filter-value-item:hover { background: var(--primary-light); }
.filter-value-item.active { border-color: var(--primary); background: var(--primary-light); color: var(--primary); font-weight: 600; }

/* 列设置 */
.column-setting-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 8px;
  border-bottom: 1px solid #F3F4F6;
}
.column-setting-label { font-size: 14px; }

/* 颜色选择 */
.color-picker { display: flex; flex-wrap: wrap; gap: 12px; }
.color-option {
  width: calc(33.333% - 8px);
  padding: 12px;
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  border: 2px solid transparent;
  font-size: 14px;
}
.color-option:hover { border-color: var(--primary); }
.color-option.active { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(22,119,255,0.1); }
.color-dot { width: 18px; height: 18px; border-radius: 50%; flex-shrink: 0; border: 1px solid rgba(0,0,0,0.1); }

/* ===== 按钮 ===== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 8px 20px;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 500;
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
  outline: none;
}
.btn:hover { opacity: 0.9; transform: translateY(-1px); }
.btn:active { transform: scale(0.97); }
.btn-primary { background: var(--primary); color: #fff; border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-dark); }
.btn-success { background: var(--success); color: #fff; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-warning { background: var(--warning); color: #fff; }
.btn-default { background: #fff; color: var(--text-primary); border-color: var(--border); }
.btn-default:hover { border-color: var(--primary); color: var(--primary); }
.btn-outline { background: transparent; border-color: var(--border); }
.btn-outline:hover { border-color: var(--primary); }
.btn-text { background: transparent; color: var(--text-secondary); padding: 8px 12px; }
.btn-text:hover { color: var(--primary); }

.btn-sm { padding: 5px 14px; font-size: 13px; }
.btn-xs { padding: 4px 10px; font-size: 12px; border-radius: 4px; }
.btn-full { width: 100%; }

/* ===== 输入 ===== */
.input {
  padding: 8px 14px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 14px;
  outline: none;
  transition: border-color 0.15s;
  background: #fff;
}
.input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(22,119,255,0.1); }

/* Switch */
.switch-wrap { display: flex; align-items: center; justify-content: space-between; padding: 8px 0; }
.switch {
  position: relative;
  width: 44px;
  height: 24px;
  background: #D0D5DD;
  border-radius: 12px;
  cursor: pointer;
  transition: background 0.2s;
}
.switch.on { background: var(--primary); }
.switch::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 20px;
  height: 20px;
  background: #fff;
  border-radius: 50%;
  transition: transform 0.2s;
}
.switch.on::after { transform: translateX(20px); }

/* Toast */
.toast {
  position: fixed;
  top: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0,0,0,0.75);
  color: #fff;
  padding: 10px 24px;
  border-radius: 8px;
  font-size: 14px;
  z-index: 9999;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.25s;
}
.toast.show { opacity: 1; }

/* 用户卡 */
.detail-user-card {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px;
  background: linear-gradient(135deg, #E6F0FF, #F0F5FF);
  border-radius: var(--radius);
  margin-bottom: 16px;
}
.detail-avatar {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  border: 3px solid #fff;
  box-shadow: 0 2px 8px rgba(22,119,255,0.2);
}
.detail-avatar-placeholder {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: linear-gradient(135deg, #91CAFF, #69B1FF);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 20px;
}

/* 滚动条美化 */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #D0D5DD; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #B0B5BD; }

/* 响应式 */
@media (max-width: 768px) {
  .sidebar { width: 60px; }
  .sidebar-title, .sidebar-user-info, .nav-item span:not(.nav-icon), .sidebar-user .btn { display: none; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
}
