/* =========================================================
   DIGITAL LIBRARY MA NW SURALAGA - MAIN STYLESHEET
   ========================================================= */

:root {
    --primary: #0f5132;
    --primary-light: #146c43;
    --primary-dark: #0a3622;
    --accent: #d4a418;
    --bg: #f4f7f5;
    --card-bg: #ffffff;
    --text: #22292f;
    --text-muted: #6c757d;
    --border: #e2e8e4;
    --danger: #b02a37;
    --success: #146c43;
    --warning: #a9720d;
    --radius: 12px;
}

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

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

a { text-decoration: none; color: inherit; }

/* ============ NAVBAR (USER) ============ */
.navbar {
    background: var(--primary-dark);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 32px;
    flex-wrap: wrap;
    gap: 12px;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}

.navbar-brand { display: flex; align-items: center; gap: 10px; }
.navbar-logo { width: 42px; height: 42px; object-fit: contain; background: #fff; border-radius: 8px; padding: 3px; }
.logo-icon { font-size: 28px; }
.brand-title { font-weight: 700; font-size: 17px; }
.brand-subtitle { font-size: 12px; opacity: 0.8; }

.navbar-menu { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.navbar-menu a {
    padding: 8px 14px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    transition: background 0.2s;
}
.navbar-menu a:hover, .navbar-menu a.active { background: rgba(255,255,255,0.15); }
.btn-logout {
    background: var(--danger) !important;
    color: #fff !important;
}

/* ============ SIDEBAR (ADMIN) ============ */
.admin-body { display: flex; min-height: 100vh; }
.sidebar {
    width: 260px;
    background: var(--primary-dark);
    color: #fff;
    flex-shrink: 0;
    padding: 20px 0;
    height: 100vh;
    position: sticky;
    top: 0;
    overflow-y: auto;
}
.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0 20px 20px 20px;
    border-bottom: 1px solid rgba(255,255,255,0.15);
    margin-bottom: 16px;
}
.sidebar-logo { width: 44px; height: 44px; object-fit: contain; background: #fff; border-radius: 8px; padding: 3px; flex-shrink: 0; }
.sidebar-menu { display: flex; flex-direction: column; }
.sidebar-menu a {
    padding: 12px 20px;
    color: #dce7e0;
    font-size: 14px;
    font-weight: 500;
    border-left: 3px solid transparent;
    transition: all 0.2s;
}
.sidebar-menu a:hover, .sidebar-menu a.active {
    background: rgba(255,255,255,0.08);
    border-left-color: var(--accent);
    color: #fff;
}
.btn-logout-sidebar { margin-top: 16px; color: #ffb4b4 !important; }

.admin-main { flex: 1; padding: 28px 32px; max-width: 100%; overflow-x: auto; }

/* ============ LAYOUT ============ */
.main-container { max-width: 1200px; margin: 0 auto; padding: 28px 20px; }

.page-title { font-size: 24px; font-weight: 700; margin-bottom: 6px; color: var(--primary-dark); }
.page-subtitle { color: var(--text-muted); margin-bottom: 24px; font-size: 14px; }

/* ============ CARDS ============ */
.card {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 24px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.05);
    border: 1px solid var(--border);
    margin-bottom: 24px;
}

.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 18px; margin-bottom: 24px; }
.stat-card {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 20px;
    border-left: 4px solid var(--primary);
    box-shadow: 0 2px 10px rgba(0,0,0,0.05);
}
.stat-card .stat-number { font-size: 28px; font-weight: 700; color: var(--primary-dark); }
.stat-card .stat-label { color: var(--text-muted); font-size: 13px; margin-top: 4px; }

/* ============ FORMS ============ */
.form-group { margin-bottom: 18px; }
.form-group label { display: block; font-weight: 500; margin-bottom: 6px; font-size: 14px; }
.form-control {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 14px;
    font-family: inherit;
    background: var(--card-bg);
    color: var(--text);
}
.form-control:focus { outline: none; border-color: var(--primary-light); box-shadow: 0 0 0 3px rgba(15,81,50,0.1); }
textarea.form-control { resize: vertical; min-height: 90px; }

.form-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; }

/* ============ BUTTONS ============ */
.btn {
    display: inline-block;
    padding: 10px 22px;
    border-radius: 8px;
    font-weight: 600;
    font-size: 14px;
    border: none;
    cursor: pointer;
    text-align: center;
    transition: transform 0.1s, opacity 0.2s;
}
.btn:hover { opacity: 0.9; }
.btn:active { transform: scale(0.98); }
.btn-primary { background: var(--primary); color: #fff; }
.btn-accent { background: var(--accent); color: #3a2c02; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-success { background: var(--success); color: #fff; }
.btn-secondary { background: #e9ecef; color: var(--text); }
.btn-sm { padding: 6px 14px; font-size: 13px; }
.btn-block { width: 100%; }

/* ============ AUTH PAGES ============ */
.auth-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--primary-dark), var(--primary));
    padding: 24px;
}
.auth-card {
    background: var(--card-bg);
    border-radius: 16px;
    padding: 40px;
    max-width: 440px;
    width: 100%;
    box-shadow: 0 10px 40px rgba(0,0,0,0.2);
}
.auth-logo { text-align: center; margin-bottom: 24px; }
.auth-logo-img { width: 90px; height: 90px; object-fit: contain; }
.auth-logo h1 { font-size: 19px; color: var(--primary-dark); margin-top: 8px; }
.auth-logo p { font-size: 13px; color: var(--text-muted); }
.auth-footer-link { text-align: center; margin-top: 18px; font-size: 14px; }

/* ============ ALERTS ============ */
.alert {
    padding: 12px 18px;
    border-radius: 8px;
    margin-bottom: 18px;
    font-size: 14px;
}
.alert-success { background: #d1e7dd; color: #0a3622; border: 1px solid #a3cfbb; }
.alert-danger { background: #f8d7da; color: #58151c; border: 1px solid #f1aeb5; }

/* ============ BADGES ============ */
.badge { display: inline-block; padding: 4px 10px; border-radius: 20px; font-size: 12px; font-weight: 600; }
.badge-pending { background: #fff3cd; color: #664d03; }
.badge-approved { background: #d1e7dd; color: #0a3622; }
.badge-rejected { background: #f8d7da; color: #58151c; }
.badge-dipinjam { background: #cfe2ff; color: #084298; }
.badge-dikembalikan { background: #d1e7dd; color: #0a3622; }
.badge-terlambat { background: #f8d7da; color: #58151c; }

/* ============ TABLES ============ */
.table-wrapper { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
table th, table td { padding: 12px 14px; text-align: left; border-bottom: 1px solid var(--border); }
table th { background: #f0f4f1; font-weight: 600; color: var(--primary-dark); }
table tr:hover { background: #fafcfb; }

/* ============ BOOK GRID ============ */
.category-tabs { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 22px; }
.category-tabs a {
    padding: 8px 18px;
    border-radius: 20px;
    background: var(--card-bg);
    border: 1px solid var(--border);
    font-size: 13px;
    font-weight: 500;
}
.category-tabs a.active, .category-tabs a:hover { background: var(--primary); color: #fff; border-color: var(--primary); }

.book-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 20px; }
.book-card {
    background: var(--card-bg);
    border-radius: var(--radius);
    overflow: hidden;
    border: 1px solid var(--border);
    box-shadow: 0 2px 8px rgba(0,0,0,0.04);
    transition: transform 0.15s;
}
.book-card:hover { transform: translateY(-4px); }
.book-cover { width: 100%; height: 240px; object-fit: cover; background: #e9ecef; }
.book-info { padding: 14px; }
.book-title { font-weight: 600; font-size: 14px; margin-bottom: 4px; }
.book-author { font-size: 12px; color: var(--text-muted); margin-bottom: 8px; }
.book-stock { font-size: 12px; }

.empty-state { text-align: center; padding: 60px 20px; color: var(--text-muted); }
.empty-state .icon { font-size: 48px; margin-bottom: 12px; }

/* ============ PROFILE ============ */
.profile-header { display: flex; align-items: center; gap: 20px; margin-bottom: 24px; }
.profile-photo { width: 90px; height: 90px; border-radius: 50%; object-fit: cover; border: 3px solid var(--primary-light); background: #e9ecef; }

/* ============ FOOTER ============ */
.footer { text-align: center; padding: 20px; color: var(--text-muted); font-size: 13px; }

/* ============ RESPONSIVE ============ */
@media (max-width: 768px) {
    .admin-body { flex-direction: column; }
    .sidebar { width: 100%; height: auto; max-height: 100vh; position: sticky; top: 0; overflow-y: auto; z-index: 200; }
    .navbar { flex-direction: column; align-items: flex-start; }
}

/* =========================================================
   DARK MODE
   ========================================================= */
:root[data-theme="dark"] {
    --bg: #14181a;
    --card-bg: #1e2429;
    --text: #e8ecef;
    --text-muted: #9aa5ab;
    --border: #303a40;
}
:root[data-theme="dark"] table th { background: #262e33; }
:root[data-theme="dark"] table th { color: #eaf5ee; }
:root[data-theme="dark"] table tr:hover { background: #232a2e; }
:root[data-theme="dark"] .book-cover { background: #2a3236; }
:root[data-theme="dark"] .stat-card,
:root[data-theme="dark"] .card,
:root[data-theme="dark"] .book-card,
:root[data-theme="dark"] .auth-card { box-shadow: 0 2px 10px rgba(0,0,0,0.3); }
:root[data-theme="dark"] .profile-photo,
:root[data-theme="dark"] .no-avatar { background: #2a3236; }

/* Perbaikan kontras teks di dark mode (elemen yang tadinya pakai warna gelap tetap) */
:root[data-theme="dark"] .page-title { color: #7fcf9e; }
:root[data-theme="dark"] .stat-card .stat-number { color: #7fcf9e; }
:root[data-theme="dark"] .peringkat-angka { color: #7fcf9e; }
:root[data-theme="dark"] .btn-secondary { background: #333d44; color: #eef2f0; border: 1px solid #454f56; }
:root[data-theme="dark"] .category-tabs a { color: var(--text); }
:root[data-theme="dark"] .book-title,
:root[data-theme="dark"] .book-author { color: var(--text); }
:root[data-theme="dark"] .book-author { color: var(--text-muted); }

/* ============ NOTIFIKASI LONCENG ============ */
.notif-wrapper { position: relative; display: inline-block; }
.notif-bell {
    background: rgba(255,255,255,0.12);
    border: none;
    color: #fff;
    font-size: 18px;
    padding: 8px 12px;
    border-radius: 8px;
    cursor: pointer;
    position: relative;
}
.notif-bell:hover { background: rgba(255,255,255,0.22); }
.notif-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    background: var(--danger);
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    padding: 2px 6px;
    border-radius: 10px;
    line-height: 1.4;
}
.notif-dropdown {
    display: none;
    position: absolute;
    right: 0;
    top: calc(100% + 8px);
    width: 300px;
    max-height: 360px;
    overflow-y: auto;
    background: var(--card-bg);
    color: var(--text);
    border-radius: 10px;
    box-shadow: 0 8px 30px rgba(0,0,0,0.25);
    z-index: 500;
}
.notif-dropdown.show { display: block; }
.notif-dropdown-title { font-weight: 700; padding: 14px 16px; border-bottom: 1px solid var(--border); }
.notif-item {
    display: block;
    padding: 12px 16px;
    font-size: 13px;
    color: var(--text);
    border-bottom: 1px solid var(--border);
}
.notif-item:hover { background: rgba(20,108,67,0.08); }
.notif-item:last-child { border-bottom: none; }
.notif-empty { color: var(--text-muted); text-align: center; }
.notif-bell-sidebar { color: #fff; }

/* Dropdown notifikasi DI SIDEBAR ADMIN pakai posisi "fixed" (bukan absolute)
   supaya tidak ikut terpotong oleh overflow-y:auto sidebar yang sempit (260px). */
.sidebar .notif-dropdown {
    position: fixed;
    top: 88px;
    left: 16px;
    right: auto;
    width: 300px;
    max-width: calc(100vw - 32px);
}

/* ============ TOGGLE TEMA GELAP/TERANG ============ */
.theme-toggle {
    background: rgba(255,255,255,0.12);
    border: none;
    color: #fff;
    font-size: 16px;
    padding: 8px 12px;
    border-radius: 8px;
    cursor: pointer;
}
.theme-toggle:hover { background: rgba(255,255,255,0.22); }
.theme-toggle-sidebar {
    display: flex;
    align-items: center;
    gap: 8px;
    width: calc(100% - 40px);
    margin: 10px 20px;
    background: rgba(255,255,255,0.08);
    color: #dce7e0;
    font-size: 14px;
    text-align: left;
}

/* ============ CAROUSEL LANDING PAGE ============ */
.carousel-wrapper { overflow: hidden; width: 100%; max-width: 900px; margin: 0 auto; }
.carousel-track { display: flex; gap: 16px; animation: carousel-scroll 25s linear infinite; width: max-content; }
.carousel-track:hover { animation-play-state: paused; }
.carousel-item {
    width: 130px;
    flex-shrink: 0;
    background: #fff;
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 4px 14px rgba(0,0,0,0.15);
}
.carousel-item img { width: 100%; height: 170px; object-fit: cover; display: block; }
.carousel-item .carousel-caption { padding: 8px; font-size: 11px; color: #333; text-align: center; }
@keyframes carousel-scroll {
    0% { transform: translateX(0); }
    100% { transform: translateX(-50%); }
}

/* ============ TESTIMONI LANDING PAGE ============ */
.testimoni-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 18px; max-width: 900px; margin: 0 auto; }
.testimoni-card {
    background: rgba(255,255,255,0.1);
    border: 1px solid rgba(255,255,255,0.2);
    border-radius: 12px;
    padding: 20px;
    text-align: left;
    backdrop-filter: blur(4px);
}
.testimoni-card .bintang { color: #ffd747; font-size: 14px; margin-bottom: 8px; }
.testimoni-card p { font-size: 13px; opacity: 0.95; margin-bottom: 12px; line-height: 1.6; }
.testimoni-card .nama { font-weight: 700; font-size: 13px; }
.testimoni-card .buku { font-size: 12px; opacity: 0.8; }

/* ============ KARTU REMINDER OTOMATIS (selalu kontras, tak peduli tema) ============ */
.kartu-reminder-otomatis {
    background: #eaf6ee;
    border: 1px solid #b9dfc4;
    color: #0a3622;
}
.kartu-reminder-otomatis h3,
.kartu-reminder-otomatis p { color: #0a3622; }
