/* MQTT 账户中心样式表：响应式布局，绿色主题配色 */

/* === CSS 变量定义（全局设计令牌） === */
:root {
  color-scheme: light;
  --ink: #17201d;         /* 主文本颜色 */
  --muted: #66716d;       /* 次要文本颜色 */
  --line: #dce3df;        /* 边框和分割线颜色 */
  --surface: #ffffff;     /* 卡片/面板背景色 */
  --canvas: #f4f7f5;      /* 页面背景色 */
  --green: #087f5b;       /* 主品牌绿色 */
  --green-dark: #086044;  /* 深绿色（hover 状态） */
  --green-soft: #e7f5ef;  /* 浅绿色背景 */
  --amber: #b45309;       /* 警告色 */
  --amber-soft: #fff7e6;  /* 浅警告背景 */
  --danger: #b42318;      /* 错误/危险色 */
  --danger-soft: #fff0ee; /* 浅错误背景 */
  --shadow: 0 14px 36px rgba(26, 48, 40, 0.08); /* 卡片阴影 */
  font-family: Inter, "Segoe UI", "Microsoft YaHei", sans-serif; /* 字体栈：优先 Inter，中文回退微软雅黑 */
}

/* === 全局重置 === */
* {
  box-sizing: border-box;
}

/* 隐藏元素（覆盖所有 display 值） */
[hidden] {
  display: none !important;
}

/* === 页面基础样式 === */
body {
  min-width: 320px;
  max-width: 100%;
  min-height: 100vh;
  margin: 0;
  overflow-x: hidden;
  color: var(--ink);
  background: var(--canvas);
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

/* === 顶部导航栏 === */
.topbar {
  min-height: 72px;
  padding: 12px max(24px, calc((100vw - 1120px) / 2));
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.94);
}

.brand,
.service-state,
.brand > span:last-child {
  display: flex;
  align-items: center;
}

.brand {
  gap: 12px;
}

.brand > span:last-child {
  align-items: flex-start;
  flex-direction: column;
}

.brand strong {
  font-size: 15px;
}

.brand small {
  margin-top: 2px;
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
}

.brand-mark {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: var(--green);
}

.brand-mark img {
  width: 21px;
  filter: brightness(0) invert(1);
}

.service-state {
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
}

.state-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #9aa6a1;
  box-shadow: 0 0 0 4px #eef1ef;
}

.service-state.ready .state-dot {
  background: #16a36f;
  box-shadow: 0 0 0 4px #dff5ea;
}

.service-state.error .state-dot {
  background: var(--amber);
  box-shadow: 0 0 0 4px #ffedd5;
}

/* === 主内容区域 === */
main {
  width: min(1120px, calc(100% - 48px));
  margin: 0 auto;
  padding: 60px 0 72px;
}

.intro {
  max-width: 670px;
  margin-bottom: 34px;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--green);
  font-size: 12px;
  font-weight: 750;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 12px;
  font-size: 36px;
  line-height: 1.2;
  letter-spacing: 0;
}

.intro > p:last-child {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 16px;
  line-height: 1.7;
}

/* === 双栏工作区布局（左侧表单 + 右侧信息栏） === */
.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  align-items: start;
  gap: 24px;
}

.workspace > *,
.side-column,
.form-panel form,
.field,
.input-wrap {
  min-width: 0;
}

.side-column {
  display: grid;
  gap: 24px;
}

.form-panel,
.security-panel,
.username-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.form-panel {
  padding: 32px;
  box-shadow: var(--shadow);
}

.username-panel,
.security-panel {
  padding: 26px;
}

.section-heading,
.security-heading,
.label-row,
.account-row,
.scope-row,
.username-panel-heading,
.directory-meta {
  display: flex;
  align-items: center;
}

.section-heading {
  gap: 14px;
  padding-bottom: 24px;
  margin-bottom: 26px;
  border-bottom: 1px solid var(--line);
}

.step-number {
  width: 42px;
  height: 42px;
  display: grid;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 8px;
  color: var(--green);
  background: var(--green-soft);
  font-size: 13px;
  font-weight: 800;
}

.section-heading h2,
.security-heading h2,
.username-panel-heading h2 {
  margin: 0;
  font-size: 18px;
  letter-spacing: 0;
}

.section-heading p,
.username-panel-copy,
.directory-message {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
}

/* === 配置警告提示 === */
.config-alert {
  display: flex;
  gap: 12px;
  padding: 14px;
  margin-bottom: 22px;
  border: 1px solid #fed7aa;
  border-radius: 6px;
  background: var(--amber-soft);
}

.config-alert > img {
  width: 19px;
  align-self: flex-start;
  filter: invert(37%) sepia(72%) saturate(1775%) hue-rotate(5deg);
}

.config-alert strong {
  color: #8a3f08;
  font-size: 14px;
}

.config-alert p {
  margin: 3px 0 0;
  color: #92551f;
  font-size: 13px;
  line-height: 1.5;
  overflow-wrap: anywhere;
}

/* === 表单字段 === */
.field {
  margin-bottom: 22px;
}

.compact-field {
  margin-bottom: 14px;
}

label {
  display: inline-block;
  margin-bottom: 8px;
  font-size: 14px;
  font-weight: 700;
}

.label-row {
  min-height: 30px;
  justify-content: space-between;
  gap: 16px;
}

.label-row label {
  margin-bottom: 8px;
}

.text-action {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 0 8px;
  border: 0;
  color: var(--green-dark);
  background: transparent;
  font-size: 12px;
  font-weight: 700;
}

.text-action img {
  width: 14px;
}

.input-wrap {
  position: relative;
}

.input-wrap > img {
  position: absolute;
  z-index: 1;
  top: 50%;
  left: 14px;
  width: 18px;
  opacity: 0.52;
  transform: translateY(-50%);
  pointer-events: none;
}

input {
  min-width: 0;
  width: 100%;
  height: 48px;
  padding: 0 46px 0 43px;
  border: 1px solid #cbd5d0;
  border-radius: 6px;
  outline: none;
  color: var(--ink);
  background: #fff;
  transition: border-color 150ms ease, box-shadow 150ms ease;
}

input::placeholder {
  color: #9aa49f;
}

input:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(8, 127, 91, 0.12);
}

input[aria-invalid="true"] {
  border-color: var(--danger);
  box-shadow: 0 0 0 3px rgba(180, 35, 24, 0.1);
}

.field-hint {
  margin: 7px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.icon-button {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
}

.icon-button:hover:not(:disabled) {
  border-color: #9caca5;
  background: #f7f9f8;
}

.icon-button:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

.icon-button img {
  width: 17px;
}

.input-action {
  position: absolute;
  top: 5px;
  right: 5px;
  border: 0;
}

.search-wrap input {
  padding-right: 14px;
}

/* === 密码强度指示器（4 段色条） === */
.strength {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 5px;
  margin-top: 9px;
}

.strength span {
  height: 3px;
  border-radius: 2px;
  background: #dfe5e2;
}

/* 密码强度色阶：红色(弱) → 橙色(一般) → 黄绿(良好) → 绿色(强) */
.strength[data-score="1"] span:nth-child(-n+1) { background: #d92d20; }
.strength[data-score="2"] span:nth-child(-n+2) { background: #d97706; }
.strength[data-score="3"] span:nth-child(-n+3) { background: #65a30d; }
.strength[data-score="4"] span:nth-child(-n+4) { background: var(--green); }

.password-rules {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 16px;
  margin-top: 10px;
}

.password-rules span {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: var(--muted);
  font-size: 11px;
}

.password-rules img {
  width: 12px;
  opacity: 0.55;
}

.password-rules .passed {
  color: var(--green-dark);
}

.password-rules .passed img {
  opacity: 1;
  filter: invert(35%) sepia(87%) saturate(697%) hue-rotate(113deg);
}

.form-message {
  min-height: 20px;
  margin: -6px 0 12px;
  color: var(--danger);
  font-size: 13px;
}

.captcha-field {
  min-height: 92px;
}

/* === 滑动验证码 === */
.slider-captcha {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 100%;
}

.slider-canvas-wrap {
  border: 2px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  transition: border-color 0.3s ease;
}

.slider-canvas {
  display: block;
  width: 100%;
  height: auto;
}

.slider-piece {
  display: block;
}

.slider-track {
  position: relative;
  height: 44px;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: #f8faf9;
  overflow: hidden;
  transition: border-color 0.3s ease;
  user-select: none;
  touch-action: none;
}

.slider-fill {
  position: absolute;
  top: 0;
  left: 0;
  height: 100%;
  width: 0;
  background: rgba(8, 127, 91, 0.12);
  border-radius: 22px 0 0 22px;
  transition: width 0.05s linear;
}

.slider-thumb {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
  cursor: grab;
  transition: transform 0.05s linear, background 0.3s ease, color 0.3s ease;
  z-index: 2;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
}

.slider-thumb:active {
  cursor: grabbing;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.18);
}

.slider-label {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  font-size: 13px;
  pointer-events: none;
  z-index: 1;
}

.slider-status {
  min-height: 18px;
  font-size: 12px;
  color: var(--green-dark);
}

.slider-status.error {
  color: var(--danger);
}

.primary-button,
.secondary-button {
  min-height: 48px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  border-radius: 6px;
  font-weight: 750;
}

.primary-button {
  width: 100%;
  border: 1px solid var(--green);
  color: #fff;
  background: var(--green);
}

.primary-button:hover:not(:disabled) {
  background: var(--green-dark);
}

.primary-button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.primary-button img,
.secondary-button img {
  width: 18px;
}

.primary-button img {
  filter: brightness(0) invert(1);
}

.username-panel-heading,
.directory-meta,
.scope-row,
.account-row {
  justify-content: space-between;
  gap: 16px;
}

.username-panel-copy {
  line-height: 1.6;
}

.directory-meta {
  padding: 8px 0 10px;
  color: var(--muted);
  font-size: 12px;
}

.directory-message {
  min-height: 18px;
  margin-bottom: 12px;
  line-height: 1.5;
}

.username-list {
  min-height: 92px;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-content: flex-start;
}

.username-chip {
  padding: 9px 12px;
  border: 1px solid #cfe0d8;
  border-radius: 999px;
  color: var(--green-dark);
  background: linear-gradient(180deg, #f7fcf9 0%, #edf8f3 100%);
  font-size: 12px;
  font-weight: 700;
}

.username-chip:hover {
  border-color: #9bc7b4;
  background: #e4f4ec;
}

.username-chip:focus-visible {
  outline: 2px solid rgba(8, 127, 91, 0.25);
  outline-offset: 2px;
}

.username-skeleton {
  width: calc(50% - 5px);
  min-width: 120px;
  height: 36px;
  border-radius: 999px;
  background: linear-gradient(90deg, #edf2ef 0%, #f8faf9 50%, #edf2ef 100%);
  background-size: 220% 100%;
  animation: shimmer 1.4s linear infinite;
}

.security-heading {
  align-items: flex-start;
  gap: 12px;
}

.security-heading .eyebrow {
  margin-bottom: 5px;
}

.security-icon {
  width: 40px;
  height: 40px;
  display: grid;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 8px;
  background: var(--amber-soft);
}

.security-icon img {
  width: 21px;
  filter: invert(34%) sepia(98%) saturate(1009%) hue-rotate(8deg);
}

.security-list {
  padding: 24px 0;
  margin: 24px 0 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  list-style: none;
}

.security-list li {
  display: flex;
  align-items: flex-start;
  gap: 12px;
}

.security-list li + li {
  margin-top: 20px;
}

.security-list li > img {
  width: 18px;
  margin-top: 2px;
  opacity: 0.68;
}

.security-list span {
  display: flex;
  flex-direction: column;
}

.security-list strong {
  font-size: 13px;
}

.security-list small {
  margin-top: 4px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.45;
}

.scope-row {
  padding-top: 18px;
  color: var(--muted);
  font-size: 12px;
}

.scope-row strong {
  color: var(--ink);
}

.success-panel {
  padding: 20px 4px 4px;
  text-align: center;
}

.success-icon {
  width: 58px;
  margin-bottom: 18px;
  filter: invert(35%) sepia(94%) saturate(562%) hue-rotate(112deg);
}

.success-panel h2 {
  margin-bottom: 24px;
  font-size: 24px;
}

.account-row {
  padding: 14px 16px;
  margin: 0 auto 22px;
  border: 1px solid var(--line);
  border-radius: 6px;
  text-align: left;
  background: #f8faf9;
}

.account-row span {
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.account-row small {
  margin-bottom: 3px;
  color: var(--muted);
}

.account-row strong {
  overflow-wrap: anywhere;
}

.secondary-button {
  padding: 0 18px;
  border: 1px solid #bfcac5;
  color: var(--ink);
  background: #fff;
}

footer {
  min-height: 60px;
  padding: 16px max(24px, calc((100vw - 1120px) / 2));
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  background: #fff;
  font-size: 11px;
}

.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  max-width: min(360px, calc(100vw - 40px));
  padding: 12px 16px;
  border-radius: 6px;
  color: #fff;
  background: #26332e;
  box-shadow: var(--shadow);
  font-size: 13px;
}

@keyframes shimmer {
  from {
    background-position: 200% 0;
  }

  to {
    background-position: -20% 0;
  }
}

/* === 响应式布局：平板设备（<=820px），切换为单栏布局 === */
@media (max-width: 820px) {
  main {
    width: min(100% - 32px, 680px);
    padding: 42px 0 56px;
  }

  .workspace {
    grid-template-columns: minmax(0, 1fr);
  }

  h1 {
    font-size: 30px;
  }
}

/* === 响应式布局：手机设备（<=520px），进一步压缩间距 === */
@media (max-width: 520px) {
  .topbar {
    min-height: 64px;
    padding: 10px 16px;
  }

  .brand small,
  .service-state span:last-child {
    display: none;
  }

  main {
    width: calc(100% - 24px);
    padding-top: 32px;
  }

  .intro {
    margin-bottom: 24px;
  }

  h1 {
    font-size: 27px;
  }

  .intro > p:last-child {
    font-size: 14px;
  }

  .form-panel,
  .security-panel,
  .username-panel {
    padding: 22px 18px;
  }

  .label-row {
    align-items: flex-start;
    flex-direction: column;
    gap: 0;
  }

  .label-row label {
    margin-bottom: 0;
  }

  .username-chip,
  .username-skeleton {
    width: 100%;
  }

  footer {
    padding: 16px;
  }
}

/* === 无障碍：尊重用户的减少动画偏好 === */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition: none !important;
    animation: none !important;
  }
}
