/* ===========================================
   资源分享平台 - 静态版样式
   =========================================== */

:root {
  --primary: #4f46e5;
  --primary-dark: #4338ca;
  --primary-light: #818cf8;
  --success: #10b981;
  --danger: #ef4444;
  --warning: #f59e0b;
  --text: #1f2937;
  --text-light: #6b7280;
  --bg: #f9fafb;
  --bg-card: #ffffff;
  --border: #e5e7eb;
  --border-light: #f3f4f6;
  --shadow: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.08), 0 2px 4px -1px rgba(0,0,0,0.04);
  --shadow-lg: 0 10px 20px -3px rgba(0,0,0,0.08), 0 4px 6px -2px rgba(0,0,0,0.04);
  --radius: 12px;
  --radius-sm: 8px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; -webkit-text-size-adjust: 100%; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

a { color: var(--primary); text-decoration: none; transition: color 0.15s; }
a:hover { color: var(--primary-dark); }

code { background: #f3f4f6; padding: 1px 6px; border-radius: 4px; font-family: ui-monospace, Menlo, monospace; font-size: 0.88em; }

.container { max-width: 1200px; margin: 0 auto; padding: 0 20px; width: 100%; }

/* ============ Header ============ */
.site-header {
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: blur(10px);
  background: rgba(255,255,255,0.95);
}

.header-inner {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 14px 20px;
  flex-wrap: wrap;
}

.logo {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  font-size: 1.15rem;
  color: var(--primary);
  flex-shrink: 0;
}

.search-form {
  flex: 1;
  min-width: 200px;
  display: flex;
  align-items: center;
  background: var(--bg);
  border: 1.5px solid var(--border);
  border-radius: 999px;
  padding: 4px 4px 4px 14px;
  transition: border-color 0.15s, box-shadow 0.15s;
  position: relative;
}

.search-form:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

.search-icon { color: var(--text-light); flex-shrink: 0; }

.search-form input {
  flex: 1;
  border: none;
  background: transparent;
  outline: none;
  padding: 8px 10px;
  font-size: 0.95rem;
  color: var(--text);
  min-width: 0;
}

.search-form button {
  background: var(--primary);
  color: white;
  border: none;
  border-radius: 999px;
  padding: 8px 18px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
  font-size: 0.9rem;
}

.search-form button:hover { background: var(--primary-dark); }

.nav-links {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.nav-link {
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 0.9rem;
  font-weight: 500;
  transition: background 0.15s;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

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

.mobile-menu-btn {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  padding: 8px;
  color: var(--text);
}

/* ============ Main ============ */
.main-content { flex: 1; padding: 32px 0; }

.home-intro {
  color: var(--text-light);
  margin-bottom: 24px;
  font-size: 0.95rem;
}

.home-intro strong { color: var(--primary); font-size: 1.1rem; }

/* ============ Section ============ */
.letter-section {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 20px 24px;
  margin-bottom: 24px;
  box-shadow: var(--shadow);
}

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border-light);
}

.section-title {
  font-size: 1.15rem;
  display: flex;
  align-items: center;
  gap: 10px;
}

.section-count { color: var(--text-light); font-weight: normal; font-size: 0.85rem; margin-left: 4px; }

.more-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: var(--primary);
  font-weight: 500;
  font-size: 0.9rem;
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  transition: background 0.15s;
}

.more-link:hover { background: rgba(79, 70, 229, 0.08); }

/* ============ Card Grid ============ */
.card-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
}

.card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  transition: all 0.15s;
  color: var(--text);
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 96px;
}

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

.card-title {
  font-size: 0.95rem;
  font-weight: 600;
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.card-desc {
  font-size: 0.82rem;
  color: var(--text-light);
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.card-meta {
  margin-top: auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.78rem;
  color: var(--text-light);
}

.card-views { display: inline-flex; align-items: center; gap: 4px; }

/* ============ Letter Badge ============ */
.letter-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  color: white;
  font-weight: 700;
  border-radius: 8px;
  min-width: 32px;
  height: 32px;
  font-size: 0.95rem;
  padding: 0 8px;
}

.letter-badge-sm { min-width: 24px; height: 24px; font-size: 0.8rem; border-radius: 6px; }
.letter-badge-lg { min-width: 48px; height: 48px; font-size: 1.4rem; border-radius: 12px; }

/* ============ Page Header ============ */
.page-header { margin-bottom: 24px; }
.page-header h1 {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 1.6rem;
}
.page-header-meta { color: var(--text-light); margin-top: 6px; }

/* ============ Letter Nav ============ */
.letter-nav {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}

.letter-nav-home {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 0.9rem;
  flex-shrink: 0;
}

.letter-nav-home:hover { background: var(--primary); color: white; border-color: var(--primary); }

.letter-nav-letters { display: flex; flex-wrap: wrap; gap: 4px; }

.letter-nav-item {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 6px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text);
  font-weight: 600;
  font-size: 0.85rem;
  transition: all 0.15s;
}

.letter-nav-item:hover {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}

.letter-nav-item.active {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}

/* ============ Detail ============ */
.breadcrumb {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--text-light);
  font-size: 0.9rem;
  margin-bottom: 20px;
}

.breadcrumb a { color: var(--text-light); }
.breadcrumb a:hover { color: var(--primary); }
.breadcrumb svg { opacity: 0.5; }
.breadcrumb span { color: var(--text); }

.resource-detail {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 32px;
  box-shadow: var(--shadow);
}

.detail-header {
  border-bottom: 1px solid var(--border-light);
  padding-bottom: 20px;
  margin-bottom: 24px;
}

.detail-header h1 {
  font-size: 1.75rem;
  margin: 12px 0 0;
  line-height: 1.3;
}

.detail-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  margin-top: 12px;
  font-size: 0.85rem;
  color: var(--text-light);
}

.detail-meta span { display: inline-flex; align-items: center; gap: 5px; }

.detail-description { margin: 24px 0; }
.detail-description h2 { font-size: 1.05rem; margin-bottom: 8px; color: var(--text); }
.detail-description p { color: var(--text-light); white-space: pre-wrap; }

.detail-download {
  text-align: center;
  padding: 28px 0 8px;
  border-top: 1px solid var(--border-light);
}

.download-hint {
  margin-top: 12px;
  font-size: 0.85rem;
  color: var(--text-light);
}

.related-section { margin-top: 40px; }
.related-section h2 { font-size: 1.2rem; margin-bottom: 16px; }

/* ============ Empty / Error ============ */
.empty-state {
  text-align: center;
  padding: 80px 20px;
  color: var(--text-light);
  background: var(--bg-card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.empty-state h2 { color: var(--text); font-size: 1.3rem; margin-bottom: 8px; margin-top: 12px; }
.empty-state p { margin-bottom: 20px; }

.error-page {
  text-align: center;
  padding: 80px 20px;
  background: var(--bg-card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.error-code {
  font-size: 5rem;
  font-weight: 700;
  color: var(--primary);
  line-height: 1;
}

.error-page h1 { margin: 12px 0 8px; }
.error-page p { color: var(--text-light); margin-bottom: 24px; }

/* ============ Buttons ============ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 18px;
  border: none;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
  transition: all 0.15s;
  text-decoration: none;
  font-family: inherit;
}

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

.btn-outline {
  background: transparent;
  color: var(--primary);
  border: 1.5px solid var(--primary);
}
.btn-outline:hover { background: var(--primary); color: white; }

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

.btn-block { width: 100%; }
.btn-lg { padding: 14px 28px; font-size: 1rem; }
.btn-sm { padding: 6px 12px; font-size: 0.82rem; }

/* ============ Footer ============ */
.site-footer {
  background: var(--bg-card);
  border-top: 1px solid var(--border);
  padding: 24px 0;
  margin-top: auto;
  text-align: center;
  color: var(--text-light);
  font-size: 0.85rem;
}

/* ============ Responsive ============ */
@media (max-width: 900px) {
  .card-grid { grid-template-columns: repeat(3, 1fr); }
}

@media (max-width: 640px) {
  .header-inner { gap: 10px; padding: 10px 16px; }
  .logo span { display: none; }
  .search-form { order: 3; width: 100%; padding: 4px 4px 4px 12px; }
  .search-form button { padding: 7px 14px; }
  .nav-links { display: none; }
  .nav-links.open {
    display: flex;
    position: absolute;
    top: 100%;
    right: 16px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 8px;
    flex-direction: column;
    box-shadow: var(--shadow-lg);
    z-index: 200;
  }
  .mobile-menu-btn { display: block; }
  .site-header { position: relative; }

  .main-content { padding: 20px 0; }
  .container { padding: 0 16px; }

  .card-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .letter-section { padding: 16px; }
  .resource-detail { padding: 20px; }
  .detail-header h1 { font-size: 1.3rem; }

  .section-header { flex-wrap: wrap; gap: 8px; }
  .section-title { font-size: 1rem; }
}

@media (max-width: 380px) {
  .card-grid { grid-template-columns: 1fr; }
}