/* ===== Reset & Base Styles ===== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    /* Color Palette - Professional & Modern */
    --primary-blue: #2563eb;
    --primary-blue-dark: #1e40af;
    --primary-blue-light: #3b82f6;
    --accent-gray: #6b7280;
    --accent-gray-light: #9ca3af;
    --accent-gray-lighter: #d1d5db;
    --background-white: #ffffff;
    --background-gray: #f9fafb;
    --text-primary: #111827;
    --text-secondary: #4b5563;
    --text-tertiary: #6b7280;
    --border-color: #e5e7eb;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
}

html {
    padding-bottom: 0;
    margin-bottom: 0;
    min-height: 100%;
    min-height: -webkit-fill-available;
    overflow-y: scroll; /* Force scrollbar for consistent layout */
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', sans-serif;
    background-color: var(--background-white);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    min-height: 100dvh;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    overflow-x: hidden;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    padding-bottom: env(safe-area-inset-bottom);
}

/* ===== Top Header ===== */
.top-header {
    width: 100%;
    flex-shrink: 0;
    background-color: var(--background-white);
    border-bottom: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-container {
    width: 100%;
    max-width: 1400px;
    margin: 0 auto;
    padding: 1rem 2rem;
    display: flex;
    flex-wrap: nowrap;
    align-items: center;
    justify-content: space-between;
    gap: 1.5rem;
    position: relative;
    box-sizing: border-box;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-shrink: 0;
    min-width: 0;
}

.header-spacer {
    flex: 1;
    min-width: 0;
}

.icon-container {
    display: flex;
    align-items: center;
    justify-content: center;
}

.app-icon {
    width: 48px;
    height: 48px;
    object-fit: contain;
    border-radius: var(--radius-md);
    transition: transform 0.2s ease;
}

.app-icon:hover {
    transform: scale(1.05);
}

.header-right {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 0.5rem;
    flex-shrink: 0;
    min-width: 0;
}

/* ===== Profile Avatar (standalone, no container) ===== */
.profile-menu {
    position: relative;
    display: flex;
    align-items: center;
}

.profile-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary-blue), var(--primary-blue-dark));
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 0.9rem;
    text-transform: uppercase;
    box-shadow: var(--shadow-sm);
    cursor: pointer;
    transition: all 0.2s ease;
}

.profile-avatar:hover {
    transform: scale(1.05);
    box-shadow: var(--shadow-md);
}

/* Keep profile-container and profile-text styles for backward compatibility but hide them */
.profile-container {
    display: none;
}

.profile-text {
    display: none;
}

/* ===== Profile Menu Dropdown ===== */

.profile-panel {
    position: absolute;
    top: calc(100% + 0.75rem);
    right: 0;
    width: 260px;
    background: #fff;
    color: #111;
    border-radius: 16px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.35);
    padding: 1.25rem;
    display: none;
    flex-direction: column;
    gap: 1rem;
    z-index: 150;
}

.profile-panel::before {
    content: "";
    position: absolute;
    top: -6px;
    right: 16px;
    width: 18px;
    height: 18px;
    background: #ffffff;
    transform: rotate(45deg);
}

.profile-panel.show {
    display: flex;
}

.profile-panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-weight: 600;
    letter-spacing: 0.02em;
    text-transform: uppercase;
    font-size: 0.85rem;
    color: #1e1e1e;
}

.profile-close-btn {
    background: transparent;
    border: none;
    color: #9ca3af;
    font-size: 1.25rem;
    cursor: pointer;
    line-height: 1;
    padding: 0;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.2s ease;
}

.profile-close-btn:hover {
    color: #7c7e81;
}

.profile-user {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.profile-name {
    font-weight: 600;
    font-size: 1rem;
    color: #000000;
}

.profile-email {
    font-size: 0.875rem;
    color: #7c7e81;
}

.profile-action-btn {
    padding: 0.75rem 1rem;
    border-radius: 999px;
    border: none;
    background: #2563eb;
    color: #fff;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s ease, transform 0.1s ease;
    width: 100%;
}

.profile-action-btn:hover {
    background: #1741a6;
    transform: translateY(-1px);
}

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

/* ===== Secondary Navigation Bar ===== */
.secondary-nav {
    flex-shrink: 0;
    background-color: var(--background-white);
    border-bottom: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
    position: sticky;
    top: 73px;
    z-index: 99;
}

.nav-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 2rem;
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.nav-item {
    padding: 0.875rem 1.5rem;
    background-color: transparent;
    border: none;
    border-bottom: 3px solid transparent;
    color: var(--text-secondary);
    font-weight: 500;
    font-size: 0.95rem;
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
    font-family: inherit;
}

.nav-item:hover {
    color: var(--primary-blue);
    background-color: var(--background-gray);
}

.nav-item.active {
    color: var(--primary-blue);
    border-bottom-color: var(--primary-blue);
    font-weight: 600;
}

.nav-item.active::after {
    content: '';
    position: absolute;
    bottom: -1px;
    left: 0;
    right: 0;
    height: 3px;
    background-color: var(--primary-blue);
}

/* ===== Main Content Area ===== */
.main-content {
    flex: 1 1 auto;
    min-height: 0;
    max-width: 1400px;
    margin: 0 auto;
    padding: 3rem 2rem;
    width: 100%;
}

.content-view {
    background-color: var(--background-white);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 2rem;
    min-height: 500px;
    box-shadow: var(--shadow-sm);
}

/* ===== Responsive Design ===== */
@media (max-width: 1024px) {
    .header-container {
        padding: 1rem 1.5rem;
        gap: 1.25rem;
    }

    .nav-container {
        padding: 0 1.5rem;
    }

    .main-content {
        padding: 2rem 1.5rem;
    }
}

@media (max-width: 768px) {
    .header-container {
        padding: 0.875rem 1rem;
        gap: 0.75rem;
    }

    .header-left {
        min-width: 52px; /* Reserve space for hamburger when logo is centered */
    }

    .app-icon {
        width: 40px;
        height: 40px;
    }

    .profile-avatar {
        width: 32px;
        height: 32px;
        font-size: 0.8rem;
    }
    
    /* Organization Switcher Mobile */
    .org-switcher {
        margin-right: 0.5rem;
    }
    
    .org-switcher-btn {
        padding: 0.4rem 0.75rem;
        font-size: 0.85rem;
    }
    
    .org-switcher-btn span {
        max-width: 80px;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }
    
    .org-dropdown {
        min-width: 200px;
    }

    .secondary-nav {
        top: 65px;
    }

    .nav-container {
        padding: 0 1rem;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
    }

    .nav-container::-webkit-scrollbar {
        display: none;
    }

    .nav-item {
        padding: 0.75rem 1.25rem;
        font-size: 0.9rem;
        white-space: nowrap;
    }

    .main-content {
        padding: 1.5rem 1rem 2rem;
    }

    .content-view {
        padding: 1.5rem 1rem 2rem;
        min-height: 400px;
        margin-bottom: 0;
    }
    
    .content-card {
        padding: 1rem;
    }
}

@media (max-width: 480px) {
    .header-container {
        padding: 0.75rem 0.875rem;
        gap: 0.5rem;
    }

    .header-left {
        min-width: 48px;
    }

    .app-icon {
        width: 36px;
        height: 36px;
    }

    .profile-avatar {
        width: 32px;
        height: 32px;
        font-size: 0.8rem;
    }
    
    .profile-panel {
        width: 220px;
        padding: 1rem;
    }

    .nav-item {
        padding: 0.625rem 1rem;
        font-size: 0.85rem;
    }

    .content-view {
        padding: 1rem 0.75rem 2rem 0.75rem;
        min-height: 350px;
        margin-bottom: 0;
    }
    
    .main-content {
        padding: 1.25rem 0.75rem 2rem;
    }
    
    .content-card {
        padding: 0.75rem;
        border-radius: var(--radius-sm);
    }
}

/* ===== Extra Small Mobile Devices (below 400px) ===== */
@media (max-width: 400px) {
    .header-container {
        padding: 0.625rem 0.75rem;
        gap: 0.5rem;
    }

    .header-left {
        min-width: 44px;
    }

    .app-icon {
        width: 32px;
        height: 32px;
    }

    .hamburger-btn {
        width: 40px;
        height: 40px;
        font-size: 1.1rem;
        margin-right: 0.75rem;
    }

    .profile-avatar {
        width: 30px;
        height: 30px;
        font-size: 0.75rem;
    }

    .main-content {
        padding: 1.25rem 0.75rem 2rem;
    }

    .content-view {
        padding: 1rem 0.625rem 2rem 0.625rem;
        min-height: 300px;
        margin-bottom: 0;
    }

    .content-card {
        padding: 0.625rem;
    }

    .section-header {
        padding-bottom: 0.75rem;
        margin-bottom: 1.5rem;
    }

    .section-header h2 {
        font-size: 1.5rem;
    }

    .nav-item {
        padding: 0.5rem 0.75rem;
        font-size: 0.8rem;
    }
    
    .history-table-container {
        border-radius: var(--radius-sm);
    }
}

/* ===== Dashboard Footer ===== */
.dashboard-footer {
    flex-shrink: 0;
    margin-top: auto;
    display: block;
    width: 100%;
    min-height: 120px;
    background: var(--background-white);
    border-top: 1px solid var(--border-color);
    padding: 2rem 1.5rem 1.5rem;
    padding-bottom: calc(1.5rem + env(safe-area-inset-bottom));
    text-align: center;
    color: var(--text-tertiary);
    font-size: 0.9rem;
    line-height: 1.6;
}

.footer-support {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
    flex-wrap: wrap;
}

.footer-support i {
    color: var(--primary-blue);
    font-size: 1.1rem;
}

.dashboard-footer .footer-email {
    margin-bottom: 1rem;
}

.dashboard-footer .footer-email a {
    color: var(--primary-blue);
    text-decoration: none;
    font-weight: 500;
}

.dashboard-footer .footer-email a:hover {
    text-decoration: underline;
}

.dashboard-footer .footer-copyright {
    font-size: 0.8rem;
    color: var(--accent-gray-light);
    border-top: 1px solid var(--border-color);
    padding-top: 1rem;
    margin-top: 1rem;
}

/* Footer responsive - ensure visibility at all breakpoints */
@media (max-width: 1024px) {
    .dashboard-footer {
        padding: 1.75rem 1.25rem 1.5rem;
        padding-bottom: calc(1.5rem + env(safe-area-inset-bottom));
        min-height: 100px;
    }
}

@media (max-width: 768px) {
    .dashboard-footer {
        padding: 1.5rem 1rem 1.25rem;
        padding-bottom: calc(1.25rem + env(safe-area-inset-bottom));
        font-size: 0.85rem;
        min-height: 90px;
    }
    
    .footer-support {
        flex-direction: column;
        gap: 0.25rem;
    }
}

@media (max-width: 480px) {
    .dashboard-footer {
        padding: 1.25rem 0.75rem 1rem;
        padding-bottom: calc(1rem + env(safe-area-inset-bottom));
        font-size: 0.8rem;
        min-height: 80px;
    }
    
    .dashboard-footer .footer-copyright {
        font-size: 0.75rem;
    }
}

@media (max-width: 400px) {
    .dashboard-footer {
        padding: 1rem 0.5rem 1rem;
        padding-bottom: calc(1rem + env(safe-area-inset-bottom));
        min-height: 70px;
    }
}

/* ===== Smooth Transitions ===== */
* {
    transition: background-color 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}

/* ===== Loading Screen ===== */
.loading-screen {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    background-color: var(--background-white);
}

.spinner {
    width: 52px;
    height: 52px;
    border-radius: 50%;
    border: 4px solid var(--border-color);
    border-top-color: var(--primary-blue);
    animation: spin 1s linear infinite;
}

.loading-screen p {
    margin-top: 1rem;
    color: var(--text-tertiary);
    font-size: 1rem;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ===== Header Icon Button ===== */
.header-icon-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background-color: var(--background-gray);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    margin-right: 0.75rem;
}

.header-icon-btn:hover {
    background-color: var(--primary-blue);
    color: white;
    border-color: var(--primary-blue);
}

/* ===== Organization Switcher ===== */
.org-switcher {
    position: relative;
    z-index: 10;
    margin-right: 0.75rem;
    display: none; /* Hidden by default, shown only for admins via JS */
}

.org-switcher-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    background-color: var(--background-white);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.org-switcher-btn:hover {
    background-color: var(--background-gray);
    border-color: var(--accent-gray-light);
}

.org-switcher-btn i:first-child {
    color: var(--primary-blue);
    font-size: 1.1rem;
}

.org-switcher-btn i:last-child {
    font-size: 0.8rem;
    color: var(--accent-gray);
    transition: transform 0.2s ease;
}

.org-switcher.active .org-switcher-btn i:last-child {
    transform: rotate(180deg);
}

.org-dropdown {
    position: absolute;
    top: calc(100% + 0.5rem);
    right: 0;
    transform: translateY(-10px);
    background-color: var(--background-white);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    min-width: 250px;
    max-width: 300px;
    opacity: 0;
    visibility: hidden;
    transition: all 0.2s ease;
    z-index: 1100;
}

.org-switcher.active .org-dropdown {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.org-dropdown-header {
    padding: 1rem;
    border-bottom: 1px solid var(--border-color);
    font-weight: 600;
    font-size: 0.95rem;
    color: var(--text-primary);
}

.org-list {
    max-height: 300px;
    overflow-y: auto;
    padding: 0.5rem 0;
}

.org-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    cursor: pointer;
    transition: background-color 0.2s ease;
    color: var(--text-primary);
    font-size: 0.9rem;
}

.org-item:hover {
    background-color: var(--background-gray);
}

.org-item.active {
    background-color: var(--primary-blue);
    color: white;
}

.org-item.active .org-item-icon {
    color: white;
}

.org-item-icon {
    color: var(--primary-blue);
    font-size: 1rem;
}

.org-item-name {
    flex: 1;
    font-weight: 500;
}

.org-item-check {
    color: white;
    font-size: 1rem;
    opacity: 0;
}

.org-item.active .org-item-check {
    opacity: 1;
}

/* ===== Content View Overrides ===== */
.content-view {
    display: block;
}

/* ===== Section Header ===== */
.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 2rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border-color);
}

.section-header h2 {
    font-size: 1.75rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
}

.section-title-with-refresh {
    display: inline-flex;
    align-items: center;
    gap: 0.75rem;
    position: relative;
}

.refresh-icon-btn {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background-color: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 1rem;
    padding: 0;
    flex-shrink: 0;
    text-decoration: none;
}

.refresh-icon-btn:hover {
    background-color: var(--primary-blue);
    color: white;
    border-color: var(--primary-blue);
    transform: rotate(180deg);
}

.refresh-icon-btn:hover {
    background-color: var(--primary-blue);
    color: white;
    border-color: var(--primary-blue);
    transform: rotate(180deg);
}

.refresh-icon-btn i {
    display: flex;
    align-items: center;
    justify-content: center;
}

.section-subtitle {
    font-size: 0.95rem;
    color: var(--text-tertiary);
    margin-top: 0.25rem;
}

/* ===== Buttons ===== */
.ghost-button, .primary-button {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.625rem 1.25rem;
    border-radius: var(--radius-md);
    font-weight: 500;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.2s ease;
    border: 1px solid var(--border-color);
    background-color: var(--background-white);
    color: var(--text-secondary);
    text-decoration: none;
}

.ghost-button:hover, .primary-button:hover {
    background-color: var(--background-gray);
    border-color: var(--accent-gray-lighter);
}

.primary-button {
    background-color: var(--primary-blue);
    color: white;
    border-color: var(--primary-blue);
}

.primary-button:hover {
    background-color: var(--primary-blue-dark);
    border-color: var(--primary-blue-dark);
}

.ghost-button-small {
    padding: 0.45rem 1rem;
    font-size: 0.85rem;
}

/* ===== Stats Grid ===== */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.stat-card {
    display: flex;
    align-items: center;
    gap: 1.25rem;
    padding: 1.5rem;
    border-radius: var(--radius-md);
    background-color: var(--background-white);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
    transition: all 0.2s ease;
}

.stat-card:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.stat-icon {
    width: 56px;
    height: 56px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.75rem;
    flex-shrink: 0;
}

.stat-icon.blue {
    background: linear-gradient(135deg, #dbeafe, #93c5fd);
    color: #1e40af;
}

.stat-icon.green {
    background: linear-gradient(135deg, #d1fae5, #86efac);
    color: #065f46;
}

.stat-icon.red {
    background: linear-gradient(135deg, #fee2e2, #fecaca);
    color: #991b1b;
}

.stat-icon.purple {
    background: linear-gradient(135deg, #ede9fe, #ddd6fe);
    color: #5b21b6;
}

.stat-icon.user-icon, .stat-icon.book-icon, .stat-icon.magazine-icon, .stat-icon.shelf-icon {
    background: linear-gradient(135deg, #f3f4f6, #e5e7eb);
    color: var(--text-primary);
}

.stat-info {
    flex: 1;
}

.stat-label {
    font-size: 0.875rem;
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.25rem;
}

.stat-value {
    font-size: 2rem;
    font-weight: 700;
    color: var(--text-primary);
}

/* ===== Alert Banner ===== */
.alert-banner {
    background: linear-gradient(120deg, #fef2f2, #fee2e2);
    border: 1px solid #fecaca;
    border-radius: var(--radius-md);
    padding: 1rem 1.25rem;
    margin-bottom: 2rem;
    box-shadow: var(--shadow-sm);
}

.alert-content {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    color: #991b1b;
}

.alert-content i {
    font-size: 1.25rem;
}

/* ===== Content Grid ===== */
.content-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 1.5rem;
    margin-top: 2rem;
}

.content-card {
    background-color: var(--background-white);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 1.5rem;
    box-shadow: var(--shadow-sm);
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.25rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border-color);
}

.card-header h3 {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.card-header h3 i {
    color: var(--primary-blue);
}

/* ===== Trending Books ===== */
.trending-books-card {
    grid-column: 1 / -1; /* Full width */
}

.trending-books-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.trending-book-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem;
    border-radius: var(--radius-sm);
    background-color: var(--background-gray);
    border: 1px solid var(--border-color);
    transition: all 0.2s ease;
}

.trending-book-item:hover {
    background-color: #f3f4f6;
    border-color: var(--primary-blue);
    transform: translateY(-2px);
    box-shadow: var(--shadow-sm);
}

.trending-rank {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary-blue), var(--primary-blue-dark));
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 1rem;
    flex-shrink: 0;
    box-shadow: var(--shadow-sm);
}

.trending-book-info {
    flex: 1;
    min-width: 0;
}

.trending-book-title {
    font-weight: 600;
    color: var(--text-primary);
    font-size: 1rem;
    margin-bottom: 0.25rem;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.trending-book-author {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.85rem;
    color: var(--text-tertiary);
}

.trending-book-author i {
    color: var(--primary-blue);
    font-size: 0.9rem;
}

.trending-book-count {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.25rem;
    padding: 0.5rem 0.75rem;
    background-color: var(--background-white);
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
    min-width: 70px;
}

.borrow-count {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--primary-blue);
    line-height: 1;
}

.borrow-label {
    font-size: 0.7rem;
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* ===== Books Grid ===== */
.books-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 1.25rem;
}

.book-card {
    background-color: var(--background-white);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
    transition: all 0.2s ease;
}

.book-card:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-4px);
}

.book-image {
    width: 100%;
    height: 220px;
    object-fit: cover;
    background-color: var(--background-gray);
}

.book-info {
    padding: 1rem;
}

.book-title {
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.75rem;
    font-size: 0.95rem;
}

.book-details {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    font-size: 0.85rem;
    color: var(--text-tertiary);
    margin-bottom: 0.75rem;
}

.book-detail-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.book-detail-item i {
    color: var(--primary-blue);
}

.book-card-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
}

.status-badge {
    display: inline-flex;
    align-items: center;
    padding: 0.25rem 0.75rem;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 600;
}

.status-badge.active {
    background-color: #dbeafe;
    color: #1e40af;
}

.status-badge.due-soon, .status-badge.due-today {
    background-color: #fef3c7;
    color: #92400e;
}

.status-badge.overdue {
    background-color: #fee2e2;
    color: #991b1b;
}

/* ===== Upcoming List ===== */
.upcoming-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.upcoming-item {
    display: flex;
    gap: 1rem;
    align-items: center;
    padding: 1rem;
    border-radius: var(--radius-sm);
    background-color: var(--background-gray);
    border: 1px solid var(--border-color);
}

.upcoming-item-icon {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-sm);
    background-color: var(--primary-blue);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
}

.upcoming-item-title {
    font-weight: 600;
    color: var(--text-primary);
}

.upcoming-item-date {
    font-size: 0.85rem;
    color: var(--text-tertiary);
}

.upcoming-preview-item {
    display: flex;
    justify-content: space-between;
    padding: 0.75rem 1rem;
    border-radius: var(--radius-sm);
    background-color: var(--background-gray);
    border: 1px solid var(--border-color);
    font-size: 0.9rem;
}

.upcoming-preview-item span:last-child {
    color: var(--text-tertiary);
}

/* ===== History Table ===== */
.history-table-wrapper {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.history-table-head, .history-table-row {
    display: grid;
    grid-template-columns: 2fr 1fr 1fr 1fr;
    gap: 1rem;
    align-items: center;
    padding: 0.75rem 0;
}

.history-table-head {
    border-bottom: 1px solid var(--border-color);
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.history-table-row {
    padding: 0.75rem;
    border-radius: var(--radius-sm);
    transition: background-color 0.2s ease;
}

.history-table-row:hover {
    background-color: var(--background-gray);
}

.history-status-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.35rem 0.75rem;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: capitalize;
}

.history-status-badge.borrowed {
    background-color: #dbeafe;
    color: #1e40af;
}

.history-status-badge.returned {
    background-color: #d1fae5;
    color: #065f46;
}

.history-status-badge.overdue {
    background-color: #fee2e2;
    color: #991b1b;
}

.history-status-badge.default {
    background-color: var(--background-gray);
    color: var(--text-secondary);
}

/* ===== Charts Grid ===== */
.charts-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.chart-card {
    background-color: var(--background-white);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 1.5rem;
    box-shadow: var(--shadow-sm);
}

.chart-card h3 {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 1rem;
}

.chart-card canvas {
    max-height: 300px;
}

.chart-card.full-width {
    grid-column: 1 / -1;
}

.chart-container {
    position: relative;
    height: 280px;
}

.chart-card h3 i {
    color: var(--primary-blue);
    margin-right: 0.35rem;
}

/* ===== Favourite Count Badge ===== */
.fav-count-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 26px;
    height: 26px;
    padding: 0 8px;
    border-radius: 999px;
    background: linear-gradient(135deg, #ef4444, #dc2626);
    color: #fff;
    font-size: 0.8rem;
    font-weight: 700;
}

/* ===== Remove Favourite Button (Dashboard card) ===== */
.remove-fav-btn {
    position: absolute;
    top: 8px;
    right: 8px;
    z-index: 2;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: none;
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(4px);
    color: #ef4444;
    font-size: 1rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s, background 0.2s;
    box-shadow: 0 1px 4px rgba(0,0,0,0.12);
}

.remove-fav-btn:hover {
    transform: scale(1.15);
    background: #fff;
}

.fav-card {
    position: relative;
}

/* ===== Due Date Calendar List ===== */
.due-calendar-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.due-calendar-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem 1.25rem;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
    background-color: var(--background-gray);
    transition: all 0.2s ease;
}

.due-calendar-item:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow-sm);
}

.due-calendar-item.overdue {
    border-left: 4px solid #ef4444;
    background-color: #fef2f2;
}

.due-calendar-item.due-today {
    border-left: 4px solid #f59e0b;
    background-color: #fffbeb;
}

.due-calendar-item.due-soon {
    border-left: 4px solid #f97316;
    background-color: #fff7ed;
}

.due-calendar-item.upcoming {
    border-left: 4px solid #10b981;
    background-color: #f0fdf4;
}

.due-cal-icon {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 1rem;
}

.due-calendar-item.overdue .due-cal-icon {
    background: #fee2e2;
    color: #ef4444;
}

.due-calendar-item.due-today .due-cal-icon {
    background: #fef3c7;
    color: #f59e0b;
}

.due-calendar-item.due-soon .due-cal-icon {
    background: #ffedd5;
    color: #f97316;
}

.due-calendar-item.upcoming .due-cal-icon {
    background: #d1fae5;
    color: #10b981;
}

.due-cal-info {
    flex: 1;
    min-width: 0;
}

.due-cal-title {
    font-weight: 600;
    color: var(--text-primary);
    font-size: 0.95rem;
    margin-bottom: 0.25rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.due-cal-meta {
    display: flex;
    gap: 1rem;
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.due-cal-meta i {
    margin-right: 0.2rem;
}

.due-cal-date {
    text-align: right;
    flex-shrink: 0;
}

.due-cal-days {
    display: block;
    font-weight: 600;
    font-size: 0.85rem;
    color: var(--text-primary);
}

.due-calendar-item.overdue .due-cal-days {
    color: #ef4444;
}

.due-calendar-item.due-today .due-cal-days {
    color: #f59e0b;
}

.due-calendar-item.due-soon .due-cal-days {
    color: #f97316;
}

.due-cal-actual {
    display: block;
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-top: 0.1rem;
}

/* ===== Recommendation Favourite Button ===== */
.rec-fav-btn {
    position: absolute;
    top: 8px;
    right: 8px;
    z-index: 2;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: none;
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(4px);
    color: #9ca3af;
    font-size: 1rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s, background 0.2s, color 0.2s;
    box-shadow: 0 1px 4px rgba(0,0,0,0.12);
}

.rec-fav-btn:hover {
    color: #ef4444;
    background: #fff;
    transform: scale(1.15);
}

.rec-fav-btn.active {
    color: #ef4444;
}

.rec-fav-btn.active:hover {
    color: #dc2626;
}

/* ===== Recommendation Reason Badge ===== */
.rec-reason-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    font-size: 0.7rem;
    font-weight: 600;
    color: #8b5cf6;
    background: #f5f3ff;
    padding: 3px 8px;
    border-radius: 999px;
    border: 1px solid #ddd6fe;
}

.rec-reason-badge i {
    font-size: 0.7rem;
}

/* ===== Data Grid ===== */
.data-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 1.5rem;
}

.data-card {
    background-color: var(--background-white);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 1.5rem;
    box-shadow: var(--shadow-sm);
}

.data-card h3 {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 1rem;
}

.data-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.data-list-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1rem;
    border-radius: var(--radius-sm);
    background-color: var(--background-gray);
    border: 1px solid var(--border-color);
}

.data-item-content {
    flex: 1;
}

.data-item-title {
    font-weight: 600;
    color: var(--text-primary);
    font-size: 0.9rem;
}

.data-item-subtitle {
    font-size: 0.8rem;
    color: var(--text-tertiary);
    margin-top: 0.25rem;
}

.data-item-count {
    font-weight: 700;
    color: var(--primary-blue);
    font-size: 1.1rem;
}

/* ===== Empty States ===== */
.empty-state {
    text-align: center;
    padding: 3rem 2rem;
    color: var(--text-tertiary);
}

.empty-state i {
    font-size: 2.5rem;
    margin-bottom: 1rem;
    display: block;
    opacity: 0.5;
}

.empty-state.small {
    padding: 1.5rem;
}

.empty-state.small i {
    font-size: 1.5rem;
}

.loading-placeholder {
    text-align: center;
    color: var(--text-tertiary);
    padding: 2rem 1rem;
}

.error-message {
    text-align: center;
    color: #991b1b;
    padding: 2rem;
    background-color: #fef2f2;
    border-radius: var(--radius-md);
    border: 1px solid #fecaca;
}

/* ===== Text Utilities ===== */
.text-danger {
    color: #991b1b;
}

/* ===== Responsive Updates ===== */
@media (max-width: 768px) {
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .content-grid {
        grid-template-columns: 1fr;
    }
    
    .charts-grid {
        grid-template-columns: 1fr;
    }
    
    .data-grid {
        grid-template-columns: 1fr;
    }
    
    .books-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.75rem;
    }

    .book-image {
        height: 140px;
    }

    .book-info {
        padding: 0.75rem;
    }

    .book-title {
        font-size: 0.85rem;
        margin-bottom: 0.5rem;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .book-details {
        gap: 0.3rem;
        font-size: 0.75rem;
        margin-bottom: 0.5rem;
    }

    .book-detail-item {
        gap: 0.35rem;
    }

    .book-detail-item i {
        font-size: 0.7rem;
    }

    .status-badge {
        font-size: 0.65rem;
        padding: 1px 6px;
    }

    .book-card-footer {
        flex-wrap: wrap;
        gap: 0.3rem;
    }

    .rec-reason-badge {
        font-size: 0.6rem;
        padding: 2px 6px;
    }

    .remove-fav-btn {
        width: 28px;
        height: 28px;
        font-size: 0.85rem;
    }

    .history-table-head,
    .history-table-row {
        grid-template-columns: 2fr 1fr;
        font-size: 0.85rem;
    }
    
    .history-table-row span:nth-child(3),
    .history-table-row span:nth-child(4) {
        display: none;
    }
    
    .due-calendar-item {
        flex-wrap: wrap;
        gap: 0.5rem;
        padding: 0.75rem;
    }

    .due-cal-date {
        width: 100%;
        text-align: left;
        display: flex;
        gap: 0.5rem;
        align-items: center;
    }

    .due-cal-meta {
        flex-wrap: wrap;
        gap: 0.5rem;
    }

    .chart-container {
        height: 220px;
    }

    .trending-book-item {
        padding: 0.75rem;
        gap: 0.75rem;
    }
    
    .trending-rank {
        width: 36px;
        height: 36px;
        font-size: 0.9rem;
    }
    
    .trending-book-title {
        font-size: 0.95rem;
    }
    
    .trending-book-author {
        font-size: 0.8rem;
    }
    
    .trending-book-count {
        min-width: 60px;
        padding: 0.4rem 0.6rem;
    }
    
    .borrow-count {
        font-size: 1.1rem;
    }
    
    .borrow-label {
        font-size: 0.65rem;
    }
}

@media (max-width: 480px) {
    .stats-grid {
        grid-template-columns: 1fr;
    }
    
    .books-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.6rem;
    }

    .book-image {
        height: 120px;
    }

    .book-info {
        padding: 0.6rem;
    }

    .book-title {
        font-size: 0.8rem;
        margin-bottom: 0.4rem;
    }

    .book-details {
        gap: 0.25rem;
        font-size: 0.7rem;
        margin-bottom: 0.4rem;
    }

    .book-detail-item i {
        font-size: 0.65rem;
    }

    .status-badge {
        font-size: 0.6rem;
        padding: 1px 5px;
    }

    .rec-reason-badge {
        font-size: 0.55rem;
        padding: 1px 5px;
    }

    .remove-fav-btn {
        width: 26px;
        height: 26px;
        font-size: 0.8rem;
    }
    
    .section-header {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .trending-book-item {
        padding: 0.625rem;
        gap: 0.625rem;
        flex-wrap: wrap;
    }
    
    .trending-rank {
        width: 32px;
        height: 32px;
        font-size: 0.85rem;
    }
    
    .trending-book-info {
        flex: 1;
        min-width: 0;
    }
    
    .trending-book-title {
        font-size: 0.9rem;
    }
    
    .trending-book-author {
        font-size: 0.75rem;
    }
    
    .trending-book-count {
        width: 100%;
        flex-direction: row;
        justify-content: center;
        gap: 0.5rem;
        min-width: auto;
    }
    
    .borrow-count {
        font-size: 1rem;
    }
}

/* ===== Mobile Side Navigation (Users Only) ===== */
.hamburger-btn {
    display: none; /* Hidden by default, shown on mobile for users */
    width: 44px;
    height: 44px;
    border-radius: var(--radius-md);
    background-color: var(--background-gray);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    margin-right: 1rem;
    font-size: 1.25rem;
}

.hamburger-btn:hover {
    background-color: var(--primary-blue);
    color: white;
    border-color: var(--primary-blue);
}

.side-nav {
    position: fixed;
    top: 0;
    left: -320px;
    width: 320px;
    height: 100vh;
    background-color: var(--background-white);
    border-right: 1px solid var(--border-color);
    box-shadow: var(--shadow-lg);
    z-index: 1000;
    transition: left 0.3s ease;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}

.side-nav.open {
    left: 0;
}

.side-nav-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.5rem;
    border-bottom: 1px solid var(--border-color);
    background-color: var(--background-white);
    position: sticky;
    top: 0;
    z-index: 10;
}

.side-nav-header h3 {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
}

.side-nav-close {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background-color: var(--background-gray);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 1.1rem;
}

.side-nav-close:hover {
    background-color: var(--primary-blue);
    color: white;
    border-color: var(--primary-blue);
}

.side-nav-menu {
    display: flex;
    flex-direction: column;
    padding: 1rem 0;
    flex: 1;
}

.side-nav-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem 1.5rem;
    color: var(--text-secondary);
    text-decoration: none;
    transition: all 0.2s ease;
    border-left: 3px solid transparent;
    font-weight: 500;
}

.side-nav-item:hover {
    background-color: var(--background-gray);
    color: var(--primary-blue);
}

.side-nav-item.active {
    background-color: rgba(37, 99, 235, 0.1);
    color: var(--primary-blue);
    border-left-color: var(--primary-blue);
    font-weight: 600;
}

.side-nav-item i {
    font-size: 1.25rem;
    width: 24px;
    text-align: center;
}

.side-nav-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 999;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.side-nav-backdrop.active {
    opacity: 1;
    visibility: visible;
}

/* ===== Responsive: Show Mobile Nav for Users on Mobile ===== */
@media (max-width: 768px) {
    /* Show hamburger button for users on mobile */
    .hamburger-btn {
        display: flex;
    }
    
    /* Center logo on mobile - use static so icon-container positions relative to header-container */
    .header-left {
        display: flex;
        align-items: center;
        position: static;
    }
    
    /* Center the logo container - keep behind org switcher when it's visible */
    .header-left .icon-container {
        position: absolute;
        left: 50%;
        transform: translateX(-50%);
        z-index: 0;
        pointer-events: auto;
    }
    
    /* Hide horizontal nav on mobile for users (but keep for admin) */
    .secondary-nav:not(.admin-nav) {
        display: none;
    }
    
    /* Adjust main content margin when side nav is open */
    .main-content {
        transition: margin-left 0.3s ease;
    }
}

/* ===== Admin Dashboard: Always Desktop View ===== */
/* Force admin to always show horizontal nav, never mobile nav */
.admin-nav {
    display: flex !important;
}

/* Hide hamburger and side nav for admin */
body.admin-dashboard .hamburger-btn {
    display: none !important;
}

body.admin-dashboard .side-nav {
    display: none !important;
}

/* Admin header: keep logo left-aligned, no extra min-width when hamburger is hidden */
body.admin-dashboard .header-left {
    min-width: 0;
}

body.admin-dashboard .header-left .icon-container {
    position: static;
    transform: none;
    left: auto;
}

/* ===== History Filters & Table Styles ===== */
.history-filters-container {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    margin-bottom: 1.5rem;
    padding: 1rem;
    background-color: var(--background-white);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
}

/* Searchable dropdown for history */
.history-filters-container .searchable-dropdown {
    position: relative;
    flex: 1;
    min-width: 240px;
    font-size: 0.95rem;
}

.history-filters-container .searchable-dropdown input {
    width: 100%;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
    background: var(--background-white);
    font-size: 0.95rem;
    box-sizing: border-box;
    transition: all 0.2s ease;
}

.history-filters-container .searchable-dropdown input:focus {
    outline: none;
    border-color: var(--primary-blue);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.history-filters-container .searchable-dropdown-list {
    display: none;
    position: absolute;
    left: 0;
    right: 0;
    margin-top: 4px;
    background: var(--background-white);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-lg);
    list-style: none;
    padding: 8px 0;
    max-height: 200px;
    overflow-y: auto;
    z-index: 1000;
}

.history-filters-container .searchable-dropdown.open .searchable-dropdown-list {
    display: block;
}

.history-filters-container .searchable-dropdown-list li {
    padding: 10px 16px;
    cursor: pointer;
    transition: all 0.15s ease;
    border-bottom: 1px solid var(--background-gray);
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.history-filters-container .searchable-dropdown-list li:last-child {
    border-bottom: none;
}

.history-filters-container .searchable-dropdown-list li:hover {
    background-color: var(--background-gray);
    color: var(--primary-blue);
    padding-left: 20px;
}

.history-filters-container .searchable-dropdown-list li.no-results {
    color: var(--text-tertiary);
    font-style: italic;
    text-align: center;
    padding: 16px;
    cursor: default;
}

.history-filters-container .searchable-dropdown-list li.no-results:hover {
    background: transparent;
    padding-left: 16px;
}

/* Custom dropdown for history */
.history-filters-container .custom-dropdown {
    position: relative;
    min-width: 180px;
    font-size: 0.95rem;
}

.history-filters-container .custom-dropdown-selected {
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
    background: var(--background-white);
    cursor: pointer;
    user-select: none;
    display: flex;
    align-items: center;
    justify-content: space-between;
    transition: all 0.2s ease;
}

.history-filters-container .custom-dropdown-selected:hover {
    border-color: var(--primary-blue);
}

.history-filters-container .custom-dropdown-list {
    display: none;
    position: absolute;
    left: 0;
    right: 0;
    margin-top: 6px;
    background: var(--background-white);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-lg);
    list-style: none;
    padding: 6px 0;
    max-height: 220px;
    overflow-y: auto;
    z-index: 1000;
}

.history-filters-container .custom-dropdown.open .custom-dropdown-list {
    display: block;
}

.history-filters-container .custom-dropdown-list li {
    padding: 8px 12px;
    cursor: pointer;
    transition: background 0.15s;
    border-bottom: 1px solid var(--background-gray);
}

.history-filters-container .custom-dropdown-list li:last-child {
    border-bottom: none;
}

.history-filters-container .custom-dropdown-list li:hover {
    background-color: var(--background-gray);
}

.history-filters-container .custom-dropdown-list li.selected {
    background-color: rgba(37, 99, 235, 0.1);
    color: var(--primary-blue);
    font-weight: 600;
}

/* Custom date inputs */
#historyCustomDateInputs {
    display: none;
    flex-wrap: wrap;
    gap: 12px;
}

#historyCustomDateInputs .input-wrapper {
    position: relative;
    min-width: 180px;
}

#historyCustomDateInputs .input-wrapper input {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-size: 0.95rem;
    background: var(--background-white);
}

#historyCustomDateInputs .input-wrapper label {
    position: absolute;
    top: 50%;
    left: 12px;
    transform: translateY(-50%);
    font-size: 0.9rem;
    color: var(--text-tertiary);
    pointer-events: none;
    background: white;
    padding: 0 4px;
    transition: 0.2s ease all;
}

#historyCustomDateInputs .input-wrapper input:focus + label,
#historyCustomDateInputs .input-wrapper input:not(:placeholder-shown) + label {
    top: -8px;
    left: 8px;
    font-size: 0.75rem;
}

/* History Table Container */
.history-table-container {
    width: 100%;
    background: var(--background-white);
    border-radius: var(--radius-md);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
}

.history-table-header {
    display: flex;
    align-items: center;
    width: 100%;
    background-color: var(--primary-blue);
    color: white;
    font-weight: 600;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.07);
}

.history-table-row {
    display: flex;
    align-items: center;
    width: 100%;
    border-bottom: 1px solid var(--border-color);
    transition: background-color 0.2s ease;
}

.history-table-row:hover {
    background-color: var(--background-gray);
}

.history-table-cell {
    flex: 1;
    text-align: left;
    padding: 12px;
    font-size: 0.95rem;
}

.history-table-cell.titleHeader {
    flex-basis: 300px;
    min-width: 200px;
    max-width: 400px;
}

.history-table-cell.borrowedHeader {
    flex-basis: 200px;
    min-width: 140px;
    max-width: 200px;
}

.history-table-cell.dueHeader {
    flex-basis: 200px;
    min-width: 140px;
    max-width: 200px;
}

.history-table-cell.statusHeader {
    flex-basis: 150px;
    min-width: 100px;
    max-width: 180px;
}

.history-table-rows {
    max-height: 600px;
    overflow-y: auto;
    padding: 10px 0;
}

/* Status badges for history */
.status-badge {
    display: inline-block;
    width: 100px;
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 600;
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.status-hired {
    background-color: #00C896;
    color: white;
}

.status-extended {
    background-color: #FFB74D;
    color: white;
}

.status-overdue {
    background-color: #E57373;
    color: white;
}

.status-returned {
    background-color: #9E9E9E;
    color: white;
}

.status-unknown {
    background-color: #E0E0E0;
    color: #616161;
}

/* Loading spinner */
.loading-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid var(--background-gray);
    border-top: 4px solid var(--primary-blue);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* History notification box */
.history-notification-box {
    position: fixed;
    top: 30px;
    left: 50%;
    transform: translateX(-50%);
    background: rgb(230, 244, 234);
    color: rgb(30, 70, 32);
    padding: 16px 32px;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-md);
    z-index: 2000;
    min-width: 260px;
    text-align: center;
    font-size: 1rem;
}

/* Responsive history filters */
@media (max-width: 768px) {
    /* Section header adjustments */
    .section-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.75rem;
        padding-bottom: 0.75rem;
        margin-bottom: 1rem;
    }
    
    .section-header h2 {
        font-size: 1.5rem;
    }
    
    .section-title-with-refresh {
        gap: 0.5rem;
    }
    
    .refresh-icon-btn {
        width: 28px;
        height: 28px;
        font-size: 0.9rem;
    }
    
    .section-title-with-refresh {
        gap: 0.4rem;
    }
    
    .section-subtitle {
        font-size: 0.85rem;
    }
    
    .history-filters-container {
        flex-direction: column;
        padding: 0.75rem;
        gap: 0.75rem;
        margin-bottom: 1rem;
        border-radius: var(--radius-sm);
    }
    
    .history-filters-container .searchable-dropdown,
    .history-filters-container .custom-dropdown {
        width: 100%;
        min-width: 100%;
    }
    
    #historyCustomDateInputs {
        flex-direction: column;
        width: 100%;
    }
    
    #historyCustomDateInputs .input-wrapper {
        width: 100%;
        min-width: 100%;
    }
    
    /* Hide table header on mobile, use card layout instead */
    .history-table-header {
        display: none;
    }
    
    .history-table-row {
        flex-direction: column;
        align-items: flex-start;
        padding: 1rem;
        border-bottom: 2px solid var(--border-color);
        gap: 0.75rem;
        background-color: var(--background-white);
        margin-bottom: 0.5rem;
        border-radius: var(--radius-sm);
        box-shadow: var(--shadow-sm);
    }
    
    .history-table-row:last-child {
        border-bottom: none;
        margin-bottom: 0;
    }
    
    .history-table-cell {
        width: 100%;
        padding: 0.5rem 0;
        display: flex;
        flex-direction: column;
        gap: 0.25rem;
        word-wrap: break-word;
        overflow-wrap: break-word;
    }
    
    .history-table-cell span {
        word-break: break-word;
    }
    
    /* Add labels before each cell value on mobile */
    .history-table-cell::before {
        content: attr(data-label);
        font-size: 0.75rem;
        font-weight: 600;
        color: var(--text-tertiary);
        text-transform: uppercase;
        letter-spacing: 0.05em;
        margin-bottom: 0.25rem;
        display: block;
    }
    
    .history-table-cell.titleHeader,
    .history-table-cell.borrowedHeader,
    .history-table-cell.dueHeader,
    .history-table-cell.statusHeader {
        flex-basis: auto;
        min-width: auto;
        max-width: none;
    }
    
    .history-table-rows {
        max-height: none;
        padding: 0.5rem;
        display: flex;
        flex-direction: column;
        gap: 0.5rem;
    }
    
    .history-table-container {
        border-radius: var(--radius-sm);
        overflow: visible;
    }
    
    .history-table-container .history-table-header {
        display: none;
    }
    
    .status-badge {
        width: auto;
        min-width: 80px;
        max-width: 120px;
    }
}

/* Extra small mobile devices */
@media (max-width: 480px) {
    .history-filters-container {
        padding: 0.5rem;
        gap: 0.5rem;
    }
    
    .history-filters-container .searchable-dropdown input,
    .history-filters-container .custom-dropdown-selected {
        padding: 8px 10px;
        font-size: 0.9rem;
    }
    
    .history-table-row {
        padding: 0.75rem;
        gap: 0.5rem;
    }
    
    .history-table-cell {
        font-size: 0.9rem;
        padding: 0.4rem 0;
    }
    
    .history-table-cell::before {
        font-size: 0.7rem;
    }
    
    .section-title-with-refresh {
        gap: 0.4rem;
    }
    
    .refresh-icon-btn {
        width: 26px;
        height: 26px;
        font-size: 0.85rem;
    }
    
    .section-header h2 {
        font-size: 1.4rem;
    }
}

/* Popup Message Styles */
.popup-message {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 10000;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s, visibility 0.3s;
}

.popup-message.active {
    opacity: 1;
    visibility: visible;
}

#popupContent {
    background: white;
    padding: 30px;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    max-width: 500px;
    width: 90%;
    position: relative;
    text-align: center;
}

.close-btn {
    position: absolute;
    top: 10px;
    right: 15px;
    font-size: 28px;
    cursor: pointer;
    color: #999;
    line-height: 1;
    transition: color 0.2s;
}

.close-btn:hover {
    color: #333;
}

#popupText {
    font-size: 16px;
    color: #333;
    line-height: 1.5;
    margin-top: 10px;
}

.blurred {
    filter: blur(5px);
    pointer-events: none;
    transition: filter 0.3s;
}

/* Success message styling */
.success-popup {
    background-color: #d4edda !important;
    border: 1px solid #c3e6cb !important;
}

.success-popup #popupText {
    color: #155724 !important;
    font-weight: 500;
}