/* ==========================================================================
   短信平台 · 统一设计系统 (Radix UI + Tailwind 风格)
   每个页面都通过 <link> 引入本文件，:root Token 因此在每页均生效。
   ========================================================================== */

:root {
  /* Accent 色阶（蓝色） */
  --accent-1:  hsl(206, 100%, 99%);
  --accent-2:  hsl(210, 100%, 98%);
  --accent-3:  hsl(209, 100%, 96%);
  --accent-4:  hsl(210,  98%, 93%);
  --accent-9:  hsl(206, 100%, 50%);   /* 主色，按钮填充 */
  --accent-10: hsl(208, 100%, 47%);   /* 主色 hover */
  --accent-11: hsl(211, 100%, 42%);   /* 主色 active / 文字 */

  /* 灰色阶 */
  --gray-1:  hsl(0, 0%, 99%);         /* 页面背景 */
  --gray-2:  hsl(0, 0%, 97.3%);       /* 区块背景 */
  --gray-3:  hsl(0, 0%, 95.1%);       /* 悬浮背景 */
  --gray-4:  hsl(0, 0%, 93%);         /* 卡片边框 */
  --gray-5:  hsl(0, 0%, 90.9%);       /* Switch 背景 */
  --gray-6:  hsl(0, 0%, 88.7%);       /* 分割线 */
  --gray-7:  hsl(0, 0%, 85.8%);       /* 禁用状态 */
  --gray-8:  hsl(0, 0%, 78%);         /* placeholder */
  --gray-9:  hsl(0, 0%, 56.1%);       /* 辅助文字 */
  --gray-11: hsl(0, 0%, 43.5%);       /* 次要文字 */
  --gray-12: hsl(0, 0%, 9%);          /* 主文字 */

  /* 语义色 */
  --success-bg: hsl(142, 76%, 94%);
  --success-fg: hsl(142, 71%, 25%);
  --warning-bg: hsl(48, 100%, 93%);
  --warning-fg: hsl(32, 95%, 30%);

  --radius-card: 12px;
  --radius-ctrl: 6px;
  --shadow-card: 0 1px 3px rgba(0,0,0,.04), 0 1px 2px rgba(0,0,0,.06);
  --shadow-card-hover: 0 4px 12px rgba(0,0,0,.08);
  --sidebar-w: 232px;
  --topbar-h: 56px;
}

/* ------------------------------ 基础 ------------------------------ */
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI',
               'PingFang SC', 'Microsoft YaHei', sans-serif;
  background: var(--gray-1);
  color: var(--gray-12);
  font-weight: 400;
  line-height: 1.6;
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 { margin: 0; }
a { color: inherit; text-decoration: none; }
p { margin: 0; }

.text-secondary { color: var(--gray-11); }
.text-muted { color: var(--gray-9); }

/* 标题体系 */
.h-display { font-weight: 800; letter-spacing: -0.02em; }
.h-title   { font-weight: 600; }

/* ------------------------------ 无障碍 ------------------------------ */
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}
.focus\:not-sr-only:focus, .sr-only:focus {
  position: fixed; top: 12px; left: 12px; z-index: 100;
  width: auto; height: auto; margin: 0; clip: auto; white-space: normal;
  padding: 8px 16px; background: var(--accent-9); color: #fff;
  border-radius: var(--radius-ctrl); box-shadow: var(--shadow-card-hover);
}

/* ------------------------------ 卡片 ------------------------------ */
.card {
  background: #fff;
  border: 1px solid var(--gray-4);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-card);
  transition: box-shadow 150ms ease;
}
.card-hover:hover { box-shadow: var(--shadow-card-hover); }

/* ------------------------------ 按钮 ------------------------------ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 36px; padding: 0 14px;
  border-radius: var(--radius-ctrl);
  font-size: 14px; font-weight: 500; line-height: 1;
  border: 1px solid transparent; cursor: pointer;
  transition: background 130ms ease, box-shadow 130ms ease, transform 120ms ease;
  white-space: nowrap; user-select: none;
}
.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn:focus-visible { outline: none; box-shadow: 0 0 0 2px #fff, 0 0 0 4px var(--accent-9); }
.btn-sm { height: 30px; padding: 0 10px; font-size: 13px; }
.btn-block { width: 100%; }

.btn-solid   { background: var(--accent-9); color: #fff; }
.btn-solid:hover   { background: var(--accent-10); }
.btn-soft    { background: var(--accent-3); color: var(--accent-11); }
.btn-soft:hover    { background: var(--accent-4); }
.btn-outline { border-color: hsl(210,80%,75%); color: var(--accent-11); background: #fff; }
.btn-outline:hover { background: var(--accent-2); }
.btn-ghost   { background: transparent; color: var(--gray-12); }
.btn-ghost:hover   { background: var(--gray-3); }
.btn-danger  { background: hsl(358,75%,54%); color: #fff; }
.btn-danger:hover  { background: hsl(358,70%,48%); }

/* ------------------------------ Badge ------------------------------ */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  border-radius: 9999px; padding: 2px 10px;
  font-size: 11px; font-weight: 500; line-height: 1.5;
}
.badge-blue    { background: var(--accent-3); color: var(--accent-11); }
.badge-success { background: var(--success-bg); color: var(--success-fg); }
.badge-warning { background: var(--warning-bg); color: var(--warning-fg); }
.badge-solid   { background: var(--accent-9); color: #fff; }
.badge-gray    { background: var(--gray-3); color: var(--gray-11); }
.badge-danger  { background: hsl(358,100%,95%); color: hsl(358,65%,42%); }

/* ------------------------------ 分割线 ------------------------------ */
hr { border: none; background: var(--gray-4); height: 1px; margin: 0; }

/* ------------------------------ 进度条 ------------------------------ */
.progress { height: 6px; border-radius: 9999px; background: var(--gray-3); overflow: hidden; }
.progress > i { display: block; height: 100%; background: var(--accent-9);
  border-radius: 9999px; transition: width .5s ease; }

/* ------------------------------ Switch ------------------------------ */
.switch {
  position: relative; width: 36px; height: 20px; border-radius: 9999px;
  background: var(--gray-5); border: none; cursor: pointer; padding: 0;
  transition: background 150ms ease; flex: none;
}
.switch::after {
  content: ""; position: absolute; top: 2px; left: 2px;
  width: 16px; height: 16px; border-radius: 9999px; background: #fff;
  box-shadow: 0 1px 2px rgba(0,0,0,.25); transition: transform 150ms ease;
}
.switch[aria-checked="true"] { background: var(--accent-9); }
.switch[aria-checked="true"]::after { transform: translateX(16px); }
.switch:focus-visible { outline: none; box-shadow: 0 0 0 2px #fff, 0 0 0 4px var(--accent-9); }

/* ------------------------------ Tooltip ------------------------------ */
.tip { position: relative; display: inline-flex; }
.tip > .tip-body {
  position: absolute; bottom: calc(100% + 6px); left: 50%; transform: translateX(-50%);
  background: var(--gray-12); color: #fff; border-radius: 4px;
  font-size: 11px; line-height: 1.4; padding: 4px 8px; white-space: nowrap;
  opacity: 0; pointer-events: none; transition: opacity 130ms ease; z-index: 50;
}
.tip:hover > .tip-body, .tip:focus-within > .tip-body { opacity: 1; }

/* ------------------------------ 表单 Input ------------------------------ */
.input, .select, .textarea {
  width: 100%; border: 1px solid var(--gray-5); border-radius: var(--radius-ctrl);
  background: #fff; font-size: 14px; color: var(--gray-12);
  font-family: inherit; transition: border-color 130ms ease, box-shadow 130ms ease;
}
.input, .select { height: 36px; padding: 0 12px; }
.textarea { padding: 10px 12px; line-height: 1.6; resize: vertical; }
.input::placeholder, .textarea::placeholder { color: var(--gray-8); }
.input:focus, .select:focus, .textarea:focus {
  outline: none; border-color: var(--accent-9); box-shadow: 0 0 0 3px var(--accent-3);
}
.select { appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%237a7a7a' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center; padding-right: 34px; }
.field-label { display: block; font-size: 13px; font-weight: 500; color: var(--gray-12); margin-bottom: 6px; }
.field-error { color: hsl(358,65%,48%); font-size: 12px; margin-top: 4px; }

/* ------------------------------ 表格 ------------------------------ */
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table thead th {
  text-align: left; font-weight: 600; color: var(--gray-11);
  font-size: 12px; letter-spacing: .02em; padding: 12px 16px;
  border-bottom: 1px solid var(--gray-4); white-space: nowrap; background: var(--gray-2);
}
.table tbody td { padding: 14px 16px; border-bottom: 1px solid var(--gray-3); color: var(--gray-12); }
.table tbody tr:hover { background: var(--gray-2); }
.table .empty { text-align: center; color: var(--gray-9); padding: 48px 16px; }

/* ------------------------------ 应用外壳 ------------------------------ */
.app { min-height: 100vh; }

.topbar {
  position: sticky; top: 0; z-index: 40; height: var(--topbar-h);
  display: flex; align-items: center; gap: 16px; padding: 0 24px;
  background: rgba(255,255,255,0.85); backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px); border-bottom: 1px solid var(--gray-4);
}

.sidebar {
  position: fixed; top: 0; left: 0; bottom: 0; width: var(--sidebar-w);
  background: #fff; border-right: 1px solid var(--gray-4);
  display: flex; flex-direction: column; padding: 16px 12px; overflow-y: auto; z-index: 30;
}
.sidebar-brand { display: flex; align-items: center; gap: 10px; padding: 6px 8px 18px; }
.sidebar-brand .logo {
  width: 30px; height: 30px; border-radius: 8px; background: var(--accent-9);
  display: grid; place-items: center; color: #fff; flex: none;
}
.nav-item {
  display: flex; align-items: center; gap: 12px; padding: 9px 12px;
  border-radius: 8px; color: var(--gray-11); font-size: 14px; font-weight: 500;
  transition: background 130ms ease, color 130ms ease; cursor: pointer;
}
.nav-item:hover { background: var(--gray-3); color: var(--gray-12); }
.nav-item.active { background: var(--accent-9); color: #fff; }
.nav-item.active svg { color: #fff; }
.nav-item svg { color: var(--gray-9); flex: none; }
.nav-group-label { font-size: 11px; font-weight: 600; color: var(--gray-9);
  text-transform: uppercase; letter-spacing: .04em; padding: 16px 12px 6px; }
.nav-sub { display: flex; align-items: center; gap: 12px; padding: 8px 12px 8px 40px;
  border-radius: 8px; color: var(--gray-11); font-size: 13px; transition: background 130ms ease; }
.nav-sub:hover { background: var(--gray-3); color: var(--gray-12); }
.nav-sub.active { color: var(--accent-11); font-weight: 600; }

.content { margin-left: var(--sidebar-w); min-height: 100vh; display: flex; flex-direction: column; }
.page { padding: 24px; flex: 1; }
.page-narrow { max-width: 1160px; margin: 0 auto; width: 100%; }

/* 子标签（短信模块顶部 tabs） */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--gray-4); overflow-x: auto; }
.tab { padding: 12px 14px; font-size: 14px; font-weight: 500; color: var(--gray-11);
  border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap;
  transition: color 130ms ease; cursor: pointer; }
.tab:hover { color: var(--gray-12); }
.tab.active { color: var(--accent-11); border-bottom-color: var(--accent-9); font-weight: 600; }

/* 头像 */
.avatar { border-radius: 9999px; background: var(--accent-3); color: var(--accent-11);
  display: grid; place-items: center; font-weight: 600; flex: none; }

/* ------------------------------ 动画 ------------------------------ */
@keyframes enter { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: none; } }
.animate-enter { opacity: 0; animation: enter .5s ease forwards; }
.delay-1 { animation-delay: .06s; }
.delay-2 { animation-delay: .12s; }
.delay-3 { animation-delay: .18s; }
.delay-4 { animation-delay: .24s; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; transition-duration: .001ms !important; }
}

/* ------------------------------ 响应式 ------------------------------ */
@media (max-width: 900px) {
  .sidebar { transform: translateX(-100%); transition: transform .2s ease; }
  .sidebar.open { transform: none; box-shadow: var(--shadow-card-hover); }
  .content { margin-left: 0; }
}
