/* ═══════════════════════════════════════════════════════
   LibraryTao – Public stylesheet
   ═══════════════════════════════════════════════════════ */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --primary:    #6c63ff;
  --primary-dk: #574fd6;
  --accent:     #f59e0b;
  --bg:         #f7f8fc;
  --card-bg:    #ffffff;
  --text:       #1e1e2e;
  --muted:      #6b7280;
  --border:     #e5e7eb;
  --radius:     10px;
  --shadow:     0 2px 12px rgba(0,0,0,.07);
}

html { scroll-behavior: smooth; }
body { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Noto Sans CJK SC", sans-serif; background: var(--bg); color: var(--text); font-size: 15px; line-height: 1.6; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Navbar ──────────────────────────────────────────── */
.navbar {
  background: #1e1e2e;
  position: sticky; top: 0; z-index: 100;
  box-shadow: 0 2px 8px rgba(0,0,0,.2);
}
.nav-inner {
  max-width: 1200px; margin: 0 auto;
  padding: 0 20px;
  display: flex; align-items: center; gap: 16px; height: 56px;
}
.nav-logo { color: #fff; font-size: 1.25rem; font-weight: 700; white-space: nowrap; }
.nav-logo:hover { text-decoration: none; color: var(--primary); }
.nav-search { flex: 1; display: flex; max-width: 480px; }
.nav-search input { flex: 1; padding: 7px 14px; border: none; border-radius: var(--radius) 0 0 var(--radius); font-size: .9rem; background: #2e2e42; color: #fff; outline: none; }
.nav-search input::placeholder { color: #9ca3af; }
.nav-search button { padding: 7px 16px; background: var(--primary); color: #fff; border: none; border-radius: 0 var(--radius) var(--radius) 0; cursor: pointer; font-size: .9rem; transition: background .2s; }
.nav-search button:hover { background: var(--primary-dk); }
.nav-links { display: flex; gap: 12px; align-items: center; margin-left: auto; }
.nav-links a { color: #d1d5db; font-size: .9rem; transition: color .2s; }
.nav-links a:hover { color: #fff; text-decoration: none; }
.nav-inline-form { margin: 0; }
.nav-link-btn {
  background: none; border: none; color: #d1d5db; font-size: .9rem; cursor: pointer;
  transition: color .2s; padding: 0; font: inherit;
}
.nav-link-btn:hover { color: #fff; }
.btn-sm { background: var(--primary); color: #fff !important; padding: 5px 14px; border-radius: 20px; font-size: .85rem; }
.btn-sm:hover { background: var(--primary-dk); }

/* ── Site notice ─────────────────────────────────────── */
.site-notice { background: var(--accent); color: #1e1e2e; text-align: center; padding: 8px 20px; font-size: .9rem; }

/* ── Main wrap ───────────────────────────────────────── */
.main-wrap { max-width: 1200px; margin: 0 auto; padding: 28px 20px 60px; min-height: calc(100vh - 180px); }

/* ── Flash messages ──────────────────────────────────── */
.flash { padding: 12px 18px; border-radius: var(--radius); margin-bottom: 20px; font-size: .92rem; }
.flash-success { background: #dcfce7; color: #166534; border: 1px solid #bbf7d0; }
.flash-error   { background: #fef2f2; color: #dc2626; border: 1px solid #fecaca; }
.flash-info    { background: #eff6ff; color: #1d4ed8; border: 1px solid #bfdbfe; }

/* ── Library page ────────────────────────────────────── */
.library-wrap { }

.filter-bar { background: var(--card-bg); border-radius: var(--radius); padding: 16px 20px; box-shadow: var(--shadow); margin-bottom: 20px; }
.filter-search { display: flex; gap: 8px; margin-bottom: 12px; }
.filter-search input { flex: 1; padding: 9px 14px; border: 1px solid var(--border); border-radius: var(--radius); font-size: .95rem; }
.filter-search input:focus { outline: none; border-color: var(--primary); }
.filter-search button { padding: 9px 20px; background: var(--primary); color: #fff; border: none; border-radius: var(--radius); cursor: pointer; font-size: .95rem; }

.filter-options { display: flex; flex-wrap: wrap; gap: 12px; }
.filter-group { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; font-size: .88rem; color: var(--muted); }
.tag { padding: 3px 10px; border-radius: 20px; background: var(--bg); color: var(--muted); font-size: .82rem; border: 1px solid var(--border); transition: all .15s; }
.tag:hover { background: var(--primary); color: #fff; border-color: var(--primary); text-decoration: none; }
.tag.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.tag-cat { font-size: .78rem; margin-top: 4px; }

.result-count { color: var(--muted); margin-bottom: 16px; font-size: .9rem; }
.result-count strong { color: var(--text); }

/* ── Book grid ───────────────────────────────────────── */
.book-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 18px; }

.book-card { background: var(--card-bg); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; display: flex; flex-direction: column; transition: transform .2s, box-shadow .2s; }
.book-card:hover { transform: translateY(-3px); box-shadow: 0 6px 20px rgba(0,0,0,.1); }

.book-card-header { position: relative; background: linear-gradient(135deg, var(--primary) 0%, #a78bfa 100%); padding: 32px 20px; display: flex; align-items: center; justify-content: center; }
.book-cover { font-size: 2.8rem; color: rgba(255,255,255,.9); font-weight: 700; text-shadow: 0 2px 8px rgba(0,0,0,.2); }

.fav-btn { position: absolute; top: 8px; right: 8px; background: rgba(255,255,255,.2); border: none; color: rgba(255,255,255,.7); font-size: 1.1rem; width: 32px; height: 32px; border-radius: 50%; cursor: pointer; display: flex; align-items: center; justify-content: center; transition: all .2s; }
.fav-btn:hover { background: rgba(255,255,255,.4); color: #fff; }
.fav-btn.active { color: #ef4444; background: rgba(255,255,255,.3); }

.book-card-body { padding: 14px 16px; flex: 1; }
.book-title { font-size: 1rem; font-weight: 600; margin-bottom: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.book-author { font-size: .82rem; color: var(--muted); margin-bottom: 6px; }
.book-desc { font-size: .8rem; color: var(--muted); line-height: 1.5; margin-top: 6px; }

.book-card-footer { padding: 10px 16px; border-top: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; }
.book-meta { font-size: .78rem; color: var(--muted); }
.btn-download { background: var(--primary); color: #fff; padding: 5px 14px; border-radius: 20px; font-size: .82rem; font-weight: 600; white-space: nowrap; }
.btn-download:hover { background: var(--primary-dk); text-decoration: none; }

/* ── Pagination ──────────────────────────────────────── */
.pagination { display: flex; gap: 6px; justify-content: center; flex-wrap: wrap; margin-top: 32px; }
.page-btn { display: inline-flex; align-items: center; justify-content: center; width: 36px; height: 36px; border-radius: 8px; background: var(--card-bg); border: 1px solid var(--border); color: var(--text); font-size: .9rem; transition: all .15s; }
.page-btn:hover { background: var(--primary); color: #fff; border-color: var(--primary); text-decoration: none; }
.page-btn.active { background: var(--primary); color: #fff; border-color: var(--primary); }

/* ── Auth pages ──────────────────────────────────────── */
.auth-wrap { display: flex; justify-content: center; align-items: flex-start; padding-top: 40px; }
.auth-card { background: var(--card-bg); border-radius: 16px; box-shadow: var(--shadow); padding: 36px 40px; width: 100%; max-width: 420px; }
.auth-card h1 { text-align: center; font-size: 1.8rem; margin-bottom: 24px; }
.field { margin-bottom: 18px; }
.field label { display: block; font-weight: 600; font-size: .88rem; margin-bottom: 6px; color: var(--muted); }
.field input[type=text], .field input[type=email], .field input[type=password], .field textarea, .field select {
  width: 100%; padding: 10px 14px; border: 1.5px solid var(--border); border-radius: var(--radius); font-size: .95rem; transition: border .2s; background: #fff;
}
.field input:focus, .field textarea:focus, .field select:focus { outline: none; border-color: var(--primary); }
.field-inline { display: flex; align-items: center; gap: 8px; font-size: .9rem; }
.field-inline label { margin-bottom: 0; font-weight: normal; }
.btn-full { width: 100%; padding: 12px; background: var(--primary); color: #fff; border: none; border-radius: var(--radius); font-size: 1rem; font-weight: 600; cursor: pointer; transition: background .2s; }
.btn-full:hover { background: var(--primary-dk); }
.auth-switch { text-align: center; margin-top: 18px; font-size: .9rem; color: var(--muted); }

/* ── Profile page ────────────────────────────────────── */
.profile-wrap { display: flex; gap: 24px; align-items: flex-start; }
.profile-sidebar { width: 220px; flex-shrink: 0; background: var(--card-bg); border-radius: var(--radius); box-shadow: var(--shadow); padding: 24px 20px; text-align: center; }
.profile-avatar { width: 70px; height: 70px; border-radius: 50%; background: linear-gradient(135deg, var(--primary), #a78bfa); display: flex; align-items: center; justify-content: center; font-size: 2rem; color: #fff; font-weight: 700; margin: 0 auto 10px; }
.profile-name { font-weight: 700; font-size: 1.1rem; }
.profile-role { font-size: .8rem; padding: 3px 10px; border-radius: 20px; margin: 6px auto; display: inline-block; }
.role-user { background: #eff6ff; color: #1d4ed8; }
.role-vip  { background: #fef9c3; color: #92400e; }
.profile-nav { margin-top: 16px; text-align: left; }
.profile-nav a { display: block; padding: 8px 12px; border-radius: 8px; color: var(--text); font-size: .9rem; transition: background .15s; }
.profile-nav a:hover, .profile-nav a.active { background: var(--bg); text-decoration: none; color: var(--primary); }
.profile-content { flex: 1; background: var(--card-bg); border-radius: var(--radius); box-shadow: var(--shadow); padding: 28px 32px; }
.profile-content h2 { margin-bottom: 20px; }
.settings-section { margin-bottom: 28px; }
.settings-section h3 { margin-bottom: 14px; font-size: 1rem; }

/* Book list (profile) */
.book-list { display: flex; flex-direction: column; gap: 10px; }
.book-list-item { display: flex; align-items: center; gap: 14px; padding: 12px; background: var(--bg); border-radius: var(--radius); }
.bli-cover { width: 40px; height: 40px; border-radius: 8px; background: linear-gradient(135deg, var(--primary), #a78bfa); display: flex; align-items: center; justify-content: center; color: #fff; font-weight: 700; font-size: 1.1rem; flex-shrink: 0; }
.bli-info { flex: 1; min-width: 0; }
.bli-info strong { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bli-info span { font-size: .82rem; color: var(--muted); }
.text-muted { color: var(--muted); font-size: .82rem; }

/* ── Footer ──────────────────────────────────────────── */
.site-footer { background: #1e1e2e; color: #9ca3af; text-align: center; padding: 20px; font-size: .85rem; margin-top: auto; }
.site-footer a { color: #9ca3af; }
.site-footer a:hover { color: #fff; }

/* ── Empty states ────────────────────────────────────── */
.empty-state { text-align: center; padding: 60px 20px; color: var(--muted); }
.empty-state p { font-size: 1.1rem; }
.empty-msg { color: var(--muted); padding: 20px 0; }

/* ── Responsive ──────────────────────────────────────── */
@media (max-width: 768px) {
  .book-grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px; }
  .profile-wrap { flex-direction: column; }
  .profile-sidebar { width: 100%; }
  .auth-card { padding: 24px 20px; }
  .nav-inner { gap: 10px; }
  .nav-search { max-width: none; }
}
@media (max-width: 480px) {
  .book-grid { grid-template-columns: 1fr 1fr; }
}
