/* 福照护家精准营养数智系统 - 全局样式 */
:root {
  --primary: #1a73e8;
  --primary-light: #e8f0fe;
  --primary-dark: #1557b0;
  --success: #34a853;
  --success-light: #e6f4ea;
  --warning: #f9ab00;
  --warning-light: #fef7e0;
  --danger: #ea4335;
  --danger-light: #fce8e6;
  --info: #00bcd4;
  --bg: #f0f2f5;
  --card-bg: #ffffff;
  --text: #1f2937;
  --text-secondary: #6b7280;
  --text-light: #9ca3af;
  --border: #e5e7eb;
  --border-light: #f3f4f6;
  --shadow: 0 1px 3px rgba(0,0,0,0.08);
  --shadow-lg: 0 4px 12px rgba(0,0,0,0.1);
  --radius: 8px;
  --sidebar-w: 240px;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Microsoft YaHei', sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
}

/* ========== 布局 ========== */
.app { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w);
  background: linear-gradient(180deg, #1a237e 0%, #0d47a1 100%);
  color: #fff;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}

.sidebar-header {
  padding: 20px 16px;
  border-bottom: 1px solid rgba(255,255,255,0.1);
  text-align: center;
}

.sidebar-header h1 {
  font-size: 16px;
  font-weight: 700;
  margin-bottom: 4px;
}

.sidebar-header p {
  font-size: 11px;
  opacity: 0.7;
}

.sidebar-nav {
  flex: 1;
  padding: 12px 0;
}

.nav-item {
  display: flex;
  align-items: center;
  padding: 10px 20px;
  cursor: pointer;
  color: rgba(255,255,255,0.75);
  transition: all 0.2s;
  border-left: 3px solid transparent;
  gap: 10px;
  font-size: 13px;
}

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

.nav-item.active {
  background: rgba(255,255,255,0.12);
  color: #fff;
  border-left-color: #4fc3f7;
}

.nav-icon { font-size: 18px; width: 24px; text-align: center; }

.main {
  flex: 1;
  margin-left: var(--sidebar-w);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.topbar {
  background: #fff;
  padding: 0 24px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: var(--shadow);
  position: sticky;
  top: 0;
  z-index: 50;
}

.topbar-left { display: flex; align-items: center; gap: 16px; }
.topbar-title { font-size: 18px; font-weight: 600; }

.topbar-right { display: flex; align-items: center; gap: 16px; }

.branch-selector {
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #fff;
  font-size: 13px;
  cursor: pointer;
}

.content {
  padding: 24px;
  flex: 1;
}

/* ========== 卡片 ========== */
.card {
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  margin-bottom: 20px;
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.card-title {
  font-size: 16px;
  font-weight: 600;
}

/* ========== 统计卡片 ========== */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
  margin-bottom: 20px;
}

.stat-card {
  background: #fff;
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
  display: flex;
  align-items: center;
  gap: 16px;
  transition: transform 0.2s;
}

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

.stat-icon {
  width: 52px;
  height: 52px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
}

.stat-info h3 { font-size: 24px; font-weight: 700; margin-bottom: 2px; }
.stat-info p { font-size: 12px; color: var(--text-secondary); }

/* ========== 表格 ========== */
.table-wrap {
  overflow-x: auto;
  border-radius: var(--radius);
}

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

th {
  background: var(--primary-light);
  color: var(--primary-dark);
  padding: 10px 12px;
  text-align: left;
  font-weight: 600;
  white-space: nowrap;
  border-bottom: 1px solid var(--border);
}

td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border-light);
  white-space: nowrap;
}

tr:hover td { background: var(--border-light); }

/* ========== 按钮 ========== */
.btn {
  padding: 8px 16px;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  transition: all 0.2s;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-success { background: var(--success); color: #fff; }
.btn-success:hover { background: #2d9148; }
.btn-warning { background: var(--warning); color: #fff; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-outline { background: #fff; border: 1px solid var(--border); color: var(--text); }
.btn-outline:hover { background: var(--border-light); }
.btn-sm { padding: 4px 10px; font-size: 12px; }

/* ========== 标签 ========== */
.tag {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 500;
}

.tag-blue { background: var(--primary-light); color: var(--primary-dark); }
.tag-green { background: var(--success-light); color: var(--success); }
.tag-orange { background: var(--warning-light); color: #b07000; }
.tag-red { background: var(--danger-light); color: var(--danger); }
.tag-gray { background: #f3f4f6; color: #6b7280; }
.tag-purple { background: #f3e5f5; color: #7b1fa2; }

/* ========== 表单 ========== */
.form-group { margin-bottom: 16px; }
.form-label { display: block; font-size: 13px; font-weight: 500; margin-bottom: 6px; color: var(--text-secondary); }
.form-input, .form-select, .form-textarea {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 14px;
  transition: border 0.2s;
}
.form-input:focus, .form-select:focus, .form-textarea:focus {
  outline: none;
  border-color: var(--primary);
}
.form-textarea { resize: vertical; min-height: 80px; }

.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;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.modal {
  background: #fff;
  border-radius: 12px;
  width: 90%;
  max-width: 700px;
  max-height: 85vh;
  overflow-y: auto;
}

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

.modal-header h3 { font-size: 18px; }

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

.modal-body { padding: 24px; }

.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 12px;
}

/* ========== 图表容器 ========== */
.chart-container {
  width: 100%;
  height: 350px;
}

.chart-container-sm {
  width: 100%;
  height: 250px;
}

/* ========== 网格 ========== */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; }

@media (max-width: 1024px) {
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .form-row, .form-row-3 { grid-template-columns: 1fr; }
}

/* ========== 告警 ========== */
.alert {
  padding: 12px 16px;
  border-radius: 6px;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
}

.alert-warning { background: var(--warning-light); color: #b07000; border: 1px solid #f9c74f; }
.alert-danger { background: var(--danger-light); color: var(--danger); border: 1px solid #f97575; }
.alert-success { background: var(--success-light); color: var(--success); border: 1px solid #81c995; }
.alert-info { background: var(--primary-light); color: var(--primary-dark); border: 1px solid #aecbfa; }

/* ========== 进度条 ========== */
.progress-bar {
  width: 100%;
  height: 8px;
  background: var(--border-light);
  border-radius: 4px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  border-radius: 4px;
  transition: width 0.3s;
}

/* ========== 页面切换 ========== */
.page { display: none; }
.page.active { display: block; }

/* ========== 工具类 ========== */
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-muted { color: var(--text-secondary); }
.text-sm { font-size: 12px; }
.text-lg { font-size: 16px; }
.text-bold { font-weight: 700; }
.mt-2 { margin-top: 8px; }
.mt-4 { margin-top: 16px; }
.mb-2 { margin-bottom: 8px; }
.mb-4 { margin-bottom: 16px; }
.flex { display: flex; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.gap-2 { gap: 8px; }
.gap-4 { gap: 16px; }
.w-full { width: 100%; }

/* ========== 指令步骤 ========== */
.step-list { list-style: none; }
.step-item {
  display: flex;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border-light);
}
.step-num {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 13px;
  flex-shrink: 0;
}
.step-content { flex: 1; }
.step-action { font-weight: 600; margin-bottom: 4px; }
.step-params { font-size: 12px; color: var(--text-secondary); }

/* ========== 滚动条 ========== */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #c1c1c1; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #a1a1a1; }

/* ========== 可拖拉窗口面板 ========== */
.resize-container {
  display: flex;
  flex-direction: column;
  height: calc(100vh - 120px);
  gap: 0;
}

.resize-panel {
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-height: 80px;
  transition: flex-grow 0s;
}

.resize-panel .card-header {
  margin-bottom: 0;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  background: linear-gradient(180deg, #fafbfc 0%, #f5f6f8 100%);
}

.resize-panel .panel-body {
  flex: 1;
  overflow: auto;
  padding: 12px 20px 16px;
}

.resize-panel .panel-body .table-wrap {
  border-radius: 0;
}

.resize-handle {
  height: 10px;
  background: #e8eaed;
  cursor: row-resize;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  position: relative;
  transition: background 0.15s;
  z-index: 5;
}

.resize-handle::before {
  content: '';
  width: 40px;
  height: 4px;
  background: #b0b3b8;
  border-radius: 2px;
  transition: background 0.15s;
}

.resize-handle:hover {
  background: #d0d4d9;
}

.resize-handle:hover::before {
  background: var(--primary);
}

.resize-handle.dragging {
  background: var(--primary-light);
}

.resize-handle.dragging::before {
  background: var(--primary);
}

.resize-handle .handle-label {
  position: absolute;
  right: 16px;
  font-size: 11px;
  color: var(--text-light);
  pointer-events: none;
  user-select: none;
}

.resize-panel.collapsed .panel-body {
  display: none;
}

.resize-panel.collapsed .card-header {
  border-bottom: none;
}

.panel-collapse-btn {
  cursor: pointer;
  font-size: 16px;
  color: var(--text-secondary);
  padding: 2px 8px;
  border-radius: 4px;
  transition: all 0.15s;
  user-select: none;
}

.panel-collapse-btn:hover {
  background: var(--border-light);
  color: var(--primary);
}
