/* Imago Login — Apple/iOS glass polish */

* { box-sizing: border-box; }

body.page-login {
  margin: 0;
  min-height: 100vh;
  font-family: var(--pn-font-main);
  color: var(--pn-text);
  background:
    radial-gradient(circle at 20% 0%, rgba(0, 122, 255, 0.08), transparent 50%),
    radial-gradient(circle at 80% 100%, rgba(175, 82, 222, 0.06), transparent 50%),
    #F5F5F7;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding:
    calc(20px + env(safe-area-inset-top))
    calc(20px + env(safe-area-inset-right))
    calc(20px + env(safe-area-inset-bottom))
    calc(20px + env(safe-area-inset-left));
}

/* ---------- Card ---------- */
.panel {
  position: relative;
  width: 100%;
  max-width: clamp(360px, 32vw, 440px);
  padding: 40px 36px;
  border-radius: 24px;
  border: 1px solid var(--pn-glass-border-outer);
  background: rgba(255, 255, 255, 0.72);
  backdrop-filter: blur(18px) saturate(160%);
  -webkit-backdrop-filter: blur(18px) saturate(160%);
  box-shadow: var(--pn-glass-shadow);
}

/* 1px inset top highlight */
.panel::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.5);
}

/* ---------- Brand ---------- */
.brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  margin-bottom: 28px;
}

.logo {
  width: 60px;
  height: 60px;
  border-radius: 16px;
  box-shadow: 0 10px 24px rgba(0, 122, 255, 0.22);
  margin-bottom: 12px;
}

.brand h1 {
  margin: 0;
  font-size: 22px;
  font-weight: 600;
  line-height: 1.2;
  letter-spacing: -0.02em;
  color: var(--pn-text);
}

.brand-sub {
  margin: 0;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--pn-muted);
}

.sub {
  margin: 0 0 22px;
  color: var(--pn-muted);
  font-size: 13px;
  text-align: center;
}

/* ---------- Form ---------- */
.field {
  margin-bottom: 14px;
}

label {
  display: block;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--pn-muted);
  margin-bottom: 6px;
}

input {
  width: 100%;
  height: 44px;
  padding: 12px 14px;
  border-radius: 10px;
  border: 1px solid var(--pn-glass-border-inner);
  background: var(--pn-surface-raised, rgba(255, 255, 255, 0.96));
  color: var(--pn-text);
  font-size: 14px;
  font-family: inherit;
  outline: none;
  transition: border-color var(--pn-motion-fast) ease, box-shadow var(--pn-motion-fast) ease;
}

input::placeholder {
  color: var(--pn-muted);
  font-size: 13px;
  opacity: 0.65;
}

input:hover {
  border-color: var(--pn-glass-border-outer);
}

input:focus {
  border-color: var(--pn-brand-500);
  box-shadow: var(--pn-focus-ring);
}

/* password toggle (text-button kept: JS sets textContent "显示"/"隐藏") */
.password-wrap {
  position: relative;
}

.password-wrap input {
  padding-right: 64px;
}

.password-toggle {
  position: absolute;
  top: 50%;
  right: 4px;
  transform: translateY(-50%);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: auto;
  min-width: 52px;
  height: 36px;
  padding: 0 10px;
  border-radius: 8px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--pn-brand-500);
  font-size: 12px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  transition: background-color var(--pn-motion-fast) ease, color var(--pn-motion-fast) ease;
}

.password-toggle:hover {
  background: rgba(0, 122, 255, 0.08);
}

.password-toggle:active {
  background: rgba(0, 122, 255, 0.14);
}

/* ---------- Submit ---------- */
button[type="submit"] {
  width: 100%;
  min-width: 128px;
  height: 44px;
  margin-top: 6px;
  border: none;
  border-radius: 12px;
  background: linear-gradient(180deg, var(--pn-brand-500), var(--pn-brand-hover));
  color: #ffffff;
  font-size: 15px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(0, 122, 255, 0.25);
  transition:
    transform var(--pn-motion-fast) var(--pn-ease-spring),
    box-shadow var(--pn-motion-fast) ease,
    opacity var(--pn-motion-fast) ease;
}

button[type="submit"]:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(0, 122, 255, 0.32);
}

button[type="submit"]:active {
  transform: scale(0.96);
  box-shadow: 0 3px 10px rgba(0, 122, 255, 0.22);
}

button[type="submit"]:disabled,
button[type="submit"].loading {
  opacity: 0.75;
  cursor: wait;
  transform: none;
}

/* loading spinner via ::after — JS sets textContent so we keep button inner text intact */
button[type="submit"].loading {
  position: relative;
  padding-right: 36px;
  /* avoid layout bounce between "登录" and "登录中..." + spinner */
  min-width: 148px;
}

button[type="submit"].loading::after {
  content: "";
  position: absolute;
  top: 50%;
  right: 14px;
  width: 14px;
  height: 14px;
  margin-top: -7px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.4);
  border-top-color: #ffffff;
  animation: login-spin 0.8s linear infinite;
}

@keyframes login-spin {
  to { transform: rotate(360deg); }
}

/* ---------- Error ----------
   使用共享组件 .pn-input-error（components.css）承载动画与基础外观。
   这里仅覆盖 login 页特有的「条带」观感：展开后带淡红底 / 边框 / 内边距。
*/
#error.pn-input-error {
  margin-top: 0;
  font-size: 13px;
  border-radius: 10px;
  align-items: center;
  gap: 8px;
}

#error.pn-input-error.is-visible {
  margin-top: 14px;
  padding: 10px 12px;
  background: rgba(255, 59, 48, 0.08);
  border: 1px solid rgba(255, 59, 48, 0.22);
}

#error .pn-input-error__icon {
  width: 16px;
  height: 16px;
  border-radius: 999px;
  background: var(--pn-danger);
  color: #ffffff;
  font-size: 11px;
  line-height: 1;
}

/* ---------- Watermark ---------- */
.login-watermark {
  margin: 20px 0 0;
  font-size: 10px;
  letter-spacing: 0.04em;
  color: var(--pn-muted);
  opacity: 0.55;
  text-align: center;
}

/* ---------- Responsive ---------- */
@media (max-width: 560px) {
  body.page-login {
    padding:
      calc(14px + env(safe-area-inset-top))
      calc(14px + env(safe-area-inset-right))
      calc(14px + env(safe-area-inset-bottom))
      calc(14px + env(safe-area-inset-left));
  }

  .panel {
    width: calc(100vw - 32px);
    max-width: calc(100vw - 32px);
    padding: 32px 24px;
  }
}

/* touch-friendly input height on small phones */
@media (max-width: 480px) {
  input {
    height: 48px;
  }

  button[type="submit"] {
    height: 48px;
  }
}

/* tablet breakpoint — slightly roomier card, preserve type rhythm */
@media (min-width: 768px) and (max-width: 1023px) {
  .panel {
    max-width: 420px;
    padding: 44px 40px;
  }

  .brand h1 {
    font-size: 24px;
  }

  .sub {
    font-size: 14px;
  }
}

/* ---------- Dark ---------- */
@media (prefers-color-scheme: dark) {
  body.page-login {
    background:
      radial-gradient(circle at 20% 0%, rgba(10, 132, 255, 0.12), transparent 50%),
      radial-gradient(circle at 80% 100%, rgba(191, 90, 242, 0.08), transparent 50%),
      #000000;
  }

  .panel {
    background: rgba(28, 28, 30, 0.72);
    border-color: var(--pn-glass-border-outer);
  }

  .logo {
    box-shadow: 0 10px 24px rgba(10, 132, 255, 0.14);
  }

  .panel::before {
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08);
  }

  .brand h1 {
    color: #ffffff;
  }

  .brand-sub,
  .sub,
  label,
  .login-watermark {
    color: rgba(235, 235, 245, 0.6);
  }

  input {
    border-color: rgba(255, 255, 255, 0.1);
    background: rgba(255, 255, 255, 0.05);
    color: #ffffff;
  }

  input:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.16);
  }

  input:focus {
    border-color: var(--pn-brand-500);
    box-shadow: var(--pn-focus-ring);
  }

  input::placeholder {
    color: rgba(235, 235, 245, 0.35);
  }

  .password-toggle {
    color: var(--pn-brand-500);
  }

  .password-toggle:hover {
    background: rgba(10, 132, 255, 0.14);
  }

  #error.pn-input-error.is-visible {
    background: rgba(255, 69, 58, 0.12);
    border-color: rgba(255, 69, 58, 0.28);
    color: #FF453A;
  }
}
