/* ============================================================
   设计系统 · 布局层
   ── 登录页 / 应用骨架 / 侧边栏 / 顶栏 / 内容区 / 响应式
   栅格与间距全部取自 base.css 的刻度表，不出现魔法数字。
   ============================================================ */

/* ============ 1. 登录页 ============
   左品牌右表单的分栏。左侧用主色渐变压住场子，
   右侧留大量留白，让表单成为唯一的视觉焦点。 */
.auth {
  display: grid;
  grid-template-columns: 1.05fr .95fr;
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--bg);
}

/* —— 左：品牌区 —— */
.auth__brand {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: var(--sp-12) var(--sp-12) var(--sp-8);
  background: radial-gradient(120% 100% at 0% 0%, #5B54E8 0%, #4338CA 45%, #312E81 100%);
  color: #fff;
  overflow: hidden;
}
/* 两团柔光，避免大面积纯色显得平板 */
.auth__brand::before,
.auth__brand::after {
  content: '';
  position: absolute;
  border-radius: 50%;
  pointer-events: none;
}
.auth__brand::before {
  width: 520px; height: 520px;
  top: -180px; right: -160px;
  background: radial-gradient(circle, rgba(165, 180, 252, .35), transparent 70%);
}
.auth__brand::after {
  width: 420px; height: 420px;
  bottom: -200px; left: -120px;
  background: radial-gradient(circle, rgba(129, 140, 248, .28), transparent 70%);
}

.auth__brand-inner {
  position: relative;
  z-index: 1;
  max-width: 460px;
  animation: fadeUp var(--dur-slow) var(--ease-out) both;
}

.auth__logo {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  font-size: var(--fs-md);
  font-weight: var(--fw-semi);
  letter-spacing: .01em;
}

.auth__title {
  margin-top: var(--sp-12);
  font-size: var(--fs-5xl);
  font-weight: var(--fw-bold);
  line-height: 1.24;
  letter-spacing: -.02em;
  color: #fff;
}

.auth__desc {
  margin-top: var(--sp-5);
  font-size: var(--fs-md);
  line-height: var(--lh-base);
  color: rgba(255, 255, 255, .74);
  max-width: 400px;
}

.auth__points {
  margin-top: var(--sp-10);
  display: flex;
  flex-direction: column;
  gap: var(--sp-4);
}
.auth__points li {
  display: flex;
  align-items: flex-start;
  gap: var(--sp-3);
  font-size: var(--fs-base);
  line-height: var(--lh-snug);
  color: rgba(255, 255, 255, .82);
}
.auth__points .dot {
  flex: none;
  width: 5px; height: 5px;
  margin-top: 8px;
  border-radius: 50%;
  background: rgba(255, 255, 255, .9);
}

.auth__footer {
  position: relative;
  z-index: 1;
  font-size: var(--fs-sm);
  color: rgba(255, 255, 255, .5);
}

/* —— 右：表单区 —— */
.auth__panel {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--sp-10) var(--sp-8);
  background: var(--surface);
}

.auth__form-wrap {
  width: 100%;
  max-width: 372px;
  animation: fadeUp var(--dur-slow) var(--ease-out) 60ms both;
}

.auth__mobile-logo {
  display: none;
  align-items: center;
  gap: var(--sp-2);
  margin-bottom: var(--sp-8);
  font-size: var(--fs-lg);
  font-weight: var(--fw-semi);
  color: var(--text);
}

.auth__h2 {
  font-size: var(--fs-3xl);
  font-weight: var(--fw-bold);
  letter-spacing: -.015em;
  color: var(--text);
}
.auth__sub {
  margin-top: var(--sp-2);
  font-size: var(--fs-base);
  color: var(--muted);
}

.auth__row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: calc(var(--sp-2) * -1) 0 var(--sp-5);
}

.auth__switch {
  margin-top: var(--sp-6);
  text-align: center;
  font-size: var(--fs-base);
  color: var(--muted);
}
.auth__switch b {
  display: inline-block;
  font-weight: var(--fw-normal);
  transition: transform var(--dur-base) var(--ease-out);
}
.auth__switch a:hover b { transform: translateX(3px); }

.auth__demo {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  flex-wrap: wrap;
  margin-top: var(--sp-8);
  padding: var(--sp-3) var(--sp-4);
  font-size: var(--fs-sm);
  color: var(--muted);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
}
.auth__demo code {
  padding: 1px 6px;
  font-size: var(--fs-sm);
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-xs);
}
.auth__demo > span { font-weight: var(--fw-medium); color: var(--text-2); }
.auth__demo .btn { margin-left: auto; }

/* ============ 2. 应用骨架 ============ */
.layout {
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  min-height: 100vh;
  min-height: 100dvh;
}

.layout__main {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 100vh;
  min-height: 100dvh;
}

/* 移动端遮罩 —— 默认 display:none 让 Playwright actionability 检查跳过它。
   打开时 display: block + fadeIn 动画；关闭时瞬间消失（trade-off：可接受）。 */
.layout__mask {
  position: fixed;
  inset: 0;
  z-index: var(--z-mask);
  display: none;
  background: rgba(12, 10, 9, .45);
  backdrop-filter: blur(2px);
}
.layout.is-drawer .layout__mask {
  display: block;
  animation: fadeIn var(--dur-base) var(--ease) both;
}

/* ============ 3. 侧边栏 ============ */
.sidebar {
  position: sticky;
  top: 0;
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  background: var(--sidebar-bg);
  border-right: 1px solid var(--border);
  z-index: var(--z-sidebar);
}

.sidebar__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-2);
  height: var(--topbar-h);
  padding: 0 var(--sp-5);
  border-bottom: 1px solid var(--border);
  flex: none;
}

.sidebar__logo {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  min-width: 0;
}
.sidebar__logo svg { flex: none; }
.sidebar__logo-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
  line-height: 1.25;
}
.sidebar__logo-text b {
  font-size: var(--fs-md);
  font-weight: var(--fw-semi);
  color: var(--text);
  letter-spacing: .01em;
}
.sidebar__logo-text small {
  font-size: var(--fs-xs);
  color: var(--muted);
}

.sidebar__close { display: none; }

.sidebar__nav {
  flex: 1;
  overflow-y: auto;
  padding: var(--sp-5) var(--sp-3);
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.sidebar__group {
  padding: var(--sp-4) var(--sp-3) var(--sp-2);
  font-size: var(--fs-xs);
  font-weight: var(--fw-semi);
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--gray-400);
}
.sidebar__group:first-child { padding-top: var(--sp-1); }

.sidebar__foot {
  flex: none;
  padding: var(--sp-4);
  border-top: 1px solid var(--border);
}
.sidebar__tip {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: var(--sp-3);
  font-size: var(--fs-xs);
  line-height: var(--lh-snug);
  color: var(--muted);
  background: var(--surface-2);
  border-radius: var(--r-md);
}
.sidebar__tip b {
  font-size: var(--fs-sm);
  font-weight: var(--fw-semi);
  color: var(--text-2);
}

/* ============ 4. 顶栏 ============ */
.topbar {
  position: sticky;
  top: 0;
  z-index: var(--z-sticky);
  display: flex;
  align-items: center;
  gap: var(--sp-4);
  height: var(--topbar-h);
  padding: 0 var(--sp-6);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex: none;
}
@supports (backdrop-filter: blur(1px)) {
  .topbar {
    background: color-mix(in srgb, var(--surface) 84%, transparent);
    backdrop-filter: saturate(180%) blur(12px);
    -webkit-backdrop-filter: saturate(180%) blur(12px);
  }
}

.topbar__burger { display: none; }

.topbar__title {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
}
.topbar__title h1 {
  font-size: var(--fs-lg);
  font-weight: var(--fw-semi);
  letter-spacing: -.01em;
  line-height: 1.3;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topbar__actions {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  margin-left: auto;
}

/* ============ 5. 内容区 ============ */
.content {
  flex: 1;
  width: 100%;
  max-width: 1560px;
  margin: 0 auto;
  padding: var(--sp-6);
  animation: fadeUp var(--dur-base) var(--ease-out) both;
}

/* ============ 6. 响应式 ============ */

@media (min-width: 1600px) {
  .auth { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 1280px) {
  :root { --sidebar-w: 224px; }
}

/* 平板：登录页合并为单栏，隐藏品牌区 */
@media (max-width: 1024px) {
  .auth { grid-template-columns: 1fr; }
  .auth__brand { display: none; }
  .auth__panel { padding: var(--sp-8) var(--sp-6); }
  .auth__mobile-logo { display: flex; }
  .content { padding: var(--sp-5); }
}

/* 中小屏：侧边栏转抽屉 */
@media (max-width: 900px) {
  .layout { grid-template-columns: minmax(0, 1fr); }

  .sidebar {
    position: fixed;
    top: 0; left: 0;
    width: 272px;
    max-width: 84vw;
    transform: translateX(-100%);
    visibility: hidden;          /* Playwright 跳过、键盘 tab 也跳过 */
    pointer-events: none;
    transition: transform var(--dur-slow) var(--ease-out),
                visibility 0s linear var(--dur-slow);
    box-shadow: var(--shadow-xl);
  }
  .layout.is-drawer .sidebar {
    transform: translateX(0);
    visibility: visible;
    pointer-events: auto;
    transition: transform var(--dur-slow) var(--ease-out),
                visibility 0s linear 0s;
  }

  .sidebar__close { display: inline-flex; }
  .topbar__burger { display: inline-flex; }

  .topbar { padding: 0 var(--sp-4); gap: var(--sp-3); }
  .content { padding: var(--sp-4); }
}

/* 手机 */
@media (max-width: 640px) {
  .auth__panel {
    padding: var(--sp-6) var(--sp-5);
    align-items: flex-start;
  }
  .auth__form-wrap { max-width: 100%; }
  .auth__h2 { font-size: var(--fs-2xl); }

  .topbar { height: 56px; padding: 0 var(--sp-4); }
  .topbar__title h1 { font-size: var(--fs-md); }

  .content { padding: var(--sp-4) var(--sp-3) var(--sp-8); }
}

/* 极窄屏 */
@media (max-width: 400px) {
  .content { padding: var(--sp-3) var(--sp-2) var(--sp-8); }
  .auth__panel { padding: var(--sp-5) var(--sp-4); }
}
