html, body {
    font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background-color: #f8fafc;
    color: #0f172a;
    margin: 0;
    padding: 0;
}

.page {
    position: relative;
    display: flex;
    flex-direction: column;
}

main {
    flex: 1;
}

.sidebar {
    background-color: #1e1b4b;
    color: #1e1b4b;
}

.top-row {
    background-color: #fff;
    background: #1e1b4b;
    border-bottom: 1px solid rgba(255, 255, 255, 0.15);
    color: #fff;
    justify-content: flex-end;
    height: 3.5rem;
    display: flex;
    align-items: center;
}

.navbar-brand {
    font-weight: 700;
    color: #fff !important;
    background: #1e1b4b;
    text-decoration: none;
    font-size: 1.1rem;
}

.nav-link {
    color: #cbd5e1 !important;
    text-decoration: none;
    padding: 0.5rem 1rem;
    display: block;
    border-radius: 6px;
    margin-bottom: 0.25rem;
}

.nav-link.active, .nav-link:hover {
    color: #fff !important;
    background-color: #1e1b4b;
}

/* Page Layout */
.page-container {
    max-width: 1400px;
    margin: 0 auto;
}

.header-section {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1.25rem;
}

.header-section h2 {
    font-size: 1.35rem;
    font-weight: 700;
    color: #0f172a;
    margin: 0;
}

.header-section .subtitle {
    font-size: 0.8rem;
    color: #64748b;
    margin: 0.15rem 0 0 0;
}

.action-buttons {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* View Switcher */
.view-toggle {
    display: inline-flex;
    background: #f1f5f9;
    border-radius: 8px;
    padding: 2px;
}

.toggle-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.35rem 0.65rem;
    font-size: 0.75rem;
    font-weight: 600;
    color: #64748b;
    background: transparent;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.15s ease;
}

.toggle-btn.active {
    background: #ffffff;
    color: #0f172a;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

/* Filter and Search Bar */
.filter-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.75rem;
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    padding: 0.65rem 0.85rem;
    margin-bottom: 1rem;
}

.search-input-wrapper {
    flex: 1;
    min-width: 240px;
    position: relative;
    display: flex;
    align-items: center;
}

.search-icon {
    position: absolute;
    left: 0.75rem;
    color: #94a3b8;
}

.search-input {
    width: 100%;
    padding: 0.45rem 0.75rem 0.45rem 2.25rem;
    font-size: 0.8rem;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    outline: none;
    color: #0f172a;
}

.search-input:focus {
    border-color: #6366f1;
    box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.15);
}

.select-filter {
    padding: 0.45rem 0.75rem;
    font-size: 0.8rem;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    background: #fff;
    color: #334155;
    outline: none;
}

.availability-toggle {
    display: inline-flex;
    background: #f1f5f9;
    border-radius: 6px;
    padding: 2px;
}

.avail-btn {
    border: none;
    background: transparent;
    font-size: 0.75rem;
    font-weight: 500;
    color: #64748b;
    padding: 0.35rem 0.65rem;
    border-radius: 4px;
    cursor: pointer;
}

.avail-btn.active {
    background: #ffffff;
    color: #0f172a;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.selection-banner {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.75rem;
    font-size: 0.8rem;
}

.select-all-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    background: transparent;
    border: none;
    color: #334155;
    font-weight: 600;
    cursor: pointer;
    padding: 0;
}

/* ========================================================
   BOOK CARDS GRID & COVER IMAGES
   ======================================================== */
.book-card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
}

.book-card {
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.03);
}

.book-card:hover {
    border-color: #cbd5e1;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.06);
    transform: translateY(-1px);
}

.book-card.selected {
    border-color: #6366f1;
    box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.2);
}

.book-card-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.75rem;
}

.format-badge {
    font-family: monospace;
    font-size: 0.7rem;
    font-weight: 700;
    color: #64748b;
    background: #f1f5f9;
    padding: 0.15rem 0.45rem;
    border-radius: 4px;
}

.availability-label {
    font-size: 0.75rem;
    font-weight: 600;
}

.avail-in-stock {
    color: #15803d;
}

.avail-out {
    color: #dc2626;
}

.book-card-body {
    display: flex;
    gap: 0.85rem;
    align-items: flex-start;
}

/* Book Cover Styling */
.book-cover-wrapper {
    width: 84px;
    height: 120px;
    flex-shrink: 0;
    border-radius: 6px;
    overflow: hidden;
    background: #f1f5f9;
    border: 1px solid #e2e8f0;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.08);
}

.book-cover-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.book-cover-fallback {
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #e0e7ff 0%, #ede9fe 100%);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 0.5rem;
    text-align: center;
    color: #4f46e5;
}

.fallback-title {
    font-size: 0.65rem;
    font-weight: 700;
    color: #3730a3;
    margin-top: 0.25rem;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.book-meta-content {
    flex: 1;
    min-width: 0;
}

.book-title {
    font-size: 0.88rem;
    font-weight: 700;
    color: #0f172a;
    line-height: 1.25;
    margin: 0 0 0.25rem 0;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.book-author {
    font-size: 0.78rem;
    color: #475569;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.book-pub-info {
    font-size: 0.7rem;
    color: #94a3b8;
    margin-top: 0.15rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.book-location-info {
    font-size: 0.72rem;
    color: #64748b;
    margin-top: 0.4rem;
}

.separator {
    margin: 0 0.25rem;
    color: #cbd5e1;
}

.book-isbn {
    font-family: monospace;
    font-size: 0.68rem;
    color: #94a3b8;
    margin-top: 0.25rem;
}

.book-synopsis {
    font-size: 0.75rem;
    color: #475569;
    line-height: 1.4;
    margin: 0.75rem 0 0.5rem 0;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.book-card-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-top: 1px solid #f1f5f9;
    padding-top: 0.65rem;
    margin-top: 0.5rem;
}

.btn-download {
    background: #eef2ff;
    color: #4f46e5;
    border: 1px solid #e0e7ff;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
}

.btn-download:hover {
    background: #e0e7ff;
    color: #4338ca;
}

/* Table Thumbnail */
.table-cover-thumb {
    width: 38px;
    height: 52px;
    border-radius: 4px;
    overflow: hidden;
    background: #f1f5f9;
    border: 1px solid #e2e8f0;
}

.thumb-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.thumb-fallback {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
}

/* Table styles */
.library-table {
    width: 100%;
    border-collapse: collapse;
    background: #fff;
    font-size: 0.85rem;
}

.library-table th {
    background: #f1f5f9;
    padding: 0.75rem 1rem;
    text-align: left;
    font-weight: 600;
    color: #475569;
    border-bottom: 1px solid #e2e8f0;
}

.library-table td {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid #f1f5f9;
    vertical-align: middle;
}

.library-table tr:hover {
    background: #f8fafc;
}

/* Modals */
.modal-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(15, 23, 42, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1050;
    padding: 1rem;
}

.modal-dialog {
    background: #ffffff;
    border-radius: 12px;
    width: 100%;
    max-width: 520px;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    overflow: hidden;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid #e2e8f0;
}

.close-btn {
    background: none;
    border: none;
    font-size: 1.5rem;
    line-height: 1;
    color: #94a3b8;
    cursor: pointer;
}

.modal-body {
    padding: 1.25rem;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
    padding: 0.85rem 1.25rem;
    border-top: 1px solid #e2e8f0;
    background: #f8fafc;
}

.modal-book-thumb {
    width: 50px;
    height: 70px;
    object-fit: cover;
    border-radius: 4px;
    border: 1px solid #cbd5e1;
}

.format-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.5rem;
}

.format-option {
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 0.65rem;
    cursor: pointer;
    transition: all 0.15s ease;
}

.format-option:hover {
    border-color: #cbd5e1;
    background: #f8fafc;
}

.format-option.active {
    border-color: #6366f1;
    background: #eef2ff;
}

.format-desc {
    display: block;
    font-size: 0.7rem;
    color: #64748b;
    margin-top: 0.15rem;
}

/* KPI Cards */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.kpi-card {
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 1rem;
}

.kpi-label {
    font-size: 0.75rem;
    color: #64748b;
    display: block;
}

.kpi-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: #0f172a;
    margin-top: 0.25rem;
    display: block;
}

.btn {
    padding: 0.4rem 0.85rem;
    font-size: 0.8rem;
    border-radius: 6px;
    cursor: pointer;
    border: 1px solid transparent;
    font-weight: 600;

}

.btn-logoff {
    padding: 0.4rem 0.85rem;
    font-size: 0.8rem;
    border-radius: 6px;
    cursor: pointer;
    border: 1px solid transparent;
    font-weight: 600;
    background: #4338ca
}

.btn-primary {
    background: #4f46e5;
    color: #fff;
}

.btn-primary:hover {
    background: #4338ca;
}

.btn-outline {
    background: transparent;
    border-color: #cbd5e1;
    color: #334155;
}

.btn-outline:hover {
    background: #f8fafc;
    border-color: #94a3b8;
}

.text-crimson { color: #dc2626; }
.text-muted { color: #64748b; }
.tabular-nums { font-variant-numeric: tabular-nums; }

@media (min-width: 641px) {
    .page {
        flex-direction: row;
    }
    .sidebar {
        width: 250px;
        min-height: 100vh;
    }
}

/* Top bar matches the navigation bar */
.page main .top-row {
    background: #1e1b4b;
    border-bottom: 1px solid rgba(255, 255, 255, 0.15);
    color: #fff;
}

.page main .top-row .text-muted {
    color: rgba(255, 255, 255, 0.75) !important;
}

.page main .top-row .btn-outline-secondary {
    color: #fff;
    border-color: rgba(255, 255, 255, 0.6);
}

.page main .top-row .btn-outline-secondary:hover {
        background: rgba(255, 255, 255, 0.15);
}

/* Navigation menu collapse */
.navbar-toggler {
    cursor: pointer;
    font-size: 0.8rem;
    font-weight: 600;
    background: #4338ca
}
.navbar-toggler-icon {
    background: #4338ca;
}

@media (max-width: 640.98px) {
    .nav-scrollable.collapse:not(.show) {
        display: none;
    }

    .nav-scrollable.collapse.show {
        display: block;
    }
}

@media (min-width: 641px) {
    .navbar-toggler {
        display: none;
    }

    .nav-scrollable.collapse {
        display: block;
    }
}
