/* ===== 全局 ===== */
* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --primary-light: #eff6ff;
  --primary-bg: #dbeafe;
  --bg: #f8fafc;
  --card-bg: #ffffff;
  --text: #0f172a;
  --text-secondary: #475569;
  --text-light: #94a3b8;
  --border: #e2e8f0;
  --border-light: #f1f5f9;
  --hover: #f1f5f9;
  --danger: #ef4444;
  --danger-light: #fef2f2;
  --success: #22c55e;
  --success-light: #f0fdf4;
  --warning: #f59e0b;
  --warning-light: #fffbeb;
  --shadow: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md: 0 4px 6px rgba(0,0,0,0.05), 0 2px 4px rgba(0,0,0,0.04);
  --shadow-lg: 0 10px 15px rgba(0,0,0,0.08), 0 4px 6px rgba(0,0,0,0.04);
  --radius: 12px;
  --radius-sm: 8px;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', 'Helvetica Neue', sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
}

a { color: var(--primary); text-decoration: none; }

/* ===== Header ===== */
.header {
  background: white;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: blur(10px);
}

.header-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 24px;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
}

.logo i {
  color: var(--primary);
  font-size: 24px;
}

.header-nav {
  display: flex;
  gap: 4px;
}

.nav-link {
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 500;
  color: var(--text-secondary);
  transition: all 0.2s;
}

.nav-link:hover { background: var(--hover); color: var(--text); }
.nav-link.active { background: var(--primary-light); color: var(--primary); }
.admin-link { color: var(--text-light); }

/* ===== Hero ===== */
.hero {
  background: linear-gradient(135deg, #1e3a8a 0%, #2563eb 50%, #3b82f6 100%);
  padding: 60px 24px 48px;
  text-align: center;
  color: white;
}

.hero-content { max-width: 700px; margin: 0 auto; }

.hero h1 {
  font-size: 36px;
  font-weight: 800;
  margin-bottom: 12px;
  letter-spacing: -0.5px;
}

.hero p {
  font-size: 16px;
  opacity: 0.85;
  margin-bottom: 20px;
}

.hero-update {
  display: inline-block;
  background: rgba(255,255,255,0.15);
  padding: 6px 16px;
  border-radius: 20px;
  font-size: 13px;
  opacity: 0.9;
  backdrop-filter: blur(4px);
}

/* ===== Container ===== */
.container {
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 32px 24px;
  flex: 1;
}

/* ===== 工具栏 ===== */
.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 24px;
  flex-wrap: wrap;
  min-width: 0;
}

/* ===== 分类标签 - 移动端3列立体按钮，桌面端一排 ===== */
.toolbar-tabs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  width: 100%;
  max-width: 100%;
}

.tab {
  padding: 10px 8px;
  border: none;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  background: linear-gradient(145deg, #ffffff, #f1f5f9);
  box-shadow: 3px 3px 6px rgba(0,0,0,0.08), -3px -3px 6px rgba(255,255,255,0.9);
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  line-height: 1.3;
  min-height: 44px;
}

.tab:hover { transform: translateY(-1px); }

.tab.active {
  background: linear-gradient(145deg, var(--primary), var(--primary-dark));
  color: white;
  box-shadow: inset 2px 2px 5px rgba(0,0,0,0.2), inset -2px -2px 5px rgba(255,255,255,0.1);
}

@media (min-width: 769px) {
  .toolbar-tabs {
    display: flex;
    align-items: center;
    gap: 6px;
    background: var(--border-light);
    padding: 4px;
    border-radius: var(--radius-sm);
    width: auto;
  }

  .tab {
    padding: 8px 18px;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    background: none;
    box-shadow: none;
    justify-content: flex-start;
    min-height: auto;
    white-space: nowrap;
  }

  .tab:hover { color: var(--text); transform: none; }

  .tab.active {
    background: white;
    color: var(--primary);
    box-shadow: var(--shadow);
  }
}

.toolbar-search {
  display: flex;
  align-items: center;
  gap: 8px;
  background: white;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 14px;
  width: 280px;
  transition: all 0.2s;
}

.toolbar-search:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-bg);
}

.toolbar-search i { color: var(--text-light); font-size: 18px; }
.toolbar-search input {
  border: none; outline: none; background: none;
  font-size: 14px; flex: 1; color: var(--text);
}

/* ===== 应用卡片网格 ===== */
.app-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 16px;
}

/* ===== 应用卡片（luckray 风格 + 优化） ===== */
.app-card {
  background: white;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  transition: all 0.2s;
  position: relative;
  overflow: hidden;
  min-width: 0;
  max-width: 100%;
}

.app-card:hover {
  box-shadow: var(--shadow-lg);
  border-color: var(--primary);
  transform: translateY(-2px);
}

.app-card.pinned {
  border-color: var(--primary);
  background: linear-gradient(to bottom, var(--primary-light), white 40%);
}

.app-card.pinned::before {
  content: '置顶';
  position: absolute;
  top: 12px;
  right: 12px;
  background: var(--primary);
  color: white;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 10px;
  border-radius: 10px;
}

.app-card-header {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 16px;
}

.app-icon {
  width: 56px;
  height: 56px;
  border-radius: 14px;
  background: linear-gradient(135deg, var(--primary), #6366f1);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 26px;
  flex-shrink: 0;
}

.app-icon.cat-app { background: linear-gradient(135deg, #2563eb, #6366f1); }
.app-icon.cat-archive { background: linear-gradient(135deg, #f59e0b, #f97316); }
.app-icon.cat-other { background: linear-gradient(135deg, #64748b, #94a3b8); }

.app-icon img {
  width: 100%; height: 100%; object-fit: cover; border-radius: 14px;
}

.app-card-title {
  flex: 1;
  min-width: 0;
  max-width: 100%;
}

.app-name {
  font-size: 17px;
  font-weight: 700;
  color: var(--text);
  word-break: break-word;
  overflow-wrap: anywhere;
  line-height: 1.4;
}

.app-subtitle {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 4px;
  flex-wrap: wrap;
}

.app-version {
  font-size: 12px;
  color: var(--text-light);
  background: var(--bg);
  padding: 2px 8px;
  border-radius: 4px;
}

.platform-badge {
  font-size: 11px;
  font-weight: 600;
  padding: 2px 10px;
  border-radius: 4px;
}

.platform-android { background: #f0fdf4; color: #16a34a; }
.platform-ios { background: #f0f9ff; color: #0369a1; }
.platform-macos { background: #f5f3ff; color: #7c3aed; }
.platform-windows { background: #eff6ff; color: #2563eb; }
.platform-linux { background: #fef2f2; color: #dc2626; }
.platform-multi { background: #fff7ed; color: #ea580c; }
.platform-general { background: #f8fafc; color: #64748b; }

.app-desc {
  font-size: 14px;
  color: var(--text-secondary);
  margin-bottom: 12px;
  line-height: 1.7;
  word-break: break-word;
  overflow-wrap: anywhere;
}

.app-desc strong {
  display: block;
  margin-bottom: 4px;
  color: var(--text);
  font-size: 14px;
}

.app-install-guide {
  font-size: 13px;
  color: var(--text-secondary);
  padding: 0;
  margin-bottom: 16px;
  line-height: 1.7;
  word-break: break-word;
  overflow-wrap: anywhere;
}

.app-install-guide strong {
  display: block;
  margin-bottom: 4px;
  color: var(--text);
  font-size: 13px;
}

.app-meta {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 16px;
  font-size: 12px;
  color: var(--text-light);
  flex-wrap: wrap;
}

.app-meta span {
  display: flex;
  align-items: center;
  gap: 4px;
}

.app-tags {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.app-tag {
  font-size: 11px;
  background: var(--bg);
  color: var(--text-secondary);
  padding: 2px 10px;
  border-radius: 10px;
}

.app-actions {
  display: flex;
  gap: 8px;
}

/* ===== 按钮 ===== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-size: 14px;
  font-weight: 600;
  padding: 10px 20px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  cursor: pointer;
  transition: all 0.2s;
  background: white;
  color: var(--text-secondary);
  line-height: 1;
}

.btn:hover { background: var(--hover); }

.btn-primary {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}

.btn-primary:hover {
  background: var(--primary-dark);
  border-color: var(--primary-dark);
  box-shadow: 0 4px 12px rgba(37,99,235,.3);
}

.btn-lg { padding: 12px 28px; font-size: 15px; }
.btn-sm { padding: 6px 12px; font-size: 12px; }
.btn-xs { padding: 4px 8px; font-size: 11px; }

.btn-download {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
  flex: 1;
}

.btn-download:hover {
  background: var(--primary-dark);
  box-shadow: 0 4px 12px rgba(37,99,235,.35);
}

.btn-download i { font-size: 18px; }

.btn-install {
  background: var(--success);
  color: white;
  border-color: var(--success);
  flex-shrink: 0;
}

.btn-install:hover {
  background: #16a34a;
  border-color: #16a34a;
  box-shadow: 0 4px 12px rgba(34,197,94,.35);
}

.btn-install i { font-size: 18px; }

.btn-outline {
  background: white;
  color: var(--primary);
  border-color: var(--primary);
}

.btn-outline:hover { background: var(--primary-light); }

.btn-danger { color: var(--danger); }
.btn-danger:hover { background: var(--danger-light); color: #dc2626; }

.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ===== 空状态 ===== */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 80px 20px;
  color: var(--text-light);
  text-align: center;
}

.empty-state i { font-size: 56px; margin-bottom: 16px; }
.empty-state p { font-size: 15px; margin-bottom: 20px; }
.empty-state.hidden { display: none; }

.loading-state {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 40px;
  color: var(--text-light);
  font-size: 14px;
}

/* ===== Footer ===== */
.footer {
  background: white;
  border-top: 1px solid var(--border);
  padding: 20px 24px;
}

.footer-content {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.footer-left {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-secondary);
}

.footer-left i { color: var(--primary); font-size: 18px; }

.footer-right {
  display: flex;
  gap: 20px;
}

.footer-stat {
  font-size: 13px;
  color: var(--text-light);
}

.footer-stat span {
  font-weight: 600;
  color: var(--text);
}

/* ===== Toast ===== */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 20px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  animation: toastIn 0.3s ease;
}

.toast.success { background: var(--success); color: white; }
.toast.error { background: var(--danger); color: white; }
.toast.info { background: var(--primary); color: white; }

@keyframes toastIn {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

.toast.fade-out {
  animation: toastOut 0.3s ease forwards;
}

@keyframes toastOut {
  to { transform: translateX(100%); opacity: 0; }
}

/* ==================== 管理页面 ==================== */

.admin-page { padding-top: 24px; }

/* 统计卡片 */
.stats-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: white;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 20px;
  display: flex;
  align-items: center;
  gap: 14px;
}

.stat-card i {
  font-size: 24px;
  color: var(--primary);
  width: 44px;
  height: 44px;
  border-radius: 10px;
  background: var(--primary-light);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.stat-info { display: flex; flex-direction: column; }

.stat-num {
  font-size: 22px;
  font-weight: 700;
  color: var(--text);
}

.stat-info span:last-child {
  font-size: 12px;
  color: var(--text-light);
}

/* 管理布局 */
.admin-layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  align-items: start;
}

@media (max-width: 900px) {
  .admin-layout {
    grid-template-columns: 1fr;
  }
}

.admin-panel {
  background: white;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
}

.admin-panel h2 {
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  gap: 10px;
}

/* 上传表单 */
.upload-form { display: flex; flex-direction: column; gap: 16px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

.form-group { display: flex; flex-direction: column; gap: 6px; }

.form-group label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
}

.required { color: var(--danger); }

.form-group input[type="text"],
.form-group input[type="number"],
.form-group select,
.form-group textarea {
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  color: var(--text);
  background: white;
  transition: border-color 0.2s;
  font-family: inherit;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-bg);
}

.form-group textarea { resize: vertical; min-height: 60px; }

.checkbox-group { justify-content: flex-end; }
.checkbox-label {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-size: 14px;
  color: var(--text);
}

.file-upload-box {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 28px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
  position: relative;
}

.file-upload-box:hover,
.file-upload-box.dragover {
  border-color: var(--primary);
  background: var(--primary-light);
}

.file-upload-box i {
  font-size: 36px;
  color: var(--primary);
  margin-bottom: 8px;
}

.file-upload-box p {
  font-size: 14px;
  color: var(--text-secondary);
  font-weight: 500;
}

.file-hint {
  font-size: 12px;
  color: var(--text-light);
  display: block;
  margin-top: 4px;
}

.file-input-hidden {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.selected-file {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--success-light);
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  color: var(--success);
}

.selected-file i { font-size: 18px; }

.selected-file.hidden { display: none; }

.icon-upload-row { display: flex; gap: 8px; }
.icon-upload-row input { flex: 1; }
.icon-preview img {
  width: 48px; height: 48px; border-radius: 10px; object-fit: cover; border: 1px solid var(--border);
}
.icon-preview.hidden { display: none; }

.form-actions { display: flex; flex-direction: column; gap: 12px; }

.upload-progress-bar {
  height: 6px;
  background: var(--bg);
  border-radius: 3px;
  overflow: hidden;
  position: relative;
}

.upload-progress-bar.hidden { display: none; }

.upb-fill {
  height: 100%;
  background: var(--primary);
  border-radius: 3px;
  transition: width 0.3s;
  width: 0%;
}

.upb-text {
  position: absolute;
  right: 0;
  top: -20px;
  font-size: 11px;
  color: var(--text-light);
}

/* 已上传列表 */
.admin-app-list { display: flex; flex-direction: column; gap: 8px; }

.admin-app-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  transition: all 0.2s;
}

.admin-app-item:hover { border-color: var(--primary); }

.admin-app-item .mini-icon {
  width: 36px; height: 36px;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--primary), #6366f1);
  display: flex; align-items: center; justify-content: center;
  color: white; font-size: 16px; flex-shrink: 0;
}

.admin-app-item .mini-info { flex: 1; min-width: 0; }

.admin-app-item .mini-name {
  font-size: 13px; font-weight: 600;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

.admin-app-item .mini-meta {
  font-size: 11px; color: var(--text-light); margin-top: 2px;
}

.admin-app-item .mini-category {
  display: inline-block;
  cursor: pointer;
  color: var(--primary);
  border-bottom: 1px dashed var(--primary-bg);
  transition: all 0.2s;
}

.admin-app-item .mini-category:hover {
  color: var(--primary-dark);
  border-bottom-color: var(--primary);
}

.admin-app-item .mini-actions { display: flex; gap: 4px; flex-shrink: 0; }

.admin-app-item .drag-handle {
  color: var(--text-light);
  cursor: grab;
  font-size: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 4px;
  margin: -4px 0;
  border-radius: 4px;
  transition: color 0.2s, background 0.2s;
  flex-shrink: 0;
}

.admin-app-item .drag-handle:hover {
  color: var(--primary);
  background: var(--bg);
}

.admin-app-item.dragging {
  opacity: 0.5;
  border-color: var(--primary);
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.15);
}

.admin-app-item.drag-over {
  border-style: dashed;
  border-color: var(--primary);
  background: rgba(37, 99, 235, 0.05);
}

/* Modal */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.5);
  z-index: 200;
  align-items: center;
  justify-content: center;
}

.modal-overlay.active { display: flex; }

.modal {
  background: white;
  border-radius: var(--radius);
  width: 520px;
  max-width: 90vw;
  max-height: 80vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  animation: modalIn 0.2s ease;
}

@keyframes modalIn {
  from { transform: scale(0.95) translateY(10px); opacity: 0; }
  to { transform: scale(1) translateY(0); opacity: 1; }
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: white;
  border-radius: var(--radius) var(--radius) 0 0;
}

.modal-header h3 { font-size: 17px; font-weight: 700; }

.modal-close {
  background: none; border: none; font-size: 20px;
  cursor: pointer; color: var(--text-light); padding: 4px; display: flex;
}

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

.modal-body { padding: 24px; }

/* 滚动条 */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #94a3b8; }

/* 响应式 */
@media (max-width: 768px) {
  .hero h1 { font-size: 28px; }
  .hero { padding: 40px 16px 32px; }
  .app-grid { grid-template-columns: 1fr; }
  .toolbar { flex-direction: column; align-items: stretch; }
  .toolbar-search { width: 100%; }
  .stats-row { grid-template-columns: 1fr; }
  .form-row { grid-template-columns: 1fr; }
}
