/* ==========================================================================
   AI视觉SOP合规检测平台 - 全局与组件样式表 (Style System)
   ========================================================================== */

:root {
  --primary-color: #1677ff;
  --primary-hover: #4096ff;
  --primary-bg: #e6f4ff;
  --header-bg: #1c2333;
  --sidebar-bg: #f8fafc;
  --body-bg: #f0f2f5;
  --card-bg: #ffffff;
  --text-main: #1f2937;
  --text-muted: #64748b;
  --border-color: #e2e8f0;
  --border-radius: 8px;
  --success-color: #52c41a;
  --warning-color: #faad14;
  --danger-color: #ff4d4f;
  --danger-bg: #fff1f0;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.05);
  --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.08);
}

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

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background-color: var(--body-bg);
  color: var(--text-main);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* 1. 顶部全局导航栏 (Global Header) */
.global-header {
  height: 56px;
  background-color: var(--header-bg);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 1000;
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}

.header-left {
  display: flex;
  align-items: center;
  gap: 32px;
}

.platform-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 17px;
  letter-spacing: 0.5px;
}

.logo-icon {
  font-size: 20px;
}

.nav-menu {
  display: flex;
  align-items: center;
  gap: 6px;
}

.nav-item {
  padding: 0 14px;
  height: 56px;
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 14px;
  color: #cbd5e1;
  cursor: pointer;
  transition: all 0.2s;
  position: relative;
}

.nav-item:hover, .nav-item.active {
  color: #ffffff;
  background-color: rgba(255, 255, 255, 0.08);
}

.nav-item.active::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 3px;
  background-color: var(--primary-color);
}

.nav-item .arrow {
  font-size: 10px;
  color: #94a3b8;
}

/* 下拉菜单 */
.nav-item.dropdown {
  position: relative;
}

.dropdown-menu {
  display: none;
  position: absolute;
  top: 56px;
  left: 0;
  background-color: #242c40;
  min-width: 140px;
  box-shadow: 0 6px 16px rgba(0,0,0,0.3);
  border-radius: 0 0 6px 6px;
  overflow: hidden;
  z-index: 100;
}

.nav-item.dropdown:hover .dropdown-menu {
  display: block;
}

.dropdown-item {
  padding: 12px 18px;
  color: #cbd5e1;
  font-size: 13px;
  transition: background 0.2s;
}

.dropdown-item:hover, .dropdown-item.active {
  background-color: var(--primary-color);
  color: #fff;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 20px;
  font-size: 13px;
  color: #94a3b8;
}

.header-lang-switch, .user-profile, .logout-btn, .header-action-icon {
  cursor: pointer;
  transition: color 0.2s;
}

.header-lang-switch:hover, .user-profile:hover, .logout-btn:hover {
  color: #fff;
}

/* 2. 主容器与视图控制 */
.main-container {
  flex: 1;
  padding: 20px 24px;
  max-width: 1600px;
  width: 100%;
  margin: 0 auto;
}

.app-view {
  display: none;
}

.app-view.active {
  display: block;
  animation: fadeIn 0.25s ease-in-out;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

.breadcrumb-bar {
  font-size: 14px;
  color: var(--text-muted);
  margin-bottom: 16px;
  font-weight: 500;
}

.content-card {
  background: var(--card-bg);
  border-radius: var(--border-radius);
  padding: 20px;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border-color);
  margin-bottom: 20px;
}

/* 3. 首页大盘 (Dashboard) 模块 */
.dashboard-header-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.section-title {
  font-size: 16px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
}

.dashboard-controls {
  display: flex;
  align-items: center;
  gap: 16px;
}

.btn-group-toggle {
  display: flex;
  background: #e2e8f0;
  padding: 2px;
  border-radius: 6px;
}

.toggle-btn {
  border: none;
  background: transparent;
  padding: 4px 14px;
  font-size: 13px;
  border-radius: 4px;
  cursor: pointer;
  color: var(--text-muted);
  transition: all 0.2s;
}

.toggle-btn.active {
  background: var(--primary-color);
  color: #fff;
  font-weight: 500;
}

.update-time {
  font-size: 12px;
  color: var(--text-muted);
}

.kpi-card-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 16px;
  margin-bottom: 20px;
}

.kpi-card {
  background: var(--card-bg);
  border-radius: var(--border-radius);
  padding: 18px 20px;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
  transition: transform 0.2s, box-shadow 0.2s;
}

.kpi-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.kpi-label {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.kpi-value {
  font-size: 26px;
  font-weight: 700;
  line-height: 1.1;
  margin-bottom: 6px;
}

.kpi-subtext {
  font-size: 12px;
  color: var(--text-muted);
}

.trend-zero {
  color: var(--text-muted);
}

.kpi-badge {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
}

.badge-blue { background: #e6f4ff; color: var(--primary-color); }
.badge-red { background: #fff1f0; color: var(--danger-color); }

.text-blue { color: var(--primary-color); }
.text-red { color: var(--danger-color); }
.text-orange { color: var(--warning-color); }
.text-green { color: var(--success-color); }

/* 下半部分 5 大卡片 */
.bottom-widgets-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}

.bottom-widgets-grid .content-card:nth-child(4) {
  grid-column: span 2;
}

.card-header {
  font-size: 15px;
  font-weight: 600;
  padding-bottom: 12px;
  margin-bottom: 12px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  gap: 8px;
}

.top5-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 0;
  font-size: 13px;
  border-bottom: 1px dashed #f1f5f9;
}

.top5-rank {
  font-weight: 700;
  margin-right: 8px;
  color: var(--primary-color);
}

.alert-item {
  font-size: 13px;
  padding: 6px 0;
  display: flex;
  align-items: center;
  gap: 8px;
}

.alert-item .time {
  margin-left: auto;
  color: var(--text-muted);
  font-size: 11px;
}

.tag-red {
  background: #fff1f0;
  color: #ff4d4f;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
}

.tag-orange {
  background: #fffbe6;
  color: #faad14;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
}

/* 4. 表格与通用过滤栏 */
.filter-action-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  gap: 12px;
}

.filter-inputs {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.input-text, .select-input, .textarea-input {
  border: 1px solid var(--border-color);
  border-radius: 6px;
  padding: 8px 12px;
  font-size: 13px;
  outline: none;
  transition: border-color 0.2s;
  background: #fff;
}

.input-text:focus, .select-input:focus, .textarea-input:focus {
  border-color: var(--primary-color);
  box-shadow: 0 0 0 2px rgba(22, 119, 255, 0.1);
}

.textarea-input {
  width: 100%;
  min-height: 80px;
  resize: vertical;
}

.input-wrapper {
  position: relative;
  width: 100%;
}

.char-count {
  position: absolute;
  right: 10px;
  bottom: 8px;
  font-size: 12px;
  color: #94a3b8;
}

.btn {
  padding: 8px 16px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all 0.2s;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.btn-primary { background: var(--primary-color); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); }

.btn-default { background: #fff; border-color: var(--border-color); color: var(--text-main); }
.btn-default:hover { border-color: var(--primary-color); color: var(--primary-color); }

.btn-outline { background: transparent; border-color: var(--border-color); color: var(--text-main); }
.btn-outline:hover { border-color: var(--primary-color); color: var(--primary-color); }

.btn-dark-blue { background: #1d39c4; color: #fff; }
.btn-light-red { background: #ffccc7; color: #cf1322; }
.btn-danger { background: #ff4d4f; color: #fff; }

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.data-table th {
  background: #f8fafc;
  color: var(--text-muted);
  font-weight: 600;
  text-align: left;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border-color);
}

.data-table td {
  padding: 14px;
  border-bottom: 1px solid var(--border-color);
}

.data-table tr:hover td {
  background: #f8fafc;
}

.action-icon-btn {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 14px;
  padding: 4px;
  margin-right: 6px;
  color: var(--text-muted);
  transition: color 0.2s;
}

.action-icon-btn:hover {
  color: var(--primary-color);
}

.status-badge {
  padding: 3px 8px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 500;
}

.badge-running { background: #e6f4ff; color: #1677ff; }
.badge-success { background: #f6ffed; color: #52c41a; }
.badge-notstarted { background: #f0f2f5; color: #64748b; }

/* 5. 新增任务配置 (左表单 + 右ROI) */
.double-column-layout {
  display: grid;
  grid-template-columns: 1fr 1.3fr;
  gap: 24px;
}

.form-title {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 16px;
}

.form-item {
  margin-bottom: 16px;
}

.form-label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  margin-bottom: 6px;
}

.form-label.required::before {
  content: '* ';
  color: var(--danger-color);
}

.input-text.disabled {
  background: #f8fafc;
  color: #94a3b8;
  cursor: not-allowed;
}

.video-roi-panel {
  display: flex;
  flex-direction: column;
}

.roi-controls {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
  font-size: 13px;
}

.video-canvas-container {
  background: #0f172a;
  border-radius: 6px;
  overflow: hidden;
  height: 315px;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}

.video-placeholder-text {
  color: #64748b;
  font-size: 14px;
  position: absolute;
  pointer-events: none;
}

#roiDrawerCanvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  cursor: crosshair;
}

.form-footer-actions {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 16px;
}

/* 6. SOP 低代码画布工作台 (X6 Studio) */
.studio-header-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.studio-layout-container {
  display: grid;
  grid-template-columns: 240px 1fr;
  height: calc(100vh - 180px);
  min-height: 580px;
  background: #fff;
  border-radius: var(--border-radius);
  border: 1px solid var(--border-color);
  overflow: hidden;
}

.palette-sidebar {
  background: #f8fafc;
  border-right: 1px solid var(--border-color);
  padding: 14px;
  overflow-y: auto;
}

.palette-group-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 8px;
  margin-top: 12px;
}

.palette-group:first-child .palette-group-title {
  margin-top: 0;
}

.palette-items-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.palette-item {
  background: #fff;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  padding: 8px 10px;
  font-size: 12px;
  cursor: grab;
  display: flex;
  align-items: center;
  gap: 6px;
  box-shadow: var(--shadow-sm);
  transition: all 0.2s;
  user-select: none;
}

.palette-item:hover {
  border-color: var(--primary-color);
  color: var(--primary-color);
  transform: translateY(-1px);
}

.canvas-main-area {
  display: flex;
  flex-direction: column;
  position: relative;
}

.canvas-toolbar {
  height: 44px;
  border-bottom: 1px solid var(--border-color);
  padding: 0 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: #ffffff;
}

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

.toolbar-buttons {
  display: flex;
  gap: 6px;
}

.tool-btn {
  background: #fff;
  border: 1px solid var(--border-color);
  border-radius: 4px;
  padding: 4px 10px;
  font-size: 12px;
  cursor: pointer;
  transition: all 0.2s;
}

.tool-btn:hover {
  border-color: var(--primary-color);
  color: var(--primary-color);
}

.grid-canvas {
  flex: 1;
  background-color: #fafafa;
  background-image: linear-gradient(#e2e8f0 1px, transparent 1px), linear-gradient(90deg, #e2e8f0 1px, transparent 1px);
  background-size: 20px 20px;
  position: relative;
  overflow: hidden;
}

.canvas-node {
  position: absolute;
  width: 160px;
  background: #fff;
  border: 2px solid #94a3b8;
  border-radius: 6px;
  padding: 10px 12px;
  box-shadow: var(--shadow-md);
  cursor: move;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 500;
  user-select: none;
  z-index: 10;
}

.canvas-node.node-start { border-color: #52c41a; }
.canvas-node.node-alert { border-color: #ff4d4f; }
.canvas-node.node-algo { border-color: #1677ff; }

.minimap-box {
  position: absolute;
  right: 14px;
  bottom: 14px;
  width: 140px;
  height: 90px;
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid var(--border-color);
  border-radius: 4px;
  box-shadow: var(--shadow-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  color: var(--text-muted);
}

/* 7. 算法管理 Tab */
.algo-category-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 8px;
}

.tab-item {
  padding: 6px 14px;
  font-size: 13px;
  cursor: pointer;
  border-radius: 4px;
  color: var(--text-muted);
  transition: all 0.2s;
}

.tab-item:hover, .tab-item.active {
  background: var(--primary-bg);
  color: var(--primary-color);
  font-weight: 600;
}

/* 8. 模态弹窗 (Modals) */
.modal-overlay {
  display: none;
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0, 0, 0, 0.45);
  z-index: 2000;
  align-items: center;
  justify-content: center;
}

.modal-overlay.active {
  display: flex;
}

.modal-card {
  background: #fff;
  border-radius: 8px;
  width: 480px;
  max-width: 90%;
  box-shadow: 0 10px 25px rgba(0,0,0,0.2);
  overflow: hidden;
  animation: modalPop 0.2s ease-out;
}

.modal-card.modal-large {
  width: 620px;
}

@keyframes modalPop {
  from { transform: scale(0.92); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

.modal-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-title {
  font-size: 15px;
  font-weight: 600;
}

.modal-close {
  cursor: pointer;
  font-size: 16px;
  color: var(--text-muted);
}

.modal-body {
  padding: 20px;
}

.modal-footer {
  padding: 12px 20px;
  background: #f8fafc;
  border-top: 1px solid var(--border-color);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.switch-item {
  display: flex;
  align-items: center;
  gap: 10px;
}

.toggle-switch {
  position: relative;
  display: inline-block;
  width: 38px;
  height: 20px;
}

.toggle-switch input { opacity: 0; width: 0; height: 0; }

.slider {
  position: absolute;
  cursor: pointer;
  top: 0; left: 0; right: 0; bottom: 0;
  background-color: #cbd5e1;
  transition: .3s;
  border-radius: 20px;
}

.slider:before {
  position: absolute;
  content: "";
  height: 14px;
  width: 14px;
  left: 3px;
  bottom: 3px;
  background-color: white;
  transition: .3s;
  border-radius: 50%;
}

input:checked + .slider { background-color: var(--primary-color); }
input:checked + .slider:before { transform: translateX(18px); }

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

.drop-upload-zone {
  border: 2px dashed #cbd5e1;
  border-radius: 8px;
  padding: 36px 20px;
  text-align: center;
  background: #f8fafc;
  cursor: pointer;
  transition: border-color 0.2s;
}

.drop-upload-zone:hover {
  border-color: var(--primary-color);
}

.upload-cloud-icon { font-size: 38px; margin-bottom: 8px; color: #94a3b8; }
.upload-main-text { font-size: 14px; font-weight: 500; margin-bottom: 4px; }
.upload-sub-text { font-size: 12px; color: #94a3b8; }
.text-link { color: var(--primary-color); text-decoration: underline; }
