/* NapCat 控制台 · 用户前台样式
   复用 base.css 的变量与原子类，仅补充控制台布局与业务组件。 */

/* ---------------- 骨架布局 ---------------- */

body.console-body {
  --side-w: 240px;
  overflow-x: hidden;
}

body.console-body.nav-collapsed {
  --side-w: 84px;
}

.app {
  display: flex;
  min-height: 100vh;
  align-items: stretch;
}

/* ---------------- 侧边栏 ---------------- */

.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 40;
  width: var(--side-w);
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 18px 13px calc(14px + env(safe-area-inset-bottom));
  border-right: 1px solid var(--line);
  background:
    linear-gradient(180deg, rgba(13, 20, 36, 0.86), rgba(7, 11, 20, 0.94)),
    rgba(8, 12, 22, 0.9);
  backdrop-filter: blur(18px);
  overflow-x: hidden;
  overflow-y: auto;
  transition: width 0.26s ease, padding 0.26s ease,
    transform 0.28s cubic-bezier(0.22, 1, 0.36, 1);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1 1 auto;
  min-width: 0;
  padding: 4px 8px 12px;
  color: var(--text);
}

.brand:hover {
  color: var(--text);
}

.brand-logo {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  flex: 0 0 auto;
  border-radius: 11px;
  background: var(--grad);
  color: #06111d;
  box-shadow: 0 12px 26px -14px rgba(56, 189, 248, 0.9);
}

.brand-logo svg {
  width: 19px;
  height: 19px;
}

.brand-copy {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.brand-text {
  font-size: 14.5px;
  font-weight: 700;
  letter-spacing: 0.01em;
}

.brand-sub {
  font-size: 11px;
  color: var(--muted);
  letter-spacing: 0.02em;
}

.nav {
  display: flex;
  flex-direction: column;
  gap: 3px;
  flex: 1 1 auto;
  overflow-y: auto;
  padding-bottom: 6px;
}

.nav-item {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  height: 40px;
  padding: 0 12px;
  border-radius: var(--radius-sm);
  color: var(--text-2);
  font-size: 13.5px;
  font-weight: 550;
  letter-spacing: 0.01em;
  transition: background 0.16s ease, color 0.16s ease;
}

.nav-item svg {
  width: 17px;
  height: 17px;
  flex: 0 0 auto;
  color: var(--muted);
  transition: color 0.16s ease;
}

.nav-item:hover {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text);
}

.nav-item:hover svg {
  color: var(--brand);
}

.nav-item.is-active {
  color: #dcf3ff;
  background: var(--grad-soft);
}

.nav-item.is-active svg {
  color: var(--brand);
}

.nav-item.is-active::before {
  content: "";
  position: absolute;
  left: 0;
  top: 9px;
  bottom: 9px;
  width: 2px;
  border-radius: 2px;
  background: var(--brand);
  box-shadow: 0 0 12px rgba(56, 189, 248, 0.85);
}

.side-foot {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
  flex: 0 0 auto;
}

.user-box {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.03);
}

.avatar {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: var(--grad);
  color: #06111d;
  font-size: 13px;
  font-weight: 700;
}

.user-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-box .badge {
  height: 19px;
  padding: 0 7px;
  font-size: 10.5px;
}

.side-links {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.side-links a {
  display: flex;
  align-items: center;
  gap: 7px;
  height: 30px;
  padding: 0 9px;
  border-radius: var(--radius-xs);
  color: var(--muted);
  font-size: 12.5px;
  transition: background 0.16s ease, color 0.16s ease;
}

.side-links a svg {
  width: 14px;
  height: 14px;
  flex: 0 0 auto;
}

.side-links a:hover {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text);
}

/* ---------------- 主内容区 ---------------- */

.main {
  width: calc(100% - var(--side-w));
  min-width: 0;
  margin-left: var(--side-w);
  padding: 22px 26px 56px;
  transition: width 0.26s ease, margin-left 0.26s ease;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

#page-title {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.page-sub {
  margin-top: 4px;
  font-size: 12.5px;
  color: var(--muted);
}

.topbar-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  flex: 0 0 auto;
}

.banner {
  display: flex;
  align-items: center;
  gap: 9px;
  margin-bottom: 16px;
  padding: 11px 14px;
  border: 1px solid rgba(251, 191, 36, 0.4);
  border-radius: var(--radius-sm);
  background: rgba(251, 191, 36, 0.1);
  color: #fcd34d;
  font-size: 13px;
}

.banner svg {
  width: 16px;
  height: 16px;
  flex: 0 0 auto;
}

.view {
  animation: view-in 0.28s cubic-bezier(0.22, 1, 0.36, 1);
}

@keyframes view-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
}

/* ---------------- 通用栅格 ---------------- */

.grid-side {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.3fr);
  gap: 18px;
  align-items: start;
  margin-top: 18px;
}

.grid-side > * {
  margin-top: 0 !important;
}

.stack {
  display: flex;
  flex-direction: column;
}

.stat-value-sm {
  font-size: 21px;
}

/* ---------------- 快速开始 / 流程步骤 ---------------- */

.steps {
  counter-reset: step;
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.steps li {
  display: flex;
  align-items: flex-start;
  gap: 11px;
}

.step-no {
  counter-increment: step;
  position: relative;
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  flex: 0 0 auto;
  margin-top: 1px;
  border: 1px solid rgba(56, 189, 248, 0.35);
  border-radius: 50%;
  background: rgba(56, 189, 248, 0.1);
  color: #7dd3fc;
  font-size: 11.5px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.step-no::before {
  content: counter(step);
}

.step-body {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.step-body strong {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text);
}

.step-body a {
  font-size: 12px;
  width: fit-content;
}

/* ---------------- 最近消息流 ---------------- */

.feed {
  display: flex;
  flex-direction: column;
  max-height: 330px;
  overflow: auto;
  margin: 0 -6px;
  padding: 0 6px;
}

.feed-row {
  display: flex;
  align-items: baseline;
  gap: 9px;
  padding: 8px 0;
  border-bottom: 1px dashed rgba(148, 163, 184, 0.12);
  font-size: 12.5px;
}

.feed-row:last-child {
  border-bottom: none;
}

.feed-time {
  flex: 0 0 auto;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 11px;
}

.feed-who {
  flex: 0 0 auto;
  max-width: 96px;
  color: var(--brand);
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.feed-text {
  min-width: 0;
  flex: 1 1 auto;
  color: var(--text-2);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ---------------- 实例卡片 ---------------- */

.ins-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(370px, 1fr));
  gap: 15px;
}

.ins-card {
  display: flex;
  flex-direction: column;
  gap: 13px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.04), rgba(255, 255, 255, 0.012));
  transition: border-color 0.2s ease, box-shadow 0.2s ease, transform 0.2s ease;
}

.ins-card:hover {
  transform: translateY(-2px);
  border-color: rgba(56, 189, 248, 0.3);
  box-shadow: var(--shadow-lg);
}

.ins-head {
  display: flex;
  align-items: center;
  gap: 11px;
}

.ins-avatar {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  flex: 0 0 auto;
  border: 1px solid rgba(56, 189, 248, 0.24);
  border-radius: 12px;
  background: var(--grad-soft);
  color: #7dd3fc;
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 700;
}

.ins-name {
  font-size: 14px;
  font-weight: 650;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ins-qq {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--muted);
}

.ins-head-right {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 0 0 auto;
}

.ins-meta {
  display: flex;
  flex-direction: column;
  gap: 7px;
  margin: 0;
  font-size: 12.5px;
}

.meta-row {
  display: grid;
  grid-template-columns: 62px minmax(0, 1fr);
  align-items: center;
  gap: 8px;
}

.meta-row dt {
  color: var(--muted);
  font-size: 12px;
}

.meta-row dd {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  margin: 0;
  color: var(--text-2);
}

.ins-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

/* ---------------- 复制胶囊 ---------------- */

.copy-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: 100%;
  min-height: 24px;
  padding: 3px 8px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.03);
  color: var(--text-2);
  font-family: var(--mono);
  font-size: 11.5px;
  line-height: 1.4;
  cursor: pointer;
  text-align: left;
  transition: border-color 0.16s ease, color 0.16s ease, background 0.16s ease;
}

.copy-pill span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.copy-pill svg {
  width: 12px;
  height: 12px;
  flex: 0 0 auto;
  color: var(--muted);
}

.copy-pill:hover {
  border-color: rgba(56, 189, 248, 0.42);
  background: rgba(56, 189, 248, 0.08);
  color: var(--text);
}

.copy-pill:hover svg {
  color: var(--brand);
}

/* ---------------- 工具条 / 搜索 ---------------- */

.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-bottom: 13px;
}

.search-box {
  position: relative;
  flex: 1 1 250px;
  max-width: 380px;
}

.search-box svg {
  position: absolute;
  left: 11px;
  top: 50%;
  width: 15px;
  height: 15px;
  color: var(--muted);
  transform: translateY(-50%);
  pointer-events: none;
}

.search-box .input {
  padding-left: 33px;
}

.select-narrow {
  width: 200px;
  flex: 0 0 auto;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-bottom: 14px;
}

.chips:empty {
  display: none;
}

.chip {
  height: 26px;
  padding: 0 11px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font-family: inherit;
  font-size: 12px;
  cursor: pointer;
  transition: border-color 0.16s ease, background 0.16s ease, color 0.16s ease;
}

.chip:hover {
  color: var(--text);
  border-color: var(--line-strong);
  background: rgba(255, 255, 255, 0.05);
}

.chip.is-active {
  border-color: rgba(56, 189, 248, 0.45);
  background: rgba(56, 189, 248, 0.14);
  color: #7dd3fc;
}

/* ---------------- 表格补充 ---------------- */

.table-tall {
  max-height: 560px;
}

.table .cell-left {
  text-align: left !important;
}

.table td.msg-content {
  max-width: 460px;
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 12.5px;
  line-height: 1.55;
}

.table td.cell-wrap {
  max-width: 320px;
  font-size: 12.5px;
  line-height: 1.55;
  word-break: break-word;
}

.mono-sm {
  font-family: var(--mono);
  font-size: 11.5px;
  color: #93c5fd;
  word-break: break-all;
}

.dir-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11.5px;
  font-weight: 600;
}

.dir-in {
  color: #6ee7b7;
}

.dir-out {
  color: #fcd34d;
}

.foot-note {
  margin-top: 10px;
}

.pager {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
  margin-top: 12px;
  font-size: 12.5px;
  color: var(--muted);
}

.pager button {
  min-width: 30px;
  height: 30px;
  padding: 0 9px;
  border: 1px solid var(--line);
  border-radius: var(--radius-xs);
  background: transparent;
  color: var(--text-2);
  font-family: inherit;
  font-size: 12.5px;
  cursor: pointer;
  transition: background 0.16s ease, color 0.16s ease, border-color 0.16s ease;
}

.pager button:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.06);
  border-color: var(--line-strong);
  color: var(--text);
}

.pager button.is-active {
  border-color: transparent;
  background: var(--grad);
  color: #06111d;
  font-weight: 650;
}

.pager button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.pager .pager-info {
  margin-right: auto;
  font-variant-numeric: tabular-nums;
}

/* ---------------- 插件卡片 ---------------- */

.plg-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 14px;
}

.plg-card {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.038), rgba(255, 255, 255, 0.012));
  transition: border-color 0.2s ease, transform 0.2s ease, box-shadow 0.2s ease;
}

.plg-card:hover {
  transform: translateY(-2px);
  border-color: rgba(99, 102, 241, 0.38);
  box-shadow: var(--shadow-lg);
}

.plg-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.plg-name {
  font-size: 14px;
  font-weight: 650;
  color: var(--text);
  word-break: break-word;
}

.plg-slug {
  margin-top: 2px;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--muted);
  word-break: break-all;
}

.plg-desc {
  min-height: 44px;
  font-size: 12.5px;
  line-height: 1.6;
  color: var(--text-2);
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.plg-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  min-height: 22px;
}

.plg-tags .badge {
  height: 20px;
  padding: 0 8px;
  font-size: 10.5px;
}

.plg-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding-top: 11px;
  border-top: 1px solid var(--line);
  font-size: 11.5px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.plg-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

/* ---------------- 设置页资料 ---------------- */

.profile-head {
  display: flex;
  align-items: center;
  gap: 13px;
  margin-bottom: 16px;
}

.profile-avatar {
  display: grid;
  place-items: center;
  width: 52px;
  height: 52px;
  flex: 0 0 auto;
  border-radius: 16px;
  background: var(--grad);
  color: #06111d;
  font-size: 19px;
  font-weight: 700;
}

.profile-name {
  font-size: 16px;
  font-weight: 700;
}

.profile-mail {
  font-size: 12.5px;
  color: var(--muted);
  word-break: break-all;
}

.kv-block {
  display: grid;
  grid-template-columns: 92px minmax(0, 1fr);
  gap: 10px 14px;
  margin: 0;
  font-size: 13px;
}

.kv-block dt {
  color: var(--muted);
  font-size: 12.5px;
}

.kv-block dd {
  margin: 0;
  color: var(--text-2);
  word-break: break-all;
}

.form-grid {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

/* ---------------- 开发者页 ---------------- */

.dev-block {
  display: flex;
  flex-direction: column;
  gap: 7px;
  margin-bottom: 18px;
}

.dev-block:last-of-type {
  margin-bottom: 12px;
}

.dev-block .code {
  max-height: 340px;
}

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

/* 桌面：侧栏可折叠为图标栏 */
@media (min-width: 1081px) {
  body.console-body.nav-collapsed .brand {
    justify-content: center;
    padding: 4px 0 12px;
  }

  body.console-body.nav-collapsed .brand-copy,
  body.console-body.nav-collapsed .nav-item > span,
  body.console-body.nav-collapsed .side-links a > span,
  body.console-body.nav-collapsed .user-box .grow {
    display: none;
  }

  body.console-body.nav-collapsed .sidebar {
    padding-left: 10px;
    padding-right: 10px;
  }

  body.console-body.nav-collapsed .nav-item {
    justify-content: center;
    padding: 0;
  }

  body.console-body.nav-collapsed .nav-item.is-active::before {
    left: 6px;
  }

  body.console-body.nav-collapsed .user-box {
    justify-content: center;
    padding: 8px 0;
    border-color: transparent;
    background: transparent;
  }

  body.console-body.nav-collapsed .side-links {
    align-items: center;
  }

  body.console-body.nav-collapsed .side-links a {
    justify-content: center;
    padding: 8px 0;
  }
}

/* 平板 / 手机：侧栏改为左侧抽屉 */
@media (max-width: 1080px) {
  body.console-body {
    --side-w: 240px;
  }

  body.console-body .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 60;
    width: min(304px, 86vw);
    height: 100vh;
    height: 100dvh;
    padding: 18px 14px calc(16px + env(safe-area-inset-bottom));
    border-right: 1px solid var(--line);
    transform: translateX(-102%);
    transition: transform 0.28s cubic-bezier(0.22, 1, 0.36, 1);
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.5);
  }

  body.console-body.sidebar-open .sidebar {
    transform: none;
  }

  body.console-body .sidebar-close {
    display: inline-flex;
  }

  body.console-body.sidebar-open {
    overflow: hidden;
  }

  body.console-body .main {
    width: 100%;
    margin-left: 0;
    padding: 16px 16px 44px;
  }

  body.console-body .topbar {
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
  }

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

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

@media (max-width: 720px) {
  body.console-body .main {
    padding: 14px 14px 40px;
  }

  #page-title {
    font-size: 18px;
  }

  .page-sub {
    display: none;
  }

  .topbar {
    gap: 10px;
  }

  .topbar-actions {
    gap: 6px;
  }

  .topbar-actions .btn {
    width: 38px;
    height: 38px;
    padding: 0;
    justify-content: center;
  }

  .topbar-actions .btn span {
    display: none;
  }

  .card {
    padding: 14px;
    border-radius: 14px;
  }

  .select-narrow {
    width: 100%;
  }

  .search-box {
    max-width: none;
  }

  .tabs {
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }

  .tabs::-webkit-scrollbar {
    display: none;
  }

  .tabs > * {
    flex: 0 0 auto;
    white-space: nowrap;
  }

  .table {
    min-width: 640px;
  }
}

/* ---------------- 焦点可见 ---------------- */

a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
[tabindex]:focus-visible,
summary:focus-visible {
  outline: 2px solid rgba(56, 189, 248, 0.6);
  outline-offset: 2px;
}

/* ---------------- 扫码登录面板 ---------------- */

.qr-panel {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
}

.qr-frame {
  display: grid;
  place-items: center;
  width: 224px;
  height: 224px;
  padding: 10px;
  border-radius: var(--radius);
  border: 1px solid var(--line-strong);
  background: #fff;
  box-shadow: 0 18px 40px -26px rgba(2, 6, 23, 0.9);
}

.qr-frame .loading {
  color: #64748b;
  font-size: 12.5px;
}

.qr-img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  border-radius: var(--radius-xs);
}

.qr-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  height: 100%;
  color: #0f172a;
  font-weight: 600;
  font-size: 13px;
}

.qr-state.is-err {
  color: #b91c1c;
}

.qr-state svg {
  width: 34px;
  height: 34px;
}

.qr-msg {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  width: 100%;
  max-width: 340px;
  padding: 9px 11px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--text-2);
  font-size: 12.5px;
  line-height: 1.6;
  word-break: break-all;
}

.qr-msg svg {
  width: 15px;
  height: 15px;
  flex: 0 0 auto;
  margin-top: 2px;
}

.qr-msg.is-info {
  color: var(--muted);
}

.qr-msg.is-ok {
  border-color: rgba(52, 211, 153, 0.42);
  background: rgba(52, 211, 153, 0.08);
  color: var(--ok);
}

.qr-msg.is-err {
  border-color: rgba(248, 113, 113, 0.42);
  background: rgba(248, 113, 113, 0.08);
  color: var(--danger);
}

.qr-panel .kv-block {
  width: 100%;
  max-width: 340px;
}

/* 组件自带 display 会覆盖 [hidden]，这里显式还原隐藏行为 */
.qr-msg[hidden],
.modal-foot .btn[hidden] {
  display: none !important;
}
