/* ==========================================================================
   Xiaolong Space v2.0 — Minimalist Admin Workbench (Notion / Linear Style)
   ========================================================================== */

.admin-page {
  background: var(--bg);
}

/* ---------- Auth / Login ---------- */
.auth-wrap {
  min-height: 100svh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.auth-topbar {
  position: fixed;
  top: 20px;
  left: 24px;
  right: 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.auth-card {
  width: min(100%, 420px);
  padding: 36px 32px;
  border-radius: var(--radius-xl);
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-md);
}
.auth-card h1 {
  font-size: 24px;
  font-weight: 720;
  letter-spacing: -0.025em;
  margin-bottom: 8px;
}
.auth-desc {
  font-size: 14px;
  color: var(--text-secondary);
  margin-bottom: 24px;
  line-height: 1.65;
}
.auth-card form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.auth-submit { width: 100%; margin-top: 6px; }
.auth-actions { display: flex; gap: 10px; margin-top: 20px; }

/* ---------- Workbench Shell ---------- */
.adm-shell {
  min-height: 100svh;
  display: grid;
  grid-template-columns: 240px minmax(0, 1fr);
}

.adm-sidebar {
  position: sticky;
  top: 0;
  height: 100svh;
  padding: 20px 14px;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 20px;
}
.adm-brand {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 6px;
}
.adm-brand-link {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}
.adm-brand-link img {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: #fff;
}
.adm-brand-link strong {
  display: block;
  font-size: 14px;
  font-weight: 650;
  line-height: 1.25;
}
.adm-brand-link span {
  display: block;
  font-size: 11.5px;
  color: var(--muted);
}

.adm-nav {
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.adm-nav button {
  height: 38px;
  padding: 0 11px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13.5px;
  color: var(--text-secondary);
  text-align: left;
  transition: background-color 0.15s ease, color 0.15s ease;
}
.adm-nav button .icon { width: 17px; height: 17px; opacity: 0.8; }
.adm-nav button:hover {
  background: var(--bg-subtle);
  color: var(--text);
}
.adm-nav button.active {
  background: var(--brand-soft);
  color: var(--brand);
  font-weight: 650;
}
.adm-nav button.active .icon { opacity: 1; color: var(--brand); }
.adm-badge {
  margin-left: auto;
  font-style: normal;
  font-size: 11.5px;
  font-variant-numeric: tabular-nums;
  padding: 1px 7px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--muted);
}
.dirty-dot {
  margin-left: auto;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--warning);
}

.adm-sidebar-foot {
  margin-top: auto;
  padding-top: 14px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 8px;
}
.adm-visit { flex: 1; }

/* ---------- Main Area ---------- */
.adm-main {
  min-width: 0;
  display: flex;
  flex-direction: column;
}
.adm-topbar {
  height: 60px;
  padding: 0 36px;
  background: var(--surface-glass);
  backdrop-filter: saturate(180%) blur(18px);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.adm-topbar h1 {
  font-size: 18px;
  font-weight: 680;
  letter-spacing: -0.02em;
}
.adm-topbar-right { display: none; align-items: center; gap: 6px; }

.adm-body {
  width: 100%;
  max-width: 1160px;
  margin: 0 auto;
  padding: 28px 36px 80px;
}
.adm-section {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* ---------- Overview Dashboard ---------- */
.overview-banner {
  padding: 26px 28px;
  border-radius: var(--radius-lg);
  background:
    radial-gradient(50% 120% at 100% 0%, rgba(124, 58, 237, 0.12), transparent 65%),
    radial-gradient(45% 120% at 0% 100%, rgba(37, 99, 235, 0.10), transparent 65%),
    var(--surface);
  border: 1px solid rgba(79, 70, 229, 0.14);
  box-shadow: var(--shadow-sm);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  flex-wrap: wrap;
}
.overview-hello {
  display: flex;
  align-items: center;
  gap: 16px;
  min-width: 0;
}
.overview-hello > div { min-width: 0; }
.overview-hello img {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: #fff;
}
.overview-hello h2 {
  font-size: 19px;
  font-weight: 700;
  letter-spacing: -0.02em;
}
.overview-hello p {
  font-size: 13px;
  color: var(--muted);
  margin-top: 2px;
}
.overview-quick-btns { display: flex; gap: 10px; }

.metric-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}
.metric-card {
  padding: 18px 20px;
  border-radius: var(--radius-lg);
  background: var(--surface);
  border: 1px solid var(--border);
  text-align: left;
  display: flex;
  flex-direction: column;
  gap: 6px;
  transition: border-color 0.18s ease, box-shadow 0.18s ease, transform 0.18s ease;
}
.metric-card:hover {
  border-color: var(--border-strong);
  box-shadow: var(--shadow-sm);
  transform: translateY(-1px);
}
.metric-label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
}
.metric-ic {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  display: inline-grid;
  place-items: center;
  font-style: normal;
}
.metric-ic .icon { width: 15px; height: 15px; }
.metric-card.m-blue .metric-ic    { background: rgba(37, 99, 235, 0.12); color: #2563eb; }
.metric-card.m-emerald .metric-ic { background: rgba(5, 150, 105, 0.12); color: #059669; }
.metric-card.m-violet .metric-ic  { background: rgba(124, 58, 237, 0.12); color: #7c3aed; }
.metric-card.m-sky .metric-ic     { background: rgba(2, 132, 199, 0.12); color: #0284c7; }
html.dark .metric-card.m-blue .metric-ic    { background: rgba(59, 130, 246, 0.22); color: #93c5fd; }
html.dark .metric-card.m-emerald .metric-ic { background: rgba(16, 185, 129, 0.22); color: #6ee7b7; }
html.dark .metric-card.m-violet .metric-ic  { background: rgba(139, 92, 246, 0.22); color: #c4b5fd; }
html.dark .metric-card.m-sky .metric-ic     { background: rgba(14, 165, 233, 0.22); color: #7dd3fc; }
.metric-num {
  font-size: 28px;
  font-weight: 720;
  letter-spacing: -0.035em;
  line-height: 1.15;
  font-variant-numeric: tabular-nums;
}
.metric-sub { font-size: 12px; color: var(--muted); }

/* ---------- WeChat Import Box ---------- */
.wechat-box {
  padding: 20px 22px;
  border-radius: var(--radius-lg);
  background: var(--surface);
  border: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.wechat-box-head > div {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 4px 10px;
}
.wechat-box-head strong {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 14.5px;
  font-weight: 650;
}
.wechat-box-head strong .icon { color: #059669; }
.wechat-box-head span { font-size: 13px; color: var(--muted); }
.wechat-box-row {
  display: flex;
  align-items: center;
  gap: 10px;
}
.wechat-box-row input { flex: 1; min-width: 0; }
.wechat-hint {
  font-size: 13px;
  color: var(--text-secondary);
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  background: var(--bg-subtle);
}

/* ---------- Cards, Filters & Rows ---------- */
.adm-card {
  padding: 24px;
  border-radius: var(--radius-lg);
  background: var(--surface);
  border: 1px solid var(--border);
}
.adm-card.flush { padding: 0; overflow: hidden; }
.adm-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}
.adm-card-head h3 { font-size: 16px; font-weight: 650; letter-spacing: -0.015em; }
.adm-card-head p { font-size: 13px; color: var(--muted); margin-top: 2px; }

.adm-list-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
}
.adm-filter-tabs {
  display: inline-flex;
  padding: 3px;
  border-radius: 10px;
  background: var(--bg-muted);
}
.adm-filter-tabs button {
  height: 32px;
  padding: 0 12px;
  border-radius: 7px;
  font-size: 13px;
  color: var(--text-secondary);
  font-variant-numeric: tabular-nums;
}
.adm-filter-tabs button.active {
  background: var(--surface);
  color: var(--text);
  font-weight: 600;
  box-shadow: var(--shadow-xs);
}
.adm-list-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}
.adm-search {
  position: relative;
  display: flex;
  align-items: center;
}
.adm-search .icon {
  position: absolute;
  left: 11px;
  width: 15px;
  height: 15px;
  color: var(--muted);
  pointer-events: none;
}
.adm-search input {
  width: 220px;
  height: 38px;
  padding: 0 12px 0 34px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  font-size: 13.5px;
  outline: none;
}
.adm-search input:focus {
  border-color: var(--border-strong);
  box-shadow: 0 0 0 3px var(--ring);
}

.record-list { display: flex; flex-direction: column; }
.adm-card:not(.flush) .record-list {
  margin: 0 -8px;
}
.record-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 12px 18px;
  border-bottom: 1px solid var(--border);
  transition: background-color 0.14s ease;
}
.adm-card:not(.flush) .record-row {
  padding: 11px 10px;
  border-radius: var(--radius-md);
  border-bottom: 0;
}
.record-row:last-child { border-bottom: 0; }
.record-row:hover { background: var(--bg-subtle); }

.record-main {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 14px;
  text-align: left;
}
.record-thumb {
  width: 58px;
  height: 38px;
  border-radius: 8px;
  overflow: hidden;
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  flex-shrink: 0;
  display: grid;
  place-items: center;
  color: var(--muted);
  font-size: 12px;
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
}
.record-thumb img { width: 100%; height: 100%; }
.record-thumb.swatch-cyan   { color: #0284c7; background: rgba(2, 132, 199, 0.08); }
.record-thumb.swatch-purple { color: #7c3aed; background: rgba(124, 58, 237, 0.08); }
.record-thumb.swatch-green  { color: #059669; background: rgba(5, 150, 105, 0.08); }
.record-thumb.swatch-yellow { color: #d97706; background: rgba(217, 119, 6, 0.09); }

.record-info {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.record-info strong {
  font-size: 14.5px;
  font-weight: 600;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.record-info small {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.meta-warn { color: var(--warning); font-weight: 500; }

.record-right {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}
.state-pill {
  height: 23px;
  padding: 0 9px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  white-space: nowrap;
}
.state-pill.pub {
  background: rgba(16, 185, 129, 0.12);
  color: #059669;
}
html.dark .state-pill.pub { color: #34d399; }
.state-pill.draft {
  background: var(--bg-muted);
  color: var(--muted);
}

.danger-btn:hover:not(:disabled) {
  color: var(--danger);
  background: rgba(225, 29, 72, 0.08);
}
.danger-text { color: var(--danger); }
.danger-text:hover:not(:disabled) { background: rgba(225, 29, 72, 0.08); color: var(--danger); }

.adm-empty {
  padding: 52px 24px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  color: var(--muted);
}
.adm-empty-inline { font-size: 13.5px; color: var(--muted); padding: 12px 0; }

/* ---------- Form Fields & Image Uploader ---------- */
.adm-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}
.password-grid { max-width: 560px; }
.adm-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}
.adm-field.full { grid-column: 1 / -1; }
.adm-field > span {
  font-size: 13px;
  font-weight: 550;
  color: var(--text);
}
.adm-field small {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.5;
}
.adm-field input,
.adm-field textarea,
.adm-field select,
.wechat-box-row input {
  width: 100%;
  padding: 9px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  outline: none;
  transition: border-color 0.16s ease, box-shadow 0.16s ease;
}
.adm-field textarea {
  resize: vertical;
  min-height: 92px;
  line-height: 1.65;
}
.adm-field input:focus,
.adm-field textarea:focus,
.wechat-box-row input:focus {
  border-color: var(--border-strong);
  box-shadow: 0 0 0 3px var(--ring);
}

.img-uploader {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 14px;
  border-radius: var(--radius-md);
  border: 1px dashed var(--border-strong);
  background: var(--bg-subtle);
  transition: border-color 0.16s ease, background-color 0.16s ease;
}
.img-uploader.drag-over {
  border-color: var(--accent);
  background: var(--ring);
}
.img-uploader-preview {
  width: 72px;
  height: 72px;
  border-radius: 12px;
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--border);
  flex-shrink: 0;
  display: grid;
  place-items: center;
  color: var(--muted);
}
.img-uploader-preview.is-avatar { border-radius: 50%; background: #fff; }
.img-uploader-preview.is-wide { width: 136px; height: 86px; text-align: center; padding: 6px; }
.img-uploader-preview.is-wide span { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.img-uploader-preview.is-wide small { font-size: 10.5px; line-height: 1.3; }
.img-uploader-preview img { width: 100%; height: 100%; }
.img-uploader-controls { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.img-uploader-row { display: flex; gap: 8px; align-items: center; }
.img-uploader-row input { flex: 1; min-width: 0; }

.swatch-group {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.swatch-btn {
  height: 34px;
  padding: 0 12px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--bg);
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 12.5px;
  color: var(--text-secondary);
}
.swatch-btn i {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
}
.swatch-btn.selected {
  border-color: var(--text);
  background: var(--bg-subtle);
  color: var(--text);
  font-weight: 600;
}

.backup-actions { display: flex; flex-wrap: wrap; gap: 10px; }

/* ---------- Sticky Settings Save Bar ---------- */
.settings-savebar {
  position: sticky;
  bottom: 18px;
  z-index: 15;
  padding: 12px 18px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-md);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  font-size: 13.5px;
  color: var(--muted);
}
.settings-savebar.visible {
  border-color: var(--border-strong);
  color: var(--text);
  font-weight: 500;
}
.settings-savebar-btns { display: flex; align-items: center; gap: 8px; }

/* ---------- Slide-Over Editor Drawer ---------- */
.drawer-backdrop {
  position: fixed;
  inset: 0;
  z-index: 120;
  background: rgba(0, 0, 0, 0.32);
  backdrop-filter: blur(3px);
  display: flex;
  justify-content: flex-end;
  animation: fadeIn 0.16s ease;
}
.drawer-panel {
  width: min(100vw, 620px);
  height: 100%;
  background: var(--surface);
  border-left: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  animation: slideIn 0.2s cubic-bezier(0.22, 1, 0.36, 1);
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideIn { from { transform: translateX(28px); opacity: 0.6; } to { transform: translateX(0); opacity: 1; } }

.drawer-head {
  height: 60px;
  padding: 0 22px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}
.drawer-head-meta { display: flex; align-items: center; gap: 10px; }
.drawer-head strong { font-size: 16.5px; font-weight: 680; }

.drawer-body {
  flex: 1;
  overflow-y: auto;
  padding: 22px 24px 28px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}
.drawer-warn {
  padding: 11px 14px;
  border-radius: var(--radius-md);
  background: rgba(217, 119, 6, 0.10);
  color: var(--warning);
  font-size: 13px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.drawer-foot {
  padding: 14px 22px;
  border-top: 1px solid var(--border);
  background: var(--bg-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-shrink: 0;
}
.drawer-foot-right { display: flex; align-items: center; gap: 8px; }

/* ---------- Responsive Admin ---------- */
@media (max-width: 960px) {
  .adm-shell { grid-template-columns: minmax(0, 1fr); }
  .adm-sidebar {
    position: static;
    height: auto;
    min-width: 0;
    padding: 12px 16px;
    border-right: 0;
    border-bottom: 1px solid var(--border);
    gap: 12px;
  }
  .adm-brand .adm-theme,
  .adm-sidebar-foot { display: none; }
  .adm-topbar-right { display: flex; }
  .adm-nav {
    flex-direction: row;
    overflow-x: auto;
    scrollbar-width: none;
    padding-bottom: 2px;
    gap: 6px;
  }
  .adm-nav::-webkit-scrollbar { display: none; }
  .adm-nav button {
    white-space: nowrap;
    height: 34px;
    padding: 0 12px;
    flex-shrink: 0;
  }
  .adm-topbar { padding: 0 16px; height: 52px; }
  .adm-body { padding: 20px 16px 72px; }
  .metric-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 640px) {
  .adm-grid { grid-template-columns: 1fr; }
  .wechat-box-row { flex-direction: column; align-items: stretch; }
  .adm-list-actions { width: 100%; }
  .adm-search { flex: 1; }
  .adm-search input { width: 100%; }
  .record-row {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
  }
  .record-right { justify-content: flex-end; }
  .img-uploader { flex-direction: column; align-items: flex-start; }
  .img-uploader-controls { width: 100%; }
  .settings-savebar {
    border-radius: var(--radius-md);
    flex-direction: column;
    align-items: stretch;
    text-align: center;
  }
  .settings-savebar-btns { justify-content: center; }
  .drawer-body { padding: 18px 16px; }
  .drawer-foot { padding: 12px 16px; }
}
