/* ================================================================
   实验室零件共享管理系统 - 样式表
   风格：简洁工科风
   ================================================================ */

/* ==================== CSS 变量 ==================== */
:root {
  --bg-primary:   #f5f6f8;
  --bg-white:     #ffffff;
  --text-primary: #1a1a2e;
  --text-secondary: #555;
  --text-muted:   #999;
  --border:       #e0e2e6;
  --border-dark:  #c0c4cc;
  --accent:       #2563eb;
  --accent-hover: #1d4ed8;
  --accent-light: #eff6ff;
  --success:      #16a34a;
  --success-light:#f0fdf4;
  --warning:      #d97706;
  --warning-light:#fffbeb;
  --danger:       #dc2626;
  --danger-light: #fef2f2;
  --radius:       6px;
  --shadow:       0 1px 3px rgba(0,0,0,0.08);
  --shadow-lg:    0 4px 12px rgba(0,0,0,0.12);
  --font:         -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono:    "SF Mono", "Fira Code", Consolas, "Courier New", monospace;
}

/* ==================== 基础重置 ==================== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: var(--font);
  font-size: 14px;
  color: var(--text-primary);
  background: var(--bg-primary);
  line-height: 1.6;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ==================== 工具类 ==================== */
.hidden { display: none !important; }
.mono { font-family: var(--font-mono); }

/* ==================== 按钮 ==================== */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  font-size: 14px;
  font-weight: 500;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-white);
  color: var(--text-primary);
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
  text-decoration: none;
}
.btn:hover { background: #f0f1f3; border-color: var(--border-dark); text-decoration: none; }
.btn:active { transform: scale(0.98); }

.btn-primary   { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn-success   { background: var(--success); color: #fff; border-color: var(--success); }
.btn-success:hover { background: #15803d; border-color: #15803d; }
.btn-danger    { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn-danger:hover  { background: #b91c1c; border-color: #b91c1c; }
.btn-warning   { background: var(--warning); color: #fff; border-color: var(--warning); }
.btn-warning:hover { background: #b45309; border-color: #b45309; }

.btn-sm     { padding: 4px 10px; font-size: 12px; }
.btn-block  { display: flex; width: 100%; justify-content: center; }

/* ==================== 表单 ==================== */
.form-group { margin-bottom: 16px; }

.form-group label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.form-group label .required { color: var(--danger); margin-left: 2px; }

.form-control {
  width: 100%;
  padding: 8px 12px;
  font-size: 14px;
  font-family: inherit;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-white);
  color: var(--text-primary);
  transition: border-color 0.15s;
}
.form-control:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}
select.form-control { cursor: pointer; }

.form-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
}

.form-hint { font-size: 12px; color: var(--text-muted); margin-top: 2px; }

/* ==================== 卡片 ==================== */
.card {
  background: var(--bg-white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.card-header {
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  font-weight: 600;
  font-size: 15px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.card-body { padding: 20px; }

/* ==================== 表格 ==================== */
.table-wrapper { overflow-x: auto; }

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

table th {
  background: #f8f9fa;
  padding: 10px 12px;
  text-align: left;
  font-weight: 600;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-secondary);
  border-bottom: 2px solid var(--border);
  white-space: nowrap;
}

table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

table tr:hover td { background: #f8f9fa; }

/* ==================== 标签 ==================== */
.tag {
  display: inline-block;
  padding: 2px 8px;
  font-size: 12px;
  font-weight: 500;
  border-radius: 4px;
  white-space: nowrap;
}
.tag-blue   { background: var(--accent-light); color: var(--accent); }
.tag-green  { background: var(--success-light); color: var(--success); }
.tag-yellow { background: var(--warning-light); color: var(--warning); }
.tag-red    { background: var(--danger-light); color: var(--danger); }
.tag-gray   { background: #f3f4f6; color: #6b7280; }

/* ==================== 数量徽章 ==================== */
.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 24px;
  height: 24px;
  padding: 0 8px;
  font-size: 12px;
  font-weight: 600;
  border-radius: 12px;
  background: var(--accent-light);
  color: var(--accent);
}

/* ==================== 导航栏 ==================== */
.navbar {
  background: var(--bg-white);
  border-bottom: 1px solid var(--border);
  padding: 0 20px;
  display: flex;
  align-items: center;
  height: 56px;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow);
}

.navbar-brand {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-primary);
  margin-right: 32px;
  white-space: nowrap;
}

.navbar-menu {
  display: flex;
  gap: 4px;
  flex: 1;
}

.navbar-menu a {
  padding: 8px 14px;
  font-size: 14px;
  color: var(--text-secondary);
  border-radius: var(--radius);
  text-decoration: none;
  transition: all 0.15s;
}
.navbar-menu a:hover   { background: #f0f1f3; color: var(--text-primary); text-decoration: none; }
.navbar-menu a.active   { background: var(--accent-light); color: var(--accent); font-weight: 600; }

.navbar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  white-space: nowrap;
}
.navbar-user .username { font-size: 14px; font-weight: 500; }

.navbar-toggle {
  display: none;
  background: none;
  border: none;
  font-size: 20px;
  cursor: pointer;
  padding: 4px;
}

/* ==================== 主区域 ==================== */
.main {
  max-width: 1200px;
  margin: 0 auto;
  padding: 24px 20px;
}

/* ==================== 统计卡片 ==================== */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--bg-white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  text-align: center;
  box-shadow: var(--shadow);
}

.stat-card .stat-value {
  font-size: 32px;
  font-weight: 700;
  font-family: var(--font-mono);
  color: var(--accent);
  line-height: 1.2;
}

.stat-card .stat-label {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 4px;
}

.stat-card.stat-success .stat-value { color: var(--success); }
.stat-card.stat-warning .stat-value { color: var(--warning); }
.stat-card.stat-danger  .stat-value { color: var(--danger); }

/* ==================== 筛选栏 ==================== */
.filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: flex-end;
}
.filter-bar .form-group { margin-bottom: 0; flex: 1; min-width: 140px; }

/* ==================== 页面标题 ==================== */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  flex-wrap: wrap;
  gap: 12px;
}
.page-title { font-size: 22px; font-weight: 700; }

/* ==================== 弹窗 ==================== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  padding: 20px;
}

.modal {
  background: var(--bg-white);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 500px;
  max-height: 90vh;
  overflow-y: auto;
}

.modal-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  font-weight: 600;
  font-size: 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-close {
  background: none; border: none; font-size: 20px;
  cursor: pointer; color: var(--text-muted); padding: 4px;
}
.modal-close:hover { color: var(--text-primary); }

.modal-body { padding: 20px; }

.modal-footer {
  padding: 16px 20px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

/* ==================== 消息提示 ==================== */
#toast-container {
  position: fixed;
  top: 70px;
  right: 20px;
  z-index: 300;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  padding: 12px 20px;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  animation: slideIn 0.3s ease;
  min-width: 200px;
  max-width: 400px;
}
.toast-success { background: var(--success); color: #fff; }
.toast-error   { background: var(--danger);  color: #fff; }
.toast-info    { background: var(--accent);  color: #fff; }

@keyframes slideIn {
  from { transform: translateX(100%); opacity: 0; }
  to   { transform: translateX(0);     opacity: 1; }
}

/* ==================== 登录/注册页 ==================== */
.auth-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-primary);
  padding: 20px;
}

.auth-card {
  background: var(--bg-white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 420px;
  padding: 32px;
}

.auth-title    { font-size: 22px; font-weight: 700; text-align: center; margin-bottom: 8px; }
.auth-subtitle { text-align: center; color: var(--text-muted); font-size: 14px; margin-bottom: 24px; }
.auth-switch   { text-align: center; margin-top: 16px; font-size: 14px; color: var(--text-secondary); }
.auth-switch a { font-weight: 600; cursor: pointer; }

/* ==================== 快捷入口 ==================== */
.quick-actions {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
  margin-bottom: 24px;
}

.quick-action-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 20px;
  background: var(--bg-white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  text-decoration: none;
  color: var(--text-primary);
  transition: all 0.15s;
}
.quick-action-btn:hover {
  border-color: var(--accent);
  background: var(--accent-light);
  text-decoration: none;
}
.quick-action-btn .icon  { font-size: 28px; }
.quick-action-btn .label { font-size: 14px; font-weight: 500; }

/* ==================== 权限下拉选择 ==================== */
.permission-select {
  padding: 4px 8px;
  font-size: 13px;
  border: 1px solid var(--border);
  border-radius: 4px;
  cursor: pointer;
}

/* ==================== 空状态 ==================== */
.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-muted);
}
.empty-state .icon { font-size: 48px; margin-bottom: 12px; }
.empty-state .text { font-size: 16px; }

/* ==================== 响应式 ==================== */
@media (max-width: 768px) {
  .navbar { padding: 0 12px; }
  .navbar-brand { margin-right: 12px; font-size: 14px; }
  .navbar-toggle { display: block; }

  .navbar-menu {
    display: none;
    position: absolute;
    top: 56px;
    left: 0; right: 0;
    flex-direction: column;
    background: var(--bg-white);
    border-bottom: 1px solid var(--border);
    padding: 8px;
    box-shadow: var(--shadow-lg);
  }
  .navbar-menu.open { display: flex; }
  .navbar-menu a { padding: 10px 14px; }

  .main { padding: 16px 12px; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .filter-bar { flex-direction: column; }
  .filter-bar .form-group { min-width: 100%; }
  .page-header { flex-direction: column; align-items: stretch; }

  /* 表格横向滚动 */
  .table-wrapper { -webkit-overflow-scrolling: touch; }
  table { min-width: 600px; }
}

@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr; }
  .auth-card  { padding: 24px 20px; }
  .quick-actions { grid-template-columns: repeat(2, 1fr); }
}