/* Bookshelf styles integrated with Arken project structure */

/* Top navigation & common layout (aligned with history/marketplace) */
.old-paper-bg,
body.bookshelf-page {
    background: #f5f1e9; /* subtle old paper tone */
    color: #2b2b2b;
}
.social-container {
        display: flex;
        flex-direction: column;
        min-height: 100vh;
}
/* Upload Modal (glassmorphism style to match history/marketplace) */
.modal { position: fixed; inset: 0; z-index: 1100; display: none; }
.modal.show { display: block; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,0.35); backdrop-filter: blur(2px); }
.modal-content {
    position: relative; max-width: 720px; margin: 8vh auto; border-radius: 16px;
    background: rgba(255,255,255,0.6);
    border: 1px solid rgba(224,224,224,0.6);
    box-shadow: 0 24px 48px rgba(0,0,0,0.12);
    backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
}

/* Floating + draggable modal behavior */
.modal-floating {
    position: fixed;
    top: 12%;
    left: 50%;
    transform: translateX(-50%);
    margin: 0;
}
.modal-header {
    cursor: move;
    user-select: none;
}

/* Resizable modal enhancements */
.modal-resizable { min-width: 480px; min-height: 320px; }
.resize-handle {
    position: absolute; right: 8px; bottom: 8px; width: 14px; height: 14px;
    cursor: se-resize; border-radius: 3px;
    background: linear-gradient(135deg, rgba(255,255,255,0.9), rgba(200,200,200,0.5));
    box-shadow: inset 0 0 0 1px rgba(0,0,0,0.08);
}
.modal-header { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid rgba(224,224,224,0.5); }
.modal-header { cursor: move; }
.modal-body { padding: 20px; }
.modal-close { border: none; background: transparent; font-size: 22px; cursor: pointer; line-height: 1; }

/* Floating modal enhancements */
.modal-content { position: relative; }
.modal-floating { position: fixed; left: 50%; top: 10vh; transform: translateX(-50%); }

/* Upload form layout */
.form-row { margin-bottom: 12px; display: flex; gap: 12px; }
.form-row.two-cols > input { flex: 1; }
input[type="text"], input[type="number"], input[type="file"] { width: 100%; padding: 10px 12px; border-radius: 10px; border: 1px solid rgba(218,220,224,0.7); background: rgba(255,255,255,0.7); }
.btn.primary { padding: 10px 16px; border-radius: 12px; border: 1px solid rgba(26,115,232,0.5); background: rgba(26,115,232,0.12); color: #1a73e8; cursor: pointer; }
.btn.primary:hover { background: rgba(26,115,232,0.18); }
.status { margin-left: 10px; font-size: 14px; color: #5f6368; }

/* Upload trigger alignment */
.upload-trigger { display: flex; justify-content: flex-end; margin: 10px 0 0; }

/* Reader modal sizing override */
#reader-modal .modal-content { max-width: 960px; }
#reader-modal .modal-body { height: 80vh; padding: 0; }

.top-nav {
    position: sticky;
    top: 0;
    z-index: 1000;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 16px;
    /* Glassmorphism */
    background: rgba(255, 255, 255, 0.6);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-bottom: 1px solid rgba(224, 224, 224, 0.6);
}

.nav-left { display: flex; align-items: center; gap: 12px; }
.logo { font-weight: 700; color: #1a1a1a; text-decoration: none; }

.search-bar { display: flex; gap: 8px; align-items: center; }
.search-bar input { padding: 8px 12px; border: 1px solid #dadce0; border-radius: 20px; }
.search-bar button { padding: 8px 12px; border: 1px solid #dadce0; border-radius: 20px; background: #f8f9fa; cursor: pointer; }

.nav-right { display: flex; align-items: center; gap: 10px; }
.mobile-menu-btn { display: inline-flex; flex-direction: column; gap: 4px; padding: 8px; border: 1px solid #dadce0; border-radius: 8px; background: #f8f9fa; cursor: pointer; }
.hamburger-line { width: 20px; height: 2px; background: #333; display: block; }
.nav-btn { border: none; background: transparent; cursor: pointer; font-size: 18px; position: relative; }
.notification-badge { position: absolute; top: -6px; right: -6px; background: #e53935; color: #fff; border-radius: 10px; padding: 0 6px; font-size: 12px; }

.user-menu { position: relative; }
.user-avatar { border: none; background: transparent; cursor: pointer; }
.user-avatar img { width: 32px; height: 32px; border-radius: 50%; }
.user-dropdown { position: absolute; right: 0; top: 40px; background: rgba(255,255,255,0.65); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); border: 1px solid rgba(224,224,224,0.6); border-radius: 12px; min-width: 200px; display: none; box-shadow: 0 10px 20px rgba(0,0,0,0.08); }
.user-dropdown.show { display: block; }
.dropdown-item { display: block; padding: 10px 12px; text-decoration: none; color: #333; }
.dropdown-item.logout-btn { background: #fff; border: none; width: 100%; text-align: left; cursor: pointer; }

/* Mobile menu overlay and drawer */
.mobile-menu-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.2); display: none; z-index: 900; }
.mobile-menu-overlay.show { display: block; }

.desktop-nav-container { position: fixed; top: 0; left: 0; height: 100%; width: 280px; background: rgba(255,255,255,0.55); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); border-right: 1px solid rgba(224,224,224,0.6); transform: translateX(-100%); transition: transform .3s ease; z-index: 950; }
.desktop-nav-container.show { transform: translateX(0); }
.mobile-menu-content { padding: 16px; height: 100%; display: flex; flex-direction: column; gap: 20px; }
.sidebar-header-nav { display: flex; justify-content: space-between; align-items: center; }
.mobile-close-btn { border: none; background: transparent; font-size: 24px; cursor: pointer; }
.mobile-menu-section h4 { margin: 12px 0; color: #444; }
.mobile-menu-items { display: flex; flex-direction: column; gap: 8px; }
.mobile-menu-item { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 12px; color: #1a1a1a; text-decoration: none; border: 1px solid rgba(230,230,230,0.7); background: rgba(255,255,255,0.5); }
.mobile-menu-item:hover { background: rgba(230,240,255,0.6); border-color: rgba(205,224,255,0.9); }
.mobile-menu-item.active { background: rgba(230, 238, 250, 0.8); border-color: #1a73e8; }
.menu-icon { width: 20px; text-align: center; }
.user-info-sidebar { display: flex; gap: 10px; align-items: center; border-top: 1px solid #eee; padding-top: 12px; }
.user-avatar-sidebar { width: 40px; height: 40px; border-radius: 50%; }

/* Desktop-only sidebar */
.desktop-only { display: none; }
@media (min-width: 1024px) {
    .desktop-only { display: block; }
    /* Ensure desktop floating sidebar is always visible on wide screens on the left */
    .desktop-only.desktop-nav-container { transform: none; left: 0; right: auto; border-right: 1px solid #e0e0e0; border-left: none; }
}

/* Content header */
.content-header {
    text-align: center;
    margin-bottom: 30px;
    padding: 20px 0;
}

.content-header h1 {
    font-size: 2.5rem;
    margin: 0;
    color: #1a1a1a;
}

.content-header .subtitle {
    font-size: 1.1rem;
    color: #666;
    margin-top: 5px;
}

/* Filter section */
.filter-section {
    margin-bottom: 30px;
    text-align: center;
}

.filter-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: center;
}

.filter-btn {
    padding: 8px 16px;
    border: 1px solid #dadce0;
    border-radius: 20px;
    background-color: #f8f9fa;
    color: #3c4043;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.filter-btn:hover {
    border-color: #c5c5c5;
    background-color: #e8eaed;
}

.filter-btn.active {
    background-color: #e6eefa;
    border-color: #1a73e8;
    color: #1a73e8;
    font-weight: bold;
}

/* Books grid */
.books-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 25px;
    margin-top: 20px;
}

.book-card {
    background-color: #fffef6; /* slightly warm to match paper */
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    padding: 20px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.book-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.book-source {
    font-size: 0.85em;
    color: #5f6368;
    margin-bottom: 5px;
    text-transform: uppercase;
}

.book-title {
    font-size: 1.2em;
    font-weight: 600;
    color: #1a0dab;
    text-decoration: none;
    margin-bottom: 10px;
    line-height: 1.3;
}

.book-title:hover {
    text-decoration: underline;
}

.book-snippet {
    font-size: 0.95em;
    color: #545454;
    line-height: 1.5;
    margin-bottom: 15px;
    flex-grow: 1;
}

.book-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.8em;
    color: #70757a;
}

.book-date {
    white-space: nowrap;
}

/* Pagination */
.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 15px;
    margin-top: 40px;
    padding-bottom: 40px;
}

.pagination button {
    padding: 10px 20px;
    border: 1px solid rgba(218,220,224,0.7);
    border-radius: 20px;
    background: rgba(248,249,250,0.6);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    color: #1a73e8;
    font-size: 15px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.pagination button:hover:not(:disabled) {
    background-color: #e8eaed;
    border-color: #c5c5c5;
}

.pagination button:disabled {
    color: #bdc1c6;
    cursor: not-allowed;
    background-color: #f1f3f4;
}

.pagination #page-info {
    font-size: 16px;
    font-weight: 500;
    color: #3c4043;
}

/* Loading indicator */
.loading-indicator {
    text-align: center;
    padding: 40px;
}

.spinner {
    border: 4px solid #f3f3f3;
    border-top: 4px solid #1a73e8;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
    margin: 0 auto 20px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* No books message */
.no-books {
    text-align: center;
    color: #5f6368;
    padding: 40px;
    font-size: 1.1rem;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .content-header h1 {
        font-size: 2rem;
    }
    
    .filter-buttons {
        justify-content: flex-start;
        overflow-x: auto;
        padding-bottom: 5px;
    }

    .filter-btn {
        flex-shrink: 0;
    }

    .books-grid {
        grid-template-columns: 1fr;
        gap: 20px;
    }
    .desktop-only { display: none; }
}