/* ============================================
   NekoChat · 响应式布局与移动端补齐
   桌面 / 平板 / 手机 三档适配
   ============================================ */

/* ============================================
   主内容区
   ============================================ */
.main {
  display: flex;
  flex-direction: column;
  min-width: 0;
  flex: 1;
  overflow: hidden;
}

.page {
  flex: 1;
  min-height: 0;
  display: none;
  flex-direction: column;
  overflow: hidden;
}

.page.active {
  display: flex;
}

.mobile-topbar {
  display: none;
}

/* ============================================
   「我的」页
   ============================================ */
.page-profile { display: none; }

.page-profile.active {
  display: flex;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.me-card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin: 16px;
  box-shadow: var(--shadow-sm);
  display: flex;
  align-items: center;
  gap: 14px;
  flex-shrink: 0;
}

.me-avatar-wrap {
  position: relative;
  width: 62px;
  height: 62px;
  flex-shrink: 0;
}

.me-avatar,
.me-avatar-fallback {
  width: 62px;
  height: 62px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid #fff;
  box-shadow: 0 3px 12px rgba(74, 163, 255, .22);
}

.me-avatar-fallback {
  background: linear-gradient(135deg, #7fc4ff, #4aa3ff);
  color: #fff;
  font-size: 24px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}

.me-avatar-edit {
  position: absolute;
  right: -2px;
  bottom: -2px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: #fff;
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  box-shadow: var(--shadow-sm);
}

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

.me-name {
  font-size: 17px;
  font-weight: 800;
  color: var(--text);
  margin-bottom: 4px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.me-level {
  display: inline-block;
  font-size: 11.5px;
  padding: 3px 10px;
  border-radius: 999px;
  background: #eef6ff;
  color: var(--accent-hover);
  font-weight: 600;
}

.me-wallet {
  margin: 0 16px 16px;
  padding: 22px 20px;
  border-radius: var(--radius);
  background: linear-gradient(135deg, #4aa3ff 0%, #2b7fe0 100%);
  box-shadow: 0 8px 22px rgba(43, 127, 224, .28);
  color: #fff;
  flex-shrink: 0;
}

.me-wallet-label {
  font-size: 12px;
  color: rgba(255, 255, 255, .85);
  margin-bottom: 8px;
  letter-spacing: .5px;
}

.me-wallet-amount {
  font-size: 34px;
  font-weight: 900;
  line-height: 1.1;
}

.me-wallet-amount small {
  font-size: 14px;
  font-weight: 500;
  margin-left: 4px;
  color: rgba(255, 255, 255, .85);
}

.me-list {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin: 0 16px 16px;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  flex-shrink: 0;
}

.me-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 18px;
  font-size: 14.5px;
  color: var(--text);
  border-bottom: 1px solid #f0f7ff;
  width: 100%;
  text-align: left;
  background: none;
  transition: background .16s ease;
}

.me-item:last-child { border-bottom: none; }
.me-item:active { background: var(--bg-hover); }

.me-item-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.me-item-icon {
  width: 32px;
  height: 32px;
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  background: #eef6ff;
  flex-shrink: 0;
}

.me-item-arrow {
  color: var(--text-faint);
  font-size: 16px;
}

.me-item.danger {
  color: #e5484d;
  font-weight: 600;
  justify-content: center;
}

.me-item.danger .me-item-icon {
  background: #fff0f0;
}

/* ============================================
   移动端 (<= 768px)
   ============================================ */
@media (max-width: 768px) {

  /* 应用容器改为纵向：顶部栏 + 内容 + 底部导航 */
  .app-view {
    flex-direction: column;
    height: 100dvh;
    overflow: hidden;
  }

  /* 顺序：顶部栏(1) → 主内容(2) → 底部导航(3) */
  .mobile-topbar { order: 1; }
  .main { order: 2; }
  .sidebar { order: 3; }

  /* 顶部栏 */
  .mobile-topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 16px;
    padding-top: calc(10px + env(safe-area-inset-top));
    background: rgba(255, 255, 255, .97);
    backdrop-filter: saturate(180%) blur(16px);
    -webkit-backdrop-filter: saturate(180%) blur(16px);
    border-bottom: 1px solid var(--border);
    z-index: 40;
    flex-shrink: 0;
  }

  .mobile-brand {
    font-size: 15px;
    font-weight: 800;
    background: linear-gradient(92deg, #4aa3ff, #2b7fe0);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
  }

  .mobile-balance {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 5px 12px;
    border-radius: 999px;
    background: linear-gradient(135deg, #4aa3ff, #2b7fe0);
    color: #fff;
    font-size: 12.5px;
    font-weight: 700;
    box-shadow: 0 3px 10px rgba(43, 127, 224, .24);
  }

  .main {
    flex: 1;
    min-height: 0;
    padding-bottom: 0;
  }

  /* 侧边栏 → 底部固定导航 */
  .sidebar {
    position: static;
    width: 100%;
    height: auto;
    flex-direction: row;
    flex-shrink: 0;
    padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
    border-right: none;
    border-top: 1px solid var(--border);
    z-index: 50;
    align-items: center;
    gap: 0;
    box-shadow: 0 -2px 16px rgba(74, 163, 255, .08);
  }

  .sidebar-head,
  .profile-mini,
  .wallet-card,
  .btn-logout {
    display: none;
  }

  .nav {
    flex-direction: row;
    justify-content: space-around;
    width: 100%;
    gap: 0;
  }

  .nav-item {
    flex-direction: column;
    gap: 3px;
    font-size: 10.5px;
    padding: 8px 4px;
    flex: 1;
    background: none !important;
    font-weight: 600;
    min-width: 0;
  }

  .nav-item.active {
    background: none !important;
    color: var(--accent-hover);
  }

  .nav-icon {
    font-size: 20px;
  }

  .page-head {
    padding: 12px 16px;
    flex-shrink: 0;
  }

  .page-head h2 {
    font-size: 18px;
    line-height: 1.2;
  }

  .online-count {
    font-size: 12px;
  }

  .chat-body {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
  }

  .messages {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 14px;
  }

  .msg-content,
  .msg-bubble {
    max-width: 76vw;
  }

  .composer {
    flex-shrink: 0;
    padding: 9px 11px;
  }

  .video-grid,
  .level-grid {
    padding: 14px;
    grid-template-columns: 1fr 1fr;
    gap: 11px;
  }

  .video-info { padding: 9px 10px 11px; }
  .video-title { font-size: 13px; }
  .video-desc { display: none; }

  .stat-grid { grid-template-columns: 1fr 1fr; }
  .admin-panel { padding: 13px; }

  .admin-tabs {
    padding: 13px 13px 0;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    flex-shrink: 0;
  }

  .table { font-size: 12px; }
  .table th, .table td { padding: 8px 7px; }

  .rp { width: 205px; }

  .page-admin,
  .page-cinema,
  .page-member {
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }
}

/* ============================================
   小屏手机 (<= 400px)
   ============================================ */
@media (max-width: 400px) {
  .video-grid,
  .level-grid {
    grid-template-columns: 1fr;
  }

  .nav-item {
    font-size: 10px;
    padding: 7px 2px;
  }

  .nav-icon { font-size: 18px; }
}

/* ============================================
   桌面端增强 (>= 1024px)
   ============================================ */
@media (min-width: 1024px) {
  .sidebar {
    width: 260px;
    padding: 20px 16px;
  }

  .page-head {
    padding: 18px 28px;
  }

  .page-head h2 {
    font-size: 21px;
  }

  .messages {
    padding: 24px 28px;
  }

  .composer {
    padding: 14px 28px;
  }

  .video-grid,
  .level-grid {
    padding: 24px 28px;
    grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
    gap: 16px;
  }

  .video-desc {
    display: block;
  }

  .stat-grid {
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 16px;
  }

  .admin-panel {
    padding: 24px 28px;
  }

  .chat-body {
    max-width: 900px;
    margin: 0 auto;
    width: 100%;
  }

  .me-card,
  .me-wallet,
  .me-list {
    max-width: 560px;
    margin-left: auto;
    margin-right: auto;
  }
}

/* ============================================
   超宽屏 (>= 1440px)
   ============================================ */
@media (min-width: 1440px) {
  .chat-body {
    max-width: 1000px;
  }

  .video-grid,
  .level-grid {
    max-width: 1400px;
    margin: 0 auto;
  }
}
