/* TRUST Compass Studio — 自定义样式 */

/* ─── 变量 ─── */
:root {
  --primary: #1A56DB;
  --primary-dark: #1E40AF;
  --primary-light: #EFF6FF;
  --success: #059669;
  --warning: #D97706;
  --danger: #DC2626;
  --gray-50: #F9FAFB;
  --gray-100: #F3F4F6;
  --gray-200: #E5E7EB;
  --gray-600: #4B5563;
  --gray-700: #374151;
  --gray-900: #111827;
  --sidebar-width: 240px;
}

/* ─── 基础重置 ─── */
*, *::before, *::after { box-sizing: border-box; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  font-size: 14px;
  color: var(--gray-900);
  background: var(--gray-50);
  line-height: 1.5;
}

/* ─── 布局 ─── */
.layout { display: flex; min-height: 100vh; }
.sidebar {
  width: var(--sidebar-width);
  background: var(--gray-900);
  color: #fff;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  overflow-y: auto;
  z-index: 100;
}
.main-content {
  margin-left: var(--sidebar-width);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}
.page-header {
  background: #fff;
  border-bottom: 1px solid var(--gray-200);
  padding: 16px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.page-title { font-size: 18px; font-weight: 600; color: var(--gray-900); margin: 0; }
.page-body { padding: 24px; flex: 1; }

/* ─── 侧边栏 ─── */
.sidebar-logo {
  padding: 20px 16px;
  border-bottom: 1px solid rgba(255,255,255,0.1);
}
.sidebar-logo-text {
  font-size: 15px;
  font-weight: 700;
  color: #fff;
  display: block;
  line-height: 1.3;
}
.sidebar-logo-sub {
  font-size: 11px;
  color: rgba(255,255,255,0.5);
  display: block;
  margin-top: 2px;
}
.sidebar-nav { padding: 8px 0; flex: 1; }
.nav-section { padding: 16px 16px 4px; font-size: 11px; text-transform: uppercase; letter-spacing: 0.05em; color: rgba(255,255,255,0.35); font-weight: 600; }
.nav-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  color: rgba(255,255,255,0.7);
  text-decoration: none;
  font-size: 14px;
  border-radius: 4px;
  margin: 1px 8px;
  transition: background 0.15s, color 0.15s;
}
.nav-item:hover, .nav-item.active {
  background: rgba(255,255,255,0.1);
  color: #fff;
}
.nav-item.active { background: var(--primary); color: #fff; }
.nav-icon { width: 18px; text-align: center; flex-shrink: 0; }
.sidebar-footer {
  padding: 12px;
  border-top: 1px solid rgba(255,255,255,0.1);
  font-size: 12px;
  color: rgba(255,255,255,0.4);
}
.user-info { padding: 12px 16px; }
.user-name { font-size: 13px; color: #fff; font-weight: 500; }
.user-role { font-size: 11px; color: rgba(255,255,255,0.45); }

/* ─── 卡片 ─── */
.card {
  background: #fff;
  border: 1px solid var(--gray-200);
  border-radius: 8px;
  padding: 20px;
}
.card-title { font-size: 15px; font-weight: 600; color: var(--gray-900); margin: 0 0 16px; }
.card-subtitle { font-size: 13px; color: var(--gray-600); margin: -12px 0 16px; }

/* ─── 统计卡片 ─── */
.stat-card {
  background: #fff;
  border: 1px solid var(--gray-200);
  border-radius: 8px;
  padding: 16px 20px;
  display: flex;
  align-items: flex-start;
  gap: 12px;
}
.stat-icon {
  width: 40px; height: 40px;
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
}
.stat-icon.blue { background: var(--primary-light); color: var(--primary); }
.stat-icon.green { background: #ECFDF5; color: var(--success); }
.stat-icon.yellow { background: #FFFBEB; color: var(--warning); }
.stat-icon.red { background: #FEF2F2; color: var(--danger); }
.stat-value { font-size: 24px; font-weight: 700; color: var(--gray-900); line-height: 1; }
.stat-label { font-size: 12px; color: var(--gray-600); margin-top: 4px; }

/* ─── 网格 ─── */
.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }
@media (max-width: 768px) {
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
}

/* ─── 表格 ─── */
.table-wrapper { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
thead th {
  background: var(--gray-50);
  padding: 10px 12px;
  text-align: left;
  font-size: 12px;
  font-weight: 600;
  color: var(--gray-600);
  border-bottom: 1px solid var(--gray-200);
  white-space: nowrap;
}
tbody td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--gray-100);
  font-size: 13px;
  color: var(--gray-700);
}
tbody tr:hover { background: var(--gray-50); }
tbody tr:last-child td { border-bottom: none; }

/* ─── 按钮 ─── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 500;
  border: 1px solid transparent;
  cursor: pointer;
  text-decoration: none;
  transition: all 0.15s;
  white-space: nowrap;
}
.btn-primary { background: var(--primary); color: #fff; border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); }
.btn-secondary { background: #fff; color: var(--gray-700); border-color: var(--gray-200); }
.btn-secondary:hover { background: var(--gray-50); border-color: var(--gray-300); }
.btn-danger { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn-danger:hover { background: #B91C1C; }
.btn-success { background: var(--success); color: #fff; }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-xs { padding: 3px 8px; font-size: 11px; }

/* ─── 表单 ─── */
.form-group { margin-bottom: 16px; }
.form-label { display: block; font-size: 13px; font-weight: 500; color: var(--gray-700); margin-bottom: 6px; }
.form-label .required { color: var(--danger); margin-left: 2px; }
.form-control {
  display: block;
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--gray-200);
  border-radius: 6px;
  font-size: 13px;
  color: var(--gray-900);
  background: #fff;
  transition: border-color 0.15s;
  outline: none;
}
.form-control:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(26,86,219,0.1); }
.form-hint { font-size: 12px; color: var(--gray-600); margin-top: 4px; }
textarea.form-control { resize: vertical; min-height: 80px; }

/* ─── Badge / 标签 ─── */
.badge {
  display: inline-flex; align-items: center;
  padding: 2px 8px;
  border-radius: 9999px;
  font-size: 11px;
  font-weight: 500;
  white-space: nowrap;
}
.badge-gray { background: var(--gray-100); color: var(--gray-600); }
.badge-blue { background: #DBEAFE; color: #1D4ED8; }
.badge-green { background: #D1FAE5; color: #065F46; }
.badge-yellow { background: #FEF3C7; color: #92400E; }
.badge-red { background: #FEE2E2; color: #991B1B; }
.badge-purple { background: #EDE9FE; color: #5B21B6; }

/* ─── TRUST 维度 badge tooltip ─── */
.trust-badge-wrap {
  position: relative;
  display: inline-flex;
  align-items: center;
}
.trust-tooltip {
  position: absolute;
  bottom: calc(100% + 5px);
  left: 50%;
  transform: translateX(-50%);
  background: #1F2937;
  color: #fff;
  font-size: 11px;
  font-weight: 400;
  white-space: nowrap;
  padding: 3px 8px;
  border-radius: 4px;
  pointer-events: none;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.15s, visibility 0.15s;
  z-index: 9999;
  box-shadow: 0 2px 6px rgba(0,0,0,0.15);
  line-height: 1.4;
}
.trust-badge-wrap:hover .trust-tooltip,
.trust-badge-wrap:focus-within .trust-tooltip {
  opacity: 1;
  visibility: visible;
}
/* Allow tooltip to escape .table-wrapper's overflow scroll container */
.table-wrapper:has(.trust-badge-wrap:hover),
.table-wrapper:has(.trust-badge-wrap:focus-within) {
  overflow: visible;
}

/* ─── 状态标签 ─── */
.status-draft { background: var(--gray-100); color: var(--gray-600); }
.status-in_review { background: #DBEAFE; color: #1D4ED8; }
.status-ready_for_report { background: #D1FAE5; color: #065F46; }
.status-archived { background: var(--gray-100); color: var(--gray-600); opacity: 0.7; }

/* 严重程度 */
.severity-低 { background: #D1FAE5; color: #065F46; }
.severity-中 { background: #FEF3C7; color: #92400E; }
.severity-高 { background: #FEE2E2; color: #991B1B; }
.severity-严重 { background: #DC2626; color: #fff; }

/* ─── 进度条 ─── */
.progress-bar { background: var(--gray-100); border-radius: 4px; height: 8px; overflow: hidden; }
.progress-fill { height: 100%; border-radius: 4px; background: var(--primary); transition: width 0.3s; }

/* ─── 雷达图容器 ─── */
.chart-container { position: relative; width: 100%; max-width: 400px; margin: 0 auto; }

/* ─── 评分组件 ─── */
.score-radio-group { display: flex; gap: 8px; flex-wrap: wrap; }
.score-radio { display: none; }
.score-label {
  width: 44px; height: 44px;
  display: flex; align-items: center; justify-content: center;
  border: 2px solid var(--gray-200);
  border-radius: 8px;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s;
  color: var(--gray-600);
}
.score-radio:checked + .score-label {
  border-color: var(--primary);
  background: var(--primary);
  color: #fff;
}
.score-label:hover { border-color: var(--primary); color: var(--primary); }

/* ─── P0 Gate ─── */
.gate-pass { background: #D1FAE5; border: 1px solid #6EE7B7; border-radius: 8px; padding: 12px 16px; color: #065F46; }
.gate-fail { background: #FEE2E2; border: 1px solid #FCA5A5; border-radius: 8px; padding: 12px 16px; color: #991B1B; }

/* ─── TML Badge ─── */
.tml-badge {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: #fff;
  border-radius: 12px;
  padding: 16px 24px;
  min-width: 120px;
}
.tml-level { font-size: 32px; font-weight: 900; line-height: 1; }
.tml-label { font-size: 10px; margin-top: 4px; opacity: 0.85; text-transform: uppercase; letter-spacing: 0.05em; }
.tml-note { font-size: 9px; margin-top: 2px; opacity: 0.6; text-align: center; }

/* ─── 免责声明 ─── */
.disclaimer {
  background: #FFFBEB;
  border: 1px solid #FDE68A;
  border-radius: 6px;
  padding: 12px 16px;
  font-size: 12px;
  color: #92400E;
  margin: 16px 0;
}
.disclaimer strong { display: block; margin-bottom: 4px; }

/* ─── 模态框 ─── */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 200;
  display: flex; align-items: center; justify-content: center;
}
.modal {
  background: #fff;
  border-radius: 10px;
  max-width: 560px;
  width: 90%;
  max-height: 85vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0,0,0,0.2);
}
.modal-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--gray-200);
  display: flex; align-items: center; justify-content: space-between;
}
.modal-title { font-size: 15px; font-weight: 600; }
.modal-body { padding: 20px; }
.modal-footer { padding: 12px 20px; border-top: 1px solid var(--gray-200); display: flex; justify-content: flex-end; gap: 8px; }

/* ─── Tab 标签 ─── */
.tab-nav { display: flex; border-bottom: 2px solid var(--gray-200); margin-bottom: 20px; overflow-x: auto; }
.tab-link {
  padding: 10px 16px;
  font-size: 13px;
  font-weight: 500;
  color: var(--gray-600);
  text-decoration: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: all 0.15s;
}
.tab-link:hover { color: var(--primary); }
.tab-link.active { color: var(--primary); border-bottom-color: var(--primary); }

/* ─── 面包屑 ─── */
.breadcrumb { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--gray-600); }
.breadcrumb a { color: var(--primary); text-decoration: none; }
.breadcrumb a:hover { text-decoration: underline; }
.breadcrumb-sep { color: var(--gray-400); }

/* ─── 空状态 ─── */
.empty-state { text-align: center; padding: 48px 20px; color: var(--gray-600); }
.empty-icon { font-size: 40px; margin-bottom: 12px; }
.empty-text { font-size: 15px; font-weight: 500; margin-bottom: 4px; }
.empty-sub { font-size: 13px; color: var(--gray-400); }

/* ─── 告警 ─── */
.alert { padding: 12px 16px; border-radius: 6px; font-size: 13px; margin-bottom: 16px; }
.alert-info { background: #EFF6FF; border: 1px solid #BFDBFE; color: #1D4ED8; }
.alert-success { background: #ECFDF5; border: 1px solid #A7F3D0; color: #065F46; }
.alert-warning { background: #FFFBEB; border: 1px solid #FDE68A; color: #92400E; }
.alert-danger { background: #FEF2F2; border: 1px solid #FECACA; color: #B91C1C; }

/* ─── 小工具 ─── */
.mt-0 { margin-top: 0; }
.mt-4 { margin-top: 4px; }
.mt-8 { margin-top: 8px; }
.mt-12 { margin-top: 12px; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.mb-0 { margin-bottom: 0; }
.mb-8 { margin-bottom: 8px; }
.mb-16 { margin-bottom: 16px; }
.mb-24 { margin-bottom: 24px; }
.flex { display: flex; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.flex-center { display: flex; align-items: center; justify-content: center; }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }
.gap-16 { gap: 16px; }
.text-sm { font-size: 12px; }
.text-muted { color: var(--gray-600); }
.text-danger { color: var(--danger); }
.text-success { color: var(--success); }
.font-bold { font-weight: 600; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ─── 加载状态 ─── */
.htmx-indicator { display: none; }
.htmx-request .htmx-indicator { display: inline; }

/* ─── 响应式：隐藏侧边栏时的调整 ─── */
@media (max-width: 640px) {
  .sidebar { transform: translateX(-100%); }
  .main-content { margin-left: 0; }
}

/* ─── 表单向导容器（批次新建、其他多步骤表单）─── */
.form-container {
  max-width: 680px;
  width: 100%;
  background: #fff;
  border-radius: 12px;
  border: 1px solid var(--gray-200);
  padding: 28px 36px 32px;
  margin: 24px auto 40px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.06);
}
.form-container .form-group { margin-bottom: 20px; }
.form-container .form-label {
  display: block;
  font-weight: 600;
  font-size: 14px;
  color: var(--gray-700);
  margin-bottom: 6px;
}
.form-container .form-input,
.form-container .form-control {
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
}
.form-container select.form-input,
.form-container select.form-control { max-width: 420px; }
.form-container .form-actions {
  display: flex;
  gap: 10px;
  margin-top: 28px;
  padding-top: 20px;
  border-top: 1px solid var(--gray-100);
}

/* Step wizard progress bar */
.step-wizard {
  display: flex;
  align-items: center;
  margin-bottom: 28px;
  gap: 0;
}
.step-wizard-item {
  display: flex;
  align-items: center;
  flex: 1;
}
.step-wizard-item:last-child { flex: 0; }
.step-wizard-circle {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  flex-shrink: 0;
  background: var(--gray-200);
  color: var(--gray-500);
}
.step-wizard-circle.active {
  background: var(--primary);
  color: #fff;
}
.step-wizard-circle.done {
  background: #16a34a;
  color: #fff;
}
.step-wizard-label {
  font-size: 12px;
  margin-left: 6px;
  color: var(--gray-500);
  white-space: nowrap;
}
.step-wizard-label.active { color: var(--gray-800); font-weight: 600; }
.step-wizard-line {
  flex: 1;
  height: 2px;
  background: var(--gray-200);
  margin: 0 8px;
}
.step-wizard-line.done { background: #16a34a; }

/* Breadcrumb inside form-container */
.form-container .breadcrumb { margin-bottom: 12px; font-size: 13px; color: var(--gray-500); }
.form-container .breadcrumb a { color: var(--primary); text-decoration: none; }

@media (max-width: 768px) {
  .form-container {
    padding: 16px 16px 20px;
    margin: 8px 8px 24px;
    border-radius: 8px;
  }
  .step-wizard-label { display: none; }
  .form-container select.form-input,
  .form-container select.form-control { max-width: 100%; }
}
