/* ==================================================================
   EdgeFT · 文件页 / 收藏页（pane 渲染）与未读 badge
   ================================================================== */

/* ---------- pane 根容器（在 .view-pane 滚动容器内自然撑开） ---------- */
.pane-root {
  display: flex;
  flex-direction: column;
  min-height: 100%;
}

/* 文件页 / 收藏页滚动容器背景与底栏（--panel）同色：
   否则滑到底部最后一条后露出 body 灰底（--ios-bg），与白色底栏之间形成分界线 */
#view-files,
#view-collections {
  background: var(--panel);
}

/* 工具栏（分类 chips + 搜索）：粘在滚动容器顶部；背景与顶栏同色（纯白），避免顶栏下方露灰缝 */
.pane-toolbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  padding: 12px var(--space-3) var(--space-2);
  background: var(--panel);
}

.pane-chips {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}

.pane-chip {
  padding: 8px 16px;
  border: 1px solid var(--ios-separator);
  border-radius: var(--radius-pill);
  background: var(--panel);
  color: var(--ios-secondary-label);
  font-size: var(--font-caption);
  line-height: 1.3;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
  transition:
    transform var(--dur-fast) var(--ease-spring),
    background var(--dur-fast) var(--ease-out),
    color var(--dur-fast) var(--ease-out);
}

.pane-chip.active {
  background: var(--ios-blue-soft);
  border-color: transparent;
  color: var(--ios-blue);
  font-weight: 600;
}
.pane-chip:active {
  transform: scale(0.96);
  background: var(--ios-fill);
}

.pane-search {
  width: 100%;
  height: 36px;
  padding: 0 var(--space-3);
  border: 0;
  border-radius: var(--radius-control);
  background: var(--ios-fill);
  color: var(--ios-label);
  font-size: 16px; /* ≥16px：防 iOS 聚焦时自动放大整个页面（Safari 对 <16px 输入框聚焦会缩放视口） */
  box-sizing: border-box;
  -webkit-appearance: none;
  appearance: none;
}
.pane-search::placeholder {
  color: var(--ios-tertiary-label);
}
.pane-search:focus {
  outline: 2px solid rgba(0, 122, 255, 0.35);
  outline-offset: -1px;
}

/* ---------- 列表 ---------- */
.pane-scroll {
  flex: 1 1 auto;
}

.list-row {
  position: relative;
  display: flex;
  align-items: center;
  gap: var(--space-3);
  min-height: 76px; /* 上下加大：适配过期行三行内容，行距替代分隔线 */
  padding: 16px var(--space-4);
  background: var(--panel);
  /* 条目间细线已去除：整页无分割线更完整，靠行距与图标区分 */
  cursor: pointer;
  transition: background var(--dur-fast) var(--ease-out);
}
.list-row:active {
  /* 必须不透明：行下层是左滑删除按钮（红色），半透明背景会把它透出来（--ios-fill 是 rgba 半透明） */
  background: var(--ios-bg);
}
.list-row.expired {
  /* 不能用整行 opacity：行下层是左滑删除按钮（红色），行背景半透明会把它透出来。
     只对内容（图标/名称/信息）降透明，行背景保持不透明以遮住删除按钮。 */
  opacity: 1;
}
.list-row.expired .list-icon,
.list-row.expired .list-name,
.list-row.expired .list-meta {
  opacity: 0.5;
}
/* 过期提示行：红色小字，不随内容降透明（醒目） */
.list-expired {
  margin-top: 4px;
  font-size: var(--font-caption-2);
  font-weight: 600;
  color: var(--ios-red);
}

/* 图标 / 缩略图方块 */
.list-icon {
  position: relative;
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  justify-content: center;
  width: 48px; /* 放大 */
  height: 48px;
  border-radius: var(--radius-card);
  background: var(--ios-fill);
  color: var(--ios-secondary-label);
}
.list-icon.orange { background: var(--ios-orange-soft); color: var(--ios-orange); }
.list-icon.green  { background: var(--ios-green-soft);  color: var(--ios-green); }
.list-icon.red    { background: var(--ios-red-soft);    color: var(--ios-red); }
.list-icon.chat   { background: var(--ios-fill); color: var(--ios-secondary-label); }

.list-icon.image-thumb {
  background: var(--ios-fill);
  overflow: hidden;
}
.list-icon.image-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* 下载完成覆盖层：半透明白层 + 绿色对勾（不依赖文字/额外图标） */
.list-icon.dl-done::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: var(--ios-white-soft);
  pointer-events: none;
}
.dl-mark {
  position: absolute;
  inset: 0;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}
.dl-mark::after {
  content: "";
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--ios-green);
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23fff' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='20 6 9 17 4 12'/%3E%3C/svg%3E") center / 62% no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23fff' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='20 6 9 17 4 12'/%3E%3C/svg%3E") center / 62% no-repeat;
  background-color: var(--ios-green);
}

/* 行文本 */
.list-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.list-name {
  font-size: 16px; /* 放大 */
  line-height: 1.25;
  color: var(--ios-label);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.list-meta {
  font-size: var(--font-caption-2);
  line-height: 1.3;
  color: var(--ios-secondary-label);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* 左滑删除（移动端）：双层结构——红色底层宽度动画 + 上层内容跟手位移
   状态机阈值（相对行宽）：10% 回弹临界 / 15% 冲到 20% / 20% 露出按钮 /
   80% 触发猛冲 / 90% 猛冲停驻位（百分比逻辑在 withSwipeDelete 内计算） */
.swipe-row {
  position: relative;
  overflow: hidden;
  background: var(--ios-red);
}
/* 底层红色：右侧对齐，宽度由 JS 控制；跟手时无过渡，猛冲时 0.15s 快进慢出冲到 90% */
.swipe-delete-bg {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: 0;
  box-sizing: border-box;
  overflow: hidden;
  background: var(--ios-red);
  pointer-events: none;
  transition: width 0.15s cubic-bezier(0.22, 0.9, 0.36, 1); /* 猛冲：快进慢出 */
}
/* 「删除」文字：位置由 JS 完全驱动（跟手 1:1 / 猛冲弹簧），复位用 200ms ease-out */
.swipe-delete-text {
  position: absolute;
  top: 50%;
  right: 14px;
  transform: translateY(-50%);
  color: var(--text-on-primary);
  font-size: 16px;
  font-weight: 600;
  white-space: nowrap;
  transition: none;
  will-change: transform;
}
.swipe-delete-text.reset {
  transition: transform var(--dur-text-reset) var(--ease-out-fast);
}
/* 露出按钮模式（open，20% 停驻）：红色区域可点击弹出确认 */
.swipe-row.open .swipe-delete-bg {
  pointer-events: auto;
  cursor: pointer;
}

/* 列表底部统计行（如「· 12 个文件 ·」） */
.pane-count {
  padding: 16px var(--space-4) 24px; /* 底部留出安全区余量 */
  text-align: center;
  font-size: var(--font-caption-2);
  color: var(--ios-tertiary-label);
  letter-spacing: 0.5px;
}

/* 空状态 */
.list-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 56px var(--space-4);
  color: var(--ios-tertiary-label);
}
.list-empty-text {
  font-size: var(--font-sub);
}

/* ---------- 收藏卡片（右侧图标对齐） ---------- */
.fav-row .list-icon {
  order: 2; /* 图标放右侧 */
}

/* ---------- 未读 badge（仅聊天 tab） ---------- */
.mobile-tabs button {
  position: relative;
}
.tab-badge {
  position: absolute;
  top: 5px;
  right: calc(50% - 22px);
  min-width: 18px;
  height: 18px;
  padding: 0 8px;
  border-radius: var(--radius-pill);
  background: var(--ios-red);
  color: var(--text-on-primary);
  font-size: var(--font-micro);
  font-weight: 700;
  line-height: 18px;
  text-align: center;
  box-sizing: border-box;
  display: none;
  pointer-events: none;
}
.tab-badge.show {
  display: block;
}
.tab-badge.burst {
  animation: badge-pop var(--dur-fast) var(--ease-spring);
}
@keyframes badge-pop {
  0% { transform: scale(0.4); }
  70% { transform: scale(1.15); }
  100% { transform: scale(1); }
}

/* ---------- 桌面端两栏下的 pane ---------- */
@media (min-width: 721px) {
  .pane-root {
    max-width: 700px;
    margin: 0 auto;
  }
  .tab-badge {
    top: 4px;
    right: 10px;
  }
}
