/* ==========================================================================
   恒拓机械 · 管理后台样式
   ========================================================================== */

body.admin-body {
  min-height: 100vh;
  background: var(--bg);
}

[hidden] {
  display: none !important;
}

body.admin-body::before {
  opacity: 0.55;
}

/* -------------------------------- 登录 ---------------------------------- */

.login-wrap {
  position: relative;
  z-index: 1;
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 40px 20px;
  background:
    radial-gradient(50% 50% at 50% 30%, rgba(47, 228, 208, 0.09), transparent 70%),
    radial-gradient(40% 40% at 85% 85%, rgba(79, 157, 255, 0.07), transparent 70%);
}

.login-card {
  width: 100%;
  max-width: 420px;
  padding: 44px 40px 34px;
  border: 1px solid var(--line-2);
  background: rgba(9, 14, 22, 0.86);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  box-shadow: 0 40px 90px -40px rgba(0, 0, 0, 0.95);
}

.login-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding-bottom: 26px;
  margin-bottom: 30px;
  border-bottom: 1px solid var(--line);
}

.login-brand .brand-mark {
  width: 36px;
  height: 36px;
}

.login-brand b {
  display: block;
  font-size: 14px;
  letter-spacing: 0.08em;
}

.login-brand > div span {
  display: block;
  margin-top: 2px;
  font-family: var(--font-mono);
  font-size: 8.5px;
  letter-spacing: 0.2em;
  color: var(--dim);
}

.login-card h1 {
  font-size: 27px;
  letter-spacing: 0.02em;
}

.login-card > p {
  margin: 10px 0 30px;
  font-size: 12.5px;
  color: var(--muted);
  line-height: 1.7;
}

.login-card label {
  display: block;
  margin-bottom: 8px;
  font-size: 12px;
  color: var(--muted);
}

.pw-field {
  position: relative;
  margin-bottom: 22px;
}

.pw-field input {
  width: 100%;
  height: 48px;
  padding: 0 64px 0 16px;
  border: 1px solid var(--line-2);
  background: rgba(5, 9, 14, 0.8);
  font-size: 14px;
  letter-spacing: 0.04em;
  outline: none;
  transition: border-color 0.25s, box-shadow 0.25s;
}

.pw-field input:focus {
  border-color: rgba(47, 228, 208, 0.55);
  box-shadow: 0 0 0 3px rgba(47, 228, 208, 0.08);
}

.pw-toggle {
  position: absolute;
  right: 6px;
  top: 6px;
  height: 36px;
  padding: 0 12px;
  border: 0;
  background: transparent;
  color: var(--dim);
  font-size: 11px;
  cursor: pointer;
}

.pw-toggle:hover {
  color: var(--accent);
}

.login-card .btn {
  width: 100%;
}

.login-error {
  min-height: 18px;
  margin-top: 14px;
  font-size: 12px;
  color: #ff8f8f;
  text-align: center;
}

.back-link {
  display: block;
  margin-top: 26px;
  text-align: center;
  font-size: 11.5px;
  color: var(--dim);
  transition: color 0.25s;
}

.back-link:hover {
  color: var(--accent);
}

/* ------------------------------- 框架 ----------------------------------- */

.admin-header {
  position: sticky;
  top: 0;
  z-index: 50;
  height: 68px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 0 28px;
  border-bottom: 1px solid var(--line);
  background: rgba(5, 7, 11, 0.9);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}

.admin-header .brand-mark {
  width: 32px;
  height: 32px;
  font-size: 12px;
}

.admin-header .brand-name {
  font-size: 14px;
}

.admin-header .brand-en {
  font-size: 8px;
}

.admin-head-tag {
  margin-left: 16px;
  padding-left: 16px;
  border-left: 1px solid var(--line-2);
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.16em;
  color: var(--accent);
}

.admin-head-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.admin-head-actions .btn {
  min-height: 36px;
  padding: 0 14px;
  font-size: 12px;
}

.admin-layout {
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
  align-items: start;
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 28px 80px;
}

.admin-side {
  position: sticky;
  top: 68px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 30px 24px 30px 0;
}

.admin-side button {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 12px 14px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  font-size: 13.5px;
  text-align: left;
  cursor: pointer;
  transition: all 0.25s;
}

.admin-side button:hover {
  color: var(--text);
  background: rgba(132, 178, 255, 0.04);
}

.admin-side button.is-active {
  color: var(--accent);
  border-color: rgba(47, 228, 208, 0.22);
  background: rgba(47, 228, 208, 0.06);
}

.admin-side button span {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--dim);
}

.admin-side button.is-active span {
  color: var(--accent);
}

.admin-main {
  min-width: 0;
  padding: 30px 0 0 30px;
  border-left: 1px solid var(--line);
  min-height: calc(100vh - 68px);
}

.admin-title {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 28px;
}

.admin-title h1 {
  font-size: 25px;
  letter-spacing: 0.01em;
}

.admin-title p {
  margin: 7px 0 0;
  font-size: 12px;
  color: var(--dim);
}

/* ------------------------------ 产品列表 --------------------------------- */

.admin-products {
  display: flex;
  flex-direction: column;
  border-top: 1px solid var(--line);
}

.ap-row {
  display: grid;
  grid-template-columns: 92px minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 20px;
  padding: 16px 0;
  border-bottom: 1px solid var(--line);
  transition: background 0.25s;
}

.ap-row:hover {
  background: rgba(132, 178, 255, 0.025);
}

.ap-thumb {
  width: 92px;
  height: 68px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  background: var(--bg-elev);
  overflow: hidden;
}

.ap-thumb img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  padding: 8px;
}

.ap-thumb img.is-art {
  filter: brightness(1.7) contrast(1.05);
}

.ap-main {
  min-width: 0;
}

.ap-main h3 {
  font-size: 15px;
  font-weight: 600;
}

.ap-main .ap-sub {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 4px;
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--accent);
}

.ap-sub i {
  font-style: normal;
  color: var(--dim);
  font-family: var(--font-sans);
}

.ap-main p {
  margin: 6px 0 0;
  font-size: 11.5px;
  color: var(--dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ap-meta {
  display: flex;
  align-items: center;
  gap: 8px;
}

.chip {
  padding: 3px 8px;
  border: 1px solid var(--line-2);
  font-family: var(--font-mono);
  font-size: 9px;
  letter-spacing: 0.1em;
  color: var(--muted);
  white-space: nowrap;
}

.chip--on {
  border-color: rgba(47, 228, 208, 0.35);
  color: var(--accent);
}

.ap-actions {
  display: flex;
  gap: 8px;
}

.ap-actions button {
  padding: 6px 12px;
  border: 1px solid var(--line-2);
  background: transparent;
  color: var(--muted);
  font-size: 11.5px;
  cursor: pointer;
  transition: all 0.25s;
}

.ap-actions button:hover {
  color: var(--accent);
  border-color: rgba(47, 228, 208, 0.45);
}

.ap-actions button.is-danger:hover {
  color: #ff8f8f;
  border-color: rgba(255, 107, 107, 0.5);
}

.admin-empty {
  padding: 80px 20px;
  text-align: center;
  border: 1px dashed var(--line-2);
  margin-top: 20px;
}

.admin-empty b {
  display: block;
  font-size: 15px;
  color: var(--muted);
  font-weight: 500;
  margin-bottom: 6px;
}

.admin-empty p {
  margin: 0 0 22px;
  font-size: 12px;
  color: var(--dim);
}

/* -------------------------------- 表单 ---------------------------------- */

.admin-form {
  max-width: 880px;
}

.form-section {
  padding: 26px 0;
  border-bottom: 1px solid var(--line);
}

.form-section:first-child {
  padding-top: 0;
}

.form-section > h2 {
  margin-bottom: 20px;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.05em;
  color: var(--text);
}

.form-section > h2 small {
  margin-left: 8px;
  font-weight: 400;
  font-size: 11px;
  color: var(--dim);
}

.grid-2,
.grid-3 {
  display: grid;
  gap: 18px;
}

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

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

.field {
  display: block;
  min-width: 0;
}

.field > span {
  display: block;
  margin-bottom: 7px;
  font-size: 11.5px;
  color: var(--muted);
}

.field > span em {
  font-style: normal;
  color: var(--accent);
}

.field input,
.field select,
.field textarea,
.spec-row input,
.cat-item input,
.cat-item textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--line-2);
  border-radius: 0;
  background: rgba(5, 9, 14, 0.7);
  color: var(--text);
  font-size: 13px;
  outline: none;
  transition: border-color 0.25s, box-shadow 0.25s;
}

.form-section > textarea,
.form-section > input:not([type="checkbox"]) {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--line-2);
  background: rgba(5, 9, 14, 0.7);
  color: var(--text);
  font-size: 13px;
  line-height: 1.7;
  outline: none;
  resize: vertical;
  transition: border-color 0.25s, box-shadow 0.25s;
}

.form-section > textarea:focus,
.form-section > input:not([type="checkbox"]):focus {
  border-color: rgba(47, 228, 208, 0.5);
  box-shadow: 0 0 0 3px rgba(47, 228, 208, 0.06);
}

.field input:focus,
.field select:focus,
.field textarea:focus,
.spec-row input:focus,
.cat-item input:focus,
.cat-item textarea:focus {
  border-color: rgba(47, 228, 208, 0.5);
  box-shadow: 0 0 0 3px rgba(47, 228, 208, 0.06);
}

.field textarea {
  resize: vertical;
  line-height: 1.7;
}

.field select {
  appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--dim) 50%),
    linear-gradient(135deg, var(--dim) 50%, transparent 50%);
  background-position: calc(100% - 16px) 50%, calc(100% - 11px) 50%;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  padding-right: 32px;
}

.check {
  display: flex;
  align-items: center;
  gap: 9px;
  padding-top: 24px;
  font-size: 12.5px;
  color: var(--muted);
  cursor: pointer;
}

.check input {
  width: 15px;
  height: 15px;
  accent-color: var(--accent);
}

.hint {
  margin: 9px 0 0;
  font-size: 11px;
  color: var(--dim);
}

.counter {
  margin-top: 6px;
  text-align: right;
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--dim);
}

.form-actions {
  position: sticky;
  bottom: 0;
  z-index: 6;
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 8px;
  padding: 16px 0;
  border-top: 1px solid var(--line);
  background: rgba(5, 7, 11, 0.94);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.form-error {
  font-size: 12px;
  color: #ff8f8f;
  margin-left: auto;
}

/* ------------------------------ 图片上传 --------------------------------- */

.uploader {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 220px;
  border: 1px dashed var(--line-2);
  background:
    linear-gradient(rgba(132, 178, 255, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(132, 178, 255, 0.035) 1px, transparent 1px),
    rgba(5, 9, 14, 0.5);
  background-size: 30px 30px, 30px 30px, auto;
  cursor: pointer;
  overflow: hidden;
  transition: border-color 0.25s, background-color 0.25s;
}

.uploader:hover,
.uploader.is-drag {
  border-color: rgba(47, 228, 208, 0.55);
  background-color: rgba(47, 228, 208, 0.03);
}

.uploader img {
  display: none;
  width: 100%;
  max-height: 340px;
  object-fit: contain;
  padding: 14px;
}

.uploader img.is-art {
  filter: brightness(1.35);
}

.uploader.has-image img {
  display: block;
}

.uploader.has-image .up-empty {
  display: none;
}

.up-empty {
  padding: 26px;
  text-align: center;
  color: var(--dim);
}

.up-empty b {
  display: block;
  font-size: 13px;
  color: var(--muted);
  font-weight: 500;
  margin-bottom: 6px;
}

.up-empty span {
  font-size: 11px;
}

.up-empty svg {
  width: 30px;
  height: 30px;
  margin: 0 auto 14px;
  color: var(--accent);
  opacity: 0.7;
}

.up-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 10px;
}

.up-actions button {
  padding: 6px 14px;
  border: 1px solid var(--line-2);
  background: transparent;
  color: var(--muted);
  font-size: 11.5px;
  cursor: pointer;
  transition: all 0.25s;
}

.up-actions button:hover {
  color: var(--accent);
  border-color: rgba(47, 228, 208, 0.45);
}

.up-actions span {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--dim);
  margin-left: auto;
}

.uploader.is-uploading::after {
  content: "上传中…";
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(4, 8, 12, 0.7);
  font-size: 12px;
  color: var(--accent);
  letter-spacing: 0.1em;
}

/* ------------------------------ 参数编辑 --------------------------------- */

.spec-row {
  display: grid;
  grid-template-columns: 1fr 1.4fr 34px;
  gap: 10px;
  margin-bottom: 8px;
}

.spec-row button {
  border: 1px solid var(--line-2);
  background: transparent;
  color: var(--dim);
  cursor: pointer;
  font-size: 15px;
  line-height: 1;
  transition: all 0.2s;
}

.spec-row button:hover {
  color: #ff8f8f;
  border-color: rgba(255, 107, 107, 0.45);
}

.text-btn {
  padding: 8px 0;
  border: 0;
  background: transparent;
  color: var(--accent);
  font-size: 12px;
  cursor: pointer;
  letter-spacing: 0.04em;
}

.text-btn:hover {
  text-decoration: underline;
}

/* ----------------------------- 分类编辑器 -------------------------------- */

.cat-item {
  display: grid;
  grid-template-columns: 130px 1fr;
  gap: 12px;
  padding: 14px;
  margin-bottom: 10px;
  border: 1px solid var(--line);
  background: rgba(132, 178, 255, 0.02);
}

.cat-item .cat-fields {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.cat-item .cat-fields .full {
  grid-column: 1 / -1;
}

.cat-item .cat-id {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--dim);
  letter-spacing: 0.1em;
}

.cat-item label {
  display: block;
  font-size: 10.5px;
  color: var(--dim);
  margin-bottom: 4px;
}

.cat-item label > span {
  display: block;
  margin-bottom: 4px;
  font-size: 10.5px;
  color: var(--dim);
}

.cat-item .cat-del {
  align-self: start;
  justify-self: end;
  padding: 4px 8px;
  border: 0;
  background: transparent;
  color: var(--dim);
  font-size: 11px;
  cursor: pointer;
}

.cat-item .cat-del:hover {
  color: #ff8f8f;
}

.points-editor .cat-item {
  grid-template-columns: 1fr;
}

.cat-item--simple {
  position: relative;
  grid-template-columns: 1fr;
  padding-right: 68px;
}

.cat-item--simple .cat-id {
  position: absolute;
  top: 8px;
  right: 8px;
  margin: 0;
}

.cat-item--simple .cat-fields {
  grid-template-columns: 1fr 1fr;
}

/* -------------------------------- 弹窗 ---------------------------------- */

.modal {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding: 40px 24px;
  background: rgba(2, 5, 8, 0.78);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  overflow-y: auto;
}

.modal[hidden] {
  display: none;
}

.modal-panel {
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 860px;
  max-height: calc(100vh - 80px);
  border: 1px solid var(--line-2);
  background: #080d14;
  box-shadow: 0 50px 120px -40px rgba(0, 0, 0, 1);
  animation: modalIn 0.3s var(--ease);
  overflow: hidden;
}

.modal-panel > form {
  display: flex;
  flex: 1;
  flex-direction: column;
  min-height: 0;
}

@keyframes modalIn {
  from { opacity: 0; transform: translateY(14px); }
  to { opacity: 1; transform: none; }
}

.modal-head {
  position: relative;
  z-index: 2;
  flex: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 20px 28px;
  border-bottom: 1px solid var(--line);
  background: #080d14;
}

.modal-head h2 {
  font-size: 17px;
  letter-spacing: 0.02em;
}

.modal-head span {
  display: block;
  margin-top: 3px;
  font-family: var(--font-mono);
  font-size: 9px;
  letter-spacing: 0.16em;
  color: var(--dim);
}

.modal-close {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line-2);
  background: transparent;
  color: var(--muted);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
}

.modal-close:hover {
  color: var(--text);
  border-color: var(--accent);
}

.modal-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 8px 28px 0;
}

.modal-foot {
  position: relative;
  z-index: 2;
  flex: none;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 18px 28px;
  margin-top: 8px;
  border-top: 1px solid var(--line);
  background: #080d14;
}

.modal-foot .form-error {
  margin-right: auto;
  margin-left: 0;
}

/* ------------------------------ 安全设置 --------------------------------- */

.security-card {
  max-width: 480px;
  padding: 26px;
  border: 1px solid var(--line);
  background: rgba(10, 16, 24, 0.6);
}

.security-card h2 {
  font-size: 14px;
  margin-bottom: 6px;
}

.security-card > p {
  margin: 0 0 22px;
  font-size: 11.5px;
  color: var(--dim);
}

.security-card .field {
  margin-bottom: 16px;
}

/* ------------------------------- 响应式 --------------------------------- */

@media (max-width: 900px) {
  .admin-layout {
    grid-template-columns: 1fr;
    padding: 0 20px 60px;
  }
  .admin-side {
    position: sticky;
    top: 68px;
    z-index: 20;
    flex-direction: row;
    gap: 6px;
    padding: 12px 0;
    margin-bottom: 4px;
    background: var(--bg);
    border-bottom: 1px solid var(--line);
    overflow-x: auto;
  }
  .admin-side button {
    white-space: nowrap;
    padding: 9px 14px;
    font-size: 12.5px;
  }
  .admin-side button span {
    margin-left: 8px;
  }
  .admin-main {
    padding: 24px 0 0;
    border-left: 0;
  }
  .admin-header {
    padding: 0 18px;
  }
  .admin-head-tag {
    display: none;
  }
  .admin-head-actions .btn span.long {
    display: none;
  }
  .ap-row {
    grid-template-columns: 72px minmax(0, 1fr);
    gap: 14px;
  }
  .ap-thumb {
    width: 72px;
    height: 54px;
  }
  .ap-meta {
    grid-column: 2;
  }
  .ap-actions {
    grid-column: 2;
  }
  .grid-2,
  .grid-3 {
    grid-template-columns: 1fr;
  }
  .cat-item {
    grid-template-columns: 1fr;
  }
  .modal {
    padding: 0;
  }
  .modal-panel {
    border-left: 0;
    border-right: 0;
    min-height: 100vh;
    max-height: none;
  }
  .modal-body,
  .modal-head,
  .modal-foot {
    padding-left: 18px;
    padding-right: 18px;
  }
}

@media (max-width: 560px) {
  .login-card {
    padding: 32px 24px 26px;
  }
  .admin-title {
    flex-direction: column;
    align-items: stretch;
  }
  .admin-title .btn {
    width: 100%;
  }
  .admin-head-actions .btn.view-site {
    display: none;
  }
}
