
* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    padding: 0;
    width: 100%;
    min-height: 100%;
    font-family: "Segoe UI", Arial, sans-serif;
    background: #f6f8fc;
    color: #17233c;
}

body {
    overflow-x: hidden;
}



.app-container {
    width: 100%;
    min-height: 100vh;
    background: #f6f8fc;
}



.header {
    height: 108px;
    width: 100%;
    background: #ffffff;
    border-bottom: 1px solid #dce3ef;
    display: flex;
    align-items: center;
    position: relative;
    z-index: 100;
}

.header-left {
    width: 260px;
    height: 100%;
    display: flex;
    align-items: center;
    padding-left: 26px;
}

.logo {
    display: flex;
    align-items: center;
}

.logo-img {
    width: 200px !important;
    height: auto !important;
    max-height: 150px;
    object-fit: contain;
}



.hamburger-menu {
    display: none;
    width: 40px;
    height: 40px;
    border: none;
    background: transparent;
    cursor: pointer;
}

    .hamburger-menu svg {
        width: 24px;
        height: 24px;
    }



.header-center {
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: center;
}

.search-box {
    width: 500px;
    max-width: 90%;
    height: 44px;
    border: 1px solid #d9e2ef;
    background: #f8faff;
    border-radius: 12px;
    display: flex;
    align-items: center;
    padding: 0 14px;
}

.search-icon {
    width: 20px;
    height: 20px;
    color: #8aa0bd;
    flex-shrink: 0;
}

.search-box input {
    flex: 1;
    height: 100%;
    border: none;
    outline: none;
    background: transparent;
    padding: 0 12px;
    font-size: 15px;
    color: #17233c;
}

    .search-box input::placeholder {
        color: #91a3bc;
    }

.search-close {
    display: none;
    border: none;
    background: transparent;
    cursor: pointer;
}



.header-right {
    width: 100px;
    display: flex;
    justify-content: center;
    align-items: center;
}

.theme-toggle,
.mobile-search-toggle {
    width: 42px;
    height: 42px;
    border: none;
    background: transparent;
    cursor: pointer;
    color: #6e819e;
    display: flex;
    justify-content: center;
    align-items: center;
}

    .theme-toggle svg,
    .mobile-search-toggle svg {
        width: 21px;
        height: 21px;
    }

.mobile-search-toggle {
    display: none;
}



.main-layout {
    display: flex;
    width: 100%;
    min-height: calc(100vh - 108px);
}



.sidebar {
    width: 260px;
    min-width: 260px;
    background: #ffffff;
    border-right: 1px solid #dce3ef;
    padding: 30px 15px;
    min-height: calc(100vh - 108px);
}

.category-nav {
    width: 100%;
}



.nav-title {
    margin: 0 0 18px 12px;
    font-size: 16px;
    font-weight: 700;
    color: #4b5f7c;
    text-transform: uppercase;
    letter-spacing: 0.8px;
}



#categoryList {
    list-style: none !important;
    margin: 0 !important;
    padding: 0 !important;
}

    #categoryList .category-item {
        list-style: none !important;
        margin: 3px 0 !important;
        padding: 0 !important;
    }



    #categoryList .db-category-link {
        display: flex !important;
        align-items: center !important;
        gap: 12px !important;
        width: 100% !important;
        min-height: 44px !important;
        padding: 0 12px !important;
        color: #344a68 !important;
        background: transparent !important;
        text-decoration: none !important;
        border-radius: 9px !important;
        font-family: "Segoe UI", Arial, sans-serif !important;
        font-size: 15px !important;
        font-weight: 550 !important;
        cursor: pointer !important;
        transition: background 0.2s ease, color 0.2s ease, transform 0.15s ease;
    }



        #categoryList .db-category-link:hover {
            background: #f0f2ff !important;
            color: #5146e5 !important;
        }



        #categoryList .db-category-link i {
            width: 20px !important;
            min-width: 20px !important;
            text-align: center !important;
            font-size: 16px !important;
            color: #667da0 !important;
            transition: color 0.2s ease, transform 0.2s ease;
        }


        #categoryList .db-category-link:hover i {
            color: #5146e5 !important;
            transform: scale(1.05);
        }



    #categoryList .category-item.active > .db-category-link {
        background: #e9ebff !important;
        color: #4b46d8 !important;
        font-weight: 650 !important;
        position: relative !important;
    }



        #categoryList
        .category-item.active > .db-category-link::before {
            content: "" !important;
            position: absolute !important;
            left: 0 !important;
            top: 7px !important;
            bottom: 7px !important;
            width: 4px !important;
            border-radius: 5px !important;
            background: #5146e5 !important;
        }


        #categoryList
        .category-item.active > .db-category-link i {
            color: #5146e5 !important;
        }



    #categoryList
    .category-item:first-child > .db-category-link {
        background: #f4f5fb !important;
        color: #354968 !important;
        font-weight: 600 !important;
        margin-bottom: 8px !important;
        border: 1px solid #e1e5ef !important;
    }



        #categoryList
        .category-item:first-child > .db-category-link:hover {
            background: #e9ebff !important;
            color: #5146e5 !important;
            border-color: #d7d9fa !important;
        }



        #categoryList
        .category-item:first-child > .db-category-link i {
            color: #617596 !important;
        }

    #categoryList
    .category-item:first-child.active > .db-category-link {
        background: #e7e9ff !important;
        color: #4b46d8 !important;
        border-color: #d5d8fa !important;
        font-weight: 700 !important;
    }



        #categoryList
        .category-item:first-child.active > .db-category-link i {
            color: #5146e5 !important;
        }



    #categoryList .subcategory-list {
        list-style: none !important;
        margin: 3px 0 9px 18px !important;
        padding: 0 0 0 14px !important;
        border-left: 1px solid #dbe2ed !important;
    }

    #categoryList .subcategory-item {
        list-style: none !important;
        margin: 2px 0 !important;
        padding: 0 !important;
    }



    #categoryList .db-subcategory-link {
        display: flex !important;
        align-items: center !important;
        position: relative !important;
        min-height: 40px !important;
        padding: 0 10px !important;
        color: #637793 !important;
        background: transparent !important;
        text-decoration: none !important;
        font-family: "Segoe UI", Arial, sans-serif !important;
        font-size: 14px !important;
        font-weight: 450 !important;
        border-radius: 7px !important;
        cursor: pointer !important;
        transition: background 0.2s ease, color 0.2s ease;
    }


        #categoryList .db-subcategory-link::before {
            content: "" !important;
            position: absolute !important;
            left: -15px !important;
            top: 50% !important;
            width: 10px !important;
            height: 1px !important;
            background: #dbe2ed !important;
        }



        #categoryList .db-subcategory-link:hover {
            background: #f4f5ff !important;
            color: #5146e5 !important;
        }



        #categoryList .db-subcategory-link i {
            width: 15px !important;
            min-width: 15px !important;
            margin-right: 7px !important;
            font-size: 10px !important;
            color: #8192ad !important;
            transition: color 0.2s ease;
        }



        #categoryList
        .db-subcategory-link:hover
        i {
            color: #5146e5 !important;
        }



        #categoryList .db-subcategory-link.active {
            background: #e9ebff !important;
            color: #4b46d8 !important;
            font-weight: 650 !important;
        }

            #categoryList
            .db-subcategory-link.active
            i {
                color: #5146e5 !important;
            }



.content {
    flex: 1;
    min-width: 0;
    padding: 34px 32px 50px;
    background: #f6f8fc;
}


.content-header {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 28px;
}

.category-title {
    margin: 0;
    font-size: 30px;
    line-height: 1.2;
    font-weight: 700;
    color: #13233d;
}

.book-count {
    font-size: 14px;
    color: #60728c;
}


.book-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(270px, 300px));
    gap: 24px;
    align-items: stretch;
}

.book-card {
    width: 100%;
    background: #ffffff;
    border: 1px solid #dce4ef;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 2px 5px rgba(30, 50, 80, 0.05);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    display: flex;
    flex-direction: column;
}

    .book-card:hover {
        transform: translateY(-3px);
        box-shadow: 0 8px 20px rgba(30, 50, 80, 0.10);
    }



.book-cover {
    width: 100%;
    height: 235px;
    position: relative;
    background: linear-gradient(135deg, #eef2f8, #e3e9f2);
    overflow: hidden;
}

    .book-cover img {
        display: block;
        width: 100%;
        height: 100%;
        object-fit: cover;
        user-select: none;
        -webkit-user-drag: none;
    }



.file-badge {
    position: absolute;
    top: 12px;
    right: 12px;
    padding: 7px 12px;
    background: rgba(255, 255, 255, 0.96);
    border: 1px solid #dce3ee;
    border-radius: 7px;
    font-size: 11px;
    font-weight: 700;
    color: #263650;
    letter-spacing: 0.5px;
    box-shadow: 0 2px 7px rgba(0, 0, 0, 0.08);
}



.book-info {
    padding: 20px;
    flex: 1;
    display: flex;
    flex-direction: column;
}

.book-title {
    margin: 0 0 16px;
    color: #13233d;
    font-size: 17px;
    font-weight: 650;
    line-height: 1.35;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.book-author {
    margin: 0 0 13px;
    color: #48617e;
    font-size: 13px;
    line-height: 1.4;
}

.book-description {
    margin: 0 0 18px;
    color: #8a9bb3;
    font-size: 12px;
    line-height: 1.5;
    min-height: 18px;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}


.view-btn {
    width: 100%;
    height: 38px;
    margin-top: auto;
    flex-shrink: 0;
    border: none;
    border-radius: 6px;
    background: #5146e5;
    color: #ffffff;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s ease, transform 0.1s ease;
}

    .view-btn:hover {
        background: #4038c8;
    }

    .view-btn:active {
        transform: scale(0.98);
    }



.empty-state {
    text-align: center;
    padding: 90px 20px;
}

.empty-icon {
    margin: 0 auto 20px;
    width: 70px;
    height: 70px;
}

    .empty-icon svg {
        width: 100%;
        height: 100%;
        color: #a5b3c6;
    }

.empty-state h2 {
    margin: 0 0 8px;
    font-size: 21px;
    color: #33445e;
}

.empty-state p {
    margin: 0;
    color: #8191a8;
    font-size: 14px;
}



.modal {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 9999;
}

    .modal.active {
        display: flex;
        align-items: center;
        justify-content: center;
    }

.modal-overlay {
    position: absolute;
    inset: 0;
    background: rgba(8, 15, 30, 0.82);
    backdrop-filter: blur(3px);
}

.modal-content {
    position: relative;
    z-index: 2;
    width: 94vw;
    height: 94vh;
    max-width: 1500px;
    background: #18181b;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 20px 70px rgba(0, 0, 0, 0.45);
    display: flex;
    flex-direction: column;
}



.modal-header {
    height: 64px;
    min-height: 64px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 18px;
    background: #202024;
    border-bottom: 1px solid #343438;
    color: white;
}

.modal-title {
    min-width: 0;
}

    .modal-title h2 {
        margin: 0 0 3px;
        font-size: 16px;
        font-weight: 600;
        color: #ffffff;
    }

.modal-author {
    font-size: 12px;
    color: #aeb0b8;
}

.modal-close {
    width: 40px;
    height: 40px;
    border: none;
    border-radius: 7px;
    background: transparent;
    color: #ffffff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

    .modal-close:hover {
        background: rgba(255, 255, 255, 0.10);
    }

    .modal-close svg {
        width: 21px;
        height: 21px;
    }


.modal-body {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    background: #18181b;
}

.viewer-container {
    flex: 1;
    min-height: 0;
    position: relative;
    overflow: hidden;
}



.flipbook-viewer {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    display: block;
}

.flipbook-container {
    width: 100%;
    height: 100%;
    position: relative;
}

    .flipbook-container > div {
        width: 100% !important;
        height: 100% !important;
    }


.loading-state {
    position: absolute;
    inset: 0;
    z-index: 20;
    background: #18181b;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: white;
}

    .loading-state.hidden {
        display: none;
    }

.loading-spinner {
    width: 38px;
    height: 38px;
    border: 3px solid #4a4a4e;
    border-top-color: #ffffff;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin-bottom: 15px;
}

.loading-state p {
    margin: 0;
    color: #c5c5ca;
    font-size: 13px;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}



.viewer-notice {
    min-height: 34px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    background: #202024;
    border-top: 1px solid #343438;
    color: #aaaab1;
    font-size: 11px;
}

    .viewer-notice svg {
        width: 15px;
        height: 15px;
    }



[data-theme="dark"] body,
[data-theme="dark"] .app-container {
    background: #111827;
}

[data-theme="dark"] .header,
[data-theme="dark"] .sidebar {
    background: #182131;
    border-color: #29364a;
}

[data-theme="dark"] .content {
    background: #111827;
}

[data-theme="dark"] .category-title,
[data-theme="dark"] .book-title {
    color: #f4f7fb;
}



[data-theme="dark"] .nav-title {
    color: #aebbd0;
}



[data-theme="dark"] #categoryList .db-category-link {
    color: #c7d2e3 !important;
}

    [data-theme="dark"]
    #categoryList
    .db-category-link
    i {
        color: #91a3c0 !important;
    }

    [data-theme="dark"]
    #categoryList
    .db-category-link:hover {
        background: #242d4a !important;
        color: #9a9fff !important;
    }

        [data-theme="dark"]
        #categoryList
        .db-category-link:hover
        i {
            color: #9a9fff !important;
        }

/* Dark active */

[data-theme="dark"]
#categoryList
.category-item.active > .db-category-link {
    background: #292f50 !important;
    color: #9a9fff !important;
}

    [data-theme="dark"]
    #categoryList
    .category-item.active > .db-category-link
    i {
        color: #9a9fff !important;
    }



[data-theme="dark"]
#categoryList
.category-item:first-child > .db-category-link {
    background: #202a3c !important;
    border-color: #344258 !important;
    color: #c7d2e3 !important;
}

[data-theme="dark"]
#categoryList
.category-item:first-child.active > .db-category-link {
    background: #292f50 !important;
    color: #9a9fff !important;
}

[data-theme="dark"]
#categoryList
.db-subcategory-link {
    color: #aebbd0 !important;
}

    [data-theme="dark"]
    #categoryList
    .db-subcategory-link:hover {
        background: #242d4a !important;
        color: #9a9fff !important;
    }

    [data-theme="dark"]
    #categoryList
    .db-subcategory-link.active {
        background: #292f50 !important;
        color: #9a9fff !important;
    }

    [data-theme="dark"]
    #categoryList
    .db-subcategory-link
    i {
        color: #8999b5 !important;
    }

    [data-theme="dark"]
    #categoryList
    .db-subcategory-link:hover
    i,
    [data-theme="dark"]
    #categoryList
    .db-subcategory-link.active
    i {
        color: #9a9fff !important;
    }

[data-theme="dark"] .book-card {
    background: #182131;
    border-color: #29364a;
}

[data-theme="dark"] .book-author {
    color: #aebbd0;
}

[data-theme="dark"] .book-description {
    color: #8796ac;
}

[data-theme="dark"] .search-box {
    background: #1b2637;
    border-color: #344258;
}

    [data-theme="dark"] .search-box input {
        color: #ffffff;
    }


.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 90;
    background: rgba(0, 0, 0, 0.45);
    opacity: 0;
    transition: opacity 0.3s ease;
}

    .sidebar-overlay.active {
        display: block;
        opacity: 1;
    }



@media (max-width: 900px) {

    .header-left {
        width: 200px;
    }

    .search-box {
        width: 400px;
    }

    .sidebar {
        width: 230px;
        min-width: 230px;
    }

    .book-grid {
        grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    }
}

@media (max-width: 700px) {

    .header {
        height: 70px;
    }

    .header-left {
        width: auto;
        padding-left: 12px;
    }

    .hamburger-menu {
        display: flex;
        align-items: center;
        justify-content: center;
    }

    .logo-img {
        width: 125px !important;
    }

    .header-center {
        display: none;
    }

    .header-right {
        width: auto;
        margin-left: auto;
    }

    .mobile-search-toggle {
        display: flex;
    }

    .header.search-active .header-center {
        display: flex;
        position: absolute;
        left: 60px;
        right: 55px;
        top: 13px;
        z-index: 10;
    }

    .header.search-active .search-box {
        width: 100%;
        max-width: none;
    }

    .header.search-active .search-close {
        display: flex;
        width: 30px;
        height: 30px;
        align-items: center;
        justify-content: center;
        color: #657893;
    }

        .header.search-active .search-close svg {
            width: 18px;
            height: 18px;
        }

    .main-layout {
        min-height: calc(100vh - 70px);
    }

    .sidebar {
        position: fixed;
        top: 0;
        left: -280px;
        bottom: 0;
        width: 260px;
        min-width: 260px;
        z-index: 100;
        min-height: 100vh;
        transition: left 0.3s ease;
        box-shadow: 5px 0 20px rgba(0, 0, 0, 0.12);
    }

        .sidebar.active {
            left: 0;
        }

    .content {
        width: 100%;
        padding: 25px 18px 40px;
    }

    .category-title {
        font-size: 25px;
    }

    .book-grid {
        grid-template-columns: 1fr;
    }

    .book-card {
        max-width: 100%;
    }

    .modal-content {
        width: 100vw;
        height: 100vh;
        border-radius: 0;
    }

  

    .nav-title {
        font-size: 15px;
    }

    #categoryList .db-category-link {
        font-size: 15px !important;
    }

    #categoryList .db-subcategory-link {
        font-size: 14px !important;
    }
}
