/* ============================================
   用户中心 & 书架页
   ============================================ */

/* —— 用户中心布局 —— */
.user-layout {
  display: grid;
  grid-template-columns: 200px minmax(0, 1fr);
  gap: var(--space-8);
  align-items: start;
}

.user-sidebar {
  position: sticky;
  top: calc(var(--header-height) + var(--space-4));
  align-self: start;
}

.user-profile-card {
  margin: 0 var(--space-2) var(--space-3);
  padding: var(--space-4) var(--space-2) var(--space-4);
  text-align: center;
  border-bottom: 1px solid var(--paper-divider);
}

.user-avatar {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--ink-primary);
  color: var(--text-inverse);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-kai);
  font-size: var(--text-xl);
  margin: 0 auto var(--space-2);
  /* 印章双环 */
  box-shadow: 0 0 0 2px var(--paper-bg), 0 0 0 3px rgba(139, 105, 20, 0.45), var(--shadow-ink);
}

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

.user-level {
  display: inline-block;
  padding: 1px 10px;
  font-size: 11px;
  line-height: 1.6;
  background: var(--ink-accent);
  color: var(--text-inverse);
  border-radius: 100px;
  letter-spacing: 0.1em;
}

.user-nav {
  padding: 0;
}

.user-nav-item {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: 8px var(--space-3);
  color: var(--text-secondary);
  font-size: var(--text-sm);
  cursor: pointer;
  transition: background var(--transition-fast), color var(--transition-fast);
  text-decoration: none;
  border-radius: var(--radius-md);
  border-bottom: none;
  margin: 2px var(--space-2);
}

.user-nav-item:hover {
  background: var(--paper-bg-dark);
  color: var(--ink-primary);
  border-bottom: none;
}

.user-nav-item.active {
  color: var(--ink-primary);
  background: var(--paper-bg-dark);
  font-weight: 600;
  border-left: 2px solid var(--ink-primary);
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
  margin-left: 0;
  padding-left: calc(var(--space-3) + var(--space-2));
}

.user-nav-item.nav-logout {
  color: var(--ink-red);
}

.user-nav-item.nav-logout:hover {
  background: rgba(160, 82, 45, 0.08);
  color: var(--ink-red);
}

.user-nav-item .nav-icon {
  width: 18px;
  height: 18px;
  font-size: 13px;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* 用户内容区 */
.user-content {
  min-height: 500px;
  min-width: 0;
}

.user-content-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-5);
  padding-bottom: var(--space-3);
  border-bottom: 1px solid var(--paper-divider);
}

.user-content-header h2 {
  font-family: var(--font-kai);
  font-size: var(--text-xl);
  font-weight: 500;
  letter-spacing: 0.08em;
}

/* —— 书架页 —— */
.shelf-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-5);
  padding-bottom: var(--space-3);
  border-bottom: 1px solid var(--paper-divider);
}

.shelf-title {
  position: relative;
  padding-left: 12px;
  font-family: var(--font-kai);
  font-size: var(--text-xl);
  font-weight: 500;
  letter-spacing: 0.12em;
  line-height: 1.3;
}

.shelf-title::before {
  content: '';
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 5px;
  height: 16px;
  background: var(--ink-primary);
  border-radius: 1px;
}

.shelf-actions {
  display: flex;
  gap: var(--space-3);
}

.shelf-view-toggle {
  display: flex;
  background: var(--paper-bg-dark);
  border-radius: var(--radius-md);
  padding: 2px;
}

.view-btn {
  padding: var(--space-2) var(--space-4);
  border: none;
  background: transparent;
  color: var(--text-tertiary);
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: all var(--transition-fast);
  font-size: var(--text-sm);
}

.view-btn.active {
  background: var(--paper-bg);
  color: var(--ink-primary);
  box-shadow: var(--shadow-sm);
}

.shelf-groups {
  display: flex;
  gap: var(--space-3);
  margin-bottom: var(--space-6);
  flex-wrap: wrap;
}

.shelf-group {
  padding: var(--space-2) var(--space-5);
  background: var(--paper-bg);
  border: 1px solid var(--paper-border);
  border-radius: 100px;
  font-size: var(--text-sm);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.shelf-group:hover {
  color: var(--ink-primary);
  border-color: var(--ink-primary);
}

.shelf-group.active {
  background: var(--ink-primary);
  color: var(--text-inverse);
  border-color: var(--ink-primary);
}

/* 书架网格视图 */
.shelf-grid {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 12px var(--space-2);
}

.shelf-item {
  position: relative;
  cursor: pointer;
  text-decoration: none;
  border-bottom: none;
  display: block;
}

.shelf-item:hover .book-cover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.shelf-item:hover .book-title {
  color: var(--ink-primary);
}

.shelf-item .book-cover {
  width: 100%;
  aspect-ratio: 3 / 4;
  background: var(--paper-bg-deep);
  border-radius: var(--radius-sm);
  overflow: hidden;
  margin-bottom: 6px;
  transition: all var(--transition-base);
  box-shadow: var(--shadow-sm);
  position: relative;
}

.shelf-item .book-cover img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.shelf-item .book-cover .cover-placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-kai);
  font-size: var(--text-xl);
  color: var(--ink-primary);
  /* 书皮质感：对角渐变 + 内阴影 + 细边框 */
  background:
    linear-gradient(135deg, rgba(253, 246, 227, 0.5) 0%, rgba(245, 230, 200, 0.7) 100%),
    var(--paper-bg-deep);
  box-shadow: inset 0 2px 8px rgba(139, 105, 20, 0.08);
  border: 1px solid rgba(139, 105, 20, 0.08);
  text-align: center;
  padding: var(--space-2);
  line-height: 1.3;
}

/* 首字符放大：模拟旧书封面题字 */

/* ===== 骨架屏 ===== */
/* 书架骨架：复刻 .shelf-item 布局 */
.shelf-skeleton-item {
  display: block;
  pointer-events: none;
}
.shelf-skeleton-item .sk-cover {
  width: 100%;
  aspect-ratio: 3 / 4;
  border-radius: var(--radius-sm);
  margin-bottom: 6px;
}
.shelf-skeleton-item .sk-line {
  height: 13px;
  border-radius: 4px;
  margin-bottom: 4px;
}
.shelf-skeleton-item .sk-line:last-child {
  width: 60%;
}

/* 历史记录骨架：复刻 .history-item 布局（48×64 封面 + 两行文字） */
.history-skeleton-item {
  display: flex;
  gap: var(--space-3);
  padding: 10px var(--space-2);
  border-top: 1px solid var(--paper-divider);
  pointer-events: none;
}
.history-skeleton-item:last-child {
  border-bottom: 1px solid var(--paper-divider);
}
.history-skeleton-item .sk-cover {
  width: 48px;
  height: 64px;
  flex-shrink: 0;
  border-radius: 2px;
}
.history-skeleton-item .sk-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 6px;
}
.history-skeleton-item .sk-line {
  height: 13px;
  border-radius: 4px;
}
.history-skeleton-item .sk-line:first-child {
  width: 55%;
}
.history-skeleton-item .sk-line:last-child {
  width: 75%;
}

/* 通用 shimmer 效果（若 home.css 未加载时兜底） */
.sk-shimmer {
  background: linear-gradient(90deg, var(--paper-bg-deep) 25%, var(--paper-bg-dark) 50%, var(--paper-bg-deep) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
}
.shelf-item .book-cover .cover-placeholder::first-letter {
  font-size: 1.7em;
  font-weight: 700;
}

.shelf-item .read-progress {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: rgba(139, 105, 20, 0.2);
}

.shelf-item .read-progress .progress-fill {
  height: 100%;
  background: var(--ink-primary);
}

.shelf-item .book-title {
  font-size: var(--text-sm);
  color: var(--text-primary);
  font-weight: 500;
  line-height: 1.4;
  margin-bottom: 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  /* 固定两行高度，保证一行/两行书名的卡片状态行基线对齐 */
  min-height: 2.8em;
  transition: color var(--transition-fast);
}

.shelf-item .book-meta {
  font-size: var(--text-xs);
  color: var(--text-tertiary);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}

.shelf-item .book-author {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* 阅读状态徽章：未读 / 继续阅读 统一尺寸与形状，仅以配色区分 */
.shelf-item .read-status {
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  min-width: 42px;
  height: 20px;
  padding: 0 8px;
  font-size: var(--text-xs);
  line-height: 1;
  border-radius: 999px;
  border: 1px solid transparent;
  white-space: nowrap;
}

.shelf-item .read-status.is-unread {
  color: var(--text-tertiary);
  background: rgba(139, 105, 20, 0.08);
  border-color: rgba(139, 105, 20, 0.2);
}

.shelf-item .read-status.is-reading {
  color: #fff;
  background: var(--ink-primary);
  border-color: var(--ink-primary);
}

.shelf-item .remove-btn {
  position: absolute;
  top: -8px;
  right: -8px;
  width: 24px;
  height: 24px;
  background: var(--ink-red);
  color: var(--text-inverse);
  border: none;
  border-radius: 50%;
  cursor: pointer;
  font-size: 14px;
  display: none;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-sm);
  z-index: 2;
}

.shelf-item:hover .remove-btn {
  display: flex;
}

/* 空书架 */
.empty-shelf {
  text-align: center;
  padding: var(--space-20) 0;
  color: var(--text-tertiary);
}

.empty-shelf .empty-icon {
  font-size: 4rem;
  margin-bottom: var(--space-4);
  opacity: 0.5;
}

.empty-shelf h3 {
  font-size: var(--text-xl);
  margin-bottom: var(--space-3);
  color: var(--text-secondary);
  font-weight: 400;
}

.empty-shelf p {
  text-indent: 0;
  text-align: center;
  margin-bottom: var(--space-6);
}

.empty-shelf .empty-link {
  color: var(--ink-primary);
  text-decoration: none;
  border-bottom: 1px solid var(--ink-primary);
  padding-bottom: 2px;
  font-size: var(--text-sm);
}

.empty-shelf .empty-link:hover {
  opacity: 0.8;
}

/* ============================================
   个人信息页 · 紧凑书案风（细线分区，无大卡片）
   ============================================ */
.profile-page {
  min-height: auto;
}

/* 页头：印章方块 + 标题 */
.profile-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-4);
  margin-bottom: var(--space-5);
}

.profile-title {
  position: relative;
  padding-left: 12px;
  font-family: var(--font-kai);
  font-size: var(--text-xl);
  font-weight: 500;
  letter-spacing: 0.12em;
  line-height: 1.3;
}

.profile-title::before {
  content: '';
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 5px;
  height: 16px;
  background: var(--ink-primary);
  border-radius: 1px;
}

.profile-head-tag {
  font-size: var(--text-xs);
  color: var(--text-tertiary);
  letter-spacing: 0.05em;
  white-space: nowrap;
}

.profile-head-tag::before {
  content: '◆';
  color: var(--ink-accent);
  margin-right: 6px;
  font-size: 10px;
}

/* 数据横匾：上下细线 + 竖线分隔 */
.profile-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  border-top: 1px solid var(--paper-divider);
  border-bottom: 1px solid var(--paper-divider);
  margin-bottom: var(--space-6);
}

.pstat {
  text-align: center;
  padding: var(--space-3) var(--space-2);
  border-left: 1px solid var(--paper-divider);
}

.pstat:first-child {
  border-left: none;
}

.pstat-num {
  font-size: var(--text-xl);
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.3;
  font-variant-numeric: tabular-nums;
}

.pstat-num em {
  font-style: normal;
  font-size: var(--text-sm);
  color: var(--text-tertiary);
  font-weight: 400;
}

.pstat-label {
  margin-top: 2px;
  font-size: var(--text-xs);
  color: var(--text-tertiary);
  letter-spacing: 0.08em;
}

/* 目录式分节标题：竖条 + 标题 + 延展细线 */
.profile-block {
  margin-top: var(--space-6);
}

.block-title {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin-bottom: var(--space-1);
}

.block-title span {
  position: relative;
  padding-left: 11px;
  font-family: var(--font-kai);
  font-size: var(--text-base);
  font-weight: 500;
  letter-spacing: 0.14em;
  color: var(--text-primary);
}

.block-title span::before {
  content: '';
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 4px;
  height: 13px;
  background: var(--ink-primary);
  border-radius: 1px;
}

.block-title i {
  flex: 1;
  height: 1px;
  background: var(--paper-divider);
}

/* 资料面板：仅靠发丝线界定，不使用填色卡片 */
.profile-panel {
  max-width: 560px;
}

.avatar-upload {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  padding: var(--space-3) 0 var(--space-4);
  border-bottom: 1px solid var(--paper-divider);
}

.avatar-upload .avatar-large {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: var(--ink-primary);
  color: var(--text-inverse);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-kai);
  font-size: var(--text-xl);
  flex-shrink: 0;
  box-shadow: var(--shadow-ink);
}

.avatar-upload .avatar-info {
  flex: 1;
  min-width: 0;
}

.avatar-upload .avatar-tip {
  font-size: var(--text-xs);
  color: var(--text-tertiary);
  line-height: 1.6;
  margin-bottom: 6px;
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0 var(--space-5);
}

.profile-panel .form-group {
  margin: var(--space-3) 0;
}

.profile-panel .form-label {
  margin-bottom: 3px;
  font-size: var(--text-xs);
  letter-spacing: 0.05em;
}

.form-input.is-plain {
  background: transparent;
  border-color: transparent;
  border-bottom: 1px solid var(--paper-divider);
  border-radius: 0;
  padding-left: 0;
  padding-right: 0;
  color: var(--text-secondary);
}

.form-input.is-plain:focus {
  box-shadow: none;
  border-bottom-color: var(--ink-primary);
}

.form-actions {
  display: flex;
  justify-content: flex-end;
  padding-top: var(--space-3);
  margin-top: var(--space-1);
  border-top: 1px solid var(--paper-divider);
}

/* 账册式安全行列表 */
.profile-list {
  max-width: 560px;
}

.list-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  padding: 10px var(--space-2);
  border-top: 1px solid var(--paper-divider);
  text-decoration: none;
  transition: background var(--transition-fast);
}

.profile-list .list-row:last-child {
  border-bottom: 1px solid var(--paper-divider);
}

.list-row:hover {
  background: var(--paper-bg-dark);
  border-bottom-color: transparent;
}

.profile-list .list-row:last-child:hover {
  border-bottom: 1px solid var(--paper-divider);
}

/* 行内右侧操作按钮统一宽度（修改 / 管理 等宽对齐） */
.list-row > .btn {
  min-width: 64px;
}

.list-row .row-title {
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--text-primary);
  line-height: 1.5;
}

.list-row .row-sub {
  font-size: var(--text-xs);
  color: var(--text-tertiary);
  line-height: 1.5;
  margin-top: 1px;
}

.list-row .row-go {
  font-size: var(--text-sm);
  color: var(--text-tertiary);
  white-space: nowrap;
  transition: color var(--transition-fast);
}

.list-row:hover .row-go {
  color: var(--ink-primary);
}

/* 展开的修改密码区 */
.list-extra {
  border-top: 1px solid var(--paper-divider);
  padding: var(--space-4) var(--space-2) var(--space-5);
  background: var(--paper-bg-dark);
}

.pwd-fields {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0 var(--space-4);
  margin-bottom: var(--space-3);
}

.pwd-fields .form-group {
  margin: 0;
}

.pwd-actions {
  display: flex;
  gap: var(--space-2);
  justify-content: flex-end;
}

@media (max-width: 640px) {
  .profile-head {
    flex-direction: column;
    align-items: flex-start;
    gap: 2px;
  }
  .form-grid,
  .pwd-fields {
    grid-template-columns: 1fr;
    gap: 0;
  }
  .pwd-fields .form-group + .form-group {
    margin-top: var(--space-3);
  }
}

/* —— 响应式 —— */
@media (max-width: 900px) {
  .user-layout {
    grid-template-columns: minmax(0, 1fr);
    gap: var(--space-4);
  }
  .user-sidebar {
    position: static;
    display: block;
    padding-bottom: 0;
    border-bottom: none;
  }
  /* 顶部身份卡：紧凑横排，不占满屏 */
  .user-profile-card {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    margin: 0 0 var(--space-2);
    padding: 6px var(--space-3);
    text-align: left;
    border-bottom: none;
    border: 1px solid var(--paper-border);
    border-radius: var(--radius-md);
    background: linear-gradient(135deg, rgba(139,105,20,0.06) 0%, transparent 70%), var(--paper-bg);
  }
  .user-avatar {
    width: 30px;
    height: 30px;
    font-size: var(--text-sm);
    margin: 0;
    flex-shrink: 0;
    box-shadow: 0 0 0 1px var(--paper-bg), 0 0 0 2px rgba(139,105,20,0.45);
  }
  .user-name {
    margin-bottom: 0;
    font-size: var(--text-sm);
  }
  .user-level {
    display: inline-block;
    font-size: 10px;
    padding: 0 8px;
    line-height: 1.6;
  }
  /* 宫格导航：inline-block 实现，兼容性最强（防手机浏览器 flex 渲染异常/字体膨胀） */
  .user-nav {
    display: block;
    padding: 0;
    overflow: visible;
    font-size: 0;  /* 消除 inline-block 间隙 */
    letter-spacing: 0;
    text-size-adjust: 100%;
    -webkit-text-size-adjust: 100%;
  }
  .user-nav-item {
    display: inline-block;
    vertical-align: top;
    width: 33.33%;
    box-sizing: border-box;
    margin: 0 0 4px 0;
    padding: 11px 4px;
    font-size: 12px;
    line-height: 1.3;
    background: var(--paper-bg);
    border: 1px solid var(--paper-border);
    border-radius: var(--radius-md);
    white-space: nowrap;
    text-align: center;
    text-size-adjust: 100%;
    -webkit-text-size-adjust: 100%;
  }
  .user-nav-item .nav-icon {
    width: auto;
    height: auto;
    font-size: 16px;
    line-height: 1.2;
  }
  .user-nav-item.active {
    background: var(--ink-primary);
    color: var(--text-inverse);
    border-color: var(--ink-primary);
    border-radius: var(--radius-md);
    margin-left: 0;
    padding-left: 4px;
    border-left: 1px solid var(--ink-primary);
    font-weight: 600;
  }
  .user-nav-item.active .nav-icon {
    color: var(--text-inverse);
  }
  .user-nav-item.nav-logout {
    color: var(--ink-red);
    background: rgba(160, 82, 45, 0.08);
    border-color: rgba(160, 82, 45, 0.2);
  }
  .user-nav-item.nav-logout .nav-icon {
    color: var(--ink-red);
  }
  .shelf-grid {
    grid-template-columns: repeat(6, 1fr);
  }
}

@media (max-width: 600px) {
  .user-nav-item {
    padding: 10px 4px;
    font-size: 11px;
  }
  .user-nav-item .nav-icon {
    font-size: 14px;
  }
  .shelf-grid {
    grid-template-columns: repeat(4, 1fr);
    gap: 10px var(--space-1);
  }
}

/* 骨架屏 shimmer 动画（独立定义，不依赖 home.css） */
@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}
