:root {
    --primary: #4f46e5;
    --primary-light: #eef2ff;
    --bg: #f8fafc;
    --white: #ffffff;
    --text-dark: #1e293b;
    --text-muted: #64748b;
    --success: #10b981;
    --danger: #ef4444;
}

* { box-sizing: border-box; margin: 0; padding: 0; font-family: 'Plus Jakarta Sans', sans-serif; }

body { background-color: var(--bg); color: var(--text-dark); line-height: 1.6; }

/* Navbar */
nav { background: var(--white); padding: 1rem 5%; box-shadow: 0 1px 3px rgba(0,0,0,0.1); position: sticky; top: 0; z-index: 100; }
.nav-container { display: flex; justify-content: space-between; align-items: center; max-width: 1200px; margin: auto; }
.logo { font-weight: 800; font-size: 1.5rem; }
.logo span { color: var(--primary); }
.school-tag { font-weight: 600; font-size: 0.9rem; color: var(--text-muted); }

/* Main Content */
main { max-width: 1200px; margin: 2rem auto; padding: 0 1.5rem; }
.lib-header { margin-bottom: 2.5rem; }
.lib-header h1 { font-size: 2.2rem; letter-spacing: -1px; margin-bottom: 0.5rem; }

/* Responsive Grid */
.book-grid { 
    display: grid; 
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); 
    gap: 1.5rem; 
}

.book-card { 
    background: var(--white); 
    padding: 1rem; 
    border-radius: 1.2rem; 
    box-shadow: 0 4px 6px -1px rgba(0,0,0,0.05);
    transition: transform 0.2s;
}
.book-card:hover { transform: translateY(-5px); }
.book-card img { width: 100%; height: 300px; object-fit: cover; border-radius: 0.8rem; margin-bottom: 1rem; }
.book-card h3 { font-size: 1.1rem; margin-bottom: 0.3rem; }
.book-card p { font-size: 0.85rem; color: var(--text-muted); margin-bottom: 1rem; }

/* Buttons */
button { width: 100%; padding: 0.8rem; border: none; border-radius: 0.7rem; font-weight: 700; cursor: pointer; transition: 0.3s; }
.btn-available { background: var(--primary); color: white; }
.btn-return { background: var(--primary-light); color: var(--primary); }
.btn-return:hover { background: var(--danger); color: white; }

/* Modal */
.modal { display: none; position: fixed; inset: 0; background: rgba(15, 23, 42, 0.6); backdrop-filter: blur(4px); z-index: 1000; justify-content: center; align-items: center; padding: 1rem; }
.modal-content { background: white; width: 100%; max-width: 450px; border-radius: 1.5rem; padding: 2rem; position: relative; }
.modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1.5rem; }
.close-btn { font-size: 1.5rem; cursor: pointer; }

.input-group { margin-bottom: 1.2rem; }
.input-group label { display: block; font-size: 0.85rem; font-weight: 600; margin-bottom: 0.4rem; }
.input-group input { width: 100%; padding: 0.8rem; border: 1px solid #e2e8f0; border-radius: 0.6rem; outline: none; }
.input-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }

/* History Table */
.history-section { margin-top: 4rem; }
.table-container { background: white; border-radius: 1.2rem; overflow-x: auto; box-shadow: 0 4px 6px rgba(0,0,0,0.05); }
table { width: 100%; border-collapse: collapse; min-width: 600px; }
th { background: #f1f5f9; text-align: left; padding: 1rem; font-size: 0.85rem; }
td { padding: 1rem; border-top: 1px solid #f1f5f9; font-size: 0.9rem; }

/* Status Badges */
.status-badge { padding: 0.3rem 0.8rem; border-radius: 2rem; font-size: 0.75rem; font-weight: 700; }
.status-pinjam { background: #fee2e2; color: var(--danger); }
.status-kembali { background: #dcfce7; color: var(--success); }

/* Mobile Optimization */
@media (max-width: 600px) {
    .lib-header h1 { font-size: 1.8rem; }
    .input-row { grid-template-columns: 1fr; }
    .book-card img { height: 250px; }
}

/* ==========================================
   CSS UNTUK PANEL ADMIN (Tempel di Bawah)
   ========================================== */

.admin-section {
    background: #1e293b; /* Warna gelap agar beda dengan area siswa */
    color: white;
    padding: 2.5rem;
    border-radius: 24px;
    margin-top: 3rem;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.2);
    border: 1px solid #334155;
}

.admin-header { 
    display: flex; 
    justify-content: space-between; 
    align-items: center; 
    margin-bottom: 2rem; 
}

.admin-header h2 {
    font-size: 1.8rem;
    color: #f8fafc;
}

/* Kartu Statistik */
.admin-stats { 
    display: grid; 
    grid-template-columns: 1fr 1fr; 
    gap: 1.5rem; 
    margin-bottom: 2.5rem; 
}

.stat-card { 
    background: #334155; 
    padding: 1.5rem; 
    border-radius: 18px; 
    text-align: center; 
    border-bottom: 4px solid #4f46e5;
}

.stat-card h4 { 
    font-size: 2.5rem; 
    color: #818cf8; 
    margin-bottom: 0.2rem;
}

.stat-card p {
    color: #94a3b8;
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 1px;
}

/* Search Bar Admin */
.admin-search input {
    width: 100%; 
    padding: 1rem 1.5rem; 
    border-radius: 12px; 
    border: 2px solid #334155; 
    margin-bottom: 1.5rem; 
    background: #0f172a; 
    color: white;
    font-size: 1rem;
    outline: none;
    transition: 0.3s;
}

.admin-search input:focus {
    border-color: #4f46e5;
}

/* Tombol Khusus Admin */
.btn-admin-nav { 
    background: #eef2ff; 
    color: #4f46e5; 
    width: auto !important; 
    padding: 10px 20px !important; 
    font-size: 0.85rem; 
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.btn-close-admin { 
    background: #ef4444; 
    color: white; 
    width: auto !important; 
    padding: 8px 18px !important; 
    font-size: 0.85rem;
}

/* Penyesuaian Tabel untuk Admin (Warna Terang agar Terbaca) */
#admin-panel table {
    background: transparent;
}

#admin-panel th {
    background: #334155;
    color: #cbd5e1;
    border: none;
}

#admin-panel td {
    border-top: 1px solid #334155;
    color: #f1f5f9;
}

/* Responsive Admin */
@media (max-width: 600px) {
    .admin-stats { grid-template-columns: 1fr; }
    .admin-section { padding: 1.5rem; }
}

.nav-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    max-width: 1200px;
    margin: 0 auto;
    padding: 1rem 5%; /* Gabungan padding agar seragam */
}

.btn-admin-nav {
    background: #4f46e5;
    color: white;
    border: none;
    padding: 8px 15px;
    border-radius: 8px;
    cursor: pointer;
    font-family: 'Plus Jakarta Sans', sans-serif;
    font-weight: 600;
    font-size: 0.8rem;
    transition: 0.3s;
}

.btn-admin-nav:hover {
    background: #3730a3;
}

/* Jika kamu ingin nama siswa di tabel riwayat user juga ikut berubah biru */
#history-body td b {
    color: #2563eb; /* Biru yang sedikit lebih gelap untuk latar putih */
}

/* Mengubah warna teks Judul Buku dan Kelas agar JELAS di area Putih */
#admin-history-body td {
    color: var(--text-dark); /* Menggunakan variabel warna teks gelap yang sudah ada */
}

/* Biar lebih aman, kita paksa warna teksnya jadi abu-abu gelap */
#admin-history-body td b {
    color: #0f172a; /* Warna teks gelap */
}

/* Tampilan Layar Login */
.login-overlay {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: #f8fafc; 
    z-index: 9999;
    display: flex;
    flex-direction: column; /* Tambahkan ini */
    justify-content: center;
    align-items: center;
}

.login-box {
    background: white;
    padding: 2.5rem;
    border-radius: 20px;
    box-shadow: 0 10px 25px rgba(0,0,0,0.1);
    width: 90%;
    max-width: 400px;
    text-align: center;
}

/* Sembunyikan konten utama jika belum login */
body.locked {
    overflow: hidden;
}