/* auth.css — 全站登录/注册统一组件（dashboard #login · chat #login-modal/#signup-modal · models #signup-modal · enterprise #login-wall/#register-wall）
   只引用 _shared/ui.css 的既有令牌（--surface/--border/--bg/--accent/--accent-light/--accent-glow/--red/--green/--radius/--shadow-lg），不新增任何主色
   本件不替代 ui.css：必须与 ui.css 同页加载，且旧页 .login-box/.login-wall/.modal 旧样式由各页自行下线
   改这里等于改全站认证面 —— 一处改动，六个入口同步；改前先读 ui.css 的 body.dark 令牌段 */

/* ---------- 容器 ---------- */
.auth-shell{
  display:flex;
  min-height:100vh;
  min-height:100dvh;
  padding:40px 20px;
  box-sizing:border-box;
}
.auth-shell[hidden]{display:none}
/* 整页门（chat #login-wall）：JS 用 display:flex 开关，这里只补底色与居中冗余 */
.auth-shell--gate{
  align-items:center;
  justify-content:center;
  background:var(--bg);
}

/* 同一张卡片，独立页与弹窗内共用 */
.auth-card{
  /* enterprise 页自带 --gold 金色令牌、缺 --accent 三元组 ⇒ 认证面在这里局部补齐，
     保证四个入口同一枚蓝；不写进 enterprise 的 :root，避免 56 处 --gold 全页变色 */
  --accent:#2f54eb;
  --accent-light:rgba(47,84,235,0.08);
  --accent-glow:rgba(47,84,235,0.2);
  width:100%;
  max-width:400px;
  margin:auto;
  box-sizing:border-box;
  padding:34px;
  background:var(--surface);
  border:1px solid var(--border);
  border-radius:var(--radius);
  box-shadow:var(--shadow-lg);
  color:var(--text);
  font-family:inherit;
  text-align:left;
  animation:auth-in .3s ease-out both;
}

/* 阴影带主色相，不再是纯黑低透明（dashboard 上已验过的观感）。
   只浅色：深色沿用 ui.css 的 --shadow-lg。:not(--flush) 是必须的 ——
   弹层外壳已经自带阴影，里面的卡再来一层就是双影。 */
body:not(.dark) .auth-card:not(.auth-card--flush){
  box-shadow:0 1px 2px rgba(16,24,40,.04),0 12px 32px rgba(47,84,235,.10);
}

/* 认证面局部补一套墨阶（只浅色）。ui.css 的 --text3=#9ca3af 落在白卡上只有
   2.54:1，低于 4.5:1 正文下限；它同时是「or」分隔线与输入框 placeholder 的颜色。
   换成 #6b7280 = 4.81:1。深色不覆盖 —— body.dark 的墨阶由 ui.css 提供。 */
body:not(.dark) .auth-card{
  --text:#0f172a;
  --text2:#4b5563;
  --text3:#6b7280;
}
@keyframes auth-in{
  from{opacity:0;transform:translateY(8px)}
  to{opacity:1;transform:translateY(0)}
}

/* 弹窗内：只保留 .modal 那一层边框与阴影，卡片自身全部归零 */
.modal .auth-card{
  width:100%;
  max-width:none;
  margin:0;
  padding:0;
  background:transparent;
  border:0;
  border-radius:0;
  box-shadow:none;
  animation:none;
}
/* 显式归零：弹窗里即使没有 .modal 祖先也成立（与上面同效，代价是几行） */
.auth-card--flush{
  width:100%;
  max-width:none;
  margin:0;
  padding:0;
  background:transparent;
  border:0;
  border-radius:0;
  box-shadow:none;
  animation:none;
}
/* 认证弹层外壳 = .auth-card 同一张皮
   ----------------------------------------------------------------
   登录口是 .auth-card 直立在 .auth-shell 里；注册口是 .auth-card--flush
   嵌在 .modal.auth-modal 里（--flush 有意把卡片自身的皮全归零）。
   于是两处的皮差了一层楼：一个 400/r12/38·34 带边框，一个 382/r16/30·26 没边框。
   这条规则把弹层外壳补成与 .auth-card 逐项相同的皮 —— 登录口与注册口只差
   「在外面」还是「在弹层里」。
   .modal.auth-modal (0,2,0) 压过 ui.css 的两份 .modal、models 的内联 .modal，
   也压过 768 断点那条把 .modal 宽度改成 100% 的规则 ⇒ 只改本文件即可收敛。 */
.modal.auth-modal{
  width:100%;
  max-width:400px;
  margin:auto;
  box-sizing:border-box;
  padding:34px;
  background:var(--surface);
  border:1px solid var(--border);
  border-radius:var(--radius);
  box-shadow:var(--shadow-lg);
}
.auth-card form{margin:0}

/* ---------- 头部 ---------- */
.auth-logo{
  display:flex;
  align-items:center;
  justify-content:center;
  min-height:36px;
  margin:0 0 18px;
}
.auth-logo img{
  display:block;
  max-height:36px;
  width:auto;
}
.auth-title{
  margin:0;
  font-size:24px;
  font-weight:700;
  line-height:1.3;
  letter-spacing:-.5px;
  text-align:center;
  color:var(--text);
}
.auth-sub{
  margin:8px 0 26px;
  font-size:14px;
  line-height:1.55;
  text-align:center;
  color:var(--text2);
}

/* 企业版标记：跟在 logo 下的小胶囊 */
.auth-badge{
  display:table;
  margin:0 auto 12px;
  padding:3px 10px;
  font-size:11px;
  font-weight:700;
  letter-spacing:.08em;
  line-height:1.6;
  text-transform:uppercase;
  color:var(--accent);
  background:var(--accent-light);
  border:1px solid var(--accent-glow);
  border-radius:999px;
  white-space:nowrap;
}

/* ---------- 字段 ---------- */
.auth-field{margin:0 0 14px}
.auth-field label{
  display:block;
  margin:0 0 6px;
  font-size:12.5px;
  font-weight:600;
  letter-spacing:.01em;
  line-height:1.4;
  color:var(--text2);
  text-align:left;
}
.auth-field input{
  display:block;
  width:100%;
  box-sizing:border-box;
  min-height:44px;
  padding:11px 13px;
  font-family:inherit;
  font-size:16px;
  line-height:1.4;
  color:var(--text);
  background:var(--bg);
  border:1px solid var(--border);
  border-radius:8px;
  -webkit-appearance:none;
  appearance:none;
  transition:border-color .15s ease,box-shadow .15s ease,background-color .15s ease;
}
.auth-field input::placeholder{color:var(--text3);opacity:1}
.auth-field input:hover:not(:focus){border-color:var(--text3)}
.auth-field input:focus{
  outline:none;
  border-color:var(--accent);
  background:var(--surface);
  box-shadow:0 0 0 3px var(--accent-light),0 0 16px -6px var(--accent-glow);
}
.auth-field input.invalid,
.auth-field input[aria-invalid="true"]{
  border-color:var(--red);
  box-shadow:0 0 0 3px color-mix(in srgb,var(--red) 12%,transparent);
}
.auth-field input.invalid:focus,
.auth-field input[aria-invalid="true"]:focus{
  border-color:var(--red);
  box-shadow:0 0 0 3px color-mix(in srgb,var(--red) 16%,transparent);
}

/* ---------- 提交 ---------- */
.auth-submit{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  width:100%;
  min-height:46px;
  margin:8px 0 0;
  padding:12px 18px;
  font-family:inherit;
  font-size:14.5px;
  font-weight:600;
  letter-spacing:.2px;
  line-height:1.2;
  color:#fff;
  background:var(--accent);
  border:0;
  border-radius:24px;
  box-shadow:0 4px 14px var(--accent-glow);
  cursor:pointer;
  transition:transform .15s ease,box-shadow .15s ease,filter .15s ease;
}
.auth-submit:hover{
  transform:translateY(-1px);
  box-shadow:0 6px 20px var(--accent-glow);
}
.auth-submit:active{transform:translateY(0);filter:brightness(.96)}
.auth-submit:disabled,
.auth-submit[aria-disabled="true"]{
  opacity:.55;
  cursor:not-allowed;
  transform:none;
  box-shadow:none;
}
.auth-card a:focus-visible,
.auth-card button:focus-visible{
  outline:2px solid var(--accent);
  outline-offset:2px;
}

/* ---------- 状态消息：语义色放在左轨，正文保持 --text 以满足 4.5:1 ---------- */
.auth-msg{
  display:none;
  margin:12px 0 0;
  padding:10px 12px;
  font-size:12.5px;
  font-weight:500;
  line-height:1.55;
  text-align:left;
  color:var(--text2);
  background:var(--bg);
  border-left:3px solid var(--border);
  border-radius:0 8px 8px 0;
}
.auth-msg.show,
.auth-msg:not(:empty){display:block}
.auth-msg.ok{color:var(--text);border-left-color:var(--green)}
.auth-msg.err{color:var(--text);border-left-color:var(--red)}

/* ---------- 分隔与切换 ---------- */
.auth-divider{
  display:flex;
  align-items:center;
  gap:12px;
  margin:20px 0 8px;
  color:var(--text3);
  font-size:12px;
  font-weight:600;
  letter-spacing:.06em;
  line-height:1;
}
.auth-divider::before,
.auth-divider::after{
  content:"";
  flex:1 1 0;
  height:1px;
  background:var(--border);
}
.auth-divider span{flex:0 0 auto}

.auth-alt{
  display:flex;
  align-items:center;
  justify-content:center;
  flex-wrap:wrap;
  gap:2px;
  min-height:44px;
  margin:0;
  font-size:13px;
  line-height:1.5;
  text-align:center;
  color:var(--text2);
}
.auth-alt a{
  display:inline-flex;
  align-items:center;
  min-height:44px;
  padding:0 6px;
  border-radius:6px;
  color:var(--accent);
  font-weight:600;
  text-decoration:none;
  transition:color .15s ease,background-color .15s ease;
}
.auth-alt a:hover{
  text-decoration:underline;
  text-underline-offset:2px;
}

/* 次级动作：同时是 <button>（chat）和 <a>（dashboard），故两种重置都写 */
/* ---- 角色一：卡片底部的小字导航（"No account? Create one"）----
   扁链接。以前这里也是描边胶囊，于是表单按钮下面又压一个胶囊，
   两坨同款圆角堆在一起，就是"登录框不好看"的主要来源。 */
.auth-secondary{
  display:flex;
  align-items:center;
  justify-content:center;
  /* 子元素是两个 <span> 时必须留缝：flex 会吞掉两者之间那个空格文本节点 */
  gap:.35em;
  width:fit-content;
  min-height:44px;
  margin:12px auto 0;
  padding:0 10px;
  font-family:inherit;
  font-size:13.5px;
  font-weight:500;
  line-height:1.2;
  text-align:center;
  text-decoration:none;
  color:var(--text2);
  background:transparent;
  border:0;
  border-radius:8px;
  cursor:pointer;
  transition:color .15s ease;
}
.auth-secondary:hover{
  background:transparent;
  color:var(--accent);
  text-decoration:underline;
  text-underline-offset:3px;
}
/* 尾段（"Create one" / "Sign Up"）点主色，是这条链接唯一的强调 */
.auth-secondary span:last-child{color:var(--accent);font-weight:600}

/* ---- 角色二：卡片里除表单外的主替代动作，描边胶囊 ----
   用在 chat 登录墙的 Sign In、enterprise 两道墙的切换入口。
   这些是真按钮，必须看得出可点 —— 不能退化成一行灰字。 */
.auth-secondary--btn{
  width:100%;
  margin:10px 0 0;
  padding:11px 18px;
  font-size:14px;
  font-weight:600;
  color:var(--accent);
  background:var(--surface);
  border:1px solid var(--accent);
  border-radius:24px;
  transition:background-color .15s ease,color .15s ease,box-shadow .15s ease;
}
.auth-secondary--btn:hover{
  background:var(--accent-light);
  color:var(--accent);
  text-decoration:none;
  box-shadow:0 4px 14px -4px var(--accent-glow);
}
.auth-secondary--btn:active{filter:brightness(.97)}
/* --btn 里不含 <span>，把上面那条尾段着色挡掉 */
.auth-secondary--btn span:last-child{color:inherit;font-weight:inherit}

/* 卡片底部小字提示 */
.auth-note{
  margin:12px 0 0;
  font-size:12px;
  line-height:1.55;
  text-align:center;
  color:var(--text3);
}

/* ---------- 合规三勾选 ---------- */
.auth-consent{
  display:flex;
  flex-direction:column;
  margin:2px 0 16px;
}
.auth-consent label{
  display:flex;
  align-items:flex-start;
  gap:10px;
  min-height:44px;
  margin:0;
  padding:8px;
  border-radius:8px;
  font-size:12.5px;
  line-height:1.55;
  color:var(--text2);
  cursor:pointer;
  transition:background-color .15s ease,color .15s ease;
}
.auth-consent label:hover{
  background:var(--bg);
  color:var(--text);
}
.auth-consent input{
  flex:0 0 auto;
  width:16px;
  height:16px;
  margin:2px 0 0;
  accent-color:var(--accent);
  cursor:pointer;
}
.auth-consent input:focus-visible{
  outline:2px solid var(--accent);
  outline-offset:2px;
  border-radius:3px;
}
.auth-consent a{
  color:var(--accent);
  font-weight:600;
  text-decoration:none;
}
.auth-consent a:hover{
  text-decoration:underline;
  text-underline-offset:2px;
}

/* ---------- 深色 ---------- */
/* 卡片内那三个局部令牌要跟着 ui.css 的 body.dark 走，否则深色下卡片仍是浅色蓝 */
body.dark .auth-card{
  --accent:#7089ff;
  --accent-light:rgba(112,137,255,0.1);
  --accent-glow:rgba(112,137,255,0.3);
  background:#1e293b;
  border-color:#334155;
}
/* 扁链接在深色下本来就透明，只需文字色跟着走（--text2 自带深色值） */
body.dark .auth-secondary{color:var(--text2)}
body.dark .auth-secondary:hover{background:transparent;color:var(--accent)}
body.dark .auth-secondary--btn{
  background:var(--surface);
  border-color:var(--accent);
  color:var(--accent);
}
body.dark .auth-secondary--btn:hover{background:var(--bg);color:var(--accent)}
body.dark .auth-badge{background:var(--bg);border-color:var(--accent-glow)}
body.dark .auth-note{color:var(--text3)}
body.dark .auth-field input{
  background:var(--bg);
  border-color:#334155;
  color:var(--text);
}
body.dark .auth-field input:hover:not(:focus){border-color:var(--text3)}
body.dark .auth-field input:focus{
  border-color:var(--accent);
  background:var(--surface);
}
body.dark .auth-msg{background:var(--bg)}
body.dark .auth-consent label:hover{background:var(--bg)}
body.dark .auth-submit{color:var(--bg)}
body.dark .auth-alt a:hover{background:var(--bg)}

/* ---------- 响应式 ---------- */
@media (max-width:480px){
  .auth-shell{padding:24px 12px}
  .auth-card{padding:22px 18px}
  .modal.auth-modal{padding:22px 18px}
  /* 手机端墙的内距是 24/12、弹层遮罩是 20 ⇒ 每边差 8px。只认认证弹层，别碰别的遮罩。 */
  .modal-overlay:has(>.modal.auth-modal){padding:24px 12px}
  .auth-logo{margin-bottom:14px}
  .auth-title{font-size:18px}
  .auth-sub{font-size:13px;margin:6px 0 18px}
  .auth-field{margin-bottom:12px}
  .auth-field input{padding:10px 12px;font-size:16px}
  .auth-submit{min-height:44px;font-size:14px}
  .auth-msg{font-size:12px}
  .auth-divider{margin:16px 0 6px}
  .auth-alt{font-size:12.5px}
  .auth-consent label{font-size:12px;padding:8px 6px}
}

/* ---------- 动效降级 ---------- */
@media (prefers-reduced-motion:reduce){
  .auth-card{animation:none}
  .auth-card,
  .auth-card *{
    transition-duration:.001ms !important;
    animation-duration:.001ms !important;
    animation-iteration-count:1 !important;
  }
  .auth-submit:hover{transform:none}
}
