/* ============================================================
   PERPUSTAKAAN SEKOLAH - SMP NEGERI 1 BUKATEJA
   ============================================================
   Satu berkas CSS untuk seluruh halaman. Tidak memakai CDN
   supaya tetap jalan di jaringan sekolah yang terbatas dan
   sesuai aturan Content-Security-Policy (hanya 'self').
   ============================================================ */

:root {
  --biru: #1d4ed8;
  --biru-gelap: #1e3a8a;
  --hijau: #15803d;
  --hijau-gelap: #14532d;
  --merah: #b91c1c;
  --oranye: #c2410c;
  --ungu: #6d28d9;
  --teks: #1f2937;
  --teks-lembut: #6b7280;
  --garis: #e5e7eb;
  --latar: #f3f4f6;
  --kartu: #ffffff;
  --radius: 8px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Segoe UI", Tahoma, Verdana, Arial, sans-serif;
  font-size: 15px;
  line-height: 1.55;
  color: var(--teks);
  background: var(--latar);
}

a { color: var(--biru); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3 { margin: 0 0 10px; line-height: 1.3; }
h1 { font-size: 24px; }
h2 { font-size: 19px; }
h3 { font-size: 16px; }

.wrap { max-width: 1180px; margin: 0 auto; padding: 0 14px; }

/* ================= TOPBAR ================= */

.topbar {
  background: var(--biru-gelap);
  color: #fff;
  box-shadow: 0 2px 6px rgba(0, 0, 0, .18);
}
.nav-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 10px;
  padding-bottom: 6px;
  flex-wrap: wrap;
  gap: 6px;
}
.brand { font-weight: 700; font-size: 16px; }
.who { font-size: 13px; text-align: right; }
.who small { opacity: .8; display: block; font-size: 11px; }

.nav-links {
  display: flex;
  flex-wrap: wrap;
  gap: 2px;
  padding-bottom: 8px;
}
.nav-links a {
  color: #dbeafe;
  padding: 6px 10px;
  border-radius: 6px;
  font-size: 13px;
  white-space: nowrap;
}
.nav-links a:hover { background: rgba(255, 255, 255, .12); text-decoration: none; }
.nav-links a.active { background: #fff; color: var(--biru-gelap); font-weight: 600; }
.nav-links a.logout { margin-left: auto; color: #fecaca; }

.lencana {
  display: inline-block;
  min-width: 18px;
  padding: 0 5px;
  margin-left: 4px;
  background: var(--merah);
  color: #fff;
  border-radius: 9px;
  font-size: 11px;
  line-height: 17px;
  text-align: center;
}

.notif-jam {
  margin: 0 0 8px;
  padding: 6px 10px;
  background: #fef3c7;
  color: #92400e;
  border-radius: 6px;
  font-size: 12.5px;
}

/* ================= KARTU ================= */

.card {
  background: var(--kartu);
  border: 1px solid var(--garis);
  border-radius: var(--radius);
  padding: 16px;
  margin: 14px 0;
}
.card > h2:first-child { margin-top: 0; }

.muted { color: var(--teks-lembut); }
.mutedSmall { color: var(--teks-lembut); font-size: 13px; margin: 2px 0; }
.mt { margin-top: 12px; }
.center { text-align: center; }

/* ================= STATISTIK ================= */

.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
  margin: 14px 0;
}
.stat {
  background: var(--kartu);
  border: 1px solid var(--garis);
  border-left: 5px solid var(--teks-lembut);
  border-radius: var(--radius);
  padding: 12px 14px;
}
.stat .num { font-size: 26px; font-weight: 700; line-height: 1.1; }
.stat .lbl { font-size: 12.5px; color: var(--teks-lembut); }
.stat.blue   { border-left-color: var(--biru); }
.stat.green  { border-left-color: var(--hijau); }
.stat.orange { border-left-color: var(--oranye); }
.stat.red    { border-left-color: var(--merah); }
.stat.purple { border-left-color: var(--ungu); }
.stat.gray   { border-left-color: #6b7280; }

/* ================= TABEL ================= */

.table-scroll { overflow-x: auto; }

table {
  width: 100%;
  border-collapse: collapse;
  background: var(--kartu);
  font-size: 14px;
}
th, td {
  border: 1px solid var(--garis);
  padding: 7px 9px;
  text-align: left;
  vertical-align: top;
}
th { background: #f3f4f6; font-weight: 600; }
tbody tr:nth-child(even) { background: #fafafa; }
td.angka, th.angka { text-align: right; white-space: nowrap; }

/* ================= BADGE ================= */

.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 12px;
  font-weight: 600;
  background: #e5e7eb;
  color: #374151;
  white-space: nowrap;
}
.badge.tersedia, .badge.aktif, .badge.hadir,
.badge.disetujui, .badge.berhasil, .badge.selesai { background: #dcfce7; color: #14532d; }
.badge.dipinjam, .badge.pending, .badge.menunggu { background: #fef3c7; color: #92400e; }
.badge.terlambat, .badge.ditolak, .badge.gagal,
.badge.rusak, .badge.hilang, .badge.dicabut { background: #fee2e2; color: #7f1d1d; }
.badge.perbaikan, .badge.rating { background: #ede9fe; color: #4c1d95; }
.badge.tidak_aktif, .badge.nonaktif, .badge.alfa,
.badge.dibatalkan { background: #e5e7eb; color: #4b5563; }

/* ================= FORMULIR ================= */

label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 3px;
  color: #374151;
}

input[type=text], input[type=password], input[type=number],
input[type=date], input[type=time], input[type=datetime-local],
input[type=search], input[type=email], input[type=file],
select, textarea {
  width: 100%;
  padding: 7px 9px;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  font: inherit;
  font-size: 14px;
  background: #fff;
  color: var(--teks);
}
input:focus, select:focus, textarea:focus {
  outline: 2px solid #bfdbfe;
  border-color: var(--biru);
}
textarea { resize: vertical; }

.form-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
  margin-bottom: 12px;
}
.form-inline {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: flex-end;
}
.form-inline > div { flex: 1 1 200px; }

.check { display: flex; align-items: center; gap: 6px; margin-bottom: 10px; }
.check input { width: auto; }
.check label { margin: 0; font-weight: 400; }

/* Daftar centang (beberapa opsi berdiri sendiri) */
.form-check { margin: 6px 0; }
.form-check label {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-bottom: 7px;
  font-weight: 400;
}
.form-check input { width: auto; }

.bantuan { font-size: 12.5px; color: var(--teks-lembut); margin: 4px 0 0; }

/* Kotak statistik pada dashboard dan laporan */
.grid-4 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
}
.grid-4 .kotak {
  border: 1px solid var(--garis);
  border-left: 4px solid var(--biru);
  border-radius: var(--radius);
  padding: 12px 14px;
  background: #fff;
}
.grid-4 .kotak b { display: block; font-size: 24px; line-height: 1.2; }
.grid-4 .kotak span { font-size: 13px; color: var(--teks-lembut); }

/* Pembungkus PDF di halaman baca */
.reader {
  border: 1px solid var(--garis);
  border-radius: var(--radius);
  overflow: hidden;
  background: #f1f5f9;
}
.reader object { display: block; border: 0; }

/* Progress bar tipis untuk progres baca */
.bar {
  display: block;
  height: 9px;
  border-radius: 99px;
  background: #e5e7eb;
  overflow: hidden;
}
.bar > span { display: block; height: 100%; background: var(--hijau); }

/* Komentar pembaca */
.komentar {
  border-left: 3px solid var(--biru);
  padding: 8px 0 8px 12px;
  margin: 12px 0;
}
.komentar p { margin: 4px 0 0; }

/* ================= TOMBOL ================= */

.btn {
  display: inline-block;
  padding: 7px 14px;
  border: 1px solid transparent;
  border-radius: 6px;
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  text-align: center;
  background: #e5e7eb;
  color: #1f2937;
  text-decoration: none;
}
.btn:hover { text-decoration: none; filter: brightness(.95); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-sm { padding: 4px 9px; font-size: 12.5px; }
.btn-block { width: 100%; }
.btn-blue   { background: var(--biru); color: #fff; }
.btn-green  { background: var(--hijau); color: #fff; }
.btn-red    { background: var(--merah); color: #fff; }
.btn-orange { background: var(--oranye); color: #fff; }
.btn-gray   { background: #e5e7eb; color: #1f2937; }
.btn-kuning { background: #ca8a04; color: #fff; }

/* ================= ALERT ================= */

.alert {
  padding: 10px 13px;
  border-radius: var(--radius);
  margin: 12px 0;
  font-size: 14px;
  border: 1px solid transparent;
}
.alert.ok  { background: #dcfce7; color: #14532d; border-color: #86efac; }
.alert.err { background: #fee2e2; color: #7f1d1d; border-color: #fca5a5; }
.alert.warn { background: #fef3c7; color: #92400e; border-color: #fcd34d; }
.alert.info { background: #dbeafe; color: #1e3a8a; border-color: #93c5fd; }

/* ================= PAGINASI ================= */

.paginasi { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; font-size: 13.5px; }
.paginasi a:not(.btn) { padding: 2px 7px; border-radius: 4px; }
.paginasi a:not(.btn):hover { background: #e5e7eb; text-decoration: none; }
.halaman-aktif {
  padding: 2px 9px;
  background: var(--biru);
  color: #fff;
  border-radius: 4px;
  font-weight: 700;
}

/* ================= KATALOG / COVER ================= */

.grid-buku {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 14px;
}
.kartu-buku { margin: 0; display: flex; flex-direction: column; }
.kartu-buku h3 { margin: 8px 0 2px; font-size: 15px; }
.kartu-buku .mt { margin-top: auto; padding-top: 8px; }

.cover {
  height: 200px;
  background: #eef2f7;
  border-radius: 6px;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}
.cover img { width: 100%; height: 100%; object-fit: cover; }
.cover.besar { height: 300px; }
.cover-teks {
  padding: 12px;
  font-size: 13px;
  font-weight: 600;
  color: #64748b;
  text-align: center;
}

.detail-buku {
  display: grid;
  grid-template-columns: 200px 1fr;
  gap: 18px;
}
@media (max-width: 640px) {
  .detail-buku { grid-template-columns: 1fr; }
}

.ulasan { border-top: 1px solid var(--garis); padding: 10px 0; }
.ulasan:first-of-type { border-top: 0; }

/* ================= SCANNER QR ================= */

.kotak-scan {
  max-width: 420px;
  margin: 0 auto;
  background: #000;
  border-radius: var(--radius);
  overflow: hidden;
}
#wadah-qr { width: 100%; min-height: 260px; background: #000; }
#wadah-qr video { width: 100% !important; display: block; }
#wadah-qr img { display: none; }

.hasil-scan {
  padding: 12px;
  border-radius: var(--radius);
  margin: 12px 0;
  border: 1px solid var(--garis);
  background: #fff;
}
.hasil-scan.ok  { background: #dcfce7; border-color: #86efac; }
.hasil-scan.err { background: #fee2e2; border-color: #fca5a5; }
.hasil-scan .nama { font-size: 19px; font-weight: 700; }

.daftar-anggota { list-style: none; margin: 0; padding: 0; }
.daftar-anggota li {
  padding: 7px 9px;
  border: 1px solid var(--garis);
  border-radius: 6px;
  margin-bottom: 5px;
  cursor: pointer;
  font-size: 14px;
}
.daftar-anggota li:hover { background: #eff6ff; }

.pilih-buku { list-style: none; margin: 0; padding: 0; }
.pilih-buku li {
  padding: 5px 8px;
  border-bottom: 1px solid var(--garis);
  font-size: 13.5px;
}
.pilih-buku label { display: flex; align-items: center; gap: 7px; font-weight: 400; margin: 0; }
.pilih-buku input { width: auto; }

.tab-atas { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.tab-atas a {
  padding: 6px 12px;
  border: 1px solid var(--garis);
  border-radius: 6px;
  background: #fff;
  font-size: 14px;
}
.tab-atas a.active { background: var(--biru); color: #fff; border-color: var(--biru); font-weight: 600; }

/* ================= GRAFIK ================= */

.grafik {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  overflow-x: auto;
  padding: 10px 0 4px;
}
.grafik-baris { min-width: 62px; text-align: center; }
.grafik-isi {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 3px;
  height: 120px;
}
.grafik-isi .bar { width: 15px; min-height: 2px; border-radius: 3px 3px 0 0; }
.bar.hijau { background: #16a34a; }
.bar.biru  { background: #2563eb; }
.grafik-label { font-size: 11.5px; color: var(--teks-lembut); }
.grafik-angka { font-size: 11px; color: var(--teks-lembut); }

/* ================= LOGIN ================= */

.login-body {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: linear-gradient(135deg, var(--biru-gelap), #0f766e);
  padding: 20px;
}
.login-box {
  background: #fff;
  border-radius: 12px;
  padding: 26px;
  width: 100%;
  max-width: 430px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, .25);
}
.login-box h1 { font-size: 20px; margin-bottom: 2px; }
.login-box > p.muted { margin-top: 0; }

/* ================= PEMBACA ================= */

.pembaca { background: #1f2937; }
.pembaca .topbar { background: #111827; }
.pembaca .wrap { max-width: 980px; }
.baca-areas { position: relative; width: 100%; background: #4b5563; }
.baca-areas iframe, .baca-areas embed, .baca-areas object {
  width: 100%;
  height: 78vh;
  border: 0;
  display: block;
}
.bar-alat {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  padding: 10px 0;
  color: #e5e7eb;
  font-size: 13.5px;
}
.bar-alat .grow { flex: 1 1 120px; }
.progres {
  width: 100%;
  height: 12px;
  background: #374151;
  border-radius: 6px;
  overflow: hidden;
  margin: 6px 0;
}
.progres > div { height: 100%; background: #22c55e; }

/* ================= CETAK ================= */

@media print {
  .topbar, .nav-links, .btn, .paginasi, .notif-jam, .cetak-hide { display: none !important; }
  body { background: #fff; }
  .card { border: 0; padding: 0; }
  a { color: #000; text-decoration: none; }
}

@media (max-width: 720px) {
  .wrap { padding: 0 10px; }
  .nav-links a { font-size: 12px; padding: 5px 7px; }
  .card { padding: 12px; }
  .stat .num { font-size: 22px; }
}
