/**
 * 筑巢·AI标书 — 登录页（流光背景 + 鼠标光晕 + 玻璃登录卡）
 */

html:has(body.login-app) {
  height: 100%;
  overflow: hidden;
}

html:has(body.login-app.login-app--tall) {
  height: auto;
  overflow: auto;
}

body.login-app {
  height: 100dvh;
  max-height: 100dvh;
  overflow: hidden;
  background: #fff;
  color: var(--text-primary, #0b0f17);
}

body.login-app.login-app--tall {
  height: auto;
  min-height: 100dvh;
  max-height: none;
  overflow: auto;
}

body.login-app::before {
  display: none;
}

/* ── 动态背景（极淡，主光晕交给鼠标层） ── */
body.login-app > .login-bg {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background:
    radial-gradient(circle at 85% 15%, rgba(99, 102, 241, 0.06), transparent 42%),
    radial-gradient(circle at 10% 90%, rgba(15, 175, 124, 0.05), transparent 38%);
  animation: loginBgMove 12s ease-in-out infinite alternate;
}

@keyframes loginBgMove {
  0% { transform: scale(1); opacity: 1; }
  100% { transform: scale(1.04); opacity: 0.92; }
}

/* ── 鼠标光晕（必须 fixed，避免被 base.css > * 覆盖） ── */
body.login-app > .login-cursor {
  position: fixed;
  left: 0;
  top: 0;
  width: 360px;
  height: 360px;
  margin: 0;
  border-radius: 50%;
  pointer-events: none;
  transform: translate3d(-9999px, -9999px, 0) translate(-50%, -50%);
  background: radial-gradient(
    circle,
    rgba(15, 175, 124, 0.22) 0%,
    rgba(15, 175, 124, 0.08) 38%,
    transparent 68%
  );
  filter: blur(8px);
  z-index: 1;
  opacity: 0;
  will-change: transform, opacity;
  transition: opacity 0.25s ease;
}

body.login-app--cursor-ready > .login-cursor {
  opacity: 1;
}

/* ── 主布局：grid 防止右侧被 flex 挤扁 ── */
body.login-app > .login-container {
  position: relative;
  z-index: 2;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(380px, 440px);
  align-items: center;
  gap: clamp(20px, 4vw, 48px);
  width: 100%;
  max-width: 1200px;
  height: 100dvh;
  max-height: 100dvh;
  margin: 0 auto;
  padding:
    clamp(24px, 3.5vh, 40px)
    clamp(20px, 4vw, 48px)
    28px;
  box-sizing: border-box;
  overflow: hidden;
}

body.login-app.login-app--tall > .login-container {
  height: auto;
  min-height: 100dvh;
  max-height: none;
  overflow: visible;
}

/* ── 左侧叙事 ── */
.login-left {
  min-width: 0;
  padding-right: clamp(0px, 2vw, 24px);
  display: flex;
  flex-direction: column;
  justify-content: center;
  animation: loginFloat 6s ease-in-out infinite;
}

@keyframes loginFloat {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-8px); }
}

.login-logo {
  display: flex;
  align-items: center;
  gap: 0.5em;
  margin-bottom: clamp(14px, 2vh, 22px);
  font-size: clamp(20px, 2.4vw, 28px);
}

.login-logo__img {
  flex-shrink: 0;
  width: 1em;
  height: 1em;
  display: block;
  border: none;
  box-shadow: none;
  overflow: hidden;
  border-radius: 22%;
  object-fit: cover;
}

.login-logo__name {
  font-size: 1em;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.2;
  color: var(--text-primary, #0b0f17);
}

.login-logo__dot {
  color: var(--brand, #0faf7c);
}

.login-hero {
  margin: 0 0 clamp(12px, 1.8vh, 18px);
  font-size: clamp(26px, 3.2vw, 40px);
  font-weight: 700;
  line-height: 1.22;
  letter-spacing: -0.03em;
}

.login-lead {
  margin: 0;
  font-size: clamp(13px, 1.4vw, 15px);
  color: var(--sub, #6b7280);
  line-height: 1.65;
  max-width: 520px;
}

.login-tags {
  margin-top: clamp(14px, 2vh, 22px);
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.login-tag {
  padding: 6px 12px;
  border: 1px solid rgba(0, 0, 0, 0.08);
  border-radius: 999px;
  font-size: 12px;
  color: var(--text-secondary, #6b7280);
  transition: transform 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}

.login-tag:hover {
  transform: translateY(-2px);
  border-color: var(--brand, #0faf7c);
  color: var(--brand, #0faf7c);
}

/* ── 右侧玻璃登录卡 ── */
.login-right {
  width: 100%;
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.login-card {
  position: relative;
  width: 100%;
  min-width: 340px;
  max-width: 400px;
  padding: clamp(20px, 2.5vh, 26px);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.78);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid rgba(0, 0, 0, 0.06);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.08);
  transition: transform 0.3s ease, box-shadow 0.3s ease;
  box-sizing: border-box;
}

.login-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.12);
}

.login-card__head {
  margin-bottom: 18px;
}

.login-card__title {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
  line-height: 1.3;
  white-space: nowrap;
}

.login-card__sub {
  margin: 4px 0 0;
  font-size: 12px;
  color: var(--sub, #6b7280);
  line-height: 1.4;
}

.login-mode {
  display: flex;
  gap: 20px;
  margin-bottom: 4px;
  border-bottom: 1px solid rgba(0, 0, 0, 0.08);
}

.login-mode__item {
  position: relative;
  border: none;
  background: none;
  padding: 0 0 8px;
  margin-bottom: -1px;
  font-family: inherit;
  font-size: 14px;
  font-weight: 500;
  color: #9ca3af;
  cursor: pointer;
  transition: color 0.15s ease;
}

.login-mode__item::after {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 2px;
  background: var(--brand, #0faf7c);
  transform: scaleX(0);
  transition: transform 0.25s ease;
}

.login-mode__item--active {
  color: #0b0f17;
  font-weight: 600;
}

.login-mode__item--active::after {
  transform: scaleX(1);
}

.login-form {
  display: flex;
  flex-direction: column;
  width: 100%;
}

.login-card .input.login-input {
  width: 100%;
  height: auto;
  min-height: 44px;
  box-sizing: border-box;
  border: none;
  border-bottom: 1px solid rgba(0, 0, 0, 0.08);
  border-radius: 0;
  padding: 12px 2px;
  margin-top: 14px;
  outline: none;
  background: transparent;
  font-size: 14px;
  box-shadow: none;
  transition: border-color 0.2s ease;
}

.login-card .input.login-input:hover {
  background: transparent;
}

.login-card .input.login-input:focus {
  border-bottom-color: var(--brand, #0faf7c);
  box-shadow: none;
}

.login-sms {
  width: 100%;
}

.login-sms__row {
  display: flex;
  align-items: flex-end;
  gap: 12px;
  width: 100%;
}

.login-sms__row .login-input {
  flex: 1 1 auto;
  min-width: 0;
  margin-top: 14px;
}

.login-code-btn {
  flex: 0 0 auto;
  border: none;
  background: none;
  padding: 12px 0;
  margin-top: 14px;
  font-family: inherit;
  font-size: 12px;
  font-weight: 500;
  color: var(--brand, #0faf7c);
  cursor: pointer;
  white-space: nowrap;
}

.login-code-btn:disabled {
  color: #9ca3af;
  cursor: not-allowed;
}

.login-password {
  width: 100%;
}

.login-password[hidden],
.login-sms[hidden] {
  display: none !important;
}

.login-forgot {
  margin: 8px 0 0;
  text-align: right;
}

.login-forgot a {
  font-size: 12px;
  color: #6b7280;
  text-decoration: none;
}

.login-forgot a:hover {
  color: var(--brand, #0faf7c);
}

.login-check {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 14px;
  font-size: 12px;
  color: #6b7280;
  cursor: pointer;
}

.login-check input {
  accent-color: var(--brand, #0faf7c);
}

.login-meta {
  margin: 10px 0 0;
  min-height: 16px;
  font-size: 12px;
  line-height: 1.45;
  color: #9ca3af;
  word-break: normal;
}

.login-error {
  margin: 8px 0 0;
  font-size: 12px;
  line-height: 1.45;
  color: #dc2626;
  word-break: normal;
}

.login-error[hidden] {
  display: none;
}

.login-success {
  margin: 8px 0 0;
  font-size: 12px;
  line-height: 1.45;
  color: var(--brand, #0faf7c);
  word-break: normal;
}

.login-success[hidden] {
  display: none;
}

.login-submit {
  width: 100%;
  margin-top: 18px;
  padding: 13px 16px;
  border: none;
  border-radius: 12px;
  background: var(--brand, #0faf7c);
  color: #fff;
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  line-height: 1.2;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.login-submit:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 15px 30px rgba(15, 175, 124, 0.25);
}

.login-submit:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.login-card__footer {
  margin-top: 16px;
}

.login-card__link {
  margin: 0;
  text-align: center;
  font-size: 12px;
  line-height: 1.5;
  color: #6b7280;
}

.login-card__link a {
  color: #0b0f17;
  font-weight: 500;
  text-decoration: none;
}

.login-card__link a:hover {
  color: var(--brand, #0faf7c);
}

.login-card__link--sub {
  margin-top: 10px;
}

.login-card__link--sub a {
  color: #6b7280;
  font-weight: 400;
}

body.login-app > .login-legal {
  position: fixed;
  left: 0;
  right: 0;
  bottom: max(8px, env(safe-area-inset-bottom, 0px));
  z-index: 2;
  text-align: center;
  font-size: 12px;
  color: #9ca3af;
  pointer-events: none;
}

/* ── 管理员模式 ── */
body.login-app--admin .login-left {
  opacity: 0.45;
}

/* ── 中等屏：略缩左侧，保证右侧宽度 ── */
@media (max-width: 1100px) {
  .login-container {
    grid-template-columns: minmax(0, 1fr) minmax(360px, 400px);
    gap: 32px;
  }

  .login-card {
    min-width: 320px;
  }
}

/* ── 平板：单列紧凑，仍禁止滚动 ── */
@media (max-width: 900px) {
  body.login-app > .login-container {
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr;
    align-items: center;
    gap: 16px;
    height: 100dvh;
    max-height: 100dvh;
    padding:
      max(16px, env(safe-area-inset-top, 0px) + 12px)
      20px
      24px;
    overflow: hidden;
  }

  .login-left {
    animation: none;
    padding-right: 0;
    justify-content: flex-start;
  }

  .login-logo {
    margin-bottom: 10px;
    font-size: clamp(18px, 5vw, 22px);
  }

  .login-hero {
    font-size: clamp(22px, 6vw, 28px);
    margin-bottom: 8px;
  }

  .login-lead {
    font-size: 13px;
    line-height: 1.55;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
  }

  .login-tags {
    margin-top: 10px;
  }

  .login-tag {
    padding: 4px 10px;
    font-size: 12px;
  }

  .login-right {
    justify-content: center;
    align-self: center;
  }

  .login-card {
    min-width: 0;
    max-width: 420px;
    padding: 20px;
  }

  .login-card__title {
    white-space: normal;
  }
}

/* ── 小屏 ── */
@media (max-width: 480px) {
  .login-container {
    padding-left: 16px;
    padding-right: 16px;
  }

  .login-card {
    padding: 22px 20px;
    border-radius: 16px;
  }

  .login-sms__row {
    flex-wrap: wrap;
  }

  .login-code-btn {
    margin-top: 0;
    padding-bottom: 8px;
  }

  .login-quota__stats {
    grid-template-columns: 1fr;
  }
}

.login-quota {
  margin-top: 4px;
  padding: 14px 16px;
  border-radius: 14px;
  border: 1px solid rgba(15, 175, 124, 0.18);
  background: linear-gradient(180deg, rgba(236, 253, 245, 0.95), rgba(255, 255, 255, 0.92));
}

.login-quota__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.login-quota__title {
  font-size: 14px;
  font-weight: 700;
  color: #0f172a;
}

.login-quota__plan {
  font-size: 12px;
  font-weight: 700;
  color: #059669;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(16, 185, 129, 0.12);
}

.login-quota__stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.login-quota__stat {
  min-width: 0;
}

.login-quota__label {
  margin: 0;
  font-size: 12px;
  color: #64748b;
}

.login-quota__value {
  margin: 4px 0 0;
  font-size: 14px;
  font-weight: 800;
  color: #0f172a;
  line-height: 1.2;
}

.login-quota__hint {
  margin: 10px 0 0;
  font-size: 12px;
  line-height: 1.5;
  color: #64748b;
}

@media (prefers-reduced-motion: reduce) {
  .login-bg,
  .login-left {
    animation: none !important;
  }

  .login-cursor {
    display: none;
  }

  .login-card:hover {
    transform: none;
  }
}

@media (pointer: coarse) {
  .login-cursor {
    display: none;
  }
}
