.library-wrapper {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
    position: relative;
}

/* SEARCH & FILTER */
.library-filter-bar {
    display: grid;
    grid-template-columns: 3fr 1fr;
    gap: 20px;
    margin-bottom: 35px;
    width: 100%;
    align-items: start;
}

.library-filter-bar input {
    width: 100%;
    height: 48px;
    padding: 0 15px;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    background-color: #fff;
    font-size: 15px;
    color: #4a5568;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
    transition: all 0.2s;
    box-sizing: border-box;
}

.library-filter-bar input:focus {
    border-color: var(--lib-theme-color);
    box-shadow: 0 0 0 3px rgba(0, 0, 0, 0.05);
    outline: none;
}

/* CUSTOM DROPDOWN CSS */
.lib-custom-select {
    position: relative;
    width: 100%;
    font-size: 15px;
    color: #4a5568;
    user-select: none;
}

.lib-select-trigger {
    height: 48px;
    padding: 0 15px;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    background-color: #fff;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: all 0.2s;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
    box-sizing: border-box;
}

.lib-custom-select.open .lib-select-trigger {
    border-color: var(--lib-theme-color);
    box-shadow: 0 0 0 3px rgba(0, 0, 0, 0.05);
}

.lib-select-trigger::after {
    content: '';
    width: 8px;
    height: 8px;
    border-right: 2px solid #a0aec0;
    border-bottom: 2px solid #a0aec0;
    transform: rotate(45deg);
    transition: transform 0.2s;
    margin-left: 10px;
    margin-top: -4px;
}

.lib-custom-select.open .lib-select-trigger::after {
    transform: rotate(-135deg);
    margin-top: 4px;
    border-color: var(--lib-theme-color);
}

.lib-select-dropdown {
    position: absolute;
    top: 110%;
    left: 0;
    width: 100%;
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    z-index: 100;
    display: none;
    overflow: hidden;
    border: 1px solid #f7fafc;
    padding: 6px;
}

.lib-custom-select.open .lib-select-dropdown {
    display: block;
    animation: libFadeDown 0.2s ease-out;
}

/* Category Search inside Dropdown */
.lib-select-search-wrap {
    padding: 4px;
    border-bottom: 1px solid #edf2f7;
    margin-bottom: 4px;
}

.lib-select-search {
    width: 100%;
    height: 36px;
    padding: 0 10px;
    font-size: 13px;
    border: 1px solid #e2e8f0;
    border-radius: 4px;
    margin-bottom: 0 !important;
}

.lib-select-options-list {
    max-height: 250px;
    overflow-y: auto;
}

@keyframes libFadeDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.lib-select-option {
    padding: 10px 12px;
    cursor: pointer;
    border-radius: 6px;
    transition: background 0.1s;
    margin-bottom: 2px;
}

.lib-select-option:hover {
    background-color: #f7fafc;
    color: var(--lib-theme-color);
}

.lib-select-option.selected {
    background-color: #ebf8ff;
    color: var(--lib-theme-color);
    font-weight: 600;
}

/* GRID & CARD */
.library-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 30px;
    justify-items: center;
}

.library-card {
    width: 100%;
    max-width: 220px;
    min-height: 400px;
    display: flex;
    flex-direction: column;
    text-align: left;
    background-color: #f8f9fa;
    border-radius: 12px;
    padding: 15px;
    box-sizing: border-box;
    border: 1px solid #edf2f7;
    transition: transform 0.2s, box-shadow 0.2s;
    cursor: pointer;
}

.library-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 15px 30px rgba(0, 0, 0, 0.08);
    background-color: #fff;
}

.library-card-img-wrap {
    width: 100%;
    height: 250px;
    overflow: hidden;
    border-radius: 8px;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
    margin-bottom: 15px;
    background: #fff;
}

.library-card-img-wrap img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s;
}

.library-card-img-wrap:hover img {
    transform: scale(1.05);
}

.library-card-body {
    display: flex;
    flex-direction: column;
    flex: 1;
}

.library-card-title {
    font-size: 16px;
    font-weight: 700;
    margin: 0 0 5px;
    line-height: 1.3;
    color: #2d3748;
}

.library-card-author {
    font-size: 13px;
    color: #4a5568;
    margin-bottom: 8px;
    font-weight: 600;
}

.library-card-desc {
    font-size: 13px;
    color: #718096;
    margin-bottom: 12px;
    line-height: 1.5;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    line-clamp: 3;
    overflow: hidden;
}

.library-card-meta {
    font-size: 12px;
    color: #a0aec0;
    margin-bottom: 15px;
    margin-top: auto;
}

/* Themed Button */
.library-card-btn,
.library-card-btn:visited {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    min-height: 44px;
    text-align: center;
    background: var(--lib-theme-color);
    color: #fff !important;
    text-decoration: none;
    padding: 0 15px;
    border-radius: 6px;
    border: none;
    font-size: 14px;
    font-weight: 600;
    transition: background 0.2s, transform 0.1s;
    cursor: pointer;
    box-sizing: border-box;
    line-height: 1;
    appearance: none;
}

.library-card-btn:hover,
.library-card-btn:focus,
.library-card-btn:active {
    background: var(--lib-theme-color);
    filter: brightness(90%);
    color: #fff !important;
    transform: translateY(-1px);
    outline: none;
}

.library-card-btn:active {
    transform: translateY(0);
}

/* PAGINATION */
.library-pagination {
    margin-top: 50px;
    display: flex;
    justify-content: center;
}

.library-pagination-links {
    background: #fff;
    display: inline-flex;
    align-items: center;
    padding: 8px 12px;
    border-radius: 12px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.05);
    gap: 5px;
    border: 1px solid #f1f5f9;
}

.library-page-btn {
    background: transparent;
    border: none;
    color: #94a3b8;
    font-weight: 600;
    font-size: 16px;
    width: 38px;
    height: 38px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    line-height: 1;
}

.library-page-btn:hover:not(.disabled):not(.active) {
    background: #f1f5f9;
    color: #334155;
}

.library-page-btn.active {
    background: var(--lib-theme-color);
    color: #fff;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.15);
}

.library-page-btn.disabled {
    opacity: 0.5;
    cursor: default;
}

.library-page-btn svg {
    pointer-events: none;
    display: block;
}

.library-page-btn.prev-btn,
.library-page-btn.next-btn {
    padding: 0;
}

.library-page-btn.prev-btn:hover:not(.disabled),
.library-page-btn.next-btn:hover:not(.disabled) {
    color: var(--lib-theme-color);
}

.library-dots {
    color: #cbd5e1;
    padding: 0 5px;
    font-weight: bold;
}

/* MODAL STYLES */
.library-modal {
    display: none;
    position: fixed;
    z-index: 99999;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(5px);
}

.library-modal-content {
    background-color: #fff;
    margin: 5% auto;
    padding: 0;
    border: none;
    width: 90%;
    max-width: 900px;
    border-radius: 16px;
    position: relative;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    overflow: hidden;
    animation: libraryFadeIn 0.3s;
}

@keyframes libraryFadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.library-modal-close {
    position: absolute;
    top: 15px;
    right: 20px;
    color: #a0aec0;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    z-index: 10;
    line-height: 1;
}

.library-modal-close:hover {
    color: #2d3748;
}

/* Modal Body Layout */
.lib-modal-grid {
    display: grid;
    grid-template-columns: 300px 1fr;
    gap: 0;
    height: 100%;
    min-height: 500px;
}

.lib-modal-img-col {
    background: #f7fafc;
    padding: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-right: 1px solid #edf2f7;
}

.lib-modal-img-col img {
    width: 100%;
    height: auto;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    border-radius: 4px;
    max-height: 400px;
    object-fit: contain;
}

.lib-modal-info-col {
    padding: 40px;
}

.lib-modal-title {
    font-size: 28px;
    font-weight: 800;
    color: #1a202c;
    line-height: 1.2;
    margin-top: 0;
    margin-bottom: 10px;
}

.lib-modal-author {
    font-size: 18px;
    color: #4a5568;
    margin-bottom: 25px;
    font-weight: 500;
}

.lib-modal-desc {
    font-size: 16px;
    line-height: 1.7;
    color: #4a5568;
    margin-bottom: 30px;
}

.lib-modal-meta-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 30px;
    background: #f8fafc;
    padding: 20px;
    border-radius: 12px;
}

.lib-modal-meta-item strong {
    display: block;
    font-size: 12px;
    text-transform: uppercase;
    color: #718096;
    margin-bottom: 3px;
    letter-spacing: 0.5px;
}

.lib-modal-meta-item span {
    font-size: 15px;
    font-weight: 600;
    color: #2d3748;
}

/* Modal Button uses Theme Color */
.lib-modal-btn {
    display: inline-block;
    background-color: var(--lib-theme-color);
    color: white !important;
    font-weight: 600;
    padding: 14px 28px;
    border-radius: 8px;
    text-decoration: none;
    font-size: 16px;
    transition: all 0.2s;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    border: none;
    cursor: pointer;
}

.lib-modal-btn:hover {
    filter: brightness(90%);
    transform: translateY(-2px);
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
}

/* MOBILE OPTIMIZATIONS */
@media (max-width: 768px) {
    .library-wrapper {
        padding: 10px;
    }

    .library-filter-bar {
        grid-template-columns: 1fr;
        margin-bottom: 20px;
    }

    .library-grid {
        grid-template-columns: 1fr;
        gap: 20px;
    }

    .library-card {
        max-width: 100%;
        min-height: auto;
    }

    /* Reduce fixed min-height on mobile */
    .library-pagination {
        margin-top: 30px;
    }

    .lib-modal-grid {
        grid-template-columns: 1fr;
    }

    .lib-modal-img-col {
        padding: 30px;
        min-height: 300px;
    }

    .lib-modal-img-col img {
        max-height: 250px;
    }

    .lib-modal-info-col {
        padding: 20px;
    }
}