/* =========================================================
   合同管理系统 - 全局样式表
   现代简洁风格，蓝色主色调
   ========================================================= */

/* ---------- 颜色系统变量 ---------- */
:root {
  --bg: #f5f7fa;          /* 页面背景 */
  --bg2: #ffffff;         /* 卡片背景 */
  --ink: #1f2937;         /* 主文字 */
  --muted: #6b7280;       /* 次要文字 */
  --rule: #e5e7eb;        /* 分割线 / 边框 */
  --accent: #2563eb;      /* 主题蓝 */
  --accent-hover: #1d4ed8;
  --accent-light: #dbeafe;
  --danger: #dc2626;      /* 过期 / 危险 */
  --warning: #f59e0b;     /* 临期 */
  --success: #16a34a;     /* 有效 */
  --shadow: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-lg: 0 10px 25px rgba(0,0,0,0.08), 0 4px 10px rgba(0,0,0,0.04);
  --radius: 8px;
  --radius-sm: 4px;
}

/* ---------- 重置 ---------- */
* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Noto Sans CJK SC", "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 14px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); }
ul, ol { list-style: none; }
img { max-width: 100%; display: block; }
input, select, textarea, button { font-family: inherit; font-size: inherit; }

/* ---------- 顶部导航栏 ---------- */
.navbar {
  background: var(--bg2);
  border-bottom: 1px solid var(--rule);
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow);
}
.navbar-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 20px;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.navbar-brand {
  font-size: 18px;
  font-weight: 600;
  color: var(--accent);
  display: flex;
  align-items: center;
  gap: 8px;
}
.navbar-brand .logo {
  width: 28px;
  height: 28px;
  background: var(--accent);
  border-radius: 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 700;
  font-size: 14px;
}
.navbar-menu {
  display: flex;
  align-items: center;
  gap: 4px;
}
.navbar-menu a {
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  color: var(--muted);
  font-weight: 500;
  transition: all 0.15s;
}
.navbar-menu a:hover { color: var(--accent); background: var(--accent-light); }
.navbar-menu a.active { color: var(--accent); background: var(--accent-light); }
.navbar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: 13px;
}
.navbar-user .avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
}
.btn-logout {
  padding: 6px 12px;
  border: 1px solid var(--rule);
  background: var(--bg2);
  color: var(--muted);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.15s;
}
.btn-logout:hover { border-color: var(--danger); color: var(--danger); }

/* ---------- 容器 ---------- */
.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 24px 20px;
}
.page-title {
  font-size: 22px;
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--ink);
}
.page-subtitle {
  color: var(--muted);
  margin-bottom: 20px;
}

/* ---------- 卡片 ---------- */
.card {
  background: var(--bg2);
  border-radius: var(--radius);
  border: 1px solid var(--rule);
  box-shadow: var(--shadow);
  margin-bottom: 20px;
  overflow: hidden;
}
.card-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--rule);
  font-weight: 600;
  font-size: 15px;
  background: #fafbfc;
}
.card-body { padding: 20px; }

/* ---------- 统计卡片网格 ---------- */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 20px;
}
.stat-card {
  background: var(--bg2);
  border-radius: var(--radius);
  border: 1px solid var(--rule);
  padding: 18px 20px;
  box-shadow: var(--shadow);
  transition: transform 0.15s, box-shadow 0.15s;
}
.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }
.stat-card .stat-label {
  color: var(--muted);
  font-size: 13px;
  margin-bottom: 6px;
}
.stat-card .stat-value {
  font-size: 28px;
  font-weight: 700;
  color: var(--ink);
}
.stat-card.expired .stat-value { color: var(--danger); }
.stat-card.warning .stat-value { color: var(--warning); }
.stat-card.active .stat-value { color: var(--success); }

/* ---------- 表单 ---------- */
.form-group { margin-bottom: 16px; }
.form-group label {
  display: block;
  margin-bottom: 6px;
  color: var(--ink);
  font-weight: 500;
  font-size: 13px;
}
.form-group label .req { color: var(--danger); margin-left: 2px; }
.form-control {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--rule);
  border-radius: var(--radius-sm);
  background: #fff;
  color: var(--ink);
  transition: border-color 0.15s, box-shadow 0.15s;
}
.form-control:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(37,99,235,0.12);
}
.form-control:disabled { background: #f3f4f6; color: var(--muted); cursor: not-allowed; }
textarea.form-control { resize: vertical; min-height: 80px; }
.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
.form-hint { color: var(--muted); font-size: 12px; margin-top: 4px; }
.form-error { color: var(--danger); font-size: 12px; margin-top: 4px; }

/* 单选 / 复选 */
.radio-group, .checkbox-group {
  display: flex;
  align-items: center;
  gap: 18px;
  flex-wrap: wrap;
}
.radio-item, .checkbox-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  color: var(--ink);
}
.radio-item input, .checkbox-item input { cursor: pointer; }

/* 开关 (用于权限设置) */
.switch { position: relative; display: inline-block; width: 44px; height: 24px; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch .slider {
  position: absolute; cursor: pointer; inset: 0;
  background: #cbd5e1; border-radius: 24px; transition: 0.2s;
}
.switch .slider:before {
  content: ""; position: absolute;
  height: 18px; width: 18px; left: 3px; top: 3px;
  background: #fff; border-radius: 50%; transition: 0.2s;
}
.switch input:checked + .slider { background: var(--accent); }
.switch input:checked + .slider:before { transform: translateX(20px); }

/* ---------- 按钮 ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 18px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-weight: 500;
  transition: all 0.15s;
  white-space: nowrap;
  background: var(--bg2);
  color: var(--ink);
}
.btn:disabled { opacity: 0.6; cursor: not-allowed; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--accent-hover); }
.btn-secondary { background: var(--bg2); border-color: var(--rule); color: var(--ink); }
.btn-secondary:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover:not(:disabled) { background: #b91c1c; }
.btn-success { background: var(--success); color: #fff; }
.btn-success:hover:not(:disabled) { background: #15803d; }
.btn-warning { background: var(--warning); color: #fff; }
.btn-warning:hover:not(:disabled) { background: #d97706; }
.btn-link { background: transparent; color: var(--accent); padding: 4px 8px; }
.btn-link:hover { background: var(--accent-light); }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-lg { padding: 11px 22px; font-size: 15px; }
.btn-block { width: 100%; }
.btn-group { display: inline-flex; gap: 8px; flex-wrap: wrap; }

/* ---------- 表格 ---------- */
.table-wrap { overflow-x: auto; }
table.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.data-table th, .data-table td {
  padding: 11px 12px;
  text-align: left;
  border-bottom: 1px solid var(--rule);
}
.data-table th {
  background: #fafbfc;
  color: var(--muted);
  font-weight: 600;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  white-space: nowrap;
}
.data-table tbody tr { transition: background 0.12s; }
.data-table tbody tr:hover { background: #f9fafb; }
.data-table tbody tr.clickable { cursor: pointer; }
.data-table .cell-link { color: var(--accent); cursor: pointer; }
.data-table .cell-link:hover { text-decoration: underline; }
.data-table input[type="checkbox"] { cursor: pointer; }

/* ---------- 状态徽章 ---------- */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 600;
  line-height: 1.4;
}
.badge::before {
  content: "";
  width: 6px; height: 6px; border-radius: 50%;
  margin-right: 6px;
  background: currentColor;
}
.badge.expired  { background: #fee2e2; color: var(--danger); }
.badge.warning  { background: #fef3c7; color: #b45309; }
.badge.active   { background: #dcfce7; color: var(--success); }
.badge.public   { background: #e0e7ff; color: #4338ca; }
.badge.private  { background: #f3e8ff; color: #7c3aed; }
.badge.neutral  { background: #f3f4f6; color: var(--muted); }

/* ---------- 搜索 / 筛选栏 ---------- */
.toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}
.toolbar .search-box {
  position: relative;
  flex: 1;
  min-width: 240px;
}
.toolbar .search-box input {
  width: 100%;
  padding: 9px 12px 9px 36px;
  border: 1px solid var(--rule);
  border-radius: var(--radius-sm);
  background: #fff;
}
.toolbar .search-box input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(37,99,235,0.12); }
.toolbar .search-box::before {
  content: "";
  position: absolute;
  left: 12px; top: 50%;
  transform: translateY(-50%);
  width: 16px; height: 16px;
  border: 2px solid var(--muted);
  border-radius: 50%;
  border-right-color: transparent;
}
.toolbar select, .toolbar input[type="date"], .toolbar input[type="text"] {
  padding: 8px 10px;
  border: 1px solid var(--rule);
  border-radius: var(--radius-sm);
  background: #fff;
}
.toolbar select:focus, .toolbar input:focus { outline: none; border-color: var(--accent); }

.filter-quick {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 16px;
}
.filter-quick .btn { padding: 5px 12px; font-size: 12px; }
.filter-quick .btn.active { background: var(--accent); color: #fff; border-color: var(--accent); }

/* ---------- 上传区域 ---------- */
.upload-zone {
  border: 2px dashed var(--rule);
  border-radius: var(--radius);
  padding: 40px 20px;
  text-align: center;
  background: #fafbfc;
  transition: all 0.2s;
  cursor: pointer;
}
.upload-zone:hover, .upload-zone.dragover {
  border-color: var(--accent);
  background: var(--accent-light);
}
.upload-zone .upload-icon {
  font-size: 40px;
  color: var(--muted);
  margin-bottom: 12px;
}
.upload-zone .upload-title {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--ink);
}
.upload-zone .upload-hint { color: var(--muted); font-size: 13px; }
.upload-zone .upload-success {
  color: var(--success);
  font-weight: 600;
  margin-top: 12px;
}
.uploaded-file {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  background: #f0f9ff;
  border: 1px solid #bae6fd;
  border-radius: var(--radius-sm);
  margin-top: 12px;
}
.uploaded-file .file-info { display: flex; align-items: center; gap: 10px; }
.uploaded-file .file-name { font-weight: 500; color: var(--ink); }
.uploaded-file .file-size { color: var(--muted); font-size: 12px; }
.uploaded-file .btn-remove { color: var(--danger); background: transparent; border: none; cursor: pointer; }

/* ---------- 分页 ---------- */
.pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 16px;
  flex-wrap: wrap;
  gap: 12px;
}
.pagination .page-info { color: var(--muted); font-size: 13px; }
.pagination .page-list { display: flex; gap: 4px; }
.pagination .page-list button {
  min-width: 32px; height: 32px;
  border: 1px solid var(--rule);
  background: #fff;
  border-radius: var(--radius-sm);
  cursor: pointer;
  color: var(--ink);
  transition: all 0.15s;
}
.pagination .page-list button:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); }
.pagination .page-list button.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.pagination .page-list button:disabled { opacity: 0.5; cursor: not-allowed; }

/* ---------- 弹窗 Modal ---------- */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.4);
  display: flex; align-items: center; justify-content: center;
  z-index: 1000;
  padding: 20px;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s, visibility 0.2s;
}
.modal-overlay.open { opacity: 1; visibility: visible; }
.modal {
  background: var(--bg2);
  border-radius: var(--radius);
  width: 100%;
  max-width: 480px;
  box-shadow: var(--shadow-lg);
  transform: translateY(-10px);
  transition: transform 0.2s;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
}
.modal-overlay.open .modal { transform: translateY(0); }
.modal-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--rule);
  font-weight: 600;
  font-size: 16px;
  display: flex; justify-content: space-between; align-items: center;
}
.modal-close {
  background: transparent; border: none; cursor: pointer;
  font-size: 22px; color: var(--muted); line-height: 1;
  padding: 0; width: 28px; height: 28px;
  border-radius: 4px;
}
.modal-close:hover { background: #f3f4f6; color: var(--ink); }
.modal-body { padding: 20px; overflow-y: auto; }
.modal-footer {
  padding: 14px 20px;
  border-top: 1px solid var(--rule);
  display: flex; justify-content: flex-end; gap: 8px;
}

/* ---------- Toast 提示 ---------- */
.toast-container {
  position: fixed;
  top: 20px; right: 20px;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
}
.toast {
  min-width: 260px;
  max-width: 360px;
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  background: #fff;
  border-left: 4px solid var(--accent);
  box-shadow: var(--shadow-lg);
  display: flex; align-items: center; gap: 10px;
  font-size: 14px;
  pointer-events: auto;
  animation: toast-in 0.25s ease;
}
.toast.success { border-left-color: var(--success); }
.toast.error   { border-left-color: var(--danger); }
.toast.warning { border-left-color: var(--warning); }
.toast.info    { border-left-color: var(--accent); }
.toast .toast-icon { font-weight: 700; font-size: 16px; }
.toast.success .toast-icon { color: var(--success); }
.toast.error .toast-icon { color: var(--danger); }
.toast.warning .toast-icon { color: var(--warning); }
.toast.info .toast-icon { color: var(--accent); }
.toast.hide { animation: toast-out 0.25s ease forwards; }
@keyframes toast-in {
  from { opacity: 0; transform: translateX(20px); }
  to { opacity: 1; transform: translateX(0); }
}
@keyframes toast-out {
  from { opacity: 1; transform: translateX(0); }
  to { opacity: 0; transform: translateX(20px); }
}

/* ---------- 详情页信息列表 ---------- */
.detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px 24px;
}
.detail-item { display: flex; flex-direction: column; gap: 4px; }
.detail-item .label { color: var(--muted); font-size: 12px; }
.detail-item .value { color: var(--ink); font-size: 15px; font-weight: 500; word-break: break-word; }
.detail-item.full { grid-column: 1 / -1; }

/* ---------- 空状态 ---------- */
.empty-state {
  text-align: center;
  padding: 50px 20px;
  color: var(--muted);
}
.empty-state .empty-icon { font-size: 48px; margin-bottom: 12px; opacity: 0.4; }
.empty-state .empty-text { font-size: 15px; margin-bottom: 6px; }
.empty-state .empty-hint { font-size: 13px; }

/* ---------- 加载状态 ---------- */
.loading {
  display: inline-block;
  width: 16px; height: 16px;
  border: 2px solid #d1d5db;
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
.loading.lg { width: 28px; height: 28px; border-width: 3px; }
@keyframes spin { to { transform: rotate(360deg); } }
.loading-text { color: var(--muted); text-align: center; padding: 30px; }

/* ---------- 权限不足提示 ---------- */
.no-permission {
  text-align: center;
  padding: 60px 20px;
  color: var(--muted);
}
.no-permission .lock-icon {
  font-size: 56px;
  color: var(--danger);
  opacity: 0.6;
  margin-bottom: 16px;
}
.no-permission h2 { color: var(--ink); margin-bottom: 8px; }
.no-permission p { margin-bottom: 16px; }

/* ---------- 标签页 Tabs ---------- */
.tabs {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--rule);
  margin-bottom: 20px;
}
.tab {
  padding: 10px 18px;
  cursor: pointer;
  color: var(--muted);
  border-bottom: 2px solid transparent;
  font-weight: 500;
  transition: all 0.15s;
}
.tab:hover { color: var(--accent); }
.tab.active { color: var(--accent); border-bottom-color: var(--accent); }
.tab-content { display: none; }
.tab-content.active { display: block; }

/* ---------- 角色卡片 ---------- */
.role-list {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}
.role-card {
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  padding: 16px 18px;
  cursor: pointer;
  transition: all 0.15s;
  background: #fff;
}
.role-card:hover { border-color: var(--accent); box-shadow: var(--shadow); }
.role-card.active { border-color: var(--accent); box-shadow: 0 0 0 2px rgba(37,99,235,0.2); background: var(--accent-light); }
.role-card .role-name { font-size: 16px; font-weight: 600; margin-bottom: 4px; }
.role-card .role-desc { color: var(--muted); font-size: 12px; }

/* 权限开关列表 */
.permission-list { display: flex; flex-direction: column; gap: 12px; }
.permission-item {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 14px;
  border: 1px solid var(--rule);
  border-radius: var(--radius-sm);
}
.permission-item .perm-label { font-weight: 500; color: var(--ink); }
.permission-item .perm-desc { color: var(--muted); font-size: 12px; }

/* ---------- 登录页 ---------- */
.login-page {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #2563eb 0%, #1e40af 100%);
  padding: 20px;
}
.login-card {
  background: #fff;
  border-radius: 12px;
  padding: 40px;
  width: 100%;
  max-width: 420px;
  box-shadow: 0 20px 50px rgba(0,0,0,0.2);
}
.login-card .login-logo {
  width: 56px; height: 56px;
  margin: 0 auto 16px;
  background: var(--accent);
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 700; font-size: 24px;
}
.login-card h1 {
  text-align: center;
  font-size: 22px;
  margin-bottom: 4px;
  color: var(--ink);
}
.login-card .login-subtitle {
  text-align: center;
  color: var(--muted);
  margin-bottom: 28px;
  font-size: 13px;
}
.login-card .default-tip {
  margin-top: 20px;
  padding: 10px 12px;
  background: #f0f9ff;
  border: 1px solid #bae6fd;
  border-radius: var(--radius-sm);
  font-size: 12px;
  color: #075985;
  text-align: center;
}

/* ---------- 工具类 ---------- */
.text-right { text-align: right; }
.text-center { text-align: center; }
.text-muted { color: var(--muted); }
.text-danger { color: var(--danger); }
.text-success { color: var(--success); }
.text-warning { color: var(--warning); }
.text-sm { font-size: 12px; }
.text-lg { font-size: 16px; }
.font-bold { font-weight: 600; }
.mt-0 { margin-top: 0; } .mt-1 { margin-top: 8px; } .mt-2 { margin-top: 16px; } .mt-3 { margin-top: 24px; }
.mb-0 { margin-bottom: 0; } .mb-1 { margin-bottom: 8px; } .mb-2 { margin-bottom: 16px; } .mb-3 { margin-bottom: 24px; }
.flex { display: flex; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.gap-1 { gap: 8px; } .gap-2 { gap: 16px; }
.hidden { display: none !important; }

/* ---------- 响应式 ---------- */
@media (max-width: 768px) {
  .navbar-inner { flex-wrap: wrap; height: auto; padding: 10px 16px; gap: 10px; }
  .navbar-brand { font-size: 16px; }
  .navbar-menu { width: 100%; overflow-x: auto; padding-bottom: 4px; }
  .navbar-menu a { padding: 6px 10px; font-size: 13px; }
  .navbar-user { font-size: 12px; }
  .container { padding: 16px; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); gap: 12px; }
  .stat-card .stat-value { font-size: 22px; }
  .form-row { grid-template-columns: 1fr; gap: 0; }
  .detail-grid { grid-template-columns: 1fr; }
  .role-list { grid-template-columns: 1fr; }
  .login-card { padding: 28px 20px; }
  .toolbar .search-box { min-width: 100%; }
  .page-title { font-size: 18px; }
}

@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .navbar-menu a { padding: 5px 8px; font-size: 12px; }
  .data-table th, .data-table td { padding: 8px 6px; font-size: 12px; }
  .pagination { justify-content: center; text-align: center; }
  .pagination .page-list button { min-width: 28px; height: 28px; }
}
