/* ============================================
   Perpus - Perpustakaan Digital Anak
   Colorful, fun, anak-anak!
   ============================================ */
@import url('https://fonts.googleapis.com/css2?family=Nunito:wght@400;600;700;800;900&display=swap');

.psd-wrap {
  font-family: 'Nunito', sans-serif;
  max-width: 1100px;
  margin: 20px auto;
  background: #fff;
  border-radius: 24px;
  box-shadow: 0 8px 40px rgba(0,0,0,.1);
  overflow: hidden;
  min-height: 500px;
  position: relative;
}

.psd-screen { display: none; padding: 24px; }
.psd-screen.active { display: block; }
.psd-screen-pdf { padding: 0; }

/* ============ NAMA / LOGIN ============ */
.psd-nama-wrap {
  text-align: center;
  padding: 60px 24px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 50%, #f093fb 100%);
  min-height: 500px;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
}
.psd-mascot { font-size: 80px; animation: bounce 1.5s infinite alternate; margin-bottom: 16px; }
@keyframes bounce { from { transform: translateY(0) rotate(-5deg); } to { transform: translateY(-12px) rotate(5deg); } }
.psd-title { font-size: clamp(1.6rem, 3vw, 2.4rem); font-weight: 900; color: #fff; line-height: 1.3; margin: 0 0 10px; }
.psd-accent { color: #fde68a; }
.psd-sub { color: rgba(255,255,255,.85); font-size: 16px; font-weight: 600; margin-bottom: 28px; }
.psd-input-nama {
  width: 100%; max-width: 400px; padding: 16px 20px;
  border: 3px solid rgba(255,255,255,.5); border-radius: 16px;
  font-size: 18px; font-weight: 700; font-family: 'Nunito', sans-serif;
  text-align: center; background: rgba(255,255,255,.2);
  color: #fff; outline: none; margin-bottom: 16px;
  transition: border-color .2s;
}
.psd-input-nama::placeholder { color: rgba(255,255,255,.7); }
.psd-input-nama:focus { border-color: #fde68a; background: rgba(255,255,255,.3); }
.psd-btn-masuk {
  background: linear-gradient(135deg, #fde68a, #fbbf24);
  color: #7c2d12; border: none; border-radius: 16px;
  padding: 16px 40px; font-size: 18px; font-weight: 900;
  cursor: pointer; font-family: 'Nunito', sans-serif;
  transition: transform .15s, box-shadow .15s;
  box-shadow: 0 4px 16px rgba(251,191,36,.4);
  width: 100%; max-width: 400px;
}
.psd-btn-masuk:hover { transform: translateY(-3px); box-shadow: 0 8px 24px rgba(251,191,36,.5); }

/* ============ HOME HEADER ============ */
.psd-home-header {
  display: flex; justify-content: space-between; align-items: center;
  background: linear-gradient(135deg, #667eea, #764ba2);
  margin: -24px -24px 20px; padding: 20px 24px;
  flex-wrap: wrap; gap: 12px;
}
.psd-home-brand { display: flex; align-items: center; gap: 12px; }
.psd-home-logo { font-size: 32px; }
.psd-home-title { color: rgba(255,255,255,.8); font-size: 13px; font-weight: 700; }
.psd-home-user { color: #fff; font-size: 16px; font-weight: 800; }
.psd-home-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.psd-btn-lb, .psd-btn-riwayat {
  background: rgba(255,255,255,.2); color: #fff;
  border: none; border-radius: 10px;
  padding: 8px 14px; font-size: 13px; font-weight: 800;
  cursor: pointer; font-family: 'Nunito', sans-serif;
  transition: background .2s;
}
.psd-btn-lb:hover, .psd-btn-riwayat:hover { background: rgba(255,255,255,.35); }
.psd-poin-badge {
  background: linear-gradient(135deg, #fde68a, #fbbf24);
  color: #7c2d12; border-radius: 100px;
  padding: 6px 14px; font-size: 13px; font-weight: 900;
}

/* ============ FILTER ============ */
.psd-filter-bar {
  display: flex; gap: 10px; margin-bottom: 16px; flex-wrap: wrap;
}
.psd-search-wrap {
  flex: 1; min-width: 200px;
  display: flex; align-items: center; gap: 8px;
  background: #f8faff; border: 2px solid #e2e8f0;
  border-radius: 12px; padding: 0 14px;
  transition: border-color .2s;
}
.psd-search-wrap:focus-within { border-color: #667eea; }
.psd-search-icon { font-size: 16px; }
.psd-search {
  flex: 1; border: none; background: transparent;
  padding: 12px 0; font-size: 14px; font-weight: 600;
  font-family: 'Nunito', sans-serif; outline: none;
}
.psd-select {
  padding: 12px 14px; border: 2px solid #e2e8f0;
  border-radius: 12px; font-size: 13px; font-weight: 700;
  font-family: 'Nunito', sans-serif; outline: none;
  background: #f8faff; cursor: pointer;
}
.psd-select:focus { border-color: #667eea; }

/* ============ KATEGORI ============ */
.psd-kategori-scroll {
  display: flex; gap: 8px; overflow-x: auto;
  padding-bottom: 8px; margin-bottom: 20px;
  scrollbar-width: none;
}
.psd-kategori-scroll::-webkit-scrollbar { display: none; }
.psd-kat-btn {
  flex-shrink: 0; padding: 8px 16px;
  border: 2px solid #e2e8f0; border-radius: 100px;
  background: #fff; font-size: 13px; font-weight: 700;
  cursor: pointer; font-family: 'Nunito', sans-serif;
  transition: all .2s; white-space: nowrap;
}
.psd-kat-btn:hover, .psd-kat-btn.active {
  background: #667eea; border-color: #667eea; color: #fff;
}

/* ============ GRID BUKU ============ */
.psd-buku-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 16px;
}
.psd-loading { grid-column: 1/-1; text-align: center; padding: 40px; color: #94a3b8; font-size: 16px; font-weight: 600; }
.psd-empty { grid-column: 1/-1; text-align: center; padding: 60px 20px; color: #94a3b8; }
.psd-empty .psd-empty-icon { font-size: 60px; display: block; margin-bottom: 12px; }

/* Kartu Buku */
.psd-buku-card {
  background: #fff; border: 2px solid #e2e8f0;
  border-radius: 18px; overflow: hidden;
  cursor: pointer; transition: transform .2s, box-shadow .2s, border-color .2s;
  display: flex; flex-direction: column;
}
.psd-buku-card:hover {
  transform: translateY(-4px) scale(1.02);
  box-shadow: 0 8px 28px rgba(102,126,234,.2);
  border-color: #667eea;
}
.psd-buku-cover {
  height: 200px; overflow: hidden;
  background: linear-gradient(135deg, #f0f4ff, #faf5ff);
  position: relative; flex-shrink: 0;
}
.psd-buku-cover img { width: 100%; height: 100%; object-fit: cover; }
.psd-cover-placeholder {
  width: 100%; height: 100%;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 8px;
}
.psd-cover-emoji { font-size: 48px; }
.psd-kat-chip {
  position: absolute; top: 8px; left: 8px;
  background: rgba(255,255,255,.9); border-radius: 100px;
  padding: 3px 10px; font-size: 11px; font-weight: 800;
  box-shadow: 0 2px 8px rgba(0,0,0,.1);
}
.psd-badge-baru {
  position: absolute; top: 8px; right: 8px;
  background: #ef4444; color: #fff;
  border-radius: 100px; padding: 3px 8px;
  font-size: 10px; font-weight: 800;
}
.psd-buku-info { padding: 12px; flex: 1; display: flex; flex-direction: column; gap: 4px; }
.psd-buku-judul { font-size: 13px; font-weight: 800; color: #1e293b; line-height: 1.3; }
.psd-buku-pengarang { font-size: 11px; color: #94a3b8; font-weight: 600; }
.psd-buku-meta { display: flex; align-items: center; justify-content: space-between; margin-top: 4px; }
.psd-buku-rating { font-size: 11px; color: #f59e0b; font-weight: 700; }
.psd-buku-hal { font-size: 11px; color: #94a3b8; }
.psd-buku-pdf-badge {
  display: inline-block; background: #d1fae5; color: #065f46;
  border-radius: 6px; padding: 2px 8px; font-size: 10px; font-weight: 800;
  margin-top: 4px;
}

/* ============ DETAIL BUKU ============ */
.psd-detail-wrap { max-width: 800px; margin: 0 auto; }
.psd-detail-grid { display: grid; grid-template-columns: 200px 1fr; gap: 28px; margin-bottom: 28px; }
.psd-detail-cover {
  border-radius: 16px; overflow: hidden;
  box-shadow: 0 8px 32px rgba(0,0,0,.15);
  height: 280px; background: #f0f4ff;
  display: flex; align-items: center; justify-content: center;
  font-size: 64px;
}
.psd-detail-cover img { width: 100%; height: 100%; object-fit: cover; }
.psd-detail-info { display: flex; flex-direction: column; gap: 10px; }
.psd-detail-judul { font-size: 1.5rem; font-weight: 900; color: #1e293b; line-height: 1.3; }
.psd-detail-pengarang { font-size: 14px; color: #64748b; font-weight: 600; }
.psd-detail-chips { display: flex; gap: 8px; flex-wrap: wrap; }
.psd-chip {
  background: #f0f4ff; color: #667eea;
  border-radius: 100px; padding: 4px 12px;
  font-size: 12px; font-weight: 800;
}
.psd-chip-green { background: #d1fae5; color: #065f46; }
.psd-detail-rating { display: flex; align-items: center; gap: 6px; font-size: 14px; font-weight: 700; }
.psd-stars { color: #f59e0b; font-size: 18px; }
.psd-detail-sinopsis { color: #475569; line-height: 1.8; font-size: 14px; }
.psd-detail-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 8px; }
.psd-btn-baca {
  background: linear-gradient(135deg, #667eea, #764ba2);
  color: #fff; border: none; border-radius: 14px;
  padding: 14px 28px; font-size: 16px; font-weight: 800;
  cursor: pointer; font-family: 'Nunito', sans-serif;
  transition: transform .15s; flex: 1;
}
.psd-btn-baca:hover { transform: translateY(-2px); }
.psd-btn-baca:disabled { background: #e2e8f0; color: #94a3b8; cursor: not-allowed; transform: none; }
.psd-btn-baca-no {
  background: #f8faff; color: #64748b;
  border: 2px solid #e2e8f0; border-radius: 14px;
  padding: 14px 20px; font-size: 14px; font-weight: 700;
  cursor: default; font-family: 'Nunito', sans-serif; flex: 1; text-align: center;
}

/* Ulasan */
.psd-ulasan-section { margin-top: 28px; }
.psd-ulasan-title { font-size: 1rem; font-weight: 800; color: #1e293b; margin-bottom: 14px; }
.psd-ulasan-form { background: #f8faff; border-radius: 16px; padding: 16px; margin-bottom: 16px; }
.psd-star-picker { display: flex; gap: 6px; margin-bottom: 10px; }
.psd-star { font-size: 28px; cursor: pointer; transition: transform .1s; }
.psd-star:hover { transform: scale(1.2); }
.psd-ulasan-input {
  width: 100%; padding: 10px 14px; border: 2px solid #e2e8f0;
  border-radius: 10px; font-family: 'Nunito', sans-serif;
  font-size: 13px; font-weight: 600; resize: vertical;
  margin-bottom: 8px;
}
.psd-btn-kirim-ulasan {
  background: #667eea; color: #fff; border: none;
  border-radius: 10px; padding: 10px 20px;
  font-size: 13px; font-weight: 800; cursor: pointer;
  font-family: 'Nunito', sans-serif;
}
.psd-ulasan-item { background: #fff; border: 1px solid #e2e8f0; border-radius: 12px; padding: 12px; margin-bottom: 10px; }
.psd-ulasan-header { display: flex; justify-content: space-between; margin-bottom: 6px; }
.psd-ulasan-nama { font-weight: 800; color: #1e293b; font-size: 13px; }
.psd-ulasan-tgl { font-size: 11px; color: #94a3b8; }
.psd-ulasan-rating { color: #f59e0b; font-size: 14px; }
.psd-ulasan-isi { font-size: 13px; color: #475569; line-height: 1.6; }

/* ============ PDF VIEWER ============ */
.psd-pdf-header {
  display: flex; align-items: center; gap: 12px;
  background: #1e293b; padding: 12px 16px; flex-wrap: wrap;
}
.psd-pdf-title { color: #fff; font-weight: 800; font-size: 14px; flex: 1; }
.psd-btn-selesai {
  background: linear-gradient(135deg, #84fab0, #4ade80);
  color: #166534; border: none; border-radius: 10px;
  padding: 10px 18px; font-size: 14px; font-weight: 800;
  cursor: pointer; font-family: 'Nunito', sans-serif;
  transition: transform .15s;
}
.psd-btn-selesai:hover { transform: scale(1.04); }
.psd-pdf-viewer-wrap { height: calc(100vh - 80px); min-height: 500px; }
.psd-pdf-frame { width: 100%; height: 100%; border: none; display: block; }

/* ============ LEADERBOARD ============ */
.psd-lb-list { display: flex; flex-direction: column; gap: 10px; max-width: 600px; margin: 0 auto; }
.psd-lb-item {
  display: flex; align-items: center; gap: 14px;
  background: #f8faff; border: 2px solid #e2e8f0;
  border-radius: 16px; padding: 14px 18px;
  transition: border-color .2s;
}
.psd-lb-item:hover { border-color: #667eea; }
.psd-lb-rank { font-size: 24px; width: 40px; text-align: center; flex-shrink: 0; }
.psd-lb-info { flex: 1; }
.psd-lb-nama { font-size: 16px; font-weight: 800; color: #1e293b; }
.psd-lb-meta { font-size: 12px; color: #94a3b8; font-weight: 600; margin-top: 2px; }
.psd-lb-poin { font-size: 22px; font-weight: 900; color: #f59e0b; }

/* ============ RIWAYAT ============ */
.psd-riwayat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 14px;
}
.psd-riwayat-card {
  background: #f8faff; border: 2px solid #e2e8f0;
  border-radius: 14px; overflow: hidden;
  text-align: center; padding-bottom: 10px;
}
.psd-riwayat-cover {
  height: 140px; background: #e2e8f0;
  display: flex; align-items: center; justify-content: center;
  font-size: 36px; margin-bottom: 8px;
}
.psd-riwayat-cover img { width: 100%; height: 100%; object-fit: cover; }
.psd-riwayat-judul { font-size: 12px; font-weight: 800; color: #1e293b; padding: 0 8px; line-height: 1.3; }
.psd-riwayat-poin { font-size: 11px; color: #f59e0b; font-weight: 700; margin-top: 4px; }

/* ============ BACK BTN ============ */
.psd-back-btn {
  display: inline-flex; align-items: center; gap: 6px;
  background: #f1f5f9; border: none; border-radius: 10px;
  padding: 8px 16px; font-size: 14px; font-weight: 700;
  color: #64748b; cursor: pointer; margin-bottom: 16px;
  font-family: 'Nunito', sans-serif; transition: background .2s;
}
.psd-back-btn:hover { background: #e2e8f0; color: #1e293b; }

/* ============ TOAST ============ */
.psd-toast {
  position: fixed; bottom: 24px; left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: #1e293b; color: #fff;
  padding: 12px 24px; border-radius: 12px;
  font-size: 14px; font-weight: 700;
  font-family: 'Nunito', sans-serif;
  opacity: 0; transition: all .3s;
  z-index: 9999; white-space: nowrap;
  pointer-events: none;
}
.psd-toast.show {
  opacity: 1; transform: translateX(-50%) translateY(0);
}
.psd-toast-poin {
  background: linear-gradient(135deg, #f59e0b, #d97706);
  font-size: 16px;
}

/* ============ RESPONSIVE ============ */
@media (max-width: 640px) {
  .psd-buku-grid { grid-template-columns: repeat(2, 1fr); }
  .psd-detail-grid { grid-template-columns: 1fr; }
  .psd-detail-cover { height: 200px; }
  .psd-home-header { padding: 14px 16px; }
  .psd-home-actions { gap: 6px; }
  .psd-btn-lb, .psd-btn-riwayat { font-size: 12px; padding: 6px 10px; }
}
@media (max-width: 400px) {
  .psd-buku-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .psd-wrap { border-radius: 0; margin: 0; }
}
