/* ============================================================
   base.css - 基础样式、设计变量、通用组件
   宁小库 原生重构版
   ============================================================ */

:root {
  /* 主题色板 */
  --primary: #6366f1;
  --primary-2: #8b5cf6;
  --primary-3: #4f46e5;
  --accent: #06b6d4;
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;

  /* 渐变 */
  --gradient-main: linear-gradient(135deg, #6366f1 0%, #8b5cf6 50%, #d946ef 100%);
  --gradient-brand: linear-gradient(135deg, #6366f1, #4f46e5);
  --gradient-soft: linear-gradient(135deg, rgba(99,102,241,.12), rgba(217,70,239,.10));

  /* 文本 */
  --text-1: #0f172a;
  --text-2: #475569;
  --text-3: #94a3b8;

  /* 背景 */
  --bg: #f1f5f9;
  --bg-soft: #eef2ff;
  --card: #ffffff;

  /* 边框/阴影 */
  --border: rgba(15, 23, 42, .08);
  --shadow-sm: 0 1px 3px rgba(15, 23, 42, .06);
  --shadow-md: 0 6px 18px rgba(15, 23, 42, .08);
  --shadow-lg: 0 16px 40px rgba(15, 23, 42, .12);

  /* 圆角 */
  --radius-sm: 8px;
  --radius: 14px;
  --radius-lg: 20px;
  --radius-xl: 28px;

  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body { min-height: 100%; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text-1);
  -webkit-font-smoothing: antialiased;
  line-height: 1.6;
}

a { color: inherit; text-decoration: none; }
button, input, textarea, select { font: inherit; color: inherit; }
ul, ol { list-style: none; }
img { display: block; max-width: 100%; }

#app { min-height: 100vh; }

.app-loading {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-3);
  font-size: 15px;
}

/* ---------- 通用按钮 ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 40px;
  padding: 0 18px;
  border: none;
  border-radius: 12px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all .18s ease;
  white-space: nowrap;
}
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--gradient-brand); color: #fff; box-shadow: 0 4px 14px rgba(99,102,241,.35); }
.btn-primary:hover { filter: brightness(1.08); box-shadow: 0 6px 20px rgba(99,102,241,.45); }
.btn-ghost { background: #fff; color: var(--text-2); border: 1px solid var(--border); }
.btn-ghost:hover { border-color: var(--primary); color: var(--primary); background: var(--bg-soft); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { filter: brightness(1.08); }
.btn-success { background: var(--success); color: #fff; }
.btn-success:hover { filter: brightness(1.08); }
.btn-warning { background: var(--warning); color: #fff; }
.btn-warning:hover { filter: brightness(1.06); }
.btn-sm { height: 32px; padding: 0 12px; font-size: 13px; border-radius: 10px; }

/* ---------- 表单 ---------- */
.input, .select, .textarea {
  width: 100%;
  border: 1.5px solid var(--border);
  border-radius: 12px;
  padding: 11px 14px;
  font-size: 14px;
  background: #fff;
  outline: none;
  transition: border-color .18s, box-shadow .18s;
}
.input:focus, .select:focus, .textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(99,102,241,.12);
}
.textarea { resize: vertical; min-height: 96px; }
.field { margin-bottom: 18px; }
.field > label { display: block; font-weight: 600; color: var(--text-2); margin-bottom: 8px; font-size: 14px; }

/* ---------- Toast ---------- */
#toast-root {
  position: fixed; top: 20px; left: 50%; transform: translateX(-50%);
  z-index: 9999; display: flex; flex-direction: column; gap: 10px; align-items: center;
  pointer-events: none;
}
.toast {
  background: rgba(15, 23, 42, .92);
  color: #fff; padding: 11px 22px; border-radius: 12px;
  font-size: 14px; box-shadow: var(--shadow-lg);
  animation: toast-in .25s ease; backdrop-filter: blur(8px);
}
.toast.success { background: rgba(16, 185, 129, .95); }
.toast.error { background: rgba(239, 68, 68, .95); }
@keyframes toast-in { from { opacity: 0; transform: translateY(-10px); } to { opacity: 1; transform: none; } }

/* ---------- 通用卡片 ---------- */
.card {
  background: var(--card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  border: 1px solid var(--border);
}

/* ---------- 空状态 ---------- */
.empty-state {
  text-align: center; color: var(--text-3); padding: 48px 20px;
}
.empty-state .empty-icon { font-size: 44px; margin-bottom: 10px; opacity: .6; }

/* ---------- 补充按钮态 ---------- */
.btn-block { display: flex; width: 100%; height: 46px; font-size: 15px; }
.btn-faved { background: linear-gradient(135deg, #f59e0b, #fbbf24); color: #fff; box-shadow: 0 4px 14px rgba(245,158,11,.35); }
.btn-faved:hover { filter: brightness(1.08); }
.btn-link { background: transparent; color: var(--primary); padding: 0; height: auto; }
.btn-link:hover { text-decoration: underline; background: transparent; }
.req { color: var(--danger); font-style: normal; }

/* ---------- 弹窗 ---------- */
#modal-root { position: fixed; inset: 0; z-index: 9000; pointer-events: none; }
.modal-mask {
  position: fixed; inset: 0; z-index: 9001; pointer-events: auto;
  background: rgba(15,23,42,.55); backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center; padding: 20px;
  animation: fade-in .18s ease;
}
.modal-card {
  background: #fff; border-radius: var(--radius-lg); box-shadow: var(--shadow-lg);
  width: 420px; max-width: 100%; max-height: 88vh; overflow: auto;
  padding: 26px; animation: pop-in .22s cubic-bezier(.2,.9,.3,1.2);
}
.modal-card.modal-lg { width: 600px; }
.modal-icon { font-size: 40px; text-align: center; margin-bottom: 14px; }
.modal-msg { text-align: center; color: var(--text-2); font-size: 15px; line-height: 1.7; margin-bottom: 22px; }
.modal-btns { display: flex; justify-content: center; gap: 12px; }
.modal-btns .btn { min-width: 110px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; }
.modal-title { font-size: 17px; font-weight: 800; }
.modal-close {
  border: none; background: #f1f5f9; width: 32px; height: 32px; border-radius: 50%;
  font-size: 18px; line-height: 1; cursor: pointer; color: var(--text-2); display: inline-flex;
  align-items: center; justify-content: center; transition: all .15s;
}
.modal-close:hover { background: #e2e8f0; color: var(--text-1); }
.modal-body .field:last-child { margin-bottom: 0; }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; margin-top: 22px; padding-top: 16px; border-top: 1px solid #f1f5f9; }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes pop-in { from { opacity: 0; transform: scale(.94) translateY(8px); } to { opacity: 1; transform: none; } }

/* ---------- Loading ---------- */
.is-loading { position: relative; }
.loading-spinner {
  position: absolute; inset: 0; z-index: 5; display: flex; align-items: center; justify-content: center;
  background: rgba(255,255,255,.72); backdrop-filter: blur(2px); border-radius: inherit;
}
.loading-spinner::after {
  content: ''; width: 30px; height: 30px; border-radius: 50%;
  border: 3px solid #e2e8f0; border-top-color: var(--primary);
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- 滚动条 ---------- */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: rgba(15,23,42,.15); border-radius: 8px; }
::-webkit-scrollbar-thumb:hover { background: rgba(15,23,42,.28); }
::-webkit-scrollbar-track { background: transparent; }
