:root {
    --shelf-wood: #754124;
    --shelf-light: #9c5c36;
    --shelf-dark: #3b1d0e;
    --shelf-edge: #b57144;
    --room-bg: #1c110a;
}

body,
.page-wrapper {
    background: #0f0a07 !important;
}

/* ── TOOLBAR ─────────────────────────────────────── */
.library-toolbar {
    position: sticky;
    top: 0;
    z-index: 30;
    margin: 0 0 60px;
    padding: 18px 32px 16px;
    background: linear-gradient(to bottom, var(--shelf-light) 0%, var(--shelf-wood) 35%, var(--shelf-dark) 100%);
    border-bottom: 16px solid var(--shelf-dark);
    border-left: 20px solid var(--shelf-wood);
    border-right: 20px solid var(--shelf-wood);
    box-shadow: inset 0 8px 15px rgba(255, 255, 255, 0.15),
        inset 0 -12px 25px rgba(0, 0, 0, 0.8),
        0 10px 25px rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(8px);
}

.library-toolbar::before {
    content: '';
    position: absolute;
    inset: 0;
    background-image: url('https://www.transparenttextures.com/patterns/wood-pattern.png');
    opacity: 0.25;
    mix-blend-mode: multiply;
    pointer-events: none;
}

.library-toolbar .form-label {
    color: #c9a97a;
    font-family: 'DM Sans', sans-serif;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin-bottom: 8px;
    display: block;
}

.library-toolbar .form-control,
.library-toolbar .form-select {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: #f0dfc0 !important;
    border-radius: 8px;
    padding: 10px 16px;
    transition: all 0.3s ease;
}

.library-toolbar .form-control::placeholder {
    color: rgba(240, 223, 192, 0.5);
}

.library-toolbar .form-control:focus,
.library-toolbar .form-select:focus {
    background: rgba(255, 255, 255, 0.1);
    border-color: #c8864a;
    box-shadow: 0 0 0 3px rgba(200, 134, 74, 0.2);
    transform: translateY(-2px);
}

.library-toolbar .form-select option {
    background: #2a1810;
    color: #f0dfc0;
}

.input-group .form-control {
    background: rgba(255, 255, 255, 0.05);
    border-color: rgba(255, 255, 255, 0.1);
}

.input-group .form-control:focus {
    background: rgba(255, 255, 255, 0.1);
    border-color: #c8864a;
    box-shadow: 0 0 0 3px rgba(200, 134, 74, 0.2);
}

.btn-reload {
    background: linear-gradient(135deg, #c8864a, #a0612e);
    border: none;
    color: #fff;
    padding: 10px 18px;
    border-radius: 8px;
    font-weight: 600;
    transition: all 0.3s ease;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(200, 134, 74, 0.3);
}

.btn-reload:hover {
    background: linear-gradient(135deg, #d99454, #b06e38);
    transform: translateY(-2px);
    box-shadow: 0 6px 18px rgba(200, 134, 74, 0.4);
}

.btn-reload:active {
    transform: translateY(0);
}

.btn-reload i {
    transition: transform 0.6s ease;
}

.btn-reload.loading i {
    animation: spin 1s linear infinite;
}

@keyframes spin {
    from {
        transform: rotate(0deg);
    }

    to {
        transform: rotate(360deg);
    }
}

@keyframes pulse {

    0%,
    100% {
        opacity: 0.5;
        background-color: rgba(68, 68, 68, 0.5) !important;
    }

    50% {
        opacity: 0.8;
        background-color: rgba(100, 100, 100, 0.6) !important;
    }
}

.library-room {
    background-color: var(--shelf-dark);
    background-image: url('https://www.transparenttextures.com/patterns/wood-pattern.png');
    border-radius: 10px;
    padding: 0 0 40px;
    position: relative;
    height: 700px;
    overflow-y: auto;
    overflow-x: hidden;
    box-shadow: inset 0 0 80px rgba(0, 0, 0, 0.9), 0 20px 50px rgba(0, 0, 0, 0.5);

    /* Thick wooden frame */
    border: 20px solid var(--shelf-wood);
    border-top-color: var(--shelf-light);
    border-left-color: var(--shelf-wood);
    border-right-color: var(--shelf-dark);
    border-bottom-color: var(--shelf-dark);
}

/* ── READ TIMER (modal) ──────────────────────────── */
.ebook-read-timer {
    display: inline-flex;
    align-items: center;
    font-family: 'DM Sans', sans-serif;
    font-size: 0.9rem;
    font-weight: 600;
    color: #f0dfc0;
    background: rgba(0, 0, 0, 0.35);
    border: 1px solid var(--shelf-edge);
    border-radius: 999px;
    padding: 5px 14px;
    letter-spacing: 0.05em;
    transition: all 0.3s ease;
}

.ebook-read-timer.is-counted {
    color: #1c110a;
    background: linear-gradient(135deg, #e8c990, #c8864a);
    border-color: #e8c990;
}

/* Custom scrollbar */
.library-room::-webkit-scrollbar {
    width: 8px;
}

.library-room::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.5);
}

.library-room::-webkit-scrollbar-thumb {
    background: var(--shelf-edge);
    border-radius: 4px;
}

.library-room::-webkit-scrollbar-thumb:hover {
    background: #c8864a;
}

.room-title {
    font-family: 'Playfair Display', serif;
    color: #e8c990;
    font-size: 2rem;
    font-weight: 700;
    text-align: center;
    margin-bottom: 50px;
    position: relative;
    text-shadow: 0 4px 15px rgba(0, 0, 0, 0.8);
    z-index: 10;
}

.room-title span {
    display: block;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.3em;
    color: #bfa57d;
    margin-bottom: 5px;
}

.shelf-row {
    display: flex;
    flex-direction: column;
    margin-bottom: 80px;
    position: relative;
    z-index: 1;
}

/* Base papan rak bagian depan */
.shelf-plank {
    position: relative;
    height: 30px;
    width: 100%;
    background-color: var(--shelf-wood);
    background-image: linear-gradient(to right, rgba(0, 0, 0, 0.4) 0%, rgba(0, 0, 0, 0) 10%, rgba(0, 0, 0, 0) 90%, rgba(0, 0, 0, 0.4) 100%), url('https://www.transparenttextures.com/patterns/wood-pattern.png');
    box-shadow: 0 15px 25px rgba(0, 0, 0, 0.8), inset 0 2px 3px rgba(255, 255, 255, 0.15);
    z-index: 3;
}

/* Papan atas rak (kedalaman) menggunakan perspective */
.shelf-plank::before {
    content: '';
    position: absolute;
    bottom: 100%;
    left: 0;
    right: 0;
    height: 120px;
    /* Kedalaman rak */
    background-color: var(--shelf-light);
    background-image:
        linear-gradient(to bottom, rgba(0, 0, 0, 0.8) 0%, rgba(0, 0, 0, 0.1) 80%, rgba(0, 0, 0, 0) 100%),
        url('https://www.transparenttextures.com/patterns/wood-pattern.png');
    transform-origin: bottom;
    transform: perspective(1000px) rotateX(60deg);
    border-top: 2px solid rgba(0, 0, 0, 0.6);
    z-index: 1;
}

.books-row {
    display: flex;
    flex-wrap: wrap;
    gap: 25px;
    align-items: flex-end;
    justify-content: space-between;
    padding: 0 40px;
    margin-bottom: 20px;
    z-index: 5;
    position: relative;
    min-height: 200px;
    perspective: 1200px;
}

.book-wrapper {
    position: relative;
    width: 130px;
    height: 190px;
    perspective: 1200px;
    /* Perspektif per buku */
    cursor: pointer;
    margin-bottom: 5px;
    transition: all 0.3s ease;
    flex-shrink: 0;
}

/* Variasi ukuran buku dihapus - semua ukuran sama */

.book-wrapper.book-tilted-left {
    transform: rotateZ(-1deg);
}

.book-wrapper.book-tilted-right {
    transform: rotateZ(1deg);
}

.book-shadow {
    position: absolute;
    width: 90%;
    height: 12px;
    bottom: -6px;
    /* lebih dekat ke rak */
    left: 5%;

    background: radial-gradient(ellipse at center,
            rgba(0, 0, 0, 0.7) 0%,
            rgba(0, 0, 0, 0.3) 60%,
            rgba(0, 0, 0, 0) 100%);

    filter: blur(6px);
    transform: scaleY(0.5);
    opacity: 0.9;
}

.book-inner {
    position: absolute;
    width: 100%;
    height: 100%;
    transform-style: preserve-3d;
    transition: transform 0.5s cubic-bezier(0.2, 0.8, 0.2, 1);

    transform: rotateY(-8deg) translateZ(-5px);

    /* Subtle angle untuk 3D effect yang subtle */
    z-index: 2;
}

/* Efek Hover: Buku ditarik keluar */
.book-wrapper:hover .book-inner {
    transform: rotateY(0deg) translateZ(40px) translateY(-15px);
}

.book-wrapper:hover .book-shadow {
    transform: perspective(600px) rotateX(70deg) skewX(-10deg) translateZ(-10px) scale(1.2);
    filter: blur(12px);
    opacity: 0.5;
}

/* Bagian Depan Buku (Cover) */
.book-front {
    position: absolute;
    width: 100%;
    height: 100%;
    transform: translateZ(12px);
    /* Setengah ketebalan buku */
    background: #fff;
    border-radius: 0 3px 3px 0;
    box-shadow:
        inset 3px 0 5px rgba(255, 255, 255, 0.3),
        inset -1px 0 2px rgba(0, 0, 0, 0.2),
        inset 0 0 15px rgba(0, 0, 0, 0.08);
    overflow: hidden;
}

.book-front img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 0 3px 3px 0;
    display: block;
    transition: all 0.3s ease;
}

.book-wrapper:hover .book-front img {
    filter: brightness(1.05) saturate(1.1);
}

/* Bagian Punggung Buku (Spine) */
.book-spine {
    position: absolute;
    width: 24px;
    /* Ketebalan buku */
    height: 100%;
    /* Warna default spine, bisa gelap agar elegan */
    background: linear-gradient(90deg, #1a1a1a 0%, #2a2a2a 25%, #333 50%, #2a2a2a 75%, #1a1a1a 100%);
    left: 0;
    transform-origin: left;
    transform: rotateY(-90deg);
    border-radius: 2px 0 0 2px;
    box-shadow:
        inset 0 0 10px rgba(0, 0, 0, 0.8),
        inset 2px 0 5px rgba(255, 255, 255, 0.1);
    border-left: 1px solid rgba(255, 255, 255, 0.08);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.spine-text {
    position: absolute;
    width: 90%;
    height: 80%;
    font-size: 0.5rem;
    color: rgba(255, 255, 255, 0.4);
    text-align: center;
    display: flex;
    align-items: center;
    justify-content: center;
    word-break: break-word;
    line-height: 1.2;
    padding: 4px;
    font-weight: 600;
    text-transform: uppercase;
    writing-mode: vertical-rl;
    text-orientation: mixed;
    letter-spacing: 1px;
}

/* Bagian Atas Kertas (Top Pages) */
.book-top {
    position: absolute;
    width: 100%;
    height: 24px;
    background: #e4e0d8;
    background-image: repeating-linear-gradient(to bottom, transparent 0px, transparent 1px, rgba(0, 0, 0, 0.05) 1px, rgba(0, 0, 0, 0.05) 2px);
    top: 0;
    transform-origin: top;
    transform: rotateX(90deg);
    box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.2);
}

/* Bagian Samping Kertas (Right Pages) */
.book-right {
    position: absolute;
    width: 24px;
    height: 100%;
    background: #e4e0d8;
    background-image: repeating-linear-gradient(to right, transparent 0px, transparent 1px, rgba(0, 0, 0, 0.05) 1px, rgba(0, 0, 0, 0.05) 2px);
    right: 0;
    transform-origin: right;
    transform: rotateY(90deg);
    box-shadow: inset 0 0 10px rgba(0, 0, 0, 0.2);
}


/* Tooltip Hover */
.book-tooltip {
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%) translateY(-10px);
    background: rgba(15, 10, 5, 0.95);
    color: #fff;
    padding: 10px 14px;
    border-radius: 8px;
    width: 160px;
    font-size: 0.8rem;
    opacity: 0;
    visibility: hidden;
    transition: 0.3s;
    border: 1px solid var(--shelf-edge);
    pointer-events: none;
    z-index: 20;
    text-align: center;
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.5);
}

/* Statistik buka/baca di tooltip */
.book-tooltip .ebook-stat span {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    color: #e8c990;
}

.book-tooltip .ebook-stat i {
    color: var(--shelf-edge);
}

/* efek hover biar hidup */
.book-wrapper:hover .book-title-overlay {
    bottom: -52px;
    background: linear-gradient(to bottom,
            rgba(0, 0, 0, 0.85),
            rgba(0, 0, 0, 0.95));
    box-shadow:
        0 6px 16px rgba(0, 0, 0, 0.9),
        inset 0 1px 0 rgba(255, 255, 255, 0.15);
}

.book-front::after {
    content: '';
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    height: 65%;

    background: linear-gradient(to top,
            rgba(0, 0, 0, 0.85) 0%,
            rgba(0, 0, 0, 0.45) 40%,
            rgba(0, 0, 0, 0.0) 100%);

    border-radius: 0 0 3px 3px;
    pointer-events: none;
}

.book-wrapper {
    overflow: visible;
    /* penting supaya card bisa keluar */
}

.book-wrapper:hover .book-tooltip {
    opacity: 1;
    visibility: visible;
    transform: translateX(-50%) translateY(0);
}

.book-title-overlay {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    padding: 10px 8px;
    background: linear-gradient(to top,
            rgba(0, 0, 0, 0.85) 0%,
            rgba(0, 0, 0, 0.6) 50%,
            rgba(0, 0, 0, 0.0) 100%);
    color: #f0dfc0;
    font-size: 0.75rem;
    font-weight: 600;
    line-height: 1.3;
    text-align: center;
    border-radius: 0 0 3px 3px;
    z-index: 5;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.library-toolbar .input-group-text {
    background: rgba(30, 18, 10, 0.9);
    border: 2px solid #b57144;
    border-right: 0;
    color: #e8c990;
    border-radius: 10px 0 0 10px;
    display: flex;
    align-items: center;
}

/* Toolbar row tetap sama seperti sebelumnya */
.library-toolbar .toolbar-row {
    max-width: 100%;
    margin: 0 auto;
    display: flex;
    align-items: center;
    gap: 14px;
    flex-wrap: wrap;
}

.library-toolbar .control-group {
    display: flex;
    align-items: center;
    gap: 8px;
    position: relative;
}

.library-toolbar .control-group .icon-btn {
    width: 46px;
    height: 46px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.08);
    border: 2px solid var(--shelf-edge);
    border-radius: 10px;
    color: #e8c990;
    font-size: 1.35rem;
    transition: all 0.3s ease;
    cursor: pointer;
}

.library-toolbar .control-group .icon-btn:hover {
    background: rgba(200, 134, 74, 0.25);
    border-color: #d9a46f;
    transform: translateY(-2px);
}

.library-toolbar .form-control {
    min-width: 260px;
    padding: 12px 16px;
    font-size: 1.02rem;
}

.library-toolbar .form-select {
    padding: 12px 14px;
    font-size: 1rem;
    min-width: 145px;
}

.library-toolbar .icon-btn {
    width: 48px;
    height: 48px;
    font-size: 1.4rem;
}

.library-toolbar .form-control,
.library-toolbar .form-select {
    background: rgba(30, 18, 10, 0.9);
    border: 2px solid var(--shelf-edge);
    color: #f0dfc0;
    border-radius: 10px;
    padding: 10px 14px;
    font-size: 1rem;
    min-width: 220px;
    box-shadow: inset 0 3px 10px rgba(0, 0, 0, 0.5);
}

.library-toolbar .form-control:focus,
.library-toolbar .form-select:focus {
    border-color: #e8b070;
    box-shadow: 0 0 0 4px rgba(232, 176, 112, 0.3);
}

/* Tooltip untuk icon */
.control-group .tooltip-text {
    position: absolute;
    bottom: -28px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(20, 15, 10, 0.95);
    color: #e8c990;
    font-size: 0.75rem;
    padding: 4px 10px;
    border-radius: 6px;
    white-space: nowrap;
    opacity: 0;
    visibility: hidden;
    transition: 0.2s;
    pointer-events: none;
    z-index: 5;
}

.control-group:hover .tooltip-text {
    opacity: 1;
    visibility: visible;
    bottom: -32px;
}

.library-toolbar .input-group-text {
    background: rgba(30, 18, 10, 0.9);
    border: 2px solid #b57144;
    border-right: 0;
    color: #e8c990;
    border-radius: 10px 0 0 10px;
    display: flex;
    align-items: center;
}

.select-icon {
    position: relative;
    width: 48px;
    height: 48px;
}

/* Select asli (disembunyikan tapi tetap bisa diklik) */
.select-icon select {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: pointer;
    z-index: 2;
}

/* Icon tampilannya */
.select-icon .icon {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;

    background: rgba(255, 255, 255, 0.08);
    border: 2px solid var(--shelf-edge);
    border-radius: 10px;
    color: #e8c990;
    font-size: 1.2rem;

    transition: all 0.3s ease;
}

/* Hover effect */
.select-icon:hover .icon {
    background: rgba(200, 134, 74, 0.25);
    border-color: #d9a46f;
}

@media (max-width: 768px) {
    .library-toolbar {
        padding: 12px 15px 10px;
        margin-bottom: 40px;
        border-left-width: 10px;
        border-right-width: 10px;
        border-bottom-width: 12px;
    }

    .library-toolbar .toolbar-row {
        flex-wrap: wrap;
        justify-content: center;
        gap: 12px;
    }

    .library-toolbar .control-group.flex-grow-1 {
        flex: 0 0 100%;
        order: -1;
    }

    .library-toolbar .input-group {
        flex-wrap: nowrap !important;
        width: 100%;
    }

    .library-toolbar .form-control {
        min-width: 0;
    }

    .library-toolbar .form-select {
        display: none;
    }

    .library-room {
        height: 550px;
        border-width: 12px;
    }

    .books-row {
        padding: 0 15px;
    }
}
