@import url("https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap");

:root {
    /* MONOCHROME NAVY THEME */
    --bg: #0b1220;
    --bg-2: #0e1830;
    --card: rgba(255, 255, 255, 0.06);
    --card-2: rgba(255, 255, 255, 0.04);
    --stroke: rgba(255, 255, 255, 0.10);
    --stroke-2: rgba(0, 0, 0, 0.30);
    --text: rgba(255, 255, 255, 0.92);
    --muted: rgba(255, 255, 255, 0.70);

    --radius: 24px;
    --inner-radius: 18px;

    --shadow: 0 16px 36px rgba(0, 0, 0, 0.35);
    --shadow-soft: 0 8px 20px rgba(0, 0, 0, 0.25);

    --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

* {
    box-sizing: border-box;
}

/* ===== GRID RESPONSIF 4 KOLOM ===== */
.book-grid {
    max-width: 1280px;
    margin: 40px auto;
    padding: 0 20px;
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 20px;
    align-items: start;
}

@media (max-width: 1100px) {
    .book-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (max-width: 820px) {
    .book-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 18px;
    }
}

@media (max-width: 520px) {
    .book-grid {
        grid-template-columns: 1fr;
        gap: 16px;
    }
}

/* ===== CARD CONTAINER (ukuran seragam) ===== */
.book-card {
    perspective: 1100px;
    width: 100%;
    height: 360px;
}

.book-card__inner {
    position: relative;
    width: 100%;
    height: 100%;
    border-radius: var(--radius);
    background: linear-gradient(180deg, var(--card) 0%, var(--card-2) 100%);
    border: 1px solid var(--stroke);
    box-shadow: var(--shadow-soft);
    overflow: hidden;
    transform-style: preserve-3d;
    transition: transform 520ms var(--ease), box-shadow 320ms var(--ease);
}

/* Hover lift */
.book-card:hover .book-card__inner {
    transform: translateY(-6px);
    box-shadow: var(--shadow);
}

/* Shine effect halus */
.book-card__inner::before {
    content: "";
    position: absolute;
    inset: -120px;
    background: linear-gradient(120deg,
            rgba(255, 255, 255, 0) 30%,
            rgba(255, 255, 255, 0.16) 48%,
            rgba(255, 255, 255, 0) 62%);
    transform: translateX(-65%) rotate(10deg);
    transition: transform 800ms var(--ease);
    pointer-events: none;
    z-index: 1;
}

.book-card:hover .book-card__inner::before {
    transform: translateX(60%) rotate(10deg);
}

/* Flip state */
.book-card.is-flipped .book-card__inner {
    transform: rotateY(180deg);
}

/* ===== FACES (FRONT & BACK) ===== */
.book-card__face {
    position: absolute;
    inset: 0;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
    padding: 14px;
    display: flex;
    flex-direction: column;
}

.book-card__front {
    z-index: 2;
}

.book-card__back {
    transform: rotateY(180deg);
    z-index: 1;
}

/* ===== MEDIA CONTAINER (cover area) ===== */
.book-card__media {
    position: relative;
    width: 100%;
    height: 240px;
    border-radius: var(--inner-radius);
    overflow: hidden;
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.10);
    background: rgba(0, 0, 0, 0.2);
    flex-shrink: 0;
}

.book-card__cover {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;
    display: block;
}

/* ===== ICON INFO (pojok kanan atas) ===== */
.book-card__info {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: 1px solid rgba(255, 255, 255, 0.35);
    background: rgba(255, 255, 255, 0.16);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    color: rgba(255, 255, 255, 0.92);
    font-size: 13px;
    font-weight: 600;
    font-family: Inter, sans-serif;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 8px 18px rgba(0, 0, 0, 0.35);
    transition: transform 220ms var(--ease), background 220ms var(--ease), box-shadow 220ms var(--ease);
    z-index: 10;
    user-select: none;
}

.book-card__info:hover {
    transform: scale(1.08);
    background: rgba(255, 255, 255, 0.22);
    box-shadow: 0 14px 28px rgba(0, 0, 0, 0.45);
}

/* ===== FOOTER (bagian bawah card) ===== */
.book-card__footer {
    margin-top: auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    border-radius: 14px;
    background: rgba(0, 0, 0, 0.28);
    border: 1px solid rgba(255, 255, 255, 0.08);
    box-shadow: 0 8px 18px rgba(0, 0, 0, 0.30);
    flex-shrink: 0;
}

.book-card__cat {
    font-family: Inter, sans-serif;
    font-weight: 700;
    font-size: 13px;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
}

.book-card__count {
    font-family: Inter, sans-serif;
    font-weight: 600;
    font-size: 12px;
    color: rgba(255, 255, 255, 0.75);
    white-space: nowrap;
    margin-left: 8px;
}

/* ===== BACK SIDE ===== */
.book-card__back-content {
    height: 100%;
    border-radius: var(--inner-radius);
    padding: 20px;
    background: rgba(0, 0, 0, 0.25);
    border: 1px solid rgba(255, 255, 255, 0.08);
    display: flex;
    flex-direction: column;
    gap: 10px;
    overflow-y: auto;
}

.book-card__badge {
    align-self: flex-start;
    padding: 6px 12px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.12);
    border: 1px solid rgba(255, 255, 255, 0.12);
    font-family: Inter, sans-serif;
    font-size: 11px;
    font-weight: 700;
    color: var(--text);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.book-card__title {
    margin: 0;
    font-family: Inter, sans-serif;
    font-size: 18px;
    font-weight: 800;
    line-height: 1.2;
    color: var(--text);
}

.book-card__meta {
    margin: 0;
    font-family: Inter, sans-serif;
    font-size: 12px;
    color: var(--muted);
    font-weight: 500;
}

.book-card__desc {
    margin: 0;
    font-family: Inter, sans-serif;
    font-size: 13px;
    line-height: 1.55;
    color: rgba(255, 255, 255, 0.82);
    flex: 1;
    overflow-y: auto;
}

.book-card__actions {
    margin-top: auto;
    display: flex;
    gap: 8px;
    flex-shrink: 0;
}

.book-card__btn {
    flex: 1;
    padding: 10px 12px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.14);
    border: 1px solid rgba(255, 255, 255, 0.16);
    color: var(--text);
    text-decoration: none;
    text-align: center;
    font-family: Inter, sans-serif;
    font-weight: 700;
    font-size: 13px;
    cursor: pointer;
    transition: transform 220ms var(--ease), background 220ms var(--ease);
    display: inline-block;
}

.book-card__btn:hover {
    transform: translateY(-2px);
    background: rgba(255, 255, 255, 0.18);
}

.book-card__btn--ghost {
    background: rgba(0, 0, 0, 0.25);
    border-color: rgba(255, 255, 255, 0.12);
}

.book-card__btn--ghost:hover {
    background: rgba(0, 0, 0, 0.35);
}

/* ===== RESPONSIVE ADJUSTMENTS ===== */
@media (max-width: 520px) {
    .book-card {
        height: 340px;
    }

    .book-card__media {
        height: 220px;
    }

    .book-card__title {
        font-size: 16px;
    }

    .book-card__desc {
        font-size: 12px;
    }
}

/* --- LIBRARY DASHBOARD --- */
.library-dashboard {
    background: white;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xl);
    padding: var(--spacing-lg);
    margin-top: -60px;
    /* Overlap Hero */
    position: relative;
    z-index: 20;
    margin-bottom: var(--spacing-2xl);
    border: 1px solid var(--color-border-subtle);

    /* Local overrides for white background context */
    --color-text-primary: #111827;
    --color-text-secondary: #4B5563;
    --color-text-muted: #6B7280;
    color: var(--color-text-primary);
}

.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: var(--spacing-md);
    text-align: center;
}

.stat-panel {
    padding: var(--spacing-md);
    border-right: 1px solid var(--color-border-subtle);
}

.stat-panel:last-child {
    border-right: none;
}

.chart-container {
    position: relative;
    width: 80px;
    height: 80px;
    margin: 0 auto var(--spacing-sm) auto;
    border-radius: 50%;
    background: conic-gradient(var(--c) calc(var(--p)*1%), #f3f4f6 0);
    display: flex;
    align-items: center;
    justify-content: center;
}

.chart-donut {
    width: 65px;
    height: 65px;
    background: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 1.1rem;
    color: var(--color-text-primary);
}

.stat-label {
    font-size: 0.85rem;
    color: var(--color-text-secondary);
    font-weight: 600;
}

@media (max-width: 768px) {
    .dashboard-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: var(--spacing-lg) var(--spacing-md);
    }

    .stat-panel {
        border-right: none;
        border-bottom: 1px solid var(--color-border-subtle);
    }

    .stat-panel:nth-child(3),
    .stat-panel:nth-child(4) {
        border-bottom: none;
    }
}

/* --- SEARCH & FILTER DOCK --- */
.filter-dock {
    position: sticky;
    top: 70px;
    /* Below header */
    z-index: 90;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--color-border-subtle);
    padding: var(--spacing-md) 0;
    transition: all 0.3s ease;
}

.search-primary-row {
    display: flex;
    gap: var(--spacing-sm);
    margin-bottom: var(--spacing-sm);
}

.search-bar-modern {
    flex: 1;
    position: relative;
    display: flex;
    align-items: center;
}

.search-input-modern {
    width: 100%;
    padding: 12px 16px 12px 42px;
    border-radius: 50px;
    border: 1px solid var(--color-border);
    font-family: inherit;
    font-size: 1rem;
    background: var(--color-surface);
    transition: all 0.2s;
}

.search-input-modern:focus {
    border-color: var(--color-accent);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
    outline: none;
}

.search-icon {
    position: absolute;
    left: 14px;
    width: 20px;
    height: 20px;
    color: var(--color-text-muted);
}

.btn-filter-toggle {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: 50%;
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-filter-toggle:hover {
    background: var(--color-surface-hover);
    border-color: var(--color-text-secondary);
}

.quick-chips-row {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding-bottom: 4px;
    scrollbar-width: none;
    /* Firefox */
}

.quick-chips-row::-webkit-scrollbar {
    display: none;
}

.chip-modern {
    padding: 6px 16px;
    border-radius: 20px;
    border: 1px solid var(--color-border);
    background: white;
    font-size: 0.85rem;
    font-weight: 500;
    color: #4B5563;
    /* Dark text for white background */
    white-space: nowrap;
    cursor: pointer;
    transition: all 0.2s;
}

.chip-modern:hover {
    background: var(--color-surface-hover);
    color: var(--color-text-primary);
}

.chip-modern.active {
    background: var(--color-accent);
    border-color: var(--color-accent);
    color: white;
}

/* --- FILTER PANEL (OFF CANVAS) --- */
.filter-panel {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: white;

    /* Local overrides for white background context */
    --color-text-primary: #111827;
    --color-text-secondary: #4B5563;
    --color-text-muted: #6B7280;
    color: var(--color-text-primary);

    z-index: 1000;
    border-top-left-radius: 20px;
    border-top-right-radius: 20px;
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.15);
    transform: translateY(100%);
    transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    max-height: 85vh;
    display: flex;
    flex-direction: column;
}

.filter-panel.open {
    transform: translateY(0);
}

.filter-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 999;
    display: none;
    opacity: 0;
    transition: opacity 0.3s;
}

.filter-panel-header {
    padding: var(--spacing-md) var(--spacing-lg);
    border-bottom: 1px solid var(--color-border-subtle);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.filter-panel-body {
    padding: var(--spacing-lg);
    overflow-y: auto;
}

.filter-panel-footer {
    padding: var(--spacing-md) var(--spacing-lg);
    border-top: 1px solid var(--color-border-subtle);
    display: flex;
    gap: var(--spacing-md);
}

.filter-group {
    margin-bottom: var(--spacing-lg);
}

.filter-group h4 {
    font-size: 0.9rem;
    margin-bottom: var(--spacing-sm);
    color: var(--color-text-primary);
}

.filter-options {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.filter-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.tag-option {
    padding: 4px 12px;
    border-radius: 6px;
    background: var(--color-surface);
    font-size: 0.8rem;
    color: var(--color-text-secondary);
    cursor: pointer;
    border: 1px solid transparent;
}

.tag-option:hover,
.tag-option.selected {
    background: #E0F2FE;
    color: var(--color-accent);
    border-color: var(--color-accent);
}

/* --- SHELF/RAK --- */
.shelf-section {
    padding: var(--spacing-xl) 0;
}

.shelf-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    margin-bottom: var(--spacing-lg);
}

.shelf-grid {
    display: flex;
    gap: var(--spacing-md);
    overflow-x: auto;
    padding-bottom: var(--spacing-md);
    scroll-behavior: smooth;
    -ms-overflow-style: none;
    scrollbar-width: none;
}

.shelf-grid::-webkit-scrollbar {
    display: none;
}

.shelf-book {
    min-width: 140px;
    width: 140px;
    flex-shrink: 0;
}

/* --- UTILS --- */
.btn--outline-light {
    border: 1px solid rgba(255, 255, 255, 0.4);
    color: white;
    background: transparent;
}

.btn--outline-light:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: white;
}