/* ===================================== */
/* 1. Global Styles & Variables          */
/* ===================================== */
:root {
    --primary-color: #007bff;
    --secondary-color: #6c757d;
    --accent-color: #28a745;
    --text-color: #343a40;
    --text-color-light: #6c757d;
    --background-color: #f8f9fa;
    --surface-color: #ffffff;
    --border-color: #dee2e6;
    --shadow-light: 0 2px 4px rgba(0, 0, 0, 0.08);
    --shadow-medium: 0 4px 8px rgba(0, 0, 0, 0.1);

    --font-family-sans: 'Inter', sans-serif; /* Kita akan pakai Inter dari Google Fonts */
    --font-size-base: 1rem; /* 16px */
    --line-height-base: 1.6;

    --spacing-xs: 0.25rem;
    --spacing-sm: 0.5rem;
    --spacing-md: 1rem;
    --spacing-lg: 1.5rem;
    --spacing-xl: 2rem;
    --spacing-xxl: 3rem;

    --border-radius-sm: 4px;
    --border-radius-md: 8px;
    --border-radius-lg: 12px;
}

/* Mengimpor font Inter dari Google Fonts */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-family-sans);
    font-size: var(--font-size-base);
    line-height: var(--line-height-base);
    color: var(--text-color);
    background-color: var(--background-color);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 var(--spacing-md);
    width: 100%;
}

a {
    color: var(--primary-color);
    text-decoration: none;
    transition: color 0.2s ease-in-out;
}

a:hover {
    color: var(--primary-color); /* Bisa ganti dengan warna yang sedikit lebih gelap jika mau */
    text-decoration: underline;
}

button {
    cursor: pointer;
    border: none;
    background: none;
    font-family: inherit;
    font-size: inherit;
}

/* ===================================== */
/* 2. Typography                         */
/* ===================================== */
h1, h2, h3, h4, h5, h6 {
    color: var(--text-color);
    margin-bottom: var(--spacing-md);
    line-height: 1.2;
}

h1 { font-size: 2.5rem; font-weight: 700; }
h2 { font-size: 2rem; font-weight: 600; }
h3 { font-size: 1.75rem; font-weight: 600; }
/* ... (Tambahkan lebih banyak heading jika perlu) */

p {
    margin-bottom: var(--spacing-md);
}

/* ===================================== */
/* 3. Buttons & Forms                    */
/* ===================================== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: var(--spacing-sm) var(--spacing-lg);
    border-radius: var(--border-radius-md);
    font-weight: 500;
    transition: background-color 0.2s ease, color 0.2s ease, border-color 0.2s ease;
    text-decoration: none;
    border: 1px solid transparent;
}

.btn-primary {
    background-color: var(--primary-color);
    color: var(--surface-color);
}

.btn-primary:hover {
    background-color: darken(var(--primary-color), 10%); /* Akan membutuhkan preprocessor atau manual color */
    background-color: #0056b3; /* Contoh warna hover */
}

.btn-secondary {
    background-color: var(--secondary-color);
    color: var(--surface-color);
}

.btn-secondary:hover {
    background-color: darken(var(--secondary-color), 10%);
    background-color: #545b62; /* Contoh warna hover */
}

.btn-outline {
    background-color: transparent;
    color: var(--primary-color);
    border-color: var(--primary-color);
}

.btn-outline:hover {
    background-color: var(--primary-color);
    color: var(--surface-color);
}

.btn-sm {
    padding: var(--spacing-xs) var(--spacing-md);
    font-size: 0.875rem;
}

input[type="text"],
input[type="email"],
input[type="password"],
textarea {
    width: 100%;
    padding: var(--spacing-sm);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-sm);
    font-family: inherit;
    font-size: var(--font-size-base);
    margin-bottom: var(--spacing-md);
    transition: border-color 0.2s ease;
}

input:focus, textarea:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 0.2rem rgba(0, 123, 255, 0.25);
}

/* ===================================== */
/* 4. Header & Navigation                */
/* ===================================== */
.header {
    background-color: var(--surface-color);
    box-shadow: var(--shadow-light);
    padding: var(--spacing-md) 0;
    position: sticky;
    top: 0;
    z-index: 1000;
}

.header .container {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo {
    display: flex;
    align-items: center;
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary-color);
}

.logo-img {
    height: 32px; /* Sesuaikan ukuran logo */
    margin-right: var(--spacing-sm);
}

.nav {
    display: flex;
    align-items: center;
}

.nav-list {
    list-style: none;
    display: flex;
    gap: var(--spacing-lg);
    margin-right: var(--spacing-xl);
}

.nav-link {
    color: var(--text-color);
    font-weight: 500;
    padding: var(--spacing-xs) 0;
    position: relative;
}

.nav-link::after {
    content: '';
    position: absolute;
    left: 0;
    bottom: -2px;
    width: 0;
    height: 2px;
    background-color: var(--primary-color);
    transition: width 0.3s ease;
}

.nav-link:hover::after,
.nav-link.active::after {
    width: 100%;
}

.auth-buttons {
    display: flex;
    gap: var(--spacing-sm);
}

.user-menu {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    background-color: var(--background-color);
    padding: var(--spacing-sm);
    border-radius: var(--border-radius-md);
    box-shadow: var(--shadow-light);
}

.user-menu #user-email {
    font-weight: 500;
    color: var(--text-color);
    margin-right: var(--spacing-sm);
}

.menu-toggle {
    display: none; /* Sembunyikan secara default di desktop */
    flex-direction: column;
    justify-content: space-between;
    width: 30px;
    height: 21px;
    background: transparent;
    border: none;
    padding: 0;
}

.menu-toggle .bar {
    display: block;
    width: 100%;
    height: 3px;
    background-color: var(--text-color);
    border-radius: 3px;
    transition: all 0.3s ease-in-out;
}

/* ===================================== */
/* 5. Main Content & Sections            */
/* ===================================== */
.main-content {
    flex-grow: 1; /* Agar main content mengisi ruang yang tersisa */
    padding: var(--spacing-xxl) 0;
}

.page {
    display: none; /* Semua halaman disembunyikan secara default */
}

.page.active {
    display: block; /* Halaman yang aktif akan ditampilkan */
}

.hero-section {
    text-align: center;
    padding: var(--spacing-xxl) 0;
    margin-bottom: var(--spacing-xl);
    background: linear-gradient(135deg, var(--primary-color) 0%, #6a93cb 100%);
    color: var(--surface-color);
    border-radius: var(--border-radius-lg);
    box-shadow: var(--shadow-medium);
}

.hero-section h1 {
    color: var(--surface-color);
    margin-bottom: var(--spacing-md);
}

.hero-section p {
    font-size: 1.15rem;
    max-width: 600px;
    margin: 0 auto var(--spacing-xl) auto;
    color: rgba(255, 255, 255, 0.9);
}

.search-bar {
    display: flex;
    justify-content: center;
    margin-top: var(--spacing-xl);
    max-width: 500px;
    margin-left: auto;
    margin-right: auto;
}

.search-bar input {
    flex-grow: 1;
    border-radius: var(--border-radius-md) 0 0 var(--border-radius-md);
    border: none;
    padding: var(--spacing-md);
    font-size: 1rem;
    box-shadow: var(--shadow-light);
}

.search-bar input:focus {
    box-shadow: 0 0 0 0.2rem rgba(255, 255, 255, 0.25);
    border-color: transparent; /* Hilangkan border default */
}

.search-bar button {
    border-radius: 0 var(--border-radius-md) var(--border-radius-md) 0;
    padding: var(--spacing-md) var(--spacing-lg);
    font-size: 1rem;
    background-color: var(--accent-color);
    color: var(--surface-color);
    box-shadow: var(--shadow-light);
}

.search-bar button:hover {
    background-color: darken(var(--accent-color), 10%);
    background-color: #218838; /* Contoh warna hover */
}


.content-grid {
    padding-top: var(--spacing-xl);
    padding-bottom: var(--spacing-xl);
}

.content-grid h2 {
    text-align: center;
    margin-bottom: var(--spacing-xxl);
}

.book-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: var(--spacing-xl);
}

.book-card {
    background-color: var(--surface-color);
    border-radius: var(--border-radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow-medium);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    display: flex;
    flex-direction: column;
}

.book-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.15);
}

.book-card-image {
    width: 100%;
    height: 250px; /* Tinggi cover yang konsisten */
    object-fit: cover;
    background-color: var(--border-color); /* Placeholder saat gambar belum load */
}

.book-card-content {
    padding: var(--spacing-md);
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.book-card-title {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: var(--spacing-sm);
    color: var(--text-color);
    line-height: 1.3;
}

.book-card-author {
    font-size: 0.95rem;
    color: var(--text-color-light);
    margin-bottom: var(--spacing-md);
}

.book-card-description {
    font-size: 0.9rem;
    color: var(--text-color-light);
    line-height: 1.5;
    margin-bottom: var(--spacing-md);
    flex-grow: 1; /* Agar deskripsi mengisi ruang */
    display: -webkit-box;
    -webkit-line-clamp: 3; /* Batasi deskripsi hingga 3 baris */
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
}

.book-card .btn {
    width: 100%;
    text-align: center;
    margin-top: auto; /* Dorong tombol ke bawah */
}

/* Skeleton Loading Effect */
.skeleton {
    animation: pulse 1.5s infinite ease-in-out;
    background: linear-gradient(-90deg, #f0f0f0 0%, #e0e0e0 50%, #f0f0f0 100%);
    background-size: 200% 100%;
}

.book-card.skeleton {
    height: 350px; /* Tinggi total card skeleton */
    border-radius: var(--border-radius-lg);
}
.book-card.skeleton .book-card-image {
    height: 200px; /* Bagian gambar */
    background: none;
}
.book-card.skeleton .book-card-content {
    padding: var(--spacing-md);
}
.book-card.skeleton .book-card-title {
    height: 20px;
    background-color: rgba(0,0,0,0.08);
    border-radius: var(--border-radius-sm);
    margin-bottom: var(--spacing-sm);
}
.book-card.skeleton .book-card-author {
    height: 16px;
    width: 70%;
    background-color: rgba(0,0,0,0.08);
    border-radius: var(--border-radius-sm);
    margin-bottom: var(--spacing-md);
}
.book-card.skeleton .book-card-description {
    height: 48px; /* 3 baris */
    background-color: rgba(0,0,0,0.08);
    border-radius: var(--border-radius-sm);
}


@keyframes pulse {
    0% { background-position: -100% 0; }
    100% { background-position: 100% 0; }
}


/* ===================================== */
/* 6. Footer                             */
/* ===================================== */
.footer {
    background-color: var(--text-color);
    color: var(--background-color);
    padding: var(--spacing-xl) 0;
    text-align: center;
    margin-top: var(--spacing-xxl);
}

.footer .container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--spacing-md);
}

.footer-links a {
    color: var(--background-color);
    margin: 0 var(--spacing-sm);
    font-size: 0.9rem;
}

.footer-links a:hover {
    color: var(--primary-color);
    text-decoration: none;
}

/* ===================================== */
/* 7. Auth Forms                         */
/* ===================================== */
.auth-form-container {
    max-width: 400px;
    margin: var(--spacing-xxl) auto;
    padding: var(--spacing-xl);
    background-color: var(--surface-color);
    border-radius: var(--border-radius-lg);
    box-shadow: var(--shadow-medium);
    text-align: center;
}

.auth-form-container h2 {
    margin-bottom: var(--spacing-xl);
}

.auth-form-container form {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-md);
}

.auth-form-container button[type="submit"] {
    width: 100%;
    margin-top: var(--spacing-md);
}

.auth-form-container p {
    margin-top: var(--spacing-md);
    font-size: 0.9rem;
}

.auth-form-container p a {
    font-weight: 500;
}


/* ===================================== */
/* 8. Media Queries (Responsiveness)     */
/* ===================================== */

@media (max-width: 992px) { /* Tablet & Kecil */
    .nav-list {
        margin-right: var(--spacing-md);
    }
}

@media (max-width: 768px) { /* Mobile & Kecil */
    h1 { font-size: 2rem; }
    h2 { font-size: 1.75rem; }

    .header .container {
        flex-wrap: wrap; /* Agar elemen bisa turun baris */
        justify-content: center;
        text-align: center;
    }

    .logo {
        width: 100%;
        justify-content: center;
        margin-bottom: var(--spacing-md);
    }

    .nav {
        order: 3; /* Pindahkan nav ke bawah */
        flex-direction: column;
        width: 100%;
        margin-top: var(--spacing-md);
        display: none; /* Sembunyikan secara default di mobile */
        transition: max-height 0.3s ease-out;
        max-height: 0;
        overflow: hidden;
    }

    .nav.active {
        display: flex;
        max-height: 300px; /* Cukup tinggi untuk menampung nav items */
    }

    .nav-list {
        flex-direction: column;
        width: 100%;
        margin-right: 0;
        gap: var(--spacing-sm);
        margin-bottom: var(--spacing-md);
    }

    .nav-item {
        width: 100%;
        text-align: center;
        border-bottom: 1px solid var(--border-color);
        padding-bottom: var(--spacing-sm);
    }
    .nav-item:last-child {
        border-bottom: none;
    }

    .auth-buttons {
        width: 100%;
        justify-content: center;
    }

    .menu-toggle {
        display: flex; /* Tampilkan tombol toggle di mobile */
        position: absolute; /* Posisikan di pojok */
        right: var(--spacing-md);
        top: var(--spacing-md);
    }

    /* Animasi Toggle Hamburger */
    .menu-toggle.active .bar:nth-child(2) {
        opacity: 0;
    }
    .menu-toggle.active .bar:nth-child(1) {
        transform: translateY(9px) rotate(45deg);
    }
    .menu-toggle.active .bar:nth-child(3) {
        transform: translateY(-9px) rotate(-45deg);
    }

    .hero-section {
        padding: var(--spacing-xl) 0;
    }

    .search-bar {
        flex-direction: column;
    }

    .search-bar input,
    .search-bar button {
        border-radius: var(--border-radius-md);
        margin-bottom: var(--spacing-sm);
    }
    .search-bar button {
        margin-top: var(--spacing-sm);
    }

    .book-grid {
        grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); /* Kolom lebih kecil di mobile */
    }

    .footer .container {
        flex-direction: column;
        gap: var(--spacing-sm);
    }
}

@media (max-width: 480px) { /* Sangat Kecil */
    .container {
        padding: 0 var(--spacing-sm);
    }

    .book-grid {
        grid-template-columns: 1fr; /* Satu kolom di layar sangat kecil */
    }
}

/* ===================================== */
/* 9. Utility Classes (Opsional)         */
/* ===================================== */
.text-center { text-align: center; }
.mt-lg { margin-top: var(--spacing-lg); }
.mb-lg { margin-bottom: var(--spacing-lg); }
/* ... tambahkan utility lain sesuai kebutuhan */