/* =========================================================================
 * YaxsAI 统一设计系统 / Unified Design System
 * ----------------------------------------------------------------------------
 *  Apple SF 玻璃拟态风,全站共享(CSS Variables + 公共组件)
 *  兼容性: 现代浏览器(Chrome 90+ / Safari 14+ / Edge 90+ / Firefox 88+)
 * ========================================================================= */

:root {
  /* ── 基础色板 ── */
  --bg:           #f5f5f7;          /* 主背景:Apple 标志性浅灰 */
  --bg-elev:      #ffffff;          /* 卡片纯白 */
  --card:         rgba(255,255,255,0.72);  /* 毛玻璃基础色 */
  --card-strong:  rgba(255,255,255,0.88);
  --text:         #1d1d1f;          /* 主文字 */
  --text-2:       #424245;          /* 次要文字 */
  --muted:        #86868b;          /* 弱化文字 */
  --muted-2:      #a1a1a6;

  /* ── 品牌色 ── */
  --accent:       #0071e3;          /* 苹果蓝 */
  --accent-hover: #005bb5;
  --accent-soft:  rgba(0,113,227,0.10);
  --green:        #34c759;
  --green-soft:   rgba(52,199,89,0.12);
  --red:          #ff3b30;
  --red-soft:     rgba(255,59,48,0.10);
  --orange:       #ff9500;
  --orange-soft:  rgba(255,149,0,0.12);

  /* ── 边框 / 阴影 ── */
  --border:       rgba(0,0,0,0.06);
  --border-2:     rgba(0,0,0,0.10);
  --shadow:       0 4px 30px rgba(0,0,0,0.04);
  --shadow-hover: 0 10px 40px rgba(0,0,0,0.08);
  --shadow-lg:    0 20px 60px rgba(0,0,0,0.10);

  /* ── 圆角 ── */
  --r-sm:  8px;
  --r:     12px;
  --r-md:  16px;
  --r-lg:  20px;
  --r-pill: 999px;

  /* ── 排版 ── */
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, "SF Pro SC",
               "Segoe UI", Roboto, "PingFang SC", "Hiragino Sans GB",
               "Microsoft YaHei", Helvetica, Arial, sans-serif;
  --font-mono: 'SF Mono', Monaco, 'Cascadia Code', Consolas, 'Courier New', monospace;

  /* ── 动画 ── */
  --ease: cubic-bezier(0.25, 0.1, 0.25, 1);
  --ease-spring: cubic-bezier(0.16, 1, 0.3, 1);
}

/* ============== 基础重置 ============== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--font-sans);
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  min-height: 100vh;
  line-height: 1.5;
  background-image:
    radial-gradient(at 0% 0%, rgba(0,113,227,0.05) 0, transparent 50%),
    radial-gradient(at 100% 100%, rgba(52,199,89,0.04) 0, transparent 50%);
  background-attachment: fixed;
}
a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; border: none; background: none; }
input, textarea, select, button { font-family: inherit; }
code, pre { font-family: var(--font-mono); }

/* ============== 顶栏 (Topbar) ============== */
.topbar {
  position: fixed; top: 0; left: 0; right: 0;
  z-index: 100;
  display: flex; justify-content: space-between; align-items: center;
  padding: 14px 24px;
  background: rgba(245,245,247,0.78);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 1px solid var(--border);
}
.topbar .brand {
  display: flex; align-items: center; gap: 10px;
  padding: 4px 12px 4px 4px;
  background: rgba(255,255,255,0.6);
  border: 1px solid var(--border);
  border-radius: var(--r-pill);
  text-decoration: none; color: var(--text);
  transition: transform 0.2s var(--ease);
}
.topbar .brand:hover { transform: translateY(-1px); }
.topbar .brand .logo {
  width: 32px; height: 32px; min-width: 32px; min-height: 32px;
  border-radius: 8px;
  background: linear-gradient(135deg, #1d1d1f, #424245);
  color: #fff; font-weight: 700; font-size: 18px;
  display: inline-flex; align-items: center; justify-content: center;
  letter-spacing: -0.02em;
  flex-shrink: 0;
  overflow: hidden;
  position: relative;
  text-decoration: none;
  user-select: none;
}
/* SVG favicon / 真实 logo 都按 contain 显示,不变形 */
.topbar .brand .logo img,
.topbar .brand .logo svg {
  width: 100%; height: 100%;
  border-radius: 8px;
  object-fit: contain;          /* 完整显示 PNG/SVG,不变形 */
  display: block;
  background: transparent;
}
/* 当图加载失败(img.onerror)时,通过 CSS 显示 "Y" */
.topbar .brand .logo.is-text::before {
  content: "Y";
  color: #fff; font-size: 18px; font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1;
}
.topbar .brand .name {
  font-size: 15px; font-weight: 600; letter-spacing: -0.01em;
}
.topbar .actions { display: flex; align-items: center; gap: 8px; }

/* 顶栏图标按钮 (通知铃 / 用户头像) */
.icon-btn {
  width: 38px; height: 38px; border-radius: var(--r-pill);
  display: inline-flex; align-items: center; justify-content: center;
  background: rgba(255,255,255,0.6);
  border: 1px solid var(--border);
  color: var(--text);
  position: relative;
  transition: all 0.2s var(--ease);
  cursor: pointer;
}
.icon-btn:hover { background: var(--bg-elev); transform: translateY(-1px); }
.icon-btn .badge {
  position: absolute; top: -3px; right: -3px;
  min-width: 18px; height: 18px; padding: 0 5px;
  background: var(--red); color: #fff;
  font-size: 10px; font-weight: 700; line-height: 18px;
  border-radius: 9px; text-align: center;
  border: 2px solid var(--bg);
}
.icon-btn svg { display: block; }

/* ============== 侧边导航 (Sidebar) ============== */
.app-shell { display: flex; min-height: 100vh; padding-top: 70px; }
.sidebar {
  position: fixed; top: 70px; left: 0; bottom: 0;
  width: 240px; padding: 24px 16px;
  background: rgba(255,255,255,0.6);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column; gap: 4px;
  z-index: 50;
  overflow-y: auto;
}
.sidebar .nav-title {
  font-size: 11px; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.1em;
  color: var(--muted);
  padding: 8px 12px; margin-top: 4px;
}
.sidebar a.nav-item {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px; border-radius: 10px;
  color: var(--text-2);
  font-size: 14px; font-weight: 500;
  transition: all 0.15s var(--ease);
}
.sidebar a.nav-item:hover { background: rgba(0,0,0,0.04); color: var(--text); }
.sidebar a.nav-item.active {
  background: var(--accent); color: #fff;
  box-shadow: 0 2px 8px rgba(0,113,227,0.30);
}
.sidebar a.nav-item .ic { width: 18px; height: 18px; flex-shrink: 0; }
.sidebar .nav-footer {
  margin-top: auto;
  padding: 16px 12px;
  font-size: 11px;
  color: var(--muted);
  text-align: center;
}
.app-main {
  flex: 1;
  margin-left: 240px;
  padding: 32px 40px 64px;
  max-width: 1200px;
  width: calc(100% - 240px);
}

/* 移动端: 侧栏变抽屉 */
@media (max-width: 900px) {
  .sidebar {
    transform: translateX(-100%);
    transition: transform 0.35s var(--ease-spring);
    width: 280px;
  }
  .sidebar.open { transform: translateX(0); }
  .app-main { margin-left: 0; width: 100%; padding: 24px 16px 48px; }
}

/* ============== 汉堡按钮 (移动端) ============== */
.hamburger {
  width: 38px; height: 38px;
  display: none; align-items: center; justify-content: center;
  background: rgba(255,255,255,0.6);
  border: 1px solid var(--border);
  border-radius: var(--r-pill);
  position: relative; cursor: pointer; padding: 0;
  transition: all 0.2s var(--ease);
}
.hamburger:hover { background: var(--bg-elev); }
.hamburger span {
  position: absolute; left: 11px; right: 11px; height: 2px;
  background: var(--text); border-radius: 1px;
  transition: all 0.3s var(--ease);
}
.hamburger span:nth-child(1) { top: 13px; }
.hamburger span:nth-child(2) { top: 18px; }
.hamburger span:nth-child(3) { top: 23px; }
.hamburger.active span:nth-child(1) { top: 18px; transform: rotate(45deg); }
.hamburger.active span:nth-child(2) { opacity: 0; }
.hamburger.active span:nth-child(3) { top: 18px; transform: rotate(-45deg); }
@media (max-width: 900px) { .hamburger { display: flex; } }

/* 抽屉遮罩 */
.drawer-mask {
  position: fixed; inset: 0; background: rgba(0,0,0,0);
  pointer-events: none; z-index: 49;
  transition: background 0.3s;
}
.drawer-mask.open { background: rgba(0,0,0,0.35); pointer-events: auto; }
@media (min-width: 901px) { .drawer-mask { display: none; } }

/* ============== 卡片 / Card ============== */
.card {
  background: var(--card);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  box-shadow: var(--shadow);
  padding: 24px;
  margin-bottom: 20px;
  transition: box-shadow 0.3s var(--ease);
}
.card:hover { box-shadow: var(--shadow-hover); }
.card-title {
  font-size: 11px; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.1em;
  color: var(--muted);
  margin-bottom: 16px;
  display: flex; align-items: center; justify-content: space-between;
}
.card-title .actions { display: flex; gap: 6px; }
.card h2, .card h3 { color: var(--text); font-weight: 600; letter-spacing: -0.01em; }

/* 静态卡片(不需要 hover 效果) */
.card-flat:hover { box-shadow: var(--shadow); transform: none; }

/* ============== 统计卡片 ============== */
.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}
.stat-card {
  background: var(--card);
  backdrop-filter: blur(20px);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 22px;
  box-shadow: var(--shadow);
  transition: all 0.3s var(--ease);
}
.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-hover); }
.stat-card .num {
  font-size: 34px; font-weight: 700; letter-spacing: -0.02em;
  line-height: 1; color: var(--text);
  font-variant-numeric: tabular-nums;
}
.stat-card .label {
  font-size: 13px; color: var(--muted);
  margin-top: 8px; font-weight: 500;
}
.stat-card.accent-blue .num   { color: var(--accent); }
.stat-card.accent-green .num  { color: var(--green); }
.stat-card.accent-orange .num { color: var(--orange); }
.stat-card.accent-red .num    { color: var(--red); }

/* ============== 按钮 ============== */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 10px 18px;
  font-size: 14px; font-weight: 500;
  border-radius: 10px;
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.15s var(--ease);
  white-space: nowrap;
  line-height: 1.2;
  user-select: none;
}
.btn:disabled { opacity: 0.5; cursor: not-allowed !important; }
.btn-primary {
  background: var(--text); color: #fff;
}
.btn-primary:hover:not(:disabled) { background: #000; transform: translateY(-1px); }
.btn-accent {
  background: var(--accent); color: #fff;
  box-shadow: 0 2px 8px rgba(0,113,227,0.25);
}
.btn-accent:hover:not(:disabled) { background: var(--accent-hover); transform: translateY(-1px); }
.btn-secondary {
  background: rgba(255,255,255,0.6);
  color: var(--text);
  border-color: var(--border);
}
.btn-secondary:hover:not(:disabled) { background: var(--bg-elev); border-color: var(--border-2); }
.btn-danger {
  background: transparent; color: var(--red);
  border-color: var(--red);
}
.btn-danger:hover:not(:disabled) { background: var(--red); color: #fff; }
.btn-success {
  background: var(--green); color: #fff;
}
.btn-success:hover:not(:disabled) { background: #2aa84a; }
.btn-warn {
  background: var(--orange); color: #fff;
}
.btn-warn:hover:not(:disabled) { background: #d97d00; }
.btn-ghost {
  background: transparent; color: var(--text-2);
}
.btn-ghost:hover:not(:disabled) { background: rgba(0,0,0,0.05); color: var(--text); }
.btn-sm { padding: 7px 12px; font-size: 13px; border-radius: 8px; }
.btn-lg { padding: 14px 28px; font-size: 16px; border-radius: 12px; }
.btn-block { width: 100%; }

/* ============== 表单 ============== */
.field { margin-bottom: 16px; }
.field label {
  display: block;
  font-size: 12px; font-weight: 600;
  color: var(--muted);
  text-transform: uppercase; letter-spacing: 0.08em;
  margin-bottom: 6px;
}
.field .hint { font-size: 12px; color: var(--muted); margin-top: 4px; }

input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="tel"],
input[type="url"],
input[type="search"],
input[type="file"],
textarea,
select {
  width: 100%;
  padding: 11px 14px;
  font-size: 14px;
  color: var(--text);
  background: rgba(255,255,255,0.6);
  border: 1px solid var(--border);
  border-radius: 10px;
  transition: all 0.2s var(--ease);
  -webkit-appearance: none;
  appearance: none;
}
input:focus, textarea:focus, select:focus {
  outline: none;
  background: #fff;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(0,113,227,0.15);
}
input::placeholder, textarea::placeholder { color: var(--muted-2); }
textarea { min-height: 100px; resize: vertical; line-height: 1.5; }
select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8'%3E%3Cpath fill='%2386868b' d='M6 8L0 0h12z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  background-size: 10px;
  padding-right: 36px;
}
input[type="file"] { padding: 9px 12px; }
input[type="checkbox"], input[type="radio"] {
  width: 16px; height: 16px;
  accent-color: var(--accent);
  cursor: pointer;
}
.check-line {
  display: inline-flex; align-items: center; gap: 8px;
  font-size: 14px; color: var(--text-2);
  cursor: pointer; user-select: none;
}

/* ============== 提示 / Alert ============== */
.alert {
  padding: 12px 16px;
  border-radius: var(--r);
  font-size: 14px; font-weight: 500;
  margin-bottom: 20px;
  display: flex; align-items: center; gap: 10px;
  line-height: 1.5;
}
.alert-icon {
  width: 20px; height: 20px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  flex-shrink: 0; font-size: 12px; font-weight: 700;
}
.alert-success { background: var(--green-soft); color: #1d7d3a; }
.alert-success .alert-icon { background: var(--green); color: #fff; }
.alert-error   { background: var(--red-soft); color: #b3271e; }
.alert-error   .alert-icon { background: var(--red); color: #fff; }
.alert-info    { background: var(--accent-soft); color: var(--accent-hover); }
.alert-info    .alert-icon { background: var(--accent); color: #fff; }
.alert-warn    { background: var(--orange-soft); color: #b36000; }
.alert-warn    .alert-icon { background: var(--orange); color: #fff; }

/* ============== 徽章 / Badge ============== */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 9px; border-radius: 8px;
  font-size: 11px; font-weight: 600;
  letter-spacing: 0.02em;
  background: rgba(0,0,0,0.06); color: var(--text-2);
}
.badge-primary { background: var(--accent-soft); color: var(--accent-hover); }
.badge-success { background: var(--green-soft); color: #1d7d3a; }
.badge-danger  { background: var(--red-soft); color: #b3271e; }
.badge-warn    { background: var(--orange-soft); color: #b36000; }
.badge-muted   { background: rgba(0,0,0,0.06); color: var(--muted); }

/* ============== 表格 / Table ============== */
.table-wrap {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--r);
  overflow: hidden;
  overflow-x: auto;
  margin-top: 16px;
}
table.data {
  width: 100%; border-collapse: collapse;
  font-size: 13px; background: #fff;
}
table.data th, table.data td {
  padding: 12px 14px; text-align: left;
  border-bottom: 1px solid var(--border);
}
table.data tr:last-child td { border-bottom: none; }
table.data th {
  background: rgba(0,0,0,0.02);
  color: var(--muted); font-weight: 600;
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em;
}
table.data tr:hover td { background: rgba(0,113,227,0.03); }

/* ============== 状态指示灯 ============== */
.dot {
  display: inline-block; width: 8px; height: 8px;
  border-radius: 50%; margin-right: 6px; vertical-align: middle;
}
.dot.green { background: var(--green); box-shadow: 0 0 8px var(--green); }
.dot.red   { background: var(--red);   box-shadow: 0 0 8px var(--red); }
.dot.gray  { background: var(--muted-2); }

/* ============== 进度条 ============== */
.progress {
  width: 100%; height: 8px;
  background: rgba(0,0,0,0.05);
  border-radius: var(--r-pill);
  overflow: hidden;
}
.progress > .bar {
  height: 100%; border-radius: var(--r-pill);
  background: var(--accent);
  transition: width 0.6s var(--ease);
}
.progress > .bar.green  { background: var(--green); }
.progress > .bar.orange { background: var(--orange); }
.progress > .bar.red    { background: var(--red); }

/* ============== Hero / 标题区 ============== */
.page-header {
  margin-bottom: 32px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--border);
}
.page-header h1 {
  font-size: 32px; font-weight: 700; letter-spacing: -0.02em;
  color: var(--text);
  line-height: 1.2;
}
.page-header .subtitle {
  font-size: 15px; color: var(--muted); margin-top: 6px;
}
.page-header .actions { margin-top: 16px; display: flex; gap: 10px; flex-wrap: wrap; }

/* ============== 网格 ============== */
.grid {
  display: grid; gap: 16px;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
}

/* ============== 内联表单辅助 ============== */
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.row > * { flex: 0 0 auto; }
.row .field { flex: 1; min-width: 0; margin-bottom: 0; }
.stack { display: flex; flex-direction: column; gap: 10px; }

/* ============== 弹窗 / Modal ============== */
.modal-mask {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.4);
  backdrop-filter: blur(8px);
  z-index: 9999;
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
  animation: fadeIn 0.2s var(--ease);
}
.modal-box {
  width: 100%; max-width: 440px;
  background: var(--card-strong);
  backdrop-filter: blur(20px);
  border: 1px solid rgba(255,255,255,0.5);
  border-radius: var(--r-lg);
  padding: 32px 28px;
  box-shadow: var(--shadow-lg);
  text-align: center;
  animation: popIn 0.3s var(--ease-spring);
}
.modal-title { font-size: 18px; font-weight: 600; margin-bottom: 8px; }
.modal-desc  { font-size: 14px; color: var(--muted); line-height: 1.6; margin-bottom: 20px; }
.modal-actions { display: flex; gap: 10px; }
.modal-actions .btn { flex: 1; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes popIn  { from { opacity: 0; transform: scale(0.92); } to { opacity: 1; transform: scale(1); } }

/* ============== 空状态 ============== */
.empty {
  text-align: center; padding: 60px 20px;
  color: var(--muted);
}
.empty .icon { font-size: 40px; margin-bottom: 12px; opacity: 0.6; }
.empty .title { font-size: 15px; color: var(--text-2); margin-bottom: 6px; }
.empty .desc  { font-size: 13px; }

/* ============== 工具类 ============== */
.text-muted { color: var(--muted); }
.text-sm    { font-size: 12px; }
.text-center { text-align: center; }
.mt-1 { margin-top: 8px; } .mt-2 { margin-top: 16px; } .mt-3 { margin-top: 24px; }
.mb-1 { margin-bottom: 8px; } .mb-2 { margin-bottom: 16px; } .mb-3 { margin-bottom: 24px; }
.mono { font-family: var(--font-mono); font-size: 13px; }
.code { font-family: var(--font-mono); background: rgba(0,0,0,0.05); padding: 1px 6px; border-radius: 4px; font-size: 12px; }
.hidden { display: none !important; }

/* ============== 响应式 ============== */
@media (max-width: 600px) {
  .topbar { padding: 12px 16px; }
  .topbar .brand .name { display: none; }
  .stat-card .num { font-size: 28px; }
  .card { padding: 18px; }
  .page-header h1 { font-size: 24px; }
  .row { flex-direction: column; align-items: stretch; }
  .row .btn { width: 100%; }
  .modal-box { padding: 24px 20px; }
}
