/* Admin layout */
.admin-layout {
  display: flex;
  min-height: 100vh;
  background: #f5f6f8;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Microsoft YaHei", sans-serif;
  color: #333;
}

.admin-sidebar {
  width: 56px;
  background: #fff;
  border-right: 1px solid #eee;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 16px 0;
  gap: 8px;
  flex-shrink: 0;
}

.admin-sidebar__btn {
  width: 40px;
  height: 40px;
  border: none;
  background: transparent;
  border-radius: 10px;
  color: #888;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s, color 0.2s;
  text-decoration: none;
}

.admin-sidebar__btn:hover,
.admin-sidebar__btn.is-active {
  background: #f0ebff;
  color: #7c3aed;
}

.admin-sidebar__btn svg {
  width: 20px;
  height: 20px;
}

.admin-sidebar__logo {
  margin-top: auto;
  font-size: 10px;
  color: #bbb;
  text-align: center;
  line-height: 1.3;
  padding: 0 4px;
}

.admin-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

/* Header */
.admin-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  height: 56px;
  background: #fff;
  border-bottom: 1px solid #eee;
  flex-shrink: 0;
}

.admin-tabs {
  display: flex;
  gap: 4px;
}

.admin-tabs__btn {
  padding: 8px 16px;
  border: none;
  background: transparent;
  font-size: 14px;
  color: #666;
  cursor: pointer;
  border-radius: 8px;
  transition: background 0.2s, color 0.2s;
}

.admin-tabs__btn:hover {
  background: #f5f5f5;
}

.admin-tabs__btn.is-active {
  background: #f0ebff;
  color: #7c3aed;
  font-weight: 600;
}

.admin-header__right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.admin-url {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  background: #f5f5f5;
  border-radius: 8px;
  font-size: 13px;
  color: #555;
}

.admin-url__btn {
  border: none;
  background: none;
  cursor: pointer;
  color: #999;
  padding: 2px;
  display: flex;
}

.admin-url__btn:hover {
  color: #7c3aed;
}

.admin-btn {
  padding: 8px 20px;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  cursor: pointer;
  transition: opacity 0.2s;
}

.admin-btn--primary {
  background: #7c3aed;
  color: #fff;
}

.admin-btn--primary:hover {
  opacity: 0.9;
}

.admin-btn--ghost {
  background: #fff;
  color: #7c3aed;
  border: 1px solid #7c3aed;
}

.admin-btn--ghost:hover {
  background: #f0ebff;
}

.admin-btn--danger {
  background: #fff;
  color: #e53935;
  border: 1px solid #ffcdd2;
}

.admin-btn--sm {
  padding: 4px 10px;
  font-size: 12px;
}

/* Body */
.admin-body {
  flex: 1;
  display: flex;
  overflow: hidden;
}

.admin-editor {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
  min-width: 0;
}

.admin-preview {
  width: 380px;
  flex-shrink: 0;
  background: #eef0f3;
  border-left: 1px solid #e0e0e0;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 24px 16px;
  overflow-y: auto;
}

/* Panels */
.admin-panel {
  display: none;
}

.admin-panel.is-active {
  display: block;
}

.admin-card {
  background: #fff;
  border-radius: 12px;
  padding: 20px;
  margin-bottom: 16px;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.04);
}

.admin-card__title {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.admin-card__title span {
  color: #999;
  font-size: 12px;
  font-weight: 400;
}

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

.form-row label {
  display: block;
  font-size: 13px;
  color: #666;
  margin-bottom: 6px;
}

.form-row input[type="text"],
.form-row input[type="url"],
.form-row textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid #e0e0e0;
  border-radius: 8px;
  font-size: 14px;
  outline: none;
  transition: border-color 0.2s;
  font-family: inherit;
}

.form-row input:focus,
.form-row textarea:focus {
  border-color: #7c3aed;
}

.form-row textarea {
  resize: vertical;
  min-height: 72px;
}

.form-hint {
  font-size: 12px;
  color: #aaa;
  margin-top: 4px;
  text-align: right;
}

.form-inline {
  display: flex;
  gap: 12px;
  align-items: center;
}

.form-inline label {
  margin-bottom: 0;
  white-space: nowrap;
}

/* Avatar upload */
.avatar-upload {
  display: flex;
  align-items: center;
  gap: 16px;
}

.avatar-upload__img {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid #eee;
}

.avatar-upload__actions {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.avatar-upload__btn {
  padding: 6px 14px;
  border: 1px solid #ddd;
  border-radius: 6px;
  background: #fff;
  font-size: 13px;
  cursor: pointer;
}

.avatar-upload__btn:hover {
  border-color: #7c3aed;
  color: #7c3aed;
}

/* Section & links editor */
.section-block {
  margin-bottom: 20px;
}

.section-block__head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}

.section-block__head input {
  flex: 1;
  padding: 8px 12px;
  border: 1px solid #e0e0e0;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
}

.section-block__actions {
  display: flex;
  gap: 6px;
}

.icon-btn {
  width: 32px;
  height: 32px;
  border: 1px solid #e0e0e0;
  background: #fff;
  border-radius: 6px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #888;
  transition: border-color 0.2s, color 0.2s;
}

.icon-btn:hover {
  border-color: #7c3aed;
  color: #7c3aed;
}

.icon-btn svg {
  width: 16px;
  height: 16px;
}

.link-item {
  background: #fafafa;
  border: 1px solid #eee;
  border-radius: 10px;
  margin-bottom: 8px;
  overflow: hidden;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.link-item.is-dragging {
  opacity: 0.5;
}

.link-item.is-disabled {
  opacity: 0.55;
}

.link-item.is-expanded {
  border-color: #7c3aed;
  box-shadow: 0 0 0 2px rgba(124, 58, 237, 0.1);
}

.link-item__bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  cursor: pointer;
}

.link-item__drag {
  cursor: grab;
  color: #ccc;
  flex-shrink: 0;
}

.link-item__drag:active {
  cursor: grabbing;
}

.link-item__icon-preview {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  overflow: hidden;
}

.link-item__icon-preview svg {
  width: 18px;
  height: 18px;
  fill: #fff;
}

.link-item__icon-preview.link-card__icon--custom,
.icon-pick-btn__dot.link-card__icon--custom {
  background: #eee;
  padding: 0;
  overflow: hidden;
}

.link-item__icon-preview.link-card__icon--custom img,
.icon-pick-btn__dot.link-card__icon--custom img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.icon-pick-btn__dot {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  overflow: hidden;
}

.icon-pick-btn__dot svg {
  width: 14px;
  height: 14px;
  fill: #fff;
}

.link-item__info {
  flex: 1;
  min-width: 0;
}

.link-item__title {
  font-size: 14px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.link-item__url {
  font-size: 12px;
  color: #aaa;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.link-item__toggle {
  position: relative;
  width: 40px;
  height: 22px;
  flex-shrink: 0;
}

.link-item__toggle input {
  opacity: 0;
  width: 0;
  height: 0;
}

.link-item__toggle span {
  position: absolute;
  inset: 0;
  background: #ddd;
  border-radius: 11px;
  cursor: pointer;
  transition: background 0.2s;
}

.link-item__toggle span::after {
  content: "";
  position: absolute;
  width: 18px;
  height: 18px;
  left: 2px;
  top: 2px;
  background: #fff;
  border-radius: 50%;
  transition: transform 0.2s;
}

.link-item__toggle input:checked + span {
  background: #7c3aed;
}

.link-item__toggle input:checked + span::after {
  transform: translateX(18px);
}

.link-item__body {
  display: none;
  padding: 0 12px 14px;
  border-top: 1px solid #eee;
}

.link-item.is-expanded .link-item__body {
  display: block;
  padding-top: 14px;
}

.link-item__body .form-row:last-child {
  margin-bottom: 0;
}

.link-item__footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px dashed #eee;
}

.icon-pick-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  border: 1px solid #e0e0e0;
  border-radius: 8px;
  background: #fff;
  cursor: pointer;
  font-size: 13px;
}

.icon-pick-btn:hover {
  border-color: #7c3aed;
}

.icon-modal__item-icon--custom {
  background: #f0f0f0 !important;
  overflow: hidden;
  color: #999;
  font-size: 22px;
}

.icon-modal__item-icon--custom img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* 裁剪弹窗 */
.crop-modal {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 600;
  background: rgba(0, 0, 0, 0.55);
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.crop-modal.is-open {
  display: flex;
}

.crop-modal__box {
  background: #fff;
  border-radius: 12px;
  overflow: hidden;
  width: 100%;
  max-width: 420px;
}

.crop-modal__head {
  padding: 12px 16px;
  font-size: 13px;
  color: #888;
  border-bottom: 1px solid #eee;
}

.crop-modal__body {
  background: #222;
  max-height: 360px;
  overflow: hidden;
}

.crop-modal__body img {
  display: block;
  max-width: 100%;
}

.crop-modal__foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  gap: 12px;
  background: #7c3aed;
}

.crop-modal__btn {
  border: none;
  background: rgba(255, 255, 255, 0.2);
  color: #fff;
  padding: 8px 20px;
  border-radius: 8px;
  font-size: 14px;
  cursor: pointer;
}

.crop-modal__btn--primary {
  background: #fff;
  color: #7c3aed;
  font-weight: 600;
}

.crop-modal__btn--icon {
  padding: 8px 12px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.color-input {
  width: 36px;
  height: 36px;
  padding: 2px;
  border: 1px solid #e0e0e0;
  border-radius: 8px;
  cursor: pointer;
}

.editor-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
}

.editor-actions .admin-btn--sm {
  margin-left: auto;
}

.qr-upload-row {
  display: flex;
  gap: 8px;
}

.qr-upload-row input {
  flex: 1;
}

.qr-preview-thumb {
  display: block;
  width: 80px;
  height: 80px;
  object-fit: contain;
  margin-top: 8px;
  border-radius: 8px;
  border: 1px solid #eee;
}

.link-item--divider .link-item__icon-preview--divider {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.link-item--divider .link-item__icon-preview--divider svg {
  width: 18px;
  height: 18px;
  fill: #fff;
}

/* 添加其他模块弹窗 */
.module-picker {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(0, 0, 0, 0.45);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.2s ease, visibility 0.2s ease;
}

.module-picker.is-open {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

.module-picker__box {
  width: 100%;
  max-width: 420px;
  background: #fff;
  border-radius: 14px;
  overflow: hidden;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.18);
}

.module-picker__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 18px;
  border-bottom: 1px solid #f0f0f0;
  font-weight: 600;
}

.module-picker__close {
  border: none;
  background: transparent;
  font-size: 22px;
  color: #999;
  cursor: pointer;
  line-height: 1;
}

.module-picker__item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px 18px;
  border-bottom: 1px solid #f5f5f5;
}

.module-picker__item:last-child {
  border-bottom: none;
}

.module-picker__icon {
  flex-shrink: 0;
  width: 44px;
  height: 44px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.module-picker__icon svg {
  width: 22px;
  height: 22px;
  fill: #fff;
}

.module-picker__info {
  flex: 1;
  min-width: 0;
}

.module-picker__title {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 4px;
}

.module-picker__desc {
  font-size: 12px;
  color: #888;
  line-height: 1.4;
}

.module-picker__add {
  flex-shrink: 0;
  border: none;
  background: transparent;
  color: #7c3aed;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  padding: 6px 10px;
}

.module-picker__add:hover {
  opacity: 0.8;
}

/* Phone preview */
.phone-frame {
  width: 320px;
  background: #1a1a1a;
  border-radius: 36px;
  padding: 12px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.15);
}

.phone-frame__notch {
  width: 100px;
  height: 24px;
  background: #1a1a1a;
  border-radius: 0 0 16px 16px;
  margin: -4px auto 0;
  position: relative;
  z-index: 2;
}

.phone-screen {
  background: var(--bg, #aee6ee);
  border-radius: 28px;
  overflow: hidden;
  height: 580px;
  overflow-y: auto;
  position: relative;
}

.phone-screen .page {
  width: 100%;
  max-width: 100%;
  padding: 12px 14px 32px;
}

.phone-screen .top-bar {
  padding: 0 0 8px;
}

.phone-screen .top-bar__btn {
  width: 28px;
  height: 28px;
}

.phone-screen .profile__avatar {
  width: 64px;
  height: 64px;
}

.phone-screen .profile__name {
  font-size: 18px;
  margin-top: 10px;
}

.phone-screen .profile__bio {
  font-size: 11px;
}

.phone-screen .link-card {
  padding: 10px 12px;
  gap: 10px;
  border-radius: 22px;
}

.phone-screen .link-card__icon {
  width: 36px;
  height: 36px;
}

.phone-screen .link-card__icon--custom img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.phone-screen .link-card__title {
  font-size: 13px;
}

.phone-screen .link-card__subtitle {
  font-size: 11px;
}

.phone-screen .section__header {
  font-size: 12px;
  padding: 8px 0 10px;
}

.phone-screen .section__links {
  gap: 8px;
}

.phone-screen .qr-float {
  display: none;
}

/* Icon modal */
.icon-modal {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 500;
  background: rgba(0, 0, 0, 0.4);
  align-items: center;
  justify-content: center;
}

.icon-modal.is-open {
  display: flex;
}

.icon-modal__box {
  background: #fff;
  border-radius: 16px;
  width: 90%;
  max-width: 480px;
  max-height: 80vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.icon-modal__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid #eee;
  font-weight: 600;
}

.icon-modal__close {
  border: none;
  background: none;
  font-size: 22px;
  cursor: pointer;
  color: #999;
  line-height: 1;
}

.icon-modal__grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 10px;
  padding: 16px 20px;
  overflow-y: auto;
}

.icon-modal__item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 8px 4px;
  border: 2px solid transparent;
  border-radius: 10px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}

.icon-modal__item:hover {
  background: #f5f5f5;
}

.icon-modal__item.is-selected {
  border-color: #7c3aed;
  background: #f0ebff;
}

.icon-modal__item-icon {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.icon-modal__item-icon svg {
  width: 20px;
  height: 20px;
  fill: #fff;
}

.icon-modal__item-label {
  font-size: 10px;
  color: #888;
  text-align: center;
}

/* Stats */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}

.stat-card {
  background: #f9f9fb;
  border-radius: 10px;
  padding: 16px;
  text-align: center;
}

.stat-card__num {
  font-size: 28px;
  font-weight: 700;
  color: #7c3aed;
}

.stats-grid--4 {
  grid-template-columns: repeat(4, 1fr);
}

@media (max-width: 900px) {
  .stats-grid--4 {
    grid-template-columns: repeat(2, 1fr);
  }
}

.stats-pv-row {
  margin-bottom: 16px;
}

.stats-pv-card {
  background: linear-gradient(135deg, #7c3aed, #a78bfa);
  color: #fff;
  border-radius: 12px;
  padding: 20px 24px;
}

.stats-pv-card__label {
  font-size: 14px;
  opacity: 0.9;
  margin-bottom: 10px;
}

.stats-pv-card__nums {
  display: flex;
  gap: 32px;
  font-size: 14px;
}

.stats-pv-card__nums strong {
  font-size: 28px;
  margin-left: 6px;
}

.stats-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.stats-table th,
.stats-table td {
  padding: 10px 12px;
  border-bottom: 1px solid #eee;
  text-align: left;
}

.stats-table th {
  color: #888;
  font-weight: 500;
}

.stats-charts-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.stats-chart-box {
  min-width: 0;
}

@media (max-width: 900px) {
  .stats-charts-row {
    grid-template-columns: 1fr;
  }
}

.form-check-group {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  margin-top: 8px;
}

.form-check-group label,
.form-check {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 14px;
  cursor: pointer;
}

.stats-empty {
  text-align: center;
  color: #aaa;
  padding: 24px;
  font-size: 13px;
}

/* Theme */
.theme-colors {
  display: flex;
  gap: 20px;
  flex-wrap: wrap;
}

.theme-color-item label {
  display: block;
  font-size: 13px;
  color: #666;
  margin-bottom: 8px;
}

.theme-color-item input[type="color"] {
  width: 64px;
  height: 40px;
  border: none;
  cursor: pointer;
  border-radius: 8px;
}

/* Toast */
.admin-toast {
  position: fixed;
  bottom: 32px;
  left: 50%;
  transform: translateX(-50%) translateY(80px);
  z-index: 600;
  padding: 10px 24px;
  background: rgba(0, 0, 0, 0.78);
  color: #fff;
  border-radius: 999px;
  font-size: 14px;
  opacity: 0;
  transition: transform 0.3s, opacity 0.3s;
  pointer-events: none;
}

.admin-toast.is-visible {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

@media (max-width: 1100px) {
  .admin-preview {
    display: none;
  }
}

@media (max-width: 768px) {
  .admin-tabs__btn {
    padding: 6px 10px;
    font-size: 12px;
  }

  .admin-url {
    display: none;
  }
}
