/* 与桌面登录窗 LOGIN_WINDOW_SIZE（360×480）一致；控件比例参考 Procore 登录 */
:root {
  /* 与 common.css --accent 同色：Procore Orange 50 */
  --login-orange: #ff5100;
  --login-orange-hover: #e64900;
  --login-ink: #343739;
  --login-muted: #676767;
  --login-border: #c3c2c2;
  --login-field-h: 44px;
  --login-btn-h: 39px;
  /* 对齐 Procore：输入框 / 按钮约 2px 小圆角 */
  --login-radius: 2px;
  --login-error-bg: #fdf7f7;
}

html,
body.login-page {
  height: 100%;
  margin: 0;
  /* 桌面登录窗客户区常 < 外框 480：禁止整页滚动条 */
  overflow: hidden;
  background: #ffffff;
}

.login {
  /* 桌面窗：贴合客户区；浏览器大屏见下方 media */
  height: 100%;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  box-sizing: border-box;
  background: #ffffff;
  overflow: hidden;
}

.login-card {
  width: 100%;
  max-width: 360px;
  /* 用客户区高度，避免写死 480 顶出滚动条（标题栏会吃高度） */
  height: 100%;
  max-height: 480px;
  flex: 0 0 auto;
  background: #ffffff;
  border: 0;
  border-radius: 0;
  box-shadow: none;
  overflow: hidden;
  color: var(--login-ink);
  display: flex;
  flex-direction: column;
  position: relative;
}

@media (min-width: 400px), (min-height: 520px) {
  html,
  body.login-page {
    overflow: auto;
  }

  .login {
    height: auto;
    min-height: 100%;
    min-height: 100dvh;
    padding: 24px 16px;
    overflow: visible;
  }

  .login-card {
    height: 480px;
    max-height: min(480px, 100%);
  }
}

.login-view {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}

.login-view[hidden] {
  display: none !important;
}

.login-head {
  padding: 28px 42px 0;
  border-bottom: 0;
  background: #ffffff;
  flex-shrink: 0;
}

.login-brand-block {
  min-width: 0;
}

/* Procore logo 区约 38px 高；文字品牌取接近视觉重量 */
.login-brand {
  font-size: 34px;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: #111;
  line-height: 1;
}

.login-status {
  margin-top: 16px;
  width: 100%;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  box-sizing: border-box;
  border: 1px solid #e6e6e6;
  border-radius: var(--login-radius);
  background: #fafafa;
  color: var(--login-ink);
  font: inherit;
  font-size: 12px;
  text-align: left;
  cursor: pointer;
}

.login-status:hover {
  border-color: var(--login-border);
  background: #f3f3f3;
}

.login-status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #b0b8c1;
  flex-shrink: 0;
}

.login-status.is-on .login-status-dot {
  background: #2e9b57;
  box-shadow: 0 0 0 3px rgba(46, 155, 87, 0.18);
}

.login-status-text {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--login-muted);
}

.login-status.is-on .login-status-text {
  color: var(--login-ink);
}

.login-status-chevron {
  flex: 0 0 22px;
  width: 22px;
  height: 22px;
  display: grid;
  place-items: center;
  color: var(--login-muted);
  line-height: 0;
}

.login-status-chevron svg {
  display: block;
  width: 18px;
  height: 18px;
  transform: rotate(0deg);
  transition: transform 0.22s ease;
  transform-origin: center;
}

/* 进入连接设置：朝下；返回登录：朝右 */
.login-card.is-settings .login-status-chevron svg {
  transform: rotate(90deg);
}

.login-body {
  padding: 18px 42px 28px;
  flex: 1;
  min-height: 0;
  /* 内容过多时仅表单区滚动，整页仍不出现双滚动条 */
  overflow: auto;
  overflow-x: hidden;
}

.login-fields {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.login-remember-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 12px;
  flex-wrap: wrap;
}

.login-forgot {
  border: 0;
  background: transparent;
  color: #2f6fed;
  font: inherit;
  font-size: 12px;
  cursor: pointer;
  padding: 0;
  text-decoration: none;
}

.login-forgot:hover {
  text-decoration: underline;
}

.login-forgot[hidden] {
  display: none !important;
}

.login-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.login-field.port .login-input {
  text-align: left;
}

/* 服务状态卡：对齐登录页「免登录 / 登录」区域 */
.login-server-card {
  margin-top: 16px;
  width: 100%;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 14px;
  padding: 14px 14px 14px 12px;
  box-sizing: border-box;
  border: 1px solid #ececec;
  border-radius: var(--login-radius);
  background: linear-gradient(180deg, #fcfcfd 0%, #f5f6f8 100%);
  color: #6b7280;
  font: inherit;
  text-align: left;
  cursor: default;
  user-select: none;
  transition: border-color 0.18s ease, background 0.18s ease, box-shadow 0.18s ease;
}

.login-server-card.is-toggle {
  cursor: pointer;
}

.login-server-card.is-toggle:hover {
  border-color: #d9dde3;
  box-shadow: 0 4px 14px rgba(28, 40, 51, 0.06);
}

.login-server-card.is-toggle:active {
  transform: translateY(1px);
}

.login-server-card[aria-disabled="true"] {
  cursor: default;
}

.login-server-ring {
  position: relative;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: #fff;
  border: 2px solid #d7dbe2;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.9);
  color: #8b93a0;
  flex-shrink: 0;
}

.login-server-ring-glow {
  position: absolute;
  inset: -5px;
  border-radius: 50%;
  border: 1px solid transparent;
  pointer-events: none;
}

.login-server-glyph {
  display: block;
  position: relative;
  z-index: 1;
}

.login-server-meta {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.login-server-status-text {
  font-size: 14px;
  font-weight: 700;
  color: #343739;
  line-height: 1.25;
}

.login-server-status-hint {
  font-size: 12px;
  color: #8a93a0;
  line-height: 1.3;
}

.login-server-badge {
  flex: 0 0 auto;
  min-width: 40px;
  height: 22px;
  padding: 0 8px;
  border-radius: var(--login-radius);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  background: #e8eaee;
  color: #7a8490;
}

.login-server-card.is-on {
  border-color: rgba(46, 155, 87, 0.28);
  background: linear-gradient(180deg, #f6fbf8 0%, #eef8f2 100%);
}

.login-server-card.is-on .login-server-ring {
  color: #2e9b57;
  border-color: rgba(46, 155, 87, 0.55);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.9),
    0 0 0 3px rgba(46, 155, 87, 0.1);
}

.login-server-card.is-on .login-server-ring-glow {
  border-color: rgba(46, 155, 87, 0.22);
  animation: login-server-pulse 1.8s ease-out infinite;
}

.login-server-card.is-on .login-server-status-text {
  color: #1f7a45;
}

.login-server-card.is-on .login-server-badge {
  background: rgba(46, 155, 87, 0.14);
  color: #1f7a45;
}

.login-server-card.is-busy {
  border-color: rgba(255, 81, 0, 0.28);
  background: linear-gradient(180deg, #fff9f5 0%, #fff3eb 100%);
}

.login-server-card.is-busy .login-server-ring {
  color: var(--login-orange);
  border-color: rgba(255, 81, 0, 0.5);
}

.login-server-card.is-busy .login-server-status-text {
  color: #c24100;
}

.login-server-card.is-busy .login-server-badge {
  background: rgba(255, 81, 0, 0.12);
  color: #c24100;
}

@keyframes login-server-pulse {
  0% {
    transform: scale(0.96);
    opacity: 0.85;
  }
  70% {
    transform: scale(1.08);
    opacity: 0;
  }
  100% {
    transform: scale(1.08);
    opacity: 0;
  }
}

/* display:flex 会盖掉原生 [hidden]，必须强制隐藏 */
.login-field.port[hidden] {
  display: none !important;
}

.login-host {
  display: flex;
  align-items: center;
  width: 100%;
  height: var(--login-field-h);
  box-sizing: border-box;
  border: 1px solid var(--login-border);
  border-radius: var(--login-radius);
  background: #ffffff;
  overflow: hidden;
}

.login-host .login-input {
  flex: 1;
  min-width: 0;
  height: 100%;
  border: 0;
  border-radius: 0;
  box-shadow: none;
  padding-right: 4px;
}

.login-host:focus-within {
  border-color: var(--login-orange);
  box-shadow: none;
}

.login-host .login-input:focus {
  outline: none;
  border-color: transparent;
  box-shadow: none;
}

.login-host-local {
  flex: 0 0 36px;
  width: 36px;
  height: 100%;
  border: 0;
  background: transparent;
  color: var(--login-muted);
  display: grid;
  place-items: center;
  padding: 0;
  cursor: pointer;
  flex-shrink: 0;
}

.login-host-local svg {
  width: 18px;
  height: 18px;
  display: block;
}

.login-host-local:hover:not(:disabled) {
  background: #f5f5f5;
  color: var(--login-ink);
}

.login-host-local:disabled {
  opacity: 0.35;
  cursor: default;
}

.login-host-local[hidden] {
  display: none !important;
}

.login-label {
  color: #000;
  font-size: 12px;
  font-weight: 400;
  line-height: 1.2;
}

.login-user-wrap {
  position: relative;
}

.login-user-suggest {
  position: absolute;
  left: 0;
  right: 0;
  top: calc(100% + 4px);
  z-index: 30;
  max-height: min(240px, 36vh);
  overflow: auto;
  background: #ffffff;
  border: 1px solid var(--login-border);
  border-radius: var(--login-radius);
  box-shadow: 0 8px 20px rgba(28, 40, 51, 0.12);
  padding: 4px;
}

.login-user-suggest[hidden] {
  display: none !important;
}

.login-user-option {
  display: flex;
  align-items: center;
  gap: 2px;
  border-radius: var(--login-radius);
}

.login-user-option:hover {
  background: #f5f5f5;
}

.login-user-pick {
  flex: 1;
  min-width: 0;
  border: 0;
  background: transparent;
  text-align: left;
  padding: 8px 8px 8px 10px;
  border-radius: var(--login-radius);
  font: inherit;
  font-size: 16px;
  color: var(--login-ink);
  cursor: pointer;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.login-user-del {
  flex: 0 0 28px;
  width: 28px;
  height: 28px;
  margin-right: 4px;
  border: 0;
  border-radius: var(--login-radius);
  background: transparent;
  color: var(--login-muted);
  font: inherit;
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  display: grid;
  place-items: center;
  padding: 0;
}

.login-user-del:hover {
  color: #c62828;
  background: rgba(198, 40, 40, 0.08);
}

/* 登录页小圆角（覆盖 common 全站 8px，对齐 Procore ~2px） */
body.login-page .login-input,
body.login-page .login-pwd,
body.login-page .login-host,
body.login-page .login-status,
body.login-page .login-enter:not(.is-success),
body.login-page .login-user-suggest,
body.login-page .login-field.port .login-input,
body.login-page #port {
  border-radius: var(--login-radius) !important;
}

.login-input {
  width: 100%;
  height: var(--login-field-h);
  box-sizing: border-box;
  border: 1px solid var(--login-border);
  border-radius: var(--login-radius);
  padding: 0 8px;
  background: #ffffff;
  color: #000;
  /* 比 Procore 标称 14px 高一级：中文在同字号下视觉偏小 */
  font-size: 16px;
  font-weight: 400;
}

.login-input:focus,
.login-pwd:focus-within {
  outline: none;
  border-color: var(--login-orange);
  box-shadow: none;
}

.login-pwd {
  display: flex;
  align-items: center;
  width: 100%;
  height: var(--login-field-h);
  box-sizing: border-box;
  border: 1px solid var(--login-border);
  border-radius: var(--login-radius);
  background: #ffffff;
  overflow: hidden;
}

.login-pwd input {
  flex: 1;
  min-width: 0;
  height: 100%;
  border: 0;
  outline: none;
  padding: 0 8px;
  background: transparent;
  color: #000;
  font-size: 16px;
}

/* 隐藏 Edge/Chrome 自带的密码眼睛，只保留本页 .eye 按钮（与桌面一致） */
.login-pwd input::-ms-reveal,
.login-pwd input::-ms-clear {
  display: none;
}

.login-pwd input::-webkit-credentials-auto-fill-button,
.login-pwd input::-webkit-strong-password-auto-fill-button,
.login-pwd input::-webkit-contacts-auto-fill-button {
  visibility: hidden;
  display: none !important;
  pointer-events: none;
}

.login-pwd .eye {
  width: 36px;
  height: 100%;
  border: 0;
  background: transparent;
  display: grid;
  place-items: center;
  cursor: pointer;
  flex-shrink: 0;
  padding: 0;
}

.login-pwd .eye img {
  display: block;
  width: 20px;
  height: 12px;
  object-fit: fill;
}

.login-pwd .eye:hover {
  background: transparent;
  opacity: 0.85;
}

.login-remember {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  color: #000;
  font-size: 12px;
  cursor: pointer;
}

.login-remember input {
  width: 14px;
  height: 14px;
  margin: 0;
}

/* 预留错误条高度，避免出现时把登录按钮顶下去 */
.login-error-slot {
  margin-top: 14px;
  min-height: 44px;
}

/* Procore flash 式错误条：浅红底 */
.login-error {
  margin: 0;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px;
  box-sizing: border-box;
  min-height: 44px;
  background: var(--login-error-bg);
  border-radius: 4px;
  color: #232729;
  font-size: 14px;
  line-height: 20px;
  letter-spacing: 0.15px;
}

/* 占位时仍占高度，仅隐藏内容 */
.login-error[hidden] {
  display: flex !important;
  visibility: hidden;
  background: transparent;
  pointer-events: none;
}

.login-error.is-on {
  visibility: visible;
  background: var(--login-error-bg);
  pointer-events: auto;
}

.login-error-mark {
  flex: 0 0 18px;
  width: 18px;
  height: 18px;
  margin-top: 1px;
  border-radius: 50%;
  background: #d9534f;
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  line-height: 18px;
  text-align: center;
}

.login-error-text {
  flex: 1;
  min-width: 0;
}

.login-enter-wrap {
  margin-top: 14px;
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: var(--login-btn-h);
}

/* Procore Continue：#FF5100、约 39px、圆角 2px、16px 字 */
.login-enter {
  --login-success-green: #00e676;
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: var(--login-btn-h);
  min-height: var(--login-btn-h);
  min-width: 0;
  padding: 10px 25px;
  border: 0;
  border-radius: var(--login-radius);
  background: var(--login-orange);
  color: #ffffff;
  font-family: inherit;
  font-size: 16px;
  font-weight: 400;
  line-height: 1;
  cursor: pointer;
  overflow: hidden;
  box-sizing: border-box;
  transition: background 0.15s ease;
}

.login-enter:hover:not(:disabled):not(.is-success) {
  background: var(--login-orange-hover);
}

.login-enter:disabled:not(.is-success):not(.is-auto) {
  opacity: 0.55;
  cursor: default;
}

.login-enter-label {
  display: inline-block;
  transition: opacity 0.16s ease;
}

.login-enter-spin {
  display: none;
  width: 16px;
  height: 16px;
  margin-right: 8px;
  border: 2px solid rgba(255, 255, 255, 0.35);
  border-top-color: #fff;
  border-radius: 50%;
  box-sizing: border-box;
  flex-shrink: 0;
}

.login-enter-check {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: #fff;
  opacity: 0;
  transform: scale(0.35);
  pointer-events: none;
}

.login-enter-check-path {
  stroke-dasharray: 28;
  stroke-dashoffset: 28;
}

.login-enter.is-loading .login-enter-label {
  opacity: 0.92;
}

.login-enter.is-loading .login-enter-spin {
  display: inline-block;
  animation: login-spin 0.7s linear infinite;
}

/* 自动登录：按钮保持橙色活力，表单变淡，避免「卡死」感 */
.login-card.is-auto-logging .login-body {
  pointer-events: none;
}

.login-card.is-auto-logging .login-fields,
.login-card.is-auto-logging .login-remember-row {
  opacity: 0.45;
  transition: opacity 0.25s ease;
}

.login-card.is-auto-logging .login-status {
  pointer-events: none;
  opacity: 0.85;
}

.login-enter.is-auto,
body.login-page .login-enter.is-auto {
  opacity: 1;
  cursor: wait;
  animation: login-auto-pulse 1.4s ease-in-out infinite;
}

.login-enter.is-auto .login-enter-spin {
  display: inline-block;
  animation: login-spin 0.7s linear infinite;
}

.login-enter.is-auto .login-enter-label {
  opacity: 1;
  letter-spacing: 0.02em;
}

@keyframes login-spin {
  to {
    transform: rotate(360deg);
  }
}

@keyframes login-auto-pulse {
  0%,
  100% {
    box-shadow: 0 0 0 0 rgba(255, 81, 0, 0.35);
    filter: brightness(1);
  }
  50% {
    box-shadow: 0 0 0 8px rgba(255, 81, 0, 0);
    filter: brightness(1.06);
  }
}

/*
 * 文字淡出 → 倒角先变成胶囊圆角 → 高度不变只缩宽成圆 → 鲜绿 → 对勾
 */
.login-enter.is-success,
body.login-page .login-enter.is-success {
  padding: 0;
  pointer-events: none;
  height: var(--login-btn-h);
  animation: login-enter-pill-circle 0.62s cubic-bezier(0.45, 0.05, 0.2, 1) forwards;
}

.login-enter.is-success .login-enter-label {
  animation: login-enter-label-out 0.1s ease forwards;
}

.login-enter.is-success .login-enter-check {
  animation: login-check-pop 0.22s cubic-bezier(0.34, 1.4, 0.64, 1) 0.4s forwards;
}

.login-enter.is-success .login-enter-check-path {
  animation: login-check-draw 0.2s ease 0.44s forwards;
}

@keyframes login-enter-label-out {
  to {
    opacity: 0;
  }
}

@keyframes login-enter-pill-circle {
  /* 小倒角宽按钮 */
  0% {
    width: 100%;
    min-width: 0;
    height: var(--login-btn-h);
    border-radius: var(--login-radius);
    background: var(--login-orange);
  }
  /* 倒角变成胶囊，立刻接着缩宽，中间不停顿 */
  18% {
    width: 100%;
    min-width: 0;
    height: var(--login-btn-h);
    border-radius: calc(var(--login-btn-h) / 2);
    background: var(--login-orange);
  }
  /* 高度不变，连续收成圆 */
  55% {
    width: var(--login-btn-h);
    min-width: var(--login-btn-h);
    height: var(--login-btn-h);
    border-radius: 50%;
    background: var(--login-orange);
  }
  /* 紧接着变鲜绿 */
  72% {
    width: var(--login-btn-h);
    min-width: var(--login-btn-h);
    height: var(--login-btn-h);
    border-radius: 50%;
    background: var(--login-success-green);
  }
  100% {
    width: var(--login-btn-h);
    min-width: var(--login-btn-h);
    height: var(--login-btn-h);
    border-radius: 50%;
    background: var(--login-success-green);
  }
}

@keyframes login-check-pop {
  from {
    opacity: 0;
    transform: scale(0.35);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

@keyframes login-check-draw {
  to {
    stroke-dashoffset: 0;
  }
}
