/* =============================================
   中铁运营公司维修工单系统 - 全局样式
   ============================================= */

* { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --primary: #1e40af;
  --primary-light: #3b82f6;
  --primary-dark: #1e3a8a;
  --success: #059669;
  --warning: #d97706;
  --danger: #dc2626;
  --info: #7c3aed;
  --gray: #6b7280;
  --bg: #f0f4f8;
  --white: #ffffff;
  --border: #e5e7eb;
  --text: #111827;
  --text-light: #6b7280;
  --shadow: 0 1px 3px rgba(0,0,0,.12), 0 1px 2px rgba(0,0,0,.08);
  --shadow-md: 0 4px 12px rgba(0,0,0,.1);
  --radius: 8px;
  --radius-lg: 12px;
}

body {
  font-family: -apple-system, 'PingFang SC', 'Microsoft YaHei', sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
}

/* ===== 顶部导航 ===== */
.topbar {
  background: linear-gradient(135deg, var(--primary-dark) 0%, var(--primary) 100%);
  color: #fff;
  height: 56px;
  display: flex;
  align-items: center;
  padding: 0 24px;
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 100;
  box-shadow: 0 2px 8px rgba(0,0,0,.2);
}

.topbar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 16px;
  font-weight: 700;
}

.topbar-logo .icon { font-size: 22px; }

.topbar-nav {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-left: 32px;
  flex: 1;
}

.topbar-nav a {
  color: rgba(255,255,255,.8);
  text-decoration: none;
  padding: 6px 14px;
  border-radius: 6px;
  font-size: 14px;
  transition: all .2s;
  cursor: pointer;
}

.topbar-nav a:hover, .topbar-nav a.active {
  background: rgba(255,255,255,.2);
  color: #fff;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.user-avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: rgba(255,255,255,.3);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 13px;
  cursor: pointer;
  border: 2px solid rgba(255,255,255,.5);
}

.badge-count {
  background: var(--danger);
  color: #fff;
  border-radius: 10px;
  padding: 1px 6px;
  font-size: 11px;
  font-weight: 700;
}

/* ===== 侧边栏 ===== */
.layout { display: flex; margin-top: 56px; min-height: calc(100vh - 56px); }

.sidebar {
  width: 220px;
  background: #fff;
  border-right: 1px solid var(--border);
  padding: 16px 0;
  position: fixed;
  top: 56px;
  left: 0;
  bottom: 0;
  overflow-y: auto;
}

.sidebar-menu { list-style: none; }

.sidebar-menu li a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 20px;
  color: var(--text);
  text-decoration: none;
  transition: all .2s;
  cursor: pointer;
  border-left: 3px solid transparent;
}

.sidebar-menu li a:hover {
  background: #f0f4f8;
  color: var(--primary);
}

.sidebar-menu li a.active {
  background: #eff6ff;
  color: var(--primary);
  border-left-color: var(--primary);
  font-weight: 600;
}

.sidebar-menu .menu-icon { font-size: 16px; width: 20px; text-align: center; }

.sidebar-divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: 8px 16px;
}

.sidebar-group-title {
  font-size: 11px;
  color: var(--text-light);
  padding: 8px 20px 4px;
  text-transform: uppercase;
  letter-spacing: .5px;
}

/* ===== 主内容区 ===== */
.main {
  margin-left: 220px;
  padding: 24px;
  flex: 1;
  min-width: 0;
}

/* ===== 页面标题 ===== */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

.page-title {
  font-size: 20px;
  font-weight: 700;
  color: var(--text);
}

.page-subtitle {
  font-size: 13px;
  color: var(--text-light);
  margin-top: 2px;
}

/* ===== 统计卡片 ===== */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: #fff;
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--shadow);
  display: flex;
  align-items: center;
  gap: 16px;
  transition: transform .2s, box-shadow .2s;
}

.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.stat-card.stat-clickable {
  cursor: pointer;
  position: relative;
  transition: transform .2s, box-shadow .2s, border-color .2s;
  border: 2px solid transparent;
}

.stat-card.stat-clickable:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-md);
  border-color: var(--primary);
}

.stat-card.stat-clickable:active {
  transform: translateY(-1px);
}

.stat-icon {
  width: 48px; height: 48px;
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 22px;
  flex-shrink: 0;
}

.stat-info .stat-value {
  font-size: 28px;
  font-weight: 800;
  line-height: 1;
}

.stat-info .stat-label {
  font-size: 12px;
  color: var(--text-light);
  margin-top: 4px;
}

/* ===== 卡片 ===== */
.card {
  background: #fff;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.card-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.card-title {
  font-size: 15px;
  font-weight: 700;
}

.card-body { padding: 20px; }

/* ===== 表格 ===== */
.table-wrap { overflow-x: auto; }

/* 项目表使用固定列宽，避免长项目名或地区名改变整张表的布局。 */
.project-table {
  table-layout: fixed;
  min-width: 820px;
}

.project-code-column { width: 18%; }
.project-name-column { width: 28%; }
.project-province-column,
.project-city-column { width: 14%; }
.project-status-column { width: 10%; }
.project-actions-column { width: 16%; }

.project-table th,
.project-table td {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.project-cell-text {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.project-code-text { font-size: 11px; }
.project-name-text { font-weight: 600; }

.project-table .action-col {
  flex-wrap: nowrap;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

table th {
  background: #f8fafc;
  padding: 10px 14px;
  text-align: left;
  font-weight: 600;
  color: var(--text-light);
  border-bottom: 2px solid var(--border);
  white-space: nowrap;
}

table td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

table tr:hover td { background: #f8fafc; }

table tr:last-child td { border-bottom: none; }

/* ===== 状态标签 ===== */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}

/* ===== 按钮 ===== */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 16px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: all .2s;
  text-decoration: none;
}

.btn:hover { filter: brightness(.92); transform: translateY(-1px); }
.btn:active { transform: none; filter: brightness(.85); }

.btn-primary { background: var(--primary); color: #fff; }
.btn-success { background: var(--success); color: #fff; }
.btn-warning { background: var(--warning); color: #fff; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-info { background: var(--info); color: #fff; }
.btn-outline { background: #fff; color: var(--primary); border: 1px solid var(--primary); }
.btn-gray { background: var(--bg); color: var(--text); border: 1px solid var(--border); }

.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn-lg { padding: 10px 24px; font-size: 15px; }

/* ===== 表单 ===== */
.form-group { margin-bottom: 16px; }

.form-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--text);
}

.form-label .required { color: var(--danger); margin-left: 2px; }

.form-control {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 13px;
  outline: none;
  transition: border-color .2s;
  background: #fff;
  color: var(--text);
}

.form-control:focus { border-color: var(--primary-light); box-shadow: 0 0 0 3px rgba(59,130,246,.15); }

textarea.form-control { resize: vertical; min-height: 80px; }

select.form-control { cursor: pointer; }

/*
 * 评分下拉（★/☆ 星条）。
 * 默认 select 的左右内边距 + 右侧箭头会占掉 ~40px，「★★★★★」的最后一颗星会被截掉；
 * 这里压紧内边距，配合「评分」列 17%（≈110px）：
 * 13px × 5 颗星(65px) + 内边距(8px) + 箭头(~20px) ≈ 93px，余量约 17px。
 * 只有小程序端用「N 分」数字口径，这里保持星条。
 */
.score-select { font-size: 13px; padding: 8px 4px; }

/*
 * 评语多行输入：可以换行看完整条评语（原先是单行 input，长评语只显示一行）。
 *
 * 选择器写成 textarea.comment-textarea 是为了压过上面的 `textarea.form-control { min-height:80px }`
 * ——只写 .comment-textarea 权重不够，min-height 会输给 80px，表格每行都会白高一头。
 * 这里固定 3 行可见（13px × 1.5 × 3 + 上下内边距 18px ≈ 78px），更长时可拖右下角拉大。
 */
textarea.comment-textarea { min-height: 78px; height: 78px; line-height: 1.5; }

.form-row {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
}

.form-row-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}

/* ===== 模态框 ===== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: fadeIn .2s;
}

@keyframes fadeIn { from { opacity: 0 } to { opacity: 1 } }
@keyframes slideUp { from { transform: translateY(20px); opacity: 0 } to { transform: none; opacity: 1 } }

.modal {
  background: #fff;
  border-radius: var(--radius-lg);
  box-shadow: 0 20px 60px rgba(0,0,0,.3);
  width: 100%;
  max-width: 600px;
  max-height: 90vh;
  overflow-y: auto;
  animation: slideUp .2s;
}

.modal-lg { max-width: 800px; }
/* 「提交处理结果」弹窗：要横排「姓名 / 用工数量 / 评分 / 评语」四列。
   700px 时评分下拉里的 ★★★★★ 仍会被内边距+箭头挤掉最后一颗星，加宽到 780px 一次到位 */
.modal-md { max-width: 780px; }
.modal-sm { max-width: 400px; }

.modal-header {
  padding: 20px 24px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-title { font-size: 17px; font-weight: 700; }

.modal-close {
  width: 28px; height: 28px;
  border-radius: 6px;
  border: none;
  background: var(--bg);
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  font-size: 16px;
  color: var(--text-light);
  transition: all .2s;
}

.modal-close:hover { background: #fce7f3; color: var(--danger); }

.modal-body { padding: 20px 24px; }
.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

/* ===== 工单详情 ===== */
.order-info-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  margin-bottom: 16px;
}

.info-item label {
  font-size: 12px;
  color: var(--text-light);
  display: block;
  margin-bottom: 2px;
}

.info-item span {
  font-size: 13px;
  font-weight: 600;
}

.timeline {
  position: relative;
  padding-left: 24px;
}

.timeline::before {
  content: '';
  position: absolute;
  left: 7px; top: 4px; bottom: 4px;
  width: 2px;
  background: var(--border);
}

.timeline-item {
  position: relative;
  margin-bottom: 16px;
}

.timeline-item::before {
  content: '';
  position: absolute;
  left: -20px;
  top: 4px;
  width: 10px; height: 10px;
  border-radius: 50%;
  background: var(--primary);
  border: 2px solid #fff;
  box-shadow: 0 0 0 2px var(--primary);
}

.timeline-time { font-size: 11px; color: var(--text-light); }
.timeline-text { font-size: 13px; color: var(--text); margin-top: 2px; }

/* ===== 筛选栏 ===== */
.filter-bar {
  background: #fff;
  border-radius: var(--radius-lg);
  padding: 16px 20px;
  margin-bottom: 16px;
  box-shadow: var(--shadow);
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.filter-bar .form-control { width: auto; min-width: 140px; }

.search-input {
  flex: 1;
  min-width: 200px;
  max-width: 300px;
  position: relative;
}

.search-input input {
  width: 100%;
  padding: 8px 12px 8px 36px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 13px;
  outline: none;
}

.search-input input:focus { border-color: var(--primary-light); }

.search-input .search-icon {
  position: absolute;
  left: 10px; top: 50%;
  transform: translateY(-50%);
  color: var(--text-light);
  font-size: 14px;
}

/* ===== 工单卡片（列表形式）===== */
.order-list { display: flex; flex-direction: column; gap: 12px; }

.order-card {
  background: #fff;
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
  border-left: 4px solid transparent;
  transition: all .2s;
  cursor: pointer;
}

.order-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateX(2px);
}

.order-card.urgent { border-left-color: var(--danger); }
.order-card.high { border-left-color: var(--warning); }
.order-card.normal { border-left-color: var(--primary); }

.order-card-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}

.order-id { font-size: 11px; color: var(--text-light); font-family: monospace; }
.order-title { font-weight: 700; font-size: 14px; flex: 1; }

.order-meta {
  display: flex;
  gap: 12px;
  font-size: 12px;
  color: var(--text-light);
}

/* ===== 评分星星 ===== */
.star-rating {
  display: flex;
  gap: 2px;
}

.star { font-size: 18px; cursor: pointer; transition: transform .1s; }
.star:hover { transform: scale(1.2); }
.star.filled { color: #f59e0b; }
.star.empty { color: #d1d5db; }

/* ===== 流程进度条 ===== */
.process-steps {
  display: flex;
  align-items: center;
  gap: 0;
  overflow-x: auto;
  padding: 8px 0;
}

.step {
  display: flex;
  flex-direction: column;
  align-items: center;
  flex: 1;
  min-width: 80px;
}

.step-dot {
  width: 32px; height: 32px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 14px;
  background: var(--border);
  color: #fff;
  font-weight: 700;
  position: relative;
  z-index: 1;
}

.step.done .step-dot { background: var(--success); }
.step.current .step-dot { background: var(--primary); box-shadow: 0 0 0 4px rgba(37,99,235,.2); }
.step.pending .step-dot { background: var(--border); }

.step-label { font-size: 11px; margin-top: 6px; color: var(--text-light); text-align: center; }
.step.done .step-label { color: var(--success); }
.step.current .step-label { color: var(--primary); font-weight: 600; }

.step-line {
  flex: 1;
  height: 2px;
  background: var(--border);
  min-width: 20px;
}

.step-line.done { background: var(--success); }

/* ===== 登录页 ===== */
.login-page {
  min-height: 100vh;
  background: linear-gradient(135deg, #1e3a8a 0%, #1e40af 50%, #2563eb 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.login-card {
  background: #fff;
  border-radius: 16px;
  padding: 40px;
  width: 100%;
  max-width: 420px;
  box-shadow: 0 24px 64px rgba(0,0,0,.3);
}

.login-logo {
  text-align: center;
  margin-bottom: 28px;
}

.login-logo .logo-icon {
  font-size: 48px;
  display: block;
  margin-bottom: 10px;
}

.login-logo h1 { font-size: 20px; font-weight: 800; color: var(--primary); }
.login-logo p { font-size: 13px; color: var(--text-light); margin-top: 4px; }

.user-select-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin-bottom: 20px;
}

.user-select-item {
  padding: 12px;
  border: 2px solid var(--border);
  border-radius: 10px;
  cursor: pointer;
  transition: all .2s;
  text-align: center;
}

.user-select-item:hover { border-color: var(--primary-light); background: #eff6ff; }
.user-select-item.selected { border-color: var(--primary); background: #eff6ff; }

.user-select-item .ua {
  width: 36px; height: 36px;
  border-radius: 50%;
  margin: 0 auto 6px;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 14px;
  color: #fff;
}

.user-select-item .un { font-size: 13px; font-weight: 600; }
.user-select-item .ur { font-size: 11px; color: var(--text-light); }

/* ===== 通知提示 ===== */
.toast-container {
  position: fixed;
  top: 70px;
  right: 20px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  background: #fff;
  border-radius: 8px;
  padding: 12px 16px;
  box-shadow: var(--shadow-md);
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 280px;
  animation: slideUp .3s;
  border-left: 4px solid var(--primary);
}

.toast.success { border-left-color: var(--success); }
.toast.error { border-left-color: var(--danger); }
.toast.warning { border-left-color: var(--warning); }

/* ===== 空状态 ===== */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-light);
}

.empty-icon { font-size: 48px; margin-bottom: 12px; display: block; }
.empty-text { font-size: 14px; }

/* ===== 图表容器 ===== */
.chart-container { position: relative; height: 250px; }

/* ===== 工单详情面板 ===== */
.detail-section {
  background: #f8fafc;
  border-radius: 8px;
  padding: 14px 16px;
  margin-bottom: 12px;
}

.detail-section-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--primary);
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.attach-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 0;
  border-bottom: 1px solid #e5e7eb;
  font-size: 13px;
}
.attach-item:last-child { border-bottom: 0; }
.attach-name { color: #1d4ed8; cursor: pointer; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.attach-name:hover { text-decoration: underline; }
.attach-size { color: #9ca3af; font-size: 11px; }
.attachment-preview-overlay {
  position: fixed;
  inset: 0;
  z-index: 3000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(15, 23, 42, .78);
}
.attachment-preview-dialog {
  position: relative;
  max-width: min(92vw, 1100px);
  max-height: 92vh;
  padding: 18px;
  border-radius: 10px;
  background: #fff;
  box-shadow: 0 20px 60px rgba(0,0,0,.35);
  text-align: center;
}
.attachment-preview-dialog img { display: block; max-width: 86vw; max-height: 78vh; object-fit: contain; }
.attachment-preview-close {
  position: absolute; right: 6px; top: 2px; border: 0; background: transparent;
  color: #64748b; font-size: 28px; line-height: 1; cursor: pointer;
}
.attachment-preview-name { margin-top: 8px; color: #475569; font-size: 12px; overflow-wrap: anywhere; }
.repair-file-item { display: flex; align-items: center; gap: 10px; padding: 6px 8px; border-bottom: 1px solid #f1f5f9; font-size: 12px; }
.repair-file-name { flex: 1; min-width: 0; color: #374151; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.repair-file-name.is-previewable { color: #1d4ed8; cursor: pointer; }
.repair-file-name.is-previewable:hover { text-decoration: underline; }
.repair-file-remove { flex-shrink: 0; }

.detail-row {
  display: flex;
  gap: 8px;
  margin-bottom: 8px;
  font-size: 13px;
}

.detail-row .label {
  color: var(--text-light);
  flex-shrink: 0;
  min-width: 80px;
}

.detail-row .value { font-weight: 600; }

/* ===== 紧急指示 ===== */
.urgency-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 700;
}

/* ===== 响应式 ===== */
@media (max-width: 768px) {
  .sidebar { display: none; }
  .main { margin-left: 0; padding: 16px; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .form-row, .form-row-3 { grid-template-columns: 1fr; }
  .order-info-grid { grid-template-columns: 1fr; }
}
