/* ============================================================
   global.css — herb32 全局样式
   用户端：温和探索风（墨绿 + 米黄 + 竹纹）
   管理端：严谨专业风（深蓝 + 灰白 + 数据感）
   ============================================================ */

/* ---------- 颜色变量 ---------- */
:root {
  /* 用户端主色（中医底蕴）*/
  --color-primary: #1b4332;        /* 深墨绿 */
  --color-primary-light: #2d6a4f;  /* 中墨绿 */
  --color-primary-dark: #081c15;   /* 暗墨绿 */
  --color-accent: #c9a66b;         /* 古金 */
  --color-danger: #e74c3c;         /* 朱砂红（仅用户端点缀）*/
  --color-paper: #faf6ee;          /* 宣纸色 */
  --color-paper-dark: #f5f0e6;     /* 深宣纸 */
  --color-text: #2d3a2e;           /* 正文墨色 */
  --color-text-light: #7a6a52;     /* 次要文字 */
  --color-border: #e0d5c1;         /* 边框 */
  --color-success: #2d6a4f;
  --color-warning: #d4a017;

  /* 管理端主色（深蓝严谨）*/
  --admin-primary: #1e3a8a;        /* 深蓝 */
  --admin-primary-light: #3b5bdb;
  --admin-bg: #f8fafc;
  --admin-bg-card: #ffffff;
  --admin-text: #1e293b;
  --admin-text-light: #64748b;
  --admin-border: #e2e8f0;
  --admin-danger: #dc2626;
  --admin-success: #059669;
  --admin-warning: #d97706;

  /* 通用 */
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --shadow-soft: 0 2px 8px rgba(27, 67, 50, 0.06);
  --shadow-card: 0 4px 20px rgba(27, 67, 50, 0.10);
  --font-body: "Noto Serif SC", "Noto Sans SC", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

/* ---------- Reset ---------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: var(--font-body);
  line-height: 1.6;
  color: var(--color-text);
  background: linear-gradient(135deg, #eef6ea, #dcecd4);
  min-height: 100vh;
}
a { color: var(--color-primary-light); text-decoration: none; }
a:hover { text-decoration: underline; }
button { cursor: pointer; font-family: inherit; border: none; background: none; }
input, textarea, select { font-family: inherit; font-size: 14px; }

/* ---------- 用户端：登录/注册卡片 ---------- */
.auth-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background:
    radial-gradient(circle at 20% 30%, rgba(45, 106, 79, 0.08) 0%, transparent 50%),
    radial-gradient(circle at 80% 70%, rgba(201, 166, 107, 0.10) 0%, transparent 40%),
    linear-gradient(135deg, #eef6ea, #dcecd4);
  position: relative;
  overflow-y: auto;
}

/* 返回主页链接（登录/注册页底部） */
.back-link {
  color: var(--color-text-light);
  font-size: 12px;
  transition: color 0.15s;
}
.back-link:hover {
  color: var(--color-primary-light);
  text-decoration: none;
}

/* HERB SVG logo 对齐 */
.brand-svg {
  display: block;
  margin-bottom: 4px;
  opacity: 0.95;
}
.auth-page::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image:
    repeating-linear-gradient(0deg, transparent, transparent 39px, rgba(45,106,79,0.03) 39px, rgba(45,106,79,0.03) 40px),
    repeating-linear-gradient(90deg, transparent, transparent 39px, rgba(45,106,79,0.03) 39px, rgba(45,106,79,0.03) 40px);
  pointer-events: none;
}

.auth-card {
  width: 100%;
  max-width: 420px;
  background: var(--color-paper);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  border: 1px solid var(--color-border);
  overflow: hidden;
  position: relative;
  z-index: 1;
}
.auth-card-header {
  padding: 32px 32px 24px;
  text-align: center;
  background: linear-gradient(135deg, var(--color-primary), var(--color-primary-light));
  color: white;
}
.auth-card-header .brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-size: 18px;
  font-weight: 600;
  letter-spacing: 2px;
}
.auth-card-header .brand-logo {
  width: 36px; height: 36px;
  background: rgba(255,255,255,0.2);
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
}
.auth-card-header h1 {
  font-size: 20px;
  margin-top: 14px;
  font-weight: 600;
  letter-spacing: 4px;
}
.auth-card-header .subtitle {
  font-size: 12px;
  opacity: 0.8;
  margin-top: 6px;
}
.auth-card-body { padding: 28px 32px 24px; }
.auth-form .form-group { margin-bottom: 18px; }
.auth-form label {
  display: block;
  font-size: 12px;
  color: var(--color-text-light);
  margin-bottom: 6px;
  letter-spacing: 1px;
}
.auth-form .form-input {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: white;
  color: var(--color-text);
  transition: border-color 0.2s, box-shadow 0.2s;
  outline: none;
}
.auth-form .form-input:focus {
  border-color: var(--color-primary-light);
  box-shadow: 0 0 0 3px rgba(45,106,79,0.12);
}
.auth-form .form-input.error {
  border-color: var(--color-danger);
  box-shadow: 0 0 0 3px rgba(231,76,60,0.12);
}
.auth-form .form-hint {
  font-size: 11px;
  color: var(--color-text-light);
  margin-top: 4px;
}
.auth-form .form-error {
  font-size: 12px;
  color: var(--color-danger);
  margin-top: 4px;
  min-height: 16px;
}
.auth-form .form-check {
  display: flex; align-items: center; gap: 8px;
  font-size: 12px; color: var(--color-text-light);
}
.auth-form .form-check input[type="checkbox"] {
  width: 16px; height: 16px;
  accent-color: var(--color-primary);
}
.btn-primary {
  width: 100%;
  padding: 13px;
  background: linear-gradient(135deg, var(--color-primary), var(--color-primary-light));
  color: white;
  border-radius: var(--radius-md);
  font-size: 14px;
  font-weight: 500;
  letter-spacing: 2px;
  transition: transform 0.15s, box-shadow 0.15s;
}
.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 14px rgba(27,67,50,0.25);
}
.btn-primary:active { transform: translateY(0); }
.btn-primary:disabled {
  opacity: 0.6; cursor: not-allowed; transform: none; box-shadow: none;
}
.auth-footer {
  text-align: center;
  padding: 16px 32px 24px;
  border-top: 1px solid var(--color-border);
  font-size: 12px;
  color: var(--color-text-light);
}
.auth-footer a { color: var(--color-primary-light); font-weight: 500; }
.auth-alert {
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  margin-bottom: 14px;
}
.auth-alert.error { background: #fef2f2; color: var(--color-danger); border: 1px solid #fecaca; }
.auth-alert.success { background: #f0fdf4; color: var(--color-success); border: 1px solid #bbf7d0; }

/* ---------- 管理端基础 ---------- */
.admin-layout {
  height: 100vh;
  overflow: hidden;
  background: var(--admin-bg);
  display: flex;
  font-size: 14px;
}
.admin-sidebar {
  width: 220px;
  background: var(--admin-primary);
  color: white;
  flex-shrink: 0;
  display: flex; flex-direction: column;
}
.admin-sidebar-brand {
  padding: 24px 20px;
  border-bottom: 1px solid rgba(255,255,255,0.1);
}
.admin-sidebar-brand .brand-title {
  font-size: 15px; font-weight: 600;
  letter-spacing: 3px;
}
.admin-sidebar-brand .brand-sub {
  font-size: 11px; opacity: 0.7; margin-top: 4px; letter-spacing: 1px;
}
.admin-sidebar-nav { flex: 1; padding: 12px 0; }
.admin-nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 11px 20px;
  color: rgba(255,255,255,0.8);
  font-size: 13px;
  cursor: pointer;
  border-left: 3px solid transparent;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.admin-nav-item:hover { background: rgba(255,255,255,0.08); color: white; }
.admin-nav-item.active {
  background: rgba(255,255,255,0.12);
  color: white;
  border-left-color: #fbbf24;
}
.admin-nav-item .icon { font-size: 16px; width: 20px; text-align: center; }
.admin-nav-item .badge {
  margin-left: auto;
  background: #ef4444;
  color: white;
  font-size: 10px;
  padding: 2px 7px;
  border-radius: 10px;
  font-weight: 600;
}
.admin-sidebar-footer {
  padding: 14px 20px;
  border-top: 1px solid rgba(255,255,255,0.1);
  font-size: 11px; opacity: 0.6; text-align: center;
}
.admin-main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.admin-topbar {
  background: white;
  border-bottom: 1px solid var(--admin-border);
  padding: 0 24px;
  height: 56px;
  display: flex; align-items: center; justify-content: space-between;
}
.admin-topbar .page-title { font-size: 16px; font-weight: 600; color: var(--admin-text); }
.admin-topbar-right { display: flex; align-items: center; gap: 14px; }
.admin-user-badge {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 12px;
  background: #f1f5f9;
  border-radius: 20px;
  font-size: 13px; color: var(--admin-text);
}
.admin-user-badge .avatar {
  width: 28px; height: 28px; border-radius: 50%;
  background: var(--admin-primary);
  color: white;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 600;
}
.admin-topbar button {
  padding: 6px 14px;
  border-radius: 6px;
  font-size: 12px; font-weight: 500;
  cursor: pointer;
  transition: background 0.15s;
}
.admin-topbar .btn-ghost {
  background: transparent; color: var(--admin-text-light);
}
.admin-topbar .btn-ghost:hover { background: #f1f5f9; color: var(--admin-text); }
.admin-topbar .btn-danger { background: #fef2f2; color: var(--admin-danger); }
.admin-topbar .btn-danger:hover { background: #fee2e2; }
.admin-content { height: 0; flex: 1; padding: 24px; overflow-y: auto; }

/* ---------- 管理端：卡片 & 表格 ---------- */
.admin-card {
  background: var(--admin-bg-card);
  border: 1px solid var(--admin-border);
  border-radius: 10px;
  padding: 20px 24px;
  margin-bottom: 20px;
}
.admin-card-title {
  font-size: 15px; font-weight: 600; color: var(--admin-text);
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--admin-border);
  display: flex; align-items: center; justify-content: space-between;
}
.admin-stats-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 20px;
}
.admin-stat {
  background: white;
  border: 1px solid var(--admin-border);
  border-radius: 10px;
  padding: 18px 20px;
}
.admin-stat .label { font-size: 12px; color: var(--admin-text-light); letter-spacing: 1px; }
.admin-stat .value { font-size: 28px; font-weight: 700; color: var(--admin-primary); margin-top: 4px; }
.admin-stat .value.warn { color: var(--admin-warning); }
.admin-stat .value.ok { color: var(--admin-success); }

.admin-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.admin-table th {
  background: #f8fafc;
  padding: 12px 14px;
  text-align: left;
  font-weight: 600;
  color: var(--admin-text-light);
  font-size: 12px;
  letter-spacing: 1px;
  border-bottom: 1px solid var(--admin-border);
}
.admin-table td {
  padding: 14px;
  border-bottom: 1px solid var(--admin-border);
  color: var(--admin-text);
  vertical-align: top;
}
.admin-table tr:hover td { background: #f8fafc; }
.admin-table .tag {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 500;
}
.admin-table .tag.pending { background: #fef3c7; color: var(--admin-warning); }
.admin-table .tag.approved { background: #d1fae5; color: var(--admin-success); }
.admin-table .tag.rejected { background: #fee2e2; color: var(--admin-danger); }
.admin-table .tag.admin { background: #dbeafe; color: var(--admin-primary); }
.admin-table .tag.user { background: #f1f5f9; color: var(--admin-text-light); }

.admin-table .btn-action {
  padding: 5px 10px;
  font-size: 12px;
  border-radius: 5px;
  cursor: pointer;
  margin-right: 6px;
  transition: all 0.15s;
}
.admin-table .btn-action.approve { background: var(--admin-success); color: white; }
.admin-table .btn-action.approve:hover { background: #047857; }
.admin-table .btn-action.reject { background: var(--admin-danger); color: white; }
.admin-table .btn-action.reject:hover { background: #b91c1c; }
.admin-table .btn-action.view { background: #e2e8f0; color: var(--admin-text); }
.admin-table .btn-action.view:hover { background: #cbd5e1; }

.admin-empty {
  text-align: center;
  padding: 60px 20px;
  color: var(--admin-text-light);
  font-size: 13px;
}
.admin-empty .icon { font-size: 36px; opacity: 0.5; margin-bottom: 10px; }

/* ---------- Modal ---------- */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.4);
  display: flex; align-items: center; justify-content: center;
  z-index: 9999;
  padding: 24px;
}
.modal {
  background: white;
  border-radius: 12px;
  width: 100%; max-width: 480px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.25);
}
.modal-header {
  padding: 18px 24px;
  border-bottom: 1px solid var(--admin-border);
  display: flex; align-items: center; justify-content: space-between;
}
.modal-title { font-size: 15px; font-weight: 600; color: var(--admin-text); }
.modal-close {
  width: 28px; height: 28px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: var(--admin-text-light); cursor: pointer;
  transition: background 0.15s;
}
.modal-close:hover { background: #f1f5f9; color: var(--admin-text); }
.modal-body { padding: 20px 24px; }
.modal-footer {
  padding: 14px 24px;
  border-top: 1px solid var(--admin-border);
  display: flex; justify-content: flex-end; gap: 10px;
}
.modal-footer button {
  padding: 8px 18px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
}
.modal-footer .btn-cancel {
  background: #f1f5f9; color: var(--admin-text);
}
.modal-footer .btn-cancel:hover { background: #e2e8f0; }
.modal-footer .btn-submit {
  background: var(--admin-primary); color: white;
}
.modal-footer .btn-submit:hover { background: var(--admin-primary-light); }
.modal textarea {
  width: 100%; padding: 10px 12px;
  border: 1px solid var(--admin-border);
  border-radius: 6px;
  resize: vertical; min-height: 80px;
  outline: none;
}
.modal textarea:focus { border-color: var(--admin-primary); box-shadow: 0 0 0 3px rgba(30,58,138,0.1); }

/* ---------- 用户端顶栏用户状态 ---------- */
.user-topbar {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: 48px;
  background: rgba(250,246,238,0.95);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--color-border);
  display: flex; align-items: center; justify-content: flex-end;
  padding: 0 20px;
  z-index: 10000;
  pointer-events: none;
}
.user-topbar > * { pointer-events: auto; }
.user-dropdown-trigger {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 12px;
  border-radius: 20px;
  cursor: pointer;
  transition: background 0.15s;
  font-size: 13px;
  color: var(--color-text);
}
.user-dropdown-trigger:hover { background: var(--color-paper-dark); }
.user-avatar {
  width: 30px; height: 30px; border-radius: 50%;
  background: var(--color-primary);
  color: white;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 600;
}
.user-dropdown {
  position: absolute;
  top: 46px; right: 20px;
  background: white;
  border: 1px solid var(--color-border);
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(27,67,50,0.15);
  min-width: 180px;
  padding: 6px;
  display: none;
}
.user-dropdown.open { display: block; }
.user-dropdown-item {
  display: flex; align-items: center; gap: 8px;
  padding: 9px 14px;
  border-radius: 6px;
  font-size: 13px;
  color: var(--color-text);
  cursor: pointer;
  transition: background 0.12s;
}
.user-dropdown-item:hover { background: var(--color-paper-dark); }
.user-dropdown-item.admin-only {
  color: var(--admin-primary);
  font-weight: 500;
  border-top: 1px solid var(--color-border);
  margin-top: 2px; padding-top: 11px;
}
.user-dropdown-item.danger { color: var(--color-danger); border-top: 1px solid var(--color-border); margin-top: 2px; padding-top: 11px; }
.user-dropdown .arrow { font-size: 10px; margin-left: auto; }
.user-dropdown .role-tag {
  margin-left: 8px;
  background: #dbeafe; color: var(--admin-primary);
  font-size: 10px; font-weight: 600;
  padding: 1px 6px;
  border-radius: 8px;
}

/* 用户端顶栏注入到原页面时，body 需顶部留白 */
body.has-user-topbar { padding-top: 48px; }

/* ---------- 响应式 ---------- */
@media (max-width: 768px) {
  .auth-card { margin: 16px; }
  .auth-card-header, .auth-card-body, .auth-footer { padding-left: 24px; padding-right: 24px; }
  .admin-layout { flex-direction: column; }
  .admin-sidebar {
    width: 100%;
    height: auto;
    flex-direction: row;
    overflow-x: auto;
  }
  .admin-sidebar-brand { display: none; }
  .admin-sidebar-nav { display: flex; padding: 8px; gap: 4px; }
  .admin-sidebar-footer { display: none; }
  .admin-nav-item { border-left: none; border-bottom: 2px solid transparent; padding: 8px 14px; white-space: nowrap; font-size: 12px; }
  .admin-nav-item.active { border-left: none; border-bottom-color: #fbbf24; }
  .admin-table { display: block; overflow-x: auto; }
  .admin-stats-row { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 480px) {
  .admin-stats-row { grid-template-columns: 1fr; }
}
