/* ==========================================================================
   Perpustakaan Sekolah — sistem desain
   Identitas visual diambil dari tradisi pesantren: hijau tua (kitab, seragam),
   kuningan/brass (bingkai buku lama), dan kertas hangat (halaman buku).
   ========================================================================== */

@font-face {
  font-family: "Fraunces";
  font-style: normal;
  font-weight: 500 700;
  font-display: swap;
  src: url("../fonts/fraunces-variable.woff2") format("woff2");
}

@font-face {
  font-family: "Karla";
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url("../fonts/karla-variable.woff2") format("woff2");
}

:root {
  /* --- Warna --- */
  --forest: #16332b;
  --forest-deep: #0d211b;
  --forest-mid: #1f4437;
  --parchment: #faf7f0;
  --parchment-dim: #f1ecdf;
  --ink: #23281f;
  --ink-soft: #565c4e;
  --brass: #a8823d;
  --brass-light: #cdae6c;
  --brick: #9c3b2e;
  --brick-light: #f4e3df;
  --leaf: #3c6e58;
  --leaf-light: #e5f0ea;
  --line: #e4ddcb;
  --line-dark: rgba(255, 255, 255, 0.14);
  --white: #ffffff;

  /* --- Tipografi --- */
  --font-display: "Fraunces", "Iowan Old Style", Georgia, serif;
  --font-body: "Karla", "Segoe UI", system-ui, sans-serif;

  /* --- Bentuk --- */
  --radius-sm: 4px;
  --radius-md: 8px;
  --shadow-card: 0 1px 2px rgba(22, 51, 43, 0.06);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
  }
}

* {
  box-sizing: border-box;
}

html,
body {
  background: var(--parchment);
  color: var(--ink);
}

body {
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4, .h1, .h2, .h3, .h4,
.brand-word, .stat-value, .cover-title {
  font-family: var(--font-display);
  color: var(--ink);
  font-weight: 600;
  letter-spacing: -0.01em;
}

a {
  color: var(--forest-mid);
}
a:hover {
  color: var(--forest);
}

/* ==========================================================================
   Layout: shell dengan sidebar (halaman admin)
   ========================================================================== */

.app-shell {
  display: flex;
  min-height: 100vh;
}

.app-sidebar {
  width: 240px;
  flex-shrink: 0;
  background: var(--forest-deep);
  color: #d9e3dc;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.app-sidebar .brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 22px 20px 18px;
  border-bottom: 1px solid var(--line-dark);
  text-decoration: none;
  color: var(--white);
}
.app-sidebar .brand img {
  width: 32px;
  height: 32px;
  flex-shrink: 0;
}
.app-sidebar .brand-word {
  font-size: 16px;
  line-height: 1.2;
  color: var(--white);
}

.app-nav {
  list-style: none;
  margin: 0;
  padding: 14px 10px;
  flex: 1;
}
.app-nav li + li {
  margin-top: 2px;
}
.app-nav a {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  color: #c3d0c7;
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  border-left: 3px solid transparent;
}
.app-nav a svg {
  width: 17px;
  height: 17px;
  flex-shrink: 0;
  opacity: 0.85;
}
.app-nav a:hover {
  background: rgba(255, 255, 255, 0.06);
  color: var(--white);
}
.app-nav a.active {
  background: rgba(168, 130, 61, 0.16);
  color: var(--white);
  border-left-color: var(--brass);
}

.app-sidebar-foot {
  padding: 14px 16px 18px;
  border-top: 1px solid var(--line-dark);
  font-size: 13px;
}
.app-sidebar-foot a {
  color: #d9e3dc;
}
.app-sidebar-foot .who {
  display: block;
  color: var(--white);
  font-weight: 600;
  margin-bottom: 8px;
  text-decoration: none;
}
.app-sidebar-foot form {
  margin: 0;
}

.app-main {
  flex: 1;
  min-width: 0;
  padding: 30px 34px 60px;
}

.app-topbar-mobile {
  display: none;
}

.page-head {
  margin-bottom: 22px;
}
.page-head h1 {
  font-size: 26px;
  margin: 0;
}
.page-head p {
  color: var(--ink-soft);
  margin: 4px 0 0;
}

/* ==========================================================================
   Kartu statistik
   ========================================================================== */

.stat-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin-bottom: 24px;
}
@media (max-width: 900px) {
  .stat-row { grid-template-columns: repeat(2, 1fr); }
}
.stat-tile {
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 16px 18px;
}
.stat-tile .stat-value {
  font-size: 32px;
  line-height: 1;
  display: block;
}
.stat-tile .stat-label {
  font-size: 13px;
  color: var(--ink-soft);
  margin-top: 6px;
  display: block;
}
.stat-tile.accent .stat-value { color: var(--forest-mid); }
.stat-tile.warn .stat-value { color: var(--brick); }

/* ==========================================================================
   Kartu & panel konten
   ========================================================================== */

.panel {
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-card);
}
.panel-head {
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
  font-weight: 600;
  font-size: 14.5px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.card {
  border: 1px solid var(--line) !important;
  border-radius: var(--radius-md) !important;
  box-shadow: var(--shadow-card);
}
.card-header {
  background: var(--white) !important;
  border-bottom: 1px solid var(--line) !important;
  font-weight: 600;
}

/* ==========================================================================
   Tabel
   ========================================================================== */

.table {
  --bs-table-bg: transparent;
  margin-bottom: 0;
  color: var(--ink);
}
.table thead th {
  background: var(--parchment-dim);
  color: var(--ink-soft);
  font-size: 12.5px;
  font-weight: 700;
  text-transform: none;
  border-bottom: 1px solid var(--line);
  padding: 10px 14px;
}
.table td {
  padding: 11px 14px;
  border-color: var(--line);
  vertical-align: middle;
}
.table-hover tbody tr:hover {
  background: var(--parchment-dim);
}
code {
  background: var(--parchment-dim);
  color: var(--forest);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.85em;
}

/* ==========================================================================
   Tombol
   ========================================================================== */

.btn {
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 14px;
  padding: 7px 16px;
  border-width: 1.5px;
}
.btn-primary {
  background: var(--forest);
  border-color: var(--forest);
}
.btn-primary:hover, .btn-primary:focus {
  background: var(--forest-deep);
  border-color: var(--forest-deep);
}
.btn-outline-primary {
  color: var(--forest);
  border-color: var(--forest);
}
.btn-outline-primary:hover {
  background: var(--forest);
  border-color: var(--forest);
}
.btn-outline-secondary {
  color: var(--ink-soft);
  border-color: var(--line);
}
.btn-outline-secondary:hover {
  background: var(--parchment-dim);
  color: var(--ink);
  border-color: var(--line);
}
.btn-outline-danger {
  color: var(--brick);
  border-color: #d9c1bc;
}
.btn-outline-danger:hover {
  background: var(--brick);
  border-color: var(--brick);
}
.btn-outline-warning {
  color: var(--brass);
  border-color: var(--brass-light);
}
.btn-outline-warning:hover {
  background: var(--brass);
  border-color: var(--brass);
  color: var(--white);
}

/* ==========================================================================
   Form
   ========================================================================== */

.form-control, .form-select {
  border-color: var(--line);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  font-size: 14.5px;
}
.form-control:focus, .form-select:focus {
  border-color: var(--forest-mid);
  box-shadow: 0 0 0 3px rgba(63, 110, 88, 0.15);
}
.form-label {
  font-weight: 600;
  font-size: 13.5px;
  color: var(--ink);
  margin-bottom: 5px;
}
.form-text {
  color: var(--ink-soft);
  font-size: 12.5px;
}

/* ==========================================================================
   Badge & alert
   ========================================================================== */

.badge {
  font-weight: 600;
  font-size: 11.5px;
  padding: 4px 9px;
  border-radius: 100px;
}
.text-bg-success { background: var(--leaf-light) !important; color: var(--forest-mid) !important; }
.text-bg-primary { background: #e6ecf5 !important; color: #3a5583 !important; }
.text-bg-danger { background: var(--brick-light) !important; color: var(--brick) !important; }
.text-bg-secondary { background: var(--parchment-dim) !important; color: var(--ink-soft) !important; }
.text-bg-warning { background: #f7ecd6 !important; color: #8a5a15 !important; }

.alert {
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  font-size: 14px;
}
.alert-success { background: var(--leaf-light); color: var(--forest-mid); border-color: #cfe4d8; }
.alert-danger { background: var(--brick-light); color: var(--brick); border-color: #e6cac4; }
.alert-info { background: #eaf1f7; color: #35618a; border-color: #d3e3ee; }

/* ==========================================================================
   Nav pills (filter status, dsb.)
   ========================================================================== */

.nav-pills .nav-link {
  color: var(--ink-soft);
  font-weight: 600;
  font-size: 14px;
  border-radius: var(--radius-sm);
  padding: 7px 14px;
}
.nav-pills .nav-link:hover {
  background: var(--parchment-dim);
  color: var(--ink);
}
.nav-pills .nav-link.active {
  background: var(--forest);
  color: var(--white);
}

/* ==========================================================================
   Halaman masuk (login) — momen utama identitas visual
   ========================================================================== */

.auth-shell {
  min-height: 100vh;
  background: var(--forest-deep);
  background-image:
    radial-gradient(circle at 15% 20%, rgba(168, 130, 61, 0.12), transparent 45%),
    radial-gradient(circle at 85% 85%, rgba(168, 130, 61, 0.10), transparent 40%);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.auth-card {
  width: 100%;
  max-width: 400px;
  background: var(--parchment);
  border-radius: var(--radius-md);
  padding: 38px 34px;
  border-top: 3px solid var(--brass);
}
.auth-logo {
  width: 64px;
  height: 64px;
  margin: 0 auto 18px;
  display: block;
}
.auth-title {
  font-size: 22px;
  text-align: center;
  margin: 0 0 4px;
}
.auth-sub {
  text-align: center;
  color: var(--ink-soft);
  font-size: 14px;
  margin: 0 0 26px;
}
.auth-foot {
  text-align: center;
  margin-top: 22px;
  font-size: 13px;
  color: var(--ink-soft);
}

/* ==========================================================================
   Navbar publik / portal (tanpa sidebar)
   ========================================================================== */

.top-shell {
  background: var(--forest-deep);
  color: var(--white);
  padding: 14px 0;
}
.top-shell .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
}
.top-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--white);
  text-decoration: none;
  font-family: var(--font-display);
  font-size: 17px;
  font-weight: 600;
}
.top-brand img { width: 30px; height: 30px; }
.top-nav {
  display: flex;
  gap: 4px;
  list-style: none;
  margin: 0;
  padding: 0;
}
.top-nav a {
  color: #d9e3dc;
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  padding: 6px 12px;
  border-radius: var(--radius-sm);
}
.top-nav a:hover { background: rgba(255,255,255,0.08); color: var(--white); }

/* ==========================================================================
   Grid buku (katalog)
   ========================================================================== */

.book-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 18px;
}
.book-card {
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.book-cover {
  aspect-ratio: 3 / 4;
  background: var(--parchment-dim);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--ink-soft);
  font-size: 12px;
  overflow: hidden;
}
.book-cover img { width: 100%; height: 100%; object-fit: cover; }
.book-body {
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1;
}
.book-title {
  font-weight: 700;
  font-size: 13.5px;
  line-height: 1.3;
}
.book-author {
  font-size: 12px;
  color: var(--ink-soft);
}

/* ==========================================================================
   Responsif: sidebar jadi drawer di layar sempit
   ========================================================================== */

@media (max-width: 860px) {
  .app-shell { display: block; }
  .app-sidebar {
    position: fixed;
    left: 0; top: 0; bottom: 0;
    z-index: 1050;
    transform: translateX(-100%);
    transition: transform 0.2s ease;
  }
  .app-sidebar.open { transform: translateX(0); }
  .app-main { padding: 20px 16px 50px; }
  .app-topbar-mobile {
    display: flex;
    align-items: center;
    gap: 12px;
    background: var(--forest-deep);
    color: var(--white);
    padding: 12px 16px;
    margin: -20px -16px 20px;
  }
  .app-topbar-mobile img { width: 26px; height: 26px; }
  .app-topbar-mobile button {
    background: none;
    border: none;
    color: var(--white);
    font-size: 22px;
    line-height: 1;
    padding: 0;
  }
  .stat-row { grid-template-columns: 1fr 1fr; }
  .sidebar-backdrop {
    display: none;
    position: fixed; inset: 0;
    background: rgba(13, 33, 27, 0.5);
    z-index: 1040;
  }
  .sidebar-backdrop.open { display: block; }
}
