/* ============================================================
   蓝海矿业内部管理系统 - 全局样式 (响应式)
   ============================================================ */
:root {
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --primary-light: #dbeafe;
  --success: #16a34a;
  --warning: #ea580c;
  --danger: #dc2626;
  --info: #0891b2;
  --bg: #f1f5f9;
  --card-bg: #ffffff;
  --text: #1e293b;
  --text-light: #64748b;
  --text-lighter: #94a3b8;
  --border: #e2e8f0;
  --border-light: #f1f5f9;
  --shadow: 0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.04);
  --shadow-lg: 0 10px 25px rgba(0,0,0,.08), 0 4px 6px rgba(0,0,0,.04);
  --radius: 8px;
  --sidebar-w: 240px;
  --sidebar-w-collapsed: 64px;
  --header-h: 60px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-dark); }
button { font-family: inherit; cursor: pointer; }
input, select, textarea { font-family: inherit; font-size: 14px; }

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

/* 侧边栏 */
.sidebar {
  width: var(--sidebar-w);
  background: linear-gradient(180deg, #1e293b 0%, #0f172a 100%);
  color: #cbd5e1;
  position: fixed; top: 0; left: 0; bottom: 0;
  display: flex; flex-direction: column;
  z-index: 100;
  transition: width .2s;
  overflow-y: auto;
}
.sidebar-brand {
  height: var(--header-h);
  display: flex; align-items: center; gap: 10px;
  padding: 0 20px;
  color: #fff; font-size: 18px; font-weight: 600;
  border-bottom: 1px solid rgba(255,255,255,.08);
  white-space: nowrap; overflow: hidden;
}
.sidebar-brand .logo { font-size: 24px; }
.sidebar-menu { flex: 1; padding: 12px 0; }
.sidebar-menu .menu-item {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 20px;
  color: #cbd5e1;
  font-size: 14px;
  border-left: 3px solid transparent;
  transition: all .15s;
  white-space: nowrap; overflow: hidden;
}
.sidebar-menu .menu-item:hover { background: rgba(255,255,255,.06); color: #fff; }
.sidebar-menu .menu-item.active {
  background: rgba(37,99,235,.2);
  border-left-color: var(--primary);
  color: #fff;
}
.sidebar-menu .menu-item .icon { font-size: 18px; width: 24px; text-align: center; flex-shrink: 0; }
.sidebar-menu .menu-group-title {
  padding: 16px 20px 6px;
  font-size: 11px; color: #64748b;
  text-transform: uppercase; letter-spacing: 1px;
}

/* 主内容 */
.main-content {
  flex: 1; margin-left: var(--sidebar-w);
  display: flex; flex-direction: column;
  min-height: 100vh;
}
.top-header {
  height: var(--header-h);
  background: var(--card-bg);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 24px;
  position: sticky; top: 0; z-index: 50;
  box-shadow: 0 1px 2px rgba(0,0,0,.03);
}
.top-header .page-title { font-size: 16px; font-weight: 600; }
.top-header .header-right { display: flex; align-items: center; gap: 16px; }
.user-info { display: flex; align-items: center; gap: 8px; cursor: pointer; }
.user-avatar {
  width: 34px; height: 34px; border-radius: 50%;
  background: var(--primary); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 14px; font-weight: 600;
}
.content-body { flex: 1; padding: 24px; }

/* ==================== 卡片 ==================== */
.card {
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid var(--border-light);
}
.card-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-light);
  display: flex; align-items: center; justify-content: space-between;
}
.card-header h3 { font-size: 15px; font-weight: 600; }
.card-body { padding: 20px; }

/* ==================== 统计卡片 ==================== */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 16px; margin-bottom: 24px;
}
.stat-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border-light);
  display: flex; align-items: center; gap: 16px;
  transition: transform .15s, box-shadow .15s;
}
.stat-card { cursor: pointer; }
.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }
.stat-card .stat-icon {
  width: 52px; height: 52px; border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 24px; flex-shrink: 0;
}
.stat-icon.blue { background: #dbeafe; color: #2563eb; }
.stat-icon.green { background: #dcfce7; color: #16a34a; }
.stat-icon.orange { background: #ffedd5; color: #ea580c; }
.stat-icon.red { background: #fee2e2; color: #dc2626; }
.stat-icon.purple { background: #f3e8ff; color: #9333ea; }
.stat-icon.cyan { background: #cffafe; color: #0891b2; }
.stat-card .stat-info .stat-value { font-size: 24px; font-weight: 700; color: var(--text); }
.stat-card .stat-info .stat-label { font-size: 13px; color: var(--text-light); margin-top: 2px; }

/* ==================== 表格 ==================== */
.table-toolbar {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 16px; flex-wrap: wrap; gap: 12px;
}
.table-toolbar .toolbar-left { display: flex; gap: 8px; flex-wrap: wrap; }
.table-toolbar .toolbar-right { display: flex; gap: 8px; flex-wrap: wrap; }
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.data-table th {
  background: #f8fafc;
  text-align: left;
  padding: 12px 14px;
  font-weight: 600;
  color: var(--text-light);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.data-table td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border-light);
  color: var(--text);
}
.data-table tbody tr:hover { background: #f8fafc; }
.data-table .text-right { text-align: right; }
.data-table .text-center { text-align: center; }

/* ==================== 分页 ==================== */
.pagination {
  display: flex; align-items: center; justify-content: flex-end;
  gap: 4px; margin-top: 16px;
}
.pagination button {
  min-width: 32px; height: 32px;
  border: 1px solid var(--border);
  background: #fff;
  border-radius: 6px;
  padding: 0 8px;
  font-size: 13px;
  color: var(--text);
}
.pagination button:hover:not(:disabled) { border-color: var(--primary); color: var(--primary); }
.pagination button.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.pagination button:disabled { opacity: .5; cursor: not-allowed; }

/* ==================== 表单 ==================== */
.form-group { margin-bottom: 16px; }
.form-group label {
  display: block; margin-bottom: 6px;
  font-size: 13px; font-weight: 500; color: var(--text);
}
.form-group label .req { color: var(--danger); margin-left: 2px; }
.form-control {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 14px;
  background: #fff;
  color: var(--text);
  transition: border-color .15s, box-shadow .15s;
}
.form-control:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37,99,235,.12);
}
.form-control:disabled { background: #f8fafc; cursor: not-allowed; }
textarea.form-control { min-height: 80px; resize: vertical; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

/* ==================== 按钮 ==================== */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 16px;
  border: 1px solid var(--border);
  background: #fff;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  transition: all .15s;
  white-space: nowrap;
}
.btn:hover { border-color: var(--text-light); }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); }
.btn-success { background: var(--success); border-color: var(--success); color: #fff; }
.btn-success:hover { background: #15803d; }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-danger:hover { background: #b91c1c; }
.btn-warning { background: var(--warning); border-color: var(--warning); color: #fff; }
.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn-lg { padding: 12px 24px; font-size: 15px; }
.btn-block { width: 100%; justify-content: center; }

/* ==================== 标签/徽章 ==================== */
.badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 500;
}
.badge-success { background: #dcfce7; color: #16a34a; }
.badge-warning { background: #ffedd5; color: #ea580c; }
.badge-danger { background: #fee2e2; color: #dc2626; }
.badge-info { background: #e0f2fe; color: #0284c7; }
.badge-default { background: #f1f5f9; color: #64748b; }
.badge-primary { background: #dbeafe; color: #2563eb; }

/* ==================== 弹窗 ==================== */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.45);
  display: none; align-items: center; justify-content: center;
  z-index: 1000; padding: 20px;
}
.modal-overlay.active { display: flex; }
.modal {
  background: #fff;
  border-radius: var(--radius);
  width: 100%; max-width: 560px;
  max-height: 90vh; overflow-y: auto;
  box-shadow: var(--shadow-lg);
}
.modal.modal-lg { max-width: 800px; }
.modal-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-light);
  display: flex; align-items: center; justify-content: space-between;
}
.modal-header h3 { font-size: 16px; font-weight: 600; }
.modal-close { font-size: 22px; color: var(--text-light); cursor: pointer; line-height: 1; background: none; border: none; }
.modal-body { padding: 20px; }
.modal-footer {
  padding: 16px 20px;
  border-top: 1px solid var(--border-light);
  display: flex; justify-content: flex-end; gap: 8px;
}

/* ==================== 提示 ==================== */
.alert {
  padding: 12px 16px;
  border-radius: 6px;
  margin-bottom: 16px;
  display: flex; align-items: center; gap: 8px;
  font-size: 13px;
}
.alert-info { background: #e0f2fe; color: #075985; border: 1px solid #bae6fd; }
.alert-success { background: #dcfce7; color: #166534; border: 1px solid #bbf7d0; }
.alert-warning { background: #ffedd5; color: #9a3412; border: 1px solid #fed7aa; }
.alert-danger { background: #fee2e2; color: #991b1b; border: 1px solid #fecaca; }

/* ==================== 空状态 ==================== */
.empty-state {
  text-align: center; padding: 48px 20px;
  color: var(--text-lighter);
}
.empty-state .icon { font-size: 48px; margin-bottom: 12px; }

/* ==================== 加载 ==================== */
.loading { text-align: center; padding: 40px; color: var(--text-light); }
.spinner {
  display: inline-block; width: 24px; height: 24px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Toast 滑入动画 (app.js showToast 使用, 全局定义避免仅 settings.html 单页可用) */
@keyframes slideIn {
  from { transform: translateX(120%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

/* ==================== 登录页 ==================== */
.login-page {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  /* 矿山行业背景图 (72KB WebP), 渐变色作为加载中的兜底 */
  background: linear-gradient(135deg, #3a2f28 0%, #4a3728 30%, #2d2419 70%, #1a1410 100%);
  background-image: url('../img/mining-bg.webp');
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  background-attachment: fixed;
  padding: 20px;
  position: relative; overflow: hidden;
}
/* 深色叠加层提高文字可读性 */
.login-page::before {
  content: ''; position: absolute; inset: 0;
  background: linear-gradient(135deg, rgba(10,5,0,.65) 0%, rgba(20,15,10,.55) 50%, rgba(5,2,0,.7) 100%);
  z-index: 0;
}
.login-card {
  background: rgba(255,255,255,.93);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-radius: 16px;
  padding: 40px;
  width: 100%; max-width: 400px;
  box-shadow: 0 20px 60px rgba(0,0,0,.35);
  position: relative; z-index: 1;
}
.login-card .login-logo {
  text-align: center; margin-bottom: 28px;
}
.login-card .login-logo .icon { font-size: 48px; }
.login-card h2 { text-align: center; font-size: 22px; margin-bottom: 8px; }
.login-card .subtitle { text-align: center; color: var(--text-light); margin-bottom: 28px; font-size: 13px; }
.login-card .form-control { padding: 10px 14px; }
.login-card .input-group { position: relative; }
.login-card .input-group .input-icon {
  position: absolute; left: 12px; top: 50%; transform: translateY(-50%);
  color: var(--text-lighter); font-size: 16px; z-index: 1;
}
.login-card .input-group .form-control { padding-left: 38px; }

/* 移动端背景优化: 切换为固定滚动 */
@media (max-width: 768px) {
  .login-page {
    background-attachment: scroll;
    background-size: auto 100%;
  }
  .login-card { padding: 28px 20px; }
}

/* ==================== 扫码页 ==================== */
.scan-page {
  min-height: 100vh; background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
  display: flex; align-items: center; justify-content: center; padding: 20px;
}
.scan-card {
  background: #fff; border-radius: 16px; padding: 32px;
  width: 100%; max-width: 480px; text-align: center;
  box-shadow: 0 20px 60px rgba(0,0,0,.3);
}
.scan-card .scan-icon { font-size: 56px; margin-bottom: 16px; }
.scan-card h2 { font-size: 20px; margin-bottom: 8px; }
.scan-card .scan-status {
  margin-top: 20px; padding: 16px; border-radius: 8px;
  font-size: 14px; text-align: left;
}
.scan-result-card {
  margin-top: 16px; padding: 16px; border-radius: 8px;
  background: #f8fafc; text-align: left; font-size: 13px;
}
.scan-result-card .row { display: flex; justify-content: space-between; padding: 4px 0; }
.scan-result-card .row .label { color: var(--text-light); }

/* ==================== 响应式 ==================== */
@media (max-width: 992px) {
  .sidebar { width: var(--sidebar-w-collapsed); }
  .sidebar-brand span, .sidebar-menu .menu-item span:not(.icon) { display: none; }
  .sidebar-menu .menu-item { justify-content: center; padding: 14px 0; }
  .sidebar-menu .menu-group-title { display: none; }
  .main-content { margin-left: var(--sidebar-w-collapsed); }
}
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); transition: transform .25s; }
  .sidebar.show { transform: translateX(0); width: var(--sidebar-w); }
  .sidebar.show span, .sidebar.show .menu-item span:not(.icon) { display: inline; }
  .sidebar.show .menu-item { justify-content: flex-start; padding: 12px 20px; }
  .main-content { margin-left: 0; }
  .content-body { padding: 16px; }
  .form-row { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .data-table { font-size: 12px; }
  .data-table th, .data-table td { padding: 8px 10px; }
  .top-header { padding: 0 16px; }
  .menu-toggle { display: flex !important; }
}
@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr; }
  .table-toolbar { flex-direction: column; align-items: stretch; }
  .toolbar-left, .toolbar-right { width: 100%; }
  .toolbar-left > *, .toolbar-right > * { flex: 1; }
}

/* 移动端菜单按钮 */
.menu-toggle {
  display: none;
  width: 36px; height: 36px;
  border: 1px solid var(--border); background: #fff;
  border-radius: 6px; align-items: center; justify-content: center;
  font-size: 18px; cursor: pointer;
}

/* 图表容器 */
.chart-container { position: relative; height: 280px; }
.chart-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 768px) { .chart-grid { grid-template-columns: 1fr; } }

/* 文本工具类 */
.text-muted { color: var(--text-light); }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.text-warning { color: var(--warning); }
.text-primary { color: var(--primary); }
.fw-bold { font-weight: 600; }
.text-center { text-align: center; }
.text-right { text-align: right; }
.mt-0 { margin-top: 0; } .mt-2 { margin-top: 8px; } .mt-4 { margin-top: 16px; }
.mb-0 { margin-bottom: 0; } .mb-2 { margin-bottom: 8px; } .mb-4 { margin-bottom: 16px; }
.d-flex { display: flex; } .gap-2 { gap: 8px; } .gap-4 { gap: 16px; }
.align-center { align-items: center; }

/* ==================== 通知铃铛 ==================== */
.notif-bell {
  position: relative; cursor: pointer;
  font-size: 20px; padding: 6px;
  border-radius: 8px; transition: background .15s;
}
.notif-bell:hover { background: #f1f5f9; }
.notif-badge {
  position: absolute; top: -2px; right: -2px;
  background: var(--danger); color: #fff;
  min-width: 18px; height: 18px;
  border-radius: 9px;
  font-size: 10px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  padding: 0 4px;
  border: 2px solid #fff;
}

/* 通知项 */
.notif-item {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 12px; border-bottom: 1px solid var(--border-light);
  cursor: pointer; transition: background .1s;
  position: relative;
}
.notif-item:hover { background: #f8fafc; }
.notif-item.read { opacity: .6; }
.notif-item .notif-type {
  font-size: 20px; flex-shrink: 0; width: 36px; text-align: center;
}
.notif-item .notif-body { flex: 1; }
.notif-item .notif-title { font-weight: 600; font-size: 14px; margin-bottom: 2px; }
.notif-item .notif-content { color: var(--text-light); font-size: 13px; }
.notif-item .notif-time { color: var(--text-lighter); font-size: 11px; margin-top: 4px; }
.notif-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--danger); flex-shrink: 0; margin-top: 6px;
}

/* 库存预警卡片 */
.alert-card {
  padding: 16px; border-radius: 8px;
  border-left: 4px solid var(--warning);
  background: #fff;
  box-shadow: var(--shadow);
}
.alert-card.danger { border-left-color: var(--danger); }
.alert-card.warning { border-left-color: var(--warning); }
.alert-card.info { border-left-color: var(--info); }
