/* ============================================
   厨房宝后台管理系统 - 公共样式
   ============================================ */

/* CSS 变量 */
:root {
  /* 主色 - 环保科技绿 */
  --primary: #1aad8b;
  --primary-light: #28c68a;
  --primary-dark: #0d8b6e;
  --primary-bg: #e6f7f2;

  /* 功能色 */
  --success: #00b42a;
  --warning: #ff7d00;
  --danger: #f53f3f;
  --info: #165dff;

  /* 中性色 */
  --text-primary: #1d2129;
  --text-secondary: #4e5969;
  --text-tertiary: #86909c;
  --text-disabled: #c9cdd4;
  --text-white: #ffffff;

  /* 背景 */
  --bg-page: #f5f7f8;
  --bg-card: #ffffff;
  --bg-hover: #f2f3f5;
  --bg-side: #1f2c34;
  --bg-side-hover: #2a3942;

  /* 边框 */
  --border: #e5e6eb;
  --border-light: #f2f3f5;

  /* 阴影 */
  --shadow-card: 0 1px 4px rgba(0, 0, 0, 0.04);
  --shadow-hover: 0 4px 12px rgba(0, 0, 0, 0.08);
  --shadow-modal: 0 8px 32px rgba(0, 0, 0, 0.12);

  /* 圆角 */
  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;

  /* 尺寸 */
  --side-width: 220px;
  --side-collapsed: 64px;
  --header-height: 60px;

  /* 字体 */
  --font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'PingFang SC', 'Microsoft YaHei', sans-serif;
}

/* 重置 */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-family);
  font-size: 14px;
  color: var(--text-primary);
  background: var(--bg-page);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a {
  color: var(--primary);
  text-decoration: none;
}

a:hover {
  color: var(--primary-light);
}

button {
  cursor: pointer;
  border: none;
  background: none;
  font-family: inherit;
  font-size: inherit;
}

input, select, textarea {
  font-family: inherit;
  font-size: inherit;
  outline: none;
  border: none;
}

ul, ol {
  list-style: none;
}

/* 通用文字工具 */
.text-primary { color: var(--primary); }
.text-success { color: var(--success); }
.text-warning { color: var(--warning); }
.text-danger  { color: var(--danger); }
.text-muted   { color: var(--text-tertiary); }
.text-bold    { font-weight: 600; }

.ellipsis {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ============================================
   按钮
   ============================================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 32px;
  padding: 0 16px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  transition: all 0.2s;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text-secondary);
  gap: 4px;
}

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

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

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

.btn-danger {
  background: #fff;
  border-color: var(--danger);
  color: var(--danger);
}

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

.btn-text {
  border: none;
  color: var(--primary);
  padding: 0 4px;
}

.btn-text:hover {
  color: var(--primary-light);
  background: var(--primary-bg);
}

.btn-sm { height: 26px; padding: 0 10px; font-size: 12px; }
.btn-lg { height: 40px; padding: 0 24px; font-size: 15px; }
.btn-block { display: flex; width: 100%; }

/* ============================================
   表单
   ============================================ */
.form-input,
.form-select,
.form-textarea {
  width: 100%;
  height: 32px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: #fff;
  color: var(--text-primary);
  font-size: 13px;
  transition: border-color 0.2s;
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
  border-color: var(--primary);
}

.form-input::placeholder {
  color: var(--text-tertiary);
}

.form-textarea {
  height: auto;
  padding: 8px 12px;
  resize: vertical;
  min-height: 80px;
  line-height: 1.6;
}

.form-label {
  display: block;
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.form-label .required {
  color: var(--danger);
  margin-right: 2px;
}

.form-row {
  display: flex;
  gap: 12px;
}

.form-row > * { flex: 1; }

/* ============================================
   卡片
   ============================================ */
.card {
  background: var(--bg-card);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-card);
}

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

.card-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
}

.card-body {
  padding: 20px;
}

/* ============================================
   表格
   ============================================ */
.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.table thead th {
  background: #fafbfc;
  text-align: left;
  padding: 12px 16px;
  color: var(--text-secondary);
  font-weight: 500;
  border-bottom: 1px solid var(--border-light);
  white-space: nowrap;
}

.table tbody td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-light);
  color: var(--text-primary);
}

.table tbody tr:hover {
  background: var(--bg-hover);
}

.table tbody tr:last-child td {
  border-bottom: none;
}

.table-actions {
  display: flex;
  gap: 4px;
}

/* ============================================
   标签 / Badge
   ============================================ */
.tag {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 12px;
  line-height: 1.5;
  background: var(--bg-hover);
  color: var(--text-secondary);
}

.tag-primary { background: var(--primary-bg); color: var(--primary); }
.tag-success { background: rgba(0, 180, 42, 0.1); color: var(--success); }
.tag-warning { background: rgba(255, 125, 0, 0.1); color: var(--warning); }
.tag-danger  { background: rgba(245, 63, 63, 0.1); color: var(--danger); }
.tag-info    { background: rgba(22, 93, 255, 0.1); color: var(--info); }

.dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-right: 6px;
}

.dot-online  { background: var(--success); box-shadow: 0 0 6px rgba(0,180,42,0.4); }
.dot-offline { background: var(--text-tertiary); }
.dot-error   { background: var(--danger); }

/* ============================================
   弹窗 / Modal
   ============================================ */
.modal-mask {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

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

.modal {
  background: #fff;
  border-radius: var(--radius-lg);
  width: 520px;
  max-width: 90vw;
  max-height: 86vh;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-modal);
}

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

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

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

.modal-body {
  padding: 20px;
  overflow-y: auto;
  flex: 1;
}

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

/* ============================================
   分页
   ============================================ */
.pagination {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding: 16px 20px;
  gap: 4px;
  font-size: 13px;
}

.pagination-info {
  color: var(--text-tertiary);
  margin-right: 16px;
}

.pagination button {
  min-width: 28px;
  height: 28px;
  padding: 0 8px;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text-secondary);
  border-radius: var(--radius-sm);
}

.pagination button.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

.pagination button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ============================================
   工具
   ============================================ */
.toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 16px 20px;
  background: var(--bg-card);
  border-radius: var(--radius-md) var(--radius-md) 0 0;
  border-bottom: 1px solid var(--border-light);
  flex-wrap: wrap;
}

.toolbar .spacer { flex: 1; }

/* 搜索框 */
.search-box {
  display: inline-flex;
  align-items: center;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  height: 32px;
  width: 240px;
  padding: 0 8px 0 12px;
  transition: border-color 0.2s;
}

.search-box:focus-within {
  border-color: var(--primary);
}

.search-box input {
  flex: 1;
  height: 30px;
  border: none;
  background: transparent;
  font-size: 13px;
}

.search-box input::placeholder {
  color: var(--text-tertiary);
}

.search-box .search-icon {
  color: var(--text-tertiary);
  margin-right: 6px;
}

/* ============================================
   统计卡片
   ============================================ */
.stat-card {
  background: #fff;
  border-radius: var(--radius-md);
  padding: 20px;
  display: flex;
  align-items: center;
  box-shadow: var(--shadow-card);
  transition: box-shadow 0.2s;
}

.stat-card:hover {
  box-shadow: var(--shadow-hover);
}

.stat-icon {
  width: 56px;
  height: 56px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  margin-right: 16px;
  background: var(--primary-bg);
  color: var(--primary);
  flex-shrink: 0;
}

.stat-icon.green  { background: var(--primary-bg); color: var(--primary); }
.stat-icon.blue   { background: rgba(22,93,255,0.1); color: var(--info); }
.stat-icon.orange { background: rgba(255,125,0,0.1); color: var(--warning); }
.stat-icon.red    { background: rgba(245,63,63,0.1); color: var(--danger); }
.stat-icon.purple { background: rgba(114,46,209,0.1); color: #722ed1; }

.stat-info { flex: 1; }

.stat-label {
  font-size: 13px;
  color: var(--text-tertiary);
  margin-bottom: 4px;
}

.stat-value {
  font-size: 26px;
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.2;
}

.stat-trend {
  font-size: 12px;
  color: var(--text-tertiary);
  margin-top: 4px;
}

.stat-trend .up { color: var(--success); }
.stat-trend .down { color: var(--danger); }

/* ============================================
   通用布局
   ============================================ */
.page {
  padding: 16px;
}

.page-header {
  margin-bottom: 16px;
}

.page-title {
  font-size: 20px;
  font-weight: 600;
  color: var(--text-primary);
}

.page-subtitle {
  font-size: 13px;
  color: var(--text-tertiary);
  margin-top: 4px;
}

.grid {
  display: grid;
  gap: 16px;
}

.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }

@media (max-width: 1100px) {
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
  .grid-3 { grid-template-columns: repeat(2, 1fr); }
}

.row-flex {
  display: flex;
  align-items: center;
  gap: 12px;
}

/* ============================================
   提示信息
   ============================================ */
.toast {
  position: fixed;
  top: 80px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0, 0, 0, 0.78);
  color: #fff;
  padding: 10px 20px;
  border-radius: var(--radius-md);
  font-size: 13px;
  z-index: 9999;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
}

.toast.show {
  opacity: 1;
}

.toast.success { background: var(--success); }
.toast.error   { background: var(--danger); }
.toast.warning { background: var(--warning); }

/* 空状态 */
.empty {
  padding: 60px 20px;
  text-align: center;
  color: var(--text-tertiary);
}

.empty-icon {
  font-size: 56px;
  margin-bottom: 8px;
  opacity: 0.4;
}