/* =====================================================
   PERPUSTAKAAN DIGITAL - STYLE UTAMA
   Font: Poppins (Google Fonts)
   Icon: Font Awesome 6 (CDN)
===================================================== */

:root {
    --primary: #4f46e5;
    --primary-dark: #3730a3;
    --primary-light: #818cf8;
    --secondary: #f59e0b;
    --bg: #f5f6fb;
    --surface: #ffffff;
    --text-dark: #1e1b3a;
    --text-muted: #6b7280;
    --border: #e5e7eb;
    --success: #16a34a;
    --danger: #dc2626;
    --radius: 16px;
    --shadow: 0 10px 30px rgba(79, 70, 229, 0.08);
    --shadow-hover: 0 16px 40px rgba(79, 70, 229, 0.18);
}

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

body {
    font-family: 'Poppins', sans-serif;
    background: var(--bg);
    color: var(--text-dark);
    line-height: 1.6;
}

a { text-decoration: none; color: inherit; }
ul { list-style: none; }
img { max-width: 100%; display: block; }

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 24px;
}

/* ============ NAVBAR (PUBLIK) ============ */
.navbar {
    background: var(--surface);
    box-shadow: 0 2px 12px rgba(0,0,0,0.05);
    position: sticky;
    top: 0;
    z-index: 100;
}
.navbar-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 24px;
    max-width: 1200px;
    margin: 0 auto;
}
.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 700;
    font-size: 1.3rem;
    color: var(--primary-dark);
}
.brand i {
    background: linear-gradient(135deg, var(--primary), var(--primary-light));
    color: #fff;
    width: 42px;
    height: 42px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 12px;
    font-size: 1.1rem;
}
.nav-links { display: flex; align-items: center; gap: 28px; }
.nav-links a {
    font-weight: 500;
    color: var(--text-muted);
    transition: color .2s;
}
.nav-links a:hover, .nav-links a.active { color: var(--primary); }
.btn-login-nav {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: #fff !important;
    padding: 10px 22px;
    border-radius: 999px;
    font-weight: 600;
    box-shadow: 0 6px 16px rgba(79,70,229,.3);
    transition: transform .2s;
}
.btn-login-nav:hover { transform: translateY(-2px); }

/* Tombol hamburger (hanya tampil di mobile) */
.nav-toggle {
    display: none;
    background: none;
    border: none;
    font-size: 1.4rem;
    color: var(--primary-dark);
    cursor: pointer;
    padding: 6px;
}

/* ============ HERO ============ */
.hero {
    background: radial-gradient(circle at top left, #6366f1, #4338ca 60%, #312e81);
    color: #fff;
    padding: 80px 24px 100px;
    position: relative;
    overflow: hidden;
}
.hero::before {
    content: '';
    position: absolute;
    width: 400px; height: 400px;
    background: rgba(255,255,255,0.08);
    border-radius: 50%;
    top: -150px; right: -100px;
}
.hero::after {
    content: '';
    position: absolute;
    width: 250px; height: 250px;
    background: rgba(245,158,11,0.15);
    border-radius: 50%;
    bottom: -100px; left: 10%;
}
.hero-content { max-width: 700px; margin: 0 auto; text-align: center; position: relative; z-index: 2; }
.hero h1 { font-size: 2.6rem; font-weight: 700; margin-bottom: 16px; }
.hero h1 span { color: var(--secondary); }
.hero p { font-size: 1.1rem; opacity: .9; margin-bottom: 32px; }

.search-box {
    background: #fff;
    border-radius: 999px;
    padding: 6px;
    display: flex;
    align-items: center;
    max-width: 560px;
    margin: 0 auto;
    box-shadow: 0 12px 30px rgba(0,0,0,0.2);
}
.search-box input {
    flex: 1;
    border: none;
    outline: none;
    padding: 12px 20px;
    font-family: inherit;
    font-size: .95rem;
    border-radius: 999px;
    color: var(--text-dark);
}
.search-box button {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: #fff;
    border: none;
    padding: 12px 26px;
    border-radius: 999px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: opacity .2s;
}
.search-box button:hover { opacity: .9; }

.hero-stats {
    display: flex;
    justify-content: center;
    gap: 48px;
    margin-top: 40px;
    flex-wrap: wrap;
}
.hero-stats div { text-align: center; }
.hero-stats strong { display: block; font-size: 1.6rem; color: var(--secondary); }
.hero-stats span { font-size: .85rem; opacity: .85; }

/* ============ SECTION ============ */
.section { padding: 56px 24px; }
.section-title {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 28px;
    max-width: 1200px;
    margin-left: auto;
    margin-right: auto;
    flex-wrap: wrap;
    gap: 12px;
}
.section-title h2 { font-size: 1.6rem; font-weight: 700; }
.section-title h2 i { color: var(--primary); margin-right: 8px; }

.filter-kategori {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}
.filter-kategori a {
    padding: 8px 18px;
    border-radius: 999px;
    background: #fff;
    border: 1px solid var(--border);
    font-size: .85rem;
    font-weight: 500;
    color: var(--text-muted);
    transition: all .2s;
}
.filter-kategori a:hover, .filter-kategori a.active {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
}

/* ============ GRID BUKU ============ */
.book-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 24px;
    max-width: 1200px;
    margin: 0 auto;
}
.book-card {
    background: var(--surface);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow);
    transition: transform .25s, box-shadow .25s;
    display: flex;
    flex-direction: column;
}
.book-card:hover {
    transform: translateY(-6px);
    box-shadow: var(--shadow-hover);
}
.book-cover {
    height: 260px;
    background: linear-gradient(135deg, #eef2ff, #e0e7ff);
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
}
.book-cover img { width: 100%; height: 100%; object-fit: cover; }
.book-cover .placeholder-icon {
    font-size: 3.2rem;
    color: var(--primary-light);
}
.badge-filetype {
    position: absolute;
    top: 10px; right: 10px;
    padding: 4px 10px;
    border-radius: 999px;
    font-size: .7rem;
    font-weight: 700;
    color: #fff;
    display: flex;
    align-items: center;
    gap: 4px;
}
.badge-pdf { background: #dc2626; }
.badge-word { background: #2563eb; }
.badge-default { background: #6b7280; }

.book-info { padding: 16px 18px 18px; display: flex; flex-direction: column; gap: 6px; flex: 1; }
.book-kategori {
    font-size: .68rem;
    font-weight: 700;
    text-transform: uppercase;
    color: var(--primary);
    letter-spacing: .04em;
}
.book-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-dark);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    min-height: 2.6em;
}
.book-author { font-size: .82rem; color: var(--text-muted); }
.book-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 10px;
    font-size: .78rem;
    color: var(--text-muted);
}
.btn-baca {
    display: block;
    text-align: center;
    margin-top: 12px;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: #fff;
    padding: 10px;
    border-radius: 10px;
    font-weight: 600;
    font-size: .88rem;
    transition: opacity .2s;
}
.btn-baca:hover { opacity: .88; }
.btn-download {
    display: block;
    text-align: center;
    margin-top: 8px;
    background: #eef2ff;
    color: var(--primary-dark);
    padding: 9px;
    border-radius: 10px;
    font-weight: 600;
    font-size: .85rem;
}

.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-muted);
    grid-column: 1 / -1;
}
.empty-state i { font-size: 3rem; color: var(--border); margin-bottom: 16px; }

/* ============ FOOTER ============ */
.footer {
    background: #1e1b3a;
    color: #cbd5e1;
    padding: 36px 24px;
    text-align: center;
    margin-top: 40px;
}
.footer strong { color: #fff; }

/* ============ LOGIN ============ */
.login-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: radial-gradient(circle at top left, #6366f1, #312e81 70%);
    padding: 20px;
}
.login-card {
    background: #fff;
    border-radius: 20px;
    padding: 44px 40px;
    width: 100%;
    max-width: 400px;
    box-shadow: 0 25px 60px rgba(0,0,0,0.3);
    text-align: center;
}
.login-card .logo-circle {
    width: 66px; height: 66px;
    background: linear-gradient(135deg, var(--primary), var(--primary-light));
    color: #fff;
    border-radius: 18px;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.6rem;
    margin: 0 auto 18px;
}
.login-card h2 { font-size: 1.4rem; margin-bottom: 6px; }
.login-card p.subtitle { color: var(--text-muted); font-size: .88rem; margin-bottom: 28px; }

.form-group { text-align: left; margin-bottom: 18px; }
.form-group label { display: block; font-size: .85rem; font-weight: 600; margin-bottom: 6px; color: var(--text-dark); }
.input-wrap { position: relative; }
.input-wrap i {
    position: absolute; left: 14px; top: 50%; transform: translateY(-50%);
    color: var(--text-muted);
}
.form-group input, .form-group select, .form-group textarea {
    width: 100%;
    padding: 12px 14px 12px 40px;
    border: 1.5px solid var(--border);
    border-radius: 10px;
    font-family: inherit;
    font-size: .92rem;
    outline: none;
    transition: border .2s;
}
.form-group select, .form-group textarea { padding-left: 14px; }
.form-group input:focus, .form-group select:focus, .form-group textarea:focus { border-color: var(--primary); }

.btn-primary {
    width: 100%;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: #fff;
    border: none;
    padding: 13px;
    border-radius: 10px;
    font-weight: 600;
    font-size: .95rem;
    cursor: pointer;
    transition: opacity .2s;
    display: flex; align-items: center; justify-content: center; gap: 8px;
}
.btn-primary:hover { opacity: .9; }

.alert {
    padding: 12px 16px;
    border-radius: 10px;
    font-size: .85rem;
    margin-bottom: 18px;
    display: flex;
    align-items: center;
    gap: 8px;
    text-align: left;
}
.alert-error { background: #fee2e2; color: #b91c1c; }
.alert-success { background: #dcfce7; color: #15803d; }

.back-link { display: inline-flex; align-items: center; gap: 6px; margin-top: 22px; font-size: .85rem; color: var(--text-muted); }
.back-link:hover { color: var(--primary); }

/* ============ ADMIN LAYOUT ============ */
.admin-wrapper { display: flex; min-height: 100vh; }
.sidebar {
    width: 260px;
    background: linear-gradient(180deg, #312e81, #1e1b3a);
    color: #fff;
    padding: 28px 20px;
    flex-shrink: 0;
    position: sticky;
    top: 0;
    height: 100vh;
}
.sidebar .brand { color: #fff; margin-bottom: 36px; }
.sidebar .brand i { background: rgba(255,255,255,.15); }
.sidebar-menu a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border-radius: 10px;
    font-size: .92rem;
    font-weight: 500;
    color: #c7d2fe;
    margin-bottom: 6px;
    transition: all .2s;
}
.sidebar-menu a i { width: 18px; text-align: center; }
.sidebar-menu a:hover, .sidebar-menu a.active {
    background: rgba(255,255,255,.12);
    color: #fff;
}
.sidebar-menu a.active { background: var(--primary); }
.sidebar-footer {
    position: absolute;
    bottom: 24px;
    width: 220px;
}

.admin-main { flex: 1; padding: 32px 36px; max-width: calc(100% - 260px); }
.admin-topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 28px;
    flex-wrap: wrap;
    gap: 16px;
}
.admin-topbar h1 { font-size: 1.5rem; font-weight: 700; }
.admin-topbar p { color: var(--text-muted); font-size: .88rem; }
.admin-user { display: flex; align-items: center; gap: 12px; background: #fff; padding: 8px 16px; border-radius: 999px; box-shadow: var(--shadow); }
.admin-user .avatar {
    width: 36px; height: 36px; border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), var(--primary-light));
    color: #fff; display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: .85rem;
}

.stat-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 20px;
    margin-bottom: 32px;
}
.stat-card {
    background: #fff;
    border-radius: var(--radius);
    padding: 22px;
    box-shadow: var(--shadow);
    display: flex;
    align-items: center;
    gap: 16px;
}
.stat-card .icon {
    width: 52px; height: 52px;
    border-radius: 14px;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.3rem;
    color: #fff;
}
.stat-card h3 { font-size: 1.5rem; font-weight: 700; }
.stat-card span { font-size: .82rem; color: var(--text-muted); }

.card-panel {
    background: #fff;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 26px 28px;
    margin-bottom: 28px;
}
.card-panel h3 { font-size: 1.1rem; margin-bottom: 20px; display: flex; align-items: center; gap: 8px; }
.card-panel h3 i { color: var(--primary); }

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.form-grid .full { grid-column: 1 / -1; }

.file-drop {
    border: 2px dashed var(--border);
    border-radius: 12px;
    padding: 24px;
    text-align: center;
    color: var(--text-muted);
    font-size: .85rem;
    cursor: pointer;
    transition: border-color .2s, background .2s;
}
.file-drop:hover { border-color: var(--primary); background: #f5f6fe; }
.file-drop i { font-size: 1.6rem; color: var(--primary); display: block; margin-bottom: 8px; }
.file-drop small { display: block; margin-top: 4px; color: #9ca3af; }

/* Tabel */
.table-wrap { overflow-x: auto; }
table.data-table { width: 100%; border-collapse: collapse; font-size: .88rem; }
table.data-table th {
    text-align: left;
    padding: 12px 14px;
    background: #f5f6fb;
    color: var(--text-muted);
    font-weight: 600;
    font-size: .78rem;
    text-transform: uppercase;
    letter-spacing: .03em;
}
table.data-table td { padding: 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
table.data-table tr:hover td { background: #fafafe; }
.book-thumb {
    width: 42px; height: 56px; border-radius: 6px; object-fit: cover;
    background: #eef2ff;
    display: flex; align-items: center; justify-content: center; color: var(--primary-light);
}
.judul-cell { display: flex; align-items: center; gap: 12px; }
.judul-cell strong { display: block; font-size: .9rem; }
.judul-cell span { font-size: .78rem; color: var(--text-muted); }

.badge-pill {
    padding: 4px 12px;
    border-radius: 999px;
    font-size: .72rem;
    font-weight: 700;
    color: #fff;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.action-btns { display: flex; gap: 8px; }
.btn-icon {
    width: 34px; height: 34px;
    border-radius: 8px;
    display: flex; align-items: center; justify-content: center;
    border: none;
    cursor: pointer;
    font-size: .85rem;
    transition: opacity .2s;
}
.btn-icon:hover { opacity: .8; }
.btn-edit { background: #fef3c7; color: #b45309; }
.btn-delete { background: #fee2e2; color: #b91c1c; }
.btn-view { background: #e0e7ff; color: var(--primary-dark); }

.btn-tambah {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: #fff;
    border: none;
    padding: 12px 22px;
    border-radius: 10px;
    font-weight: 600;
    font-size: .88rem;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    box-shadow: 0 6px 16px rgba(79,70,229,.3);
}

/* ============ VIEWER PDF ============ */
.viewer-topbar {
    background: #1e1b3a;
    color: #fff;
    padding: 14px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 10px;
}
.viewer-topbar h2 { font-size: 1rem; font-weight: 600; }
.viewer-topbar a.btn-back {
    color: #c7d2fe;
    display: flex; align-items: center; gap: 6px;
    font-size: .88rem;
}
.viewer-topbar a.btn-back:hover { color: #fff; }
.pdf-frame-wrap { width: 100%; height: calc(100vh - 60px); background: #525659; }
.pdf-frame-wrap iframe { width: 100%; height: 100%; border: none; }

/* ============ RESPONSIVE ============ */
@media (max-width: 900px) {
    .admin-wrapper { flex-direction: column; }
    .sidebar { width: 100%; height: auto; position: relative; padding: 18px 20px; }
    .sidebar-footer { position: relative; width: 100%; margin-top: 16px; }
    .admin-main { max-width: 100%; padding: 24px 18px; }
    .form-grid { grid-template-columns: 1fr; }
}
@media (max-width: 768px) {
    .nav-toggle { display: block; }
    .nav-links {
        position: absolute;
        top: 100%;
        left: 0;
        right: 0;
        flex-direction: column;
        align-items: stretch;
        gap: 0;
        background: var(--surface);
        box-shadow: 0 12px 24px rgba(0,0,0,0.08);
        max-height: 0;
        overflow: hidden;
        transition: max-height .3s ease;
    }
    .nav-links.open { max-height: 320px; }
    .nav-links a {
        padding: 16px 24px;
        border-bottom: 1px solid var(--border);
        width: 100%;
    }
    .btn-login-nav {
        border-radius: 0;
        text-align: center;
        box-shadow: none;
    }
    .navbar-inner { position: relative; }
}
@media (max-width: 640px) {
    .hero h1 { font-size: 1.9rem; }
    .search-box { flex-direction: column; border-radius: 18px; padding: 12px; gap: 10px; }
    .search-box input { width: 100%; }
    .search-box button { width: 100%; justify-content: center; }
}