/*
 * 朋友圈智能运营系统 — 公共基础样式
 * 统一品牌色、组件系统、字体层级、响应式断点
 */

/* ═══════════════════════ CSS 变量 ═══════════════════════ */
:root {
  --accent:   #4f46e5;
  --accent-h: #4338ca;
  --accent-l: #eef2ff;
  --text:     #1e1b4b;
  --text-m:   #6b7280;
  --text-s:   #9ca3af;
  --text-dim: #9ca3af;
  --text-sub: #6b7280;
  --bg:       #f8f9fc;
  --card:     #ffffff;
  --border:   #e5e7eb;
  --border-h: #d1d5db;
  --green:    #059669;
  --green-l:  #ecfdf5;
  --jade:     #059669;
  --red:      #dc2626;
  --red-l:    #fef2f2;
  --rose:     #dc2626;
  --amber:    #d97706;
  --amber-l:  #fffbeb;
  --blue:     #2563eb;
  --blue-l:   #eff6ff;
  --purple:   #7c3aed;
  --purple-l: #f5f3ff;
  --r: 12px; --r-s: 8px; --r-xs: 6px;
  --sh: 0 1px 3px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.04);
  --sh-lg: 0 4px 24px rgba(0,0,0,.08);
}

/* ═══════════════════════ 基础重置 ═══════════════════════ */
*, *::before, *::after { box-sizing: border-box; margin:0; padding:0; }
html { font-size: 15px; }
body {
  font-family: "PingFang SC", "Microsoft YaHei", "Noto Sans SC", system-ui, -apple-system, sans-serif;
  background: var(--bg); color: var(--text); line-height: 1.6; min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* ═══════════════════════ 字体层级 ═══════════════════════ */
/* 标题 1.25rem | 副标题 1rem | 正文 0.875rem | 辅助 0.75rem */
/* 最小中文字号不低于 0.75rem (11.25px) */

/* ═══════════════════════ 焦点指示器 (键盘导航) ═══════════════════════ */
:focus-visible {
  outline: 2px solid var(--accent) !important;
  outline-offset: 2px;
}
/* 表单控件仅在 keyboard 聚焦时显示 outline */
input:focus:not(:focus-visible),
select:focus:not(:focus-visible),
textarea:focus:not(:focus-visible),
button:focus:not(:focus-visible) {
  outline: none;
}

/* ═══════════════════════ 通用布局 ═══════════════════════ */
.main { max-width: 1280px; margin: 0 auto; padding: 24px 28px 48px; }
.row { display: flex; gap: 16px; }
.row > .field { flex: 1; }

/* ═══════════════════════ 顶栏 ═══════════════════════ */
.top-bar {
  background: var(--card); border-bottom: 1px solid var(--border);
  padding: 0 28px; height: 60px; display: flex; align-items: center;
  justify-content: space-between; position: sticky; top: 0; z-index: 100;
  box-shadow: 0 1px 2px rgba(0,0,0,.04);
}
.top-left { font-size: 1.05rem; font-weight: 700; color: var(--text); }

/* ═══════════════════════ 按钮系统 ═══════════════════════ */
.btn {
  display: inline-flex; align-items: center; gap: 5px; padding: 8px 18px;
  border-radius: var(--r-xs); border: none; cursor: pointer; font-size: 0.875rem;
  font-weight: 500; transition: all .15s; font-family: inherit; text-decoration: none;
}
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .6; cursor: not-allowed; transform: none; }
.btn-def { background: #fff; color: var(--text-m); border: 1px solid var(--border); }
.btn-def:hover:not(:disabled) { background: #f9fafb; border-color: var(--border-h); color: var(--text); }
.btn-prime { background: var(--accent); color: #fff; font-weight: 600; }
.btn-prime:hover:not(:disabled) { background: var(--accent-h); }
.btn-success { background: var(--green); color: #fff; font-weight: 600; }
.btn-success:hover:not(:disabled) { background: #047857; }
.btn-warn { background: var(--amber); color: #fff; font-weight: 600; }
.btn-warn:hover:not(:disabled) { background: #b45309; }
.btn-danger { background: var(--red); color: #fff; font-weight: 600; }
.btn-danger:hover:not(:disabled) { background: #b91c1c; }
.btn-sm { padding: 5px 12px; font-size: 0.75rem; }
.btn-xs { padding: 3px 9px; font-size: 0.75rem; border-radius: 4px; }
.btn-logout {
  background: none; border: 1px solid var(--border); color: var(--text-m);
  padding: 6px 16px; border-radius: var(--r-xs); font-size: 0.875rem;
  cursor: pointer; transition: all .2s; font-family: inherit;
}
.btn-logout:hover { color: var(--red); border-color: var(--red); background: var(--red-l); }
.btn-loading {
  position: relative; pointer-events: none;
}
.btn-loading::after {
  content: ""; display: inline-block; width: 14px; height: 14px;
  border: 2px solid transparent; border-top-color: currentColor;
  border-radius: 50%; animation: spin .5s linear infinite; margin-left: 6px;
}

/* ═══════════════════════ 卡片系统 ═══════════════════════ */
.card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--r); box-shadow: var(--sh); padding: 22px; margin-bottom: 14px;
}
.card-head {
  font-size: 1rem; font-weight: 700; color: var(--text); margin-bottom: 14px;
  display: flex; align-items: center; gap: 6px;
}
.card-head .hint-r { font-size: 0.75rem; font-weight: 400; color: var(--text-s); margin-left: auto; }

/* ═══════════════════════ 表单系统 ═══════════════════════ */
.field { margin-bottom: 14px; }
.field-label { display: block; font-size: 0.75rem; font-weight: 600; color: var(--text-m); margin-bottom: 5px; }
.field-desc { font-size: 0.75rem; color: var(--text-s); margin-top: 3px; }
.field-err { font-size: 0.75rem; color: var(--red); margin-top: 3px; display: none; }
.field.has-error input,
.field.has-error select,
.field.has-error textarea { border-color: var(--red); }
.field.has-error .field-err { display: block; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

input[type="text"], input[type="number"], input[type="password"],
input[type="datetime-local"], select, textarea {
  width: 100%; border: 1px solid var(--border); border-radius: var(--r-s);
  padding: 9px 13px; font-size: 0.875rem; font-family: inherit; background: #fff;
  color: var(--text); transition: border .15s, box-shadow .15s; outline: none;
}
input:hover, select:hover, textarea:hover { border-color: var(--border-h); }
input:focus, select:focus, textarea:focus {
  border-color: var(--accent); box-shadow: 0 0 0 3px rgba(79,70,229,.1);
}
textarea { resize: vertical; line-height: 1.65; }
::placeholder { color: var(--text-s); }

/* ═══════════════════════ Select 美化 ═══════════════════════ */
.sel-wrap { position: relative; }
.sel-wrap::after {
  content: ""; position: absolute; right: 14px; top: 50%; transform: translateY(-60%) rotate(45deg);
  width: 7px; height: 7px; border-right: 2px solid var(--text-s); border-bottom: 2px solid var(--text-s);
  pointer-events: none;
}
.sel-wrap select { appearance: none; -webkit-appearance: none; padding-right: 38px; cursor: pointer; }

/* ═══════════════════════ 提示条 ═══════════════════════ */
.note { padding: 10px 14px; border-radius: var(--r-s); font-size: 0.875rem; margin-bottom: 10px; }
.note-i { background: var(--accent-l); color: #4338ca; }
.note-e { background: var(--red-l); color: #991b1b; }
.note-s { background: var(--green-l); color: var(--green); }

/* ═══════════════════════ Toast 通知 ═══════════════════════ */
.toast-container {
  position: fixed; top: 20px; right: 20px; z-index: 2000;
  display: flex; flex-direction: column; gap: 8px;
}
.toast {
  padding: 12px 20px; border-radius: var(--r-s); font-size: 0.875rem; font-weight: 500;
  box-shadow: var(--sh-lg); animation: toastIn .25s ease; min-width: 200px;
  display: flex; align-items: center; gap: 8px; opacity: 1; transition: opacity .3s;
}
.toast-success { background: var(--green); color: #fff; }
.toast-error { background: var(--red); color: #fff; }
.toast-info { background: var(--accent); color: #fff; }
@keyframes toastIn { from { opacity: 0; transform: translateX(20px); } to { opacity: 1; transform: translateX(0); } }

/* ═══════════════════════ 确认对话框 ═══════════════════════ */
.confirm-overlay {
  display: none; position: fixed; inset: 0; background: rgba(0,0,0,.4);
  z-index: 1100; align-items: center; justify-content: center;
  backdrop-filter: blur(2px);
}
.confirm-overlay.open { display: flex; }
.confirm-box {
  background: var(--card); border-radius: 16px; padding: 28px; width: 380px; max-width: 90%;
  box-shadow: 0 20px 60px rgba(0,0,0,.15); text-align: center; animation: modalIn .2s ease;
}
.confirm-icon { font-size: 2rem; margin-bottom: 12px; }
.confirm-title { font-size: 1rem; font-weight: 700; color: var(--text); margin-bottom: 8px; }
.confirm-msg { font-size: 0.875rem; color: var(--text-m); margin-bottom: 22px; line-height: 1.6; }
.confirm-actions { display: flex; gap: 10px; justify-content: center; }
@keyframes modalIn { from { opacity:0; transform:translateY(-12px) scale(.98); } to { opacity:1; transform:translateY(0) scale(1); } }

/* ═══════════════════════ 登录卡片 ═══════════════════════ */
.login-wrap { display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 20px; }
.login-card {
  width: 400px; max-width: 100%; background: var(--card); border: 1px solid var(--border);
  border-radius: 16px; padding: 44px 34px; box-shadow: var(--sh-lg); text-align: center;
}
.login-icon {
  width: 56px; height: 56px; margin: 0 auto 18px; border-radius: 14px;
  background: linear-gradient(135deg, var(--accent) 0%, var(--purple) 100%);
  display: flex; align-items: center; justify-content: center; font-size: 24px; color: #fff;
}
.login-title { font-size: 1.25rem; font-weight: 700; margin-bottom: 4px; color: var(--text); }
.login-sub { font-size: 0.875rem; color: var(--text-m); margin-bottom: 28px; }
.login-card input {
  text-align: center; font-size: 0.92rem; padding: 12px; width: 100%;
  border: 1px solid var(--border); border-radius: var(--r-s); color: var(--text);
  outline: none; transition: border .15s, box-shadow .15s; background: #fafbfc; font-family: inherit;
}
.login-card input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(79,70,229,.1); background: #fff; }
.login-card .btn { width: 100%; padding: 12px; font-size: 0.92rem; margin-top: 18px; justify-content: center; }

/* ═══════════════════════ Loading Spinner ═══════════════════════ */
.loading { text-align: center; padding: 40px; color: var(--text-s); font-size: 0.875rem; }
.spinner {
  display: inline-block; width: 24px; height: 24px; border: 3px solid var(--border);
  border-top-color: var(--accent); border-radius: 50%; animation: spin .6s linear infinite;
  margin-bottom: 8px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ═══════════════════════ 空状态 ═══════════════════════ */
.empty { text-align: center; padding: 48px 20px; color: var(--text-s); }
.empty-icon { font-size: 2.5rem; margin-bottom: 12px; opacity: .5; }
.empty-text { font-size: 0.875rem; }

/* ═══════════════════════ 滚动条 ═══════════════════════ */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 10px; }

/* ═══════════════════════ 响应式断点 ═══════════════════════ */
@media (max-width: 768px) {
  html { font-size: 14px; }
  .main, .wrap { padding: 16px 14px 32px; }
  .top-bar { padding: 0 14px; }
  .form-row { grid-template-columns: 1fr; }
  .row { flex-direction: column; }
  .login-card { padding: 32px 20px; }
}

@media (max-width: 480px) {
  html { font-size: 13px; }
  .toast-container { left: 10px; right: 10px; }
  .toast { min-width: auto; }
  .modal { border-radius: 16px 16px 0 0; margin-top: auto; }
}
