/* Category Page Styles */

/* ========================================
   Category Page Layout
   ======================================== */

.category-page {
    background: var(--bg-pattern);
    min-height: 100vh;
    padding: 2rem 0 4rem;
    position: relative;
}

/* Category Header */
.category-header {
    background: linear-gradient(135deg, var(--brown-primary) 0%, var(--brown-dark) 100%);
    padding: 3rem 2rem;
    border-radius: var(--border-radius-lg);
    margin-bottom: 2rem;
    box-shadow: 0 8px 30px var(--shadow-medium);
    position: relative;
    overflow: hidden;
}

.category-header::before {
    content: '';
    position: absolute;
    top: -50%;
    right: -10%;
    width: 400px;
    height: 400px;
    background: radial-gradient(circle, rgba(255,255,255,0.1) 0%, transparent 70%);
    border-radius: 50%;
    pointer-events: none;
}

.category-header::after {
    content: '';
    position: absolute;
    bottom: -30%;
    left: -5%;
    width: 300px;
    height: 300px;
    background: radial-gradient(circle, rgba(255,255,255,0.08) 0%, transparent 70%);
    border-radius: 50%;
    pointer-events: none;
}

.header-content {
    position: relative;
    z-index: 2;
}

.page-title {
    font-size: 2.5rem;
    color: white;
    font-weight: 700;
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 1rem;
}

.page-title i {
    font-size: 2.2rem;
    color: var(--gold-accent);
}

.page-description {
    font-size: 1.1rem;
    color: rgba(255,255,255,0.9);
    margin-bottom: 1.5rem;
}

.breadcrumb-nav {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.95rem;
    color: rgba(255,255,255,0.8);
}

.breadcrumb-nav a {
    color: rgba(255,255,255,0.9);
    text-decoration: none;
    transition: var(--transition-fast);
    display: flex;
    align-items: center;
    gap: 0.3rem;
}

.breadcrumb-nav a:hover {
    color: var(--gold-accent);
}

.breadcrumb-nav .separator {
    color: rgba(255,255,255,0.5);
}

.breadcrumb-nav .current {
    color: var(--gold-accent);
    font-weight: 600;
}

/* Quick Stats */
.stats-quick {
    display: flex;
    justify-content: flex-end;
    gap: 2rem;
    position: relative;
    z-index: 2;
}

.stats-quick .stat-item {
    text-align: center;
    background: rgba(255,255,255,0.1);
    backdrop-filter: blur(10px);
    padding: 1.5rem 2rem;
    border-radius: var(--border-radius);
    border: 1px solid rgba(255,255,255,0.2);
    transition: var(--transition);
}

.stats-quick .stat-item:hover {
    transform: translateY(-5px);
    background: rgba(255,255,255,0.15);
    box-shadow: 0 8px 20px rgba(0,0,0,0.2);
}

.stats-quick .stat-number {
    display: block;
    font-size: 2.5rem;
    font-weight: 700;
    color: #fff;
    line-height: 1;
    margin-bottom: 0.5rem;
}

.stats-quick .stat-label {
    display: block;
    font-size: 0.95rem;
    color: rgba(255,255,255,0.9);
    font-weight: 500;
}

/* ========================================
   Filters Sidebar
   ======================================== */

.filters-sidebar {
    background: white;
    border-radius: var(--border-radius);
    box-shadow: 0 4px 20px var(--shadow-light);
    padding: 1.5rem;
    position: sticky;
    top: 20px;
    max-height: calc(100vh - 40px);
    overflow-y: auto;
}

.filters-sidebar::-webkit-scrollbar {
    width: 5px;
}

.filters-sidebar::-webkit-scrollbar-thumb {
    background: var(--brown-primary);
    border-radius: 5px;
}

.filter-section {
    margin-bottom: 1.5rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid var(--border-decorative);
}

.filter-section:last-child {
    border-bottom: none;
}

.filter-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    cursor: pointer;
    user-select: none;
}

.filter-header.collapsible:hover .filter-title {
    color: var(--brown-primary);
}

.filter-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-dark);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin: 0;
    transition: var(--transition-fast);
}

.filter-title i {
    color: var(--brown-primary);
    font-size: 1rem;
}

.toggle-icon {
    color: var(--text-medium);
    font-size: 0.9rem;
    transition: transform 0.3s ease;
}

.filter-header.active .toggle-icon {
    transform: rotate(180deg);
}

.filter-content {
    animation: slideDown 0.3s ease;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Search Filter */
.search-filter .search-box {
    position: relative;
}

.filter-search-input {
    width: 100%;
    padding: 0.75rem 2.5rem 0.75rem 1rem;
    border: 2px solid var(--border-decorative);
    border-radius: 8px;
    font-size: 0.95rem;
    transition: var(--transition-fast);
    background: var(--bg-pattern);
}

.filter-search-input:focus {
    outline: none;
    border-color: var(--brown-primary);
    box-shadow: 0 0 0 3px rgba(19, 95, 122, 0.1);
}

.search-icon-btn {
    position: absolute;
    left: 10px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: var(--brown-primary);
    font-size: 1rem;
    cursor: pointer;
    padding: 0.5rem;
    transition: var(--transition-fast);
}

.search-icon-btn:hover {
    color: var(--gold-accent);
    transform: translateY(-50%) scale(1.1);
}

/* Search Loading State */
.filter-search-input.searching {
    background-image: linear-gradient(90deg, transparent 0%, rgba(19, 95, 122, 0.05) 50%, transparent 100%);
    background-size: 200% 100%;
    animation: searchPulse 1.5s ease-in-out infinite;
}

@keyframes searchPulse {
    0%, 100% { background-position: -200% 0; }
    50% { background-position: 200% 0; }
}

/* Search Results Highlight */
.book-card.search-match {
    animation: fadeInUp 0.3s ease-out;
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Filter Options */
.filter-options {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

/* Collapsible section groups */
.section-group {
    display: flex;
    flex-direction: column;
}

.section-group-row {
    display: flex;
    align-items: center;
}

.section-group-row > .filter-option {
    flex: 1;
    margin-bottom: 0;
}

.children-toggle {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-medium, #888);
    padding: 4px 6px;
    flex-shrink: 0;
    line-height: 1;
    transition: transform 0.25s ease, color 0.2s;
}

.children-toggle:hover {
    color: var(--brown-primary);
}

.children-toggle.expanded {
    transform: rotate(-90deg);
}

.section-children {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    padding-right: 0.75rem;
    border-right: 2px solid var(--border-decorative, #e0d5c8);
    margin-right: 0.6rem;
    margin-top: 0.25rem;
    margin-bottom: 0.25rem;
}

.filter-option-child {
    font-size: 0.92rem;
}

.filter-option {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    cursor: pointer;
    padding: 0.5rem;
    border-radius: 6px;
    transition: var(--transition-fast);
    position: relative;
}

.filter-option:hover {
    background: var(--bg-pattern);
}

.filter-checkbox,
.filter-radio {
    position: absolute;
    opacity: 0;
    cursor: pointer;
}

.checkmark,
.radio-mark {
    width: 20px;
    height: 20px;
    border: 2px solid var(--border-decorative);
    border-radius: 4px;
    background: white;
    position: relative;
    flex-shrink: 0;
    transition: var(--transition-fast);
}

.radio-mark {
    border-radius: 50%;
}

.filter-checkbox:checked ~ .checkmark,
.filter-radio:checked ~ .radio-mark {
    background: var(--brown-primary);
    border-color: var(--brown-primary);
}

.filter-checkbox:checked ~ .checkmark::after {
    content: '\f00c';
    font-family: 'Font Awesome 6 Free';
    font-weight: 900;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: white;
    font-size: 0.7rem;
}

.filter-radio:checked ~ .radio-mark::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: white;
}

.option-label {
    flex: 1;
    font-size: 0.95rem;
    color: var(--text-dark);
}

.option-count {
    font-size: 0.85rem;
    color: var(--text-light);
    font-weight: 500;
}

/* Filter Search Box */
.filter-search-box {
    margin-bottom: 0.75rem;
}

.filter-search {
    width: 100%;
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--border-decorative);
    border-radius: 6px;
    font-size: 0.9rem;
    transition: var(--transition-fast);
}

.filter-search:focus {
    outline: none;
    border-color: var(--brown-primary);
}

/* Year Range Slider */
.year-range-slider {
    padding: 0.5rem 0;
}

.range-values {
    display: flex;
    justify-content: space-between;
    margin-bottom: 1rem;
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--brown-primary);
}

.year-range {
    width: 100%;
    height: 6px;
    border-radius: 3px;
    background: var(--border-decorative);
    outline: none;
    -webkit-appearance: none;
}

.year-range::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--brown-primary);
    cursor: pointer;
    transition: var(--transition-fast);
}

.year-range::-webkit-slider-thumb:hover {
    background: var(--gold-accent);
    transform: scale(1.2);
}

.year-range::-moz-range-thumb {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--brown-primary);
    cursor: pointer;
    border: none;
    transition: var(--transition-fast);
}

.year-range::-moz-range-thumb:hover {
    background: var(--gold-accent);
    transform: scale(1.2);
}

/* Clear Filters Button */
.clear-filters-btn {
    width: 100%;
    padding: 0.75rem;
    background: linear-gradient(135deg, var(--burgundy-accent) 0%, var(--burgundy-light) 100%);
    color: white;
    border: none;
    border-radius: 8px;
    font-weight: 600;
    font-size: 0.95rem;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    box-shadow: 0 4px 15px rgba(32, 77, 93, 0.3);
}

.clear-filters-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(32, 77, 93, 0.4);
}

.clear-filters-btn:active {
    transform: translateY(0);
}

/* ========================================
   Results Toolbar
   ======================================== */

.results-toolbar {
    background: white;
    padding: 1rem 1.5rem;
    border-radius: var(--border-radius);
    box-shadow: 0 2px 10px var(--shadow-light);
    margin-bottom: 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
}

.toolbar-left {
    display: flex;
    align-items: center;
    gap: 1.5rem;
    flex: 1;
}

.results-count {
    display: flex;
    align-items: baseline;
    gap: 0.5rem;
}

.count-number {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--brown-primary);
}

.count-label {
    font-size: 0.95rem;
    color: var(--text-medium);
}

.active-filters {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.filter-tag {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.4rem 0.75rem;
    background: var(--bg-pattern);
    border: 1px solid var(--border-decorative);
    border-radius: 20px;
    font-size: 0.85rem;
    color: var(--text-dark);
}

.filter-tag .remove-filter {
    cursor: pointer;
    color: var(--text-light);
    transition: var(--transition-fast);
}

.filter-tag .remove-filter:hover {
    color: var(--burgundy-accent);
}

.toolbar-right {
    display: flex;
    align-items: center;
    gap: 1rem;
}

/* View Toggle */
.view-toggle {
    display: flex;
    gap: 0.5rem;
    background: var(--bg-pattern);
    padding: 0.25rem;
    border-radius: 8px;
}

.view-btn {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    background: transparent;
    color: var(--text-medium);
    border-radius: 6px;
    cursor: pointer;
    transition: var(--transition-fast);
}

.view-btn:hover {
    color: var(--brown-primary);
    background: white;
}

.view-btn.active {
    background: var(--brown-primary);
    color: white;
    box-shadow: 0 2px 8px rgba(19, 95, 122, 0.3);
}

/* Sort Dropdown */
.sort-dropdown {
    position: relative;
}

.sort-toggle {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.6rem 1rem;
    background: var(--bg-pattern);
    border: 1px solid var(--border-decorative);
    border-radius: 8px;
    color: var(--text-dark);
    font-weight: 500;
    font-size: 0.95rem;
    cursor: pointer;
    transition: var(--transition-fast);
}

.sort-toggle:hover {
    border-color: var(--brown-primary);
    background: white;
}

.sort-toggle i:last-child {
    font-size: 0.8rem;
    transition: transform 0.3s ease;
}

.sort-dropdown.active .sort-toggle i:last-child {
    transform: rotate(180deg);
}

.sort-menu {
    position: absolute;
    top: calc(100% + 0.5rem);
    left: 0;
    background: white;
    border-radius: 8px;
    box-shadow: 0 8px 25px var(--shadow-medium);
    min-width: 200px;
    z-index: 100;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all 0.3s ease;
}

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

.sort-option {
    display: block;
    padding: 0.75rem 1rem;
    color: var(--text-dark);
    text-decoration: none;
    font-size: 0.95rem;
    transition: var(--transition-fast);
    border-bottom: 1px solid var(--border-decorative);
}

.sort-option:last-child {
    border-bottom: none;
}

.sort-option:hover {
    background: var(--bg-pattern);
    color: var(--brown-primary);
}

.sort-option.active {
    background: var(--brown-primary);
    color: white;
    font-weight: 600;
}

/* ========================================
   Book Cards
   ======================================== */

.results-container {
    display: grid;
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.results-container.grid-view {
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
}

.results-container.list-view {
    grid-template-columns: 1fr;
}

.book-card {
    background: white;
    border-radius: var(--border-radius);
    overflow: hidden;
    box-shadow: 0 4px 15px var(--shadow-light);
    transition: var(--transition);
    display: flex;
    flex-direction: column;
}

.book-card:hover {
    transform: translateY(-8px);
    box-shadow: 0 12px 30px var(--shadow-medium);
}

/* Book Image */
.book-image-wrapper {
    position: relative;
    overflow: hidden;
    background: var(--bg-pattern);
    height: 320px;
}

.book-image {
    /*width: 100%;*/
    height: 100%;
    padding-right: 30px;
    object-fit: cover;
    transition: transform 0.5s ease;
}

.book-card:hover .book-image {
    transform: scale(1.1);
}

.book-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(to bottom, transparent 0%, rgba(0,0,0,0.7) 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    opacity: 0;
    transition: var(--transition);
}

.book-card:hover .book-overlay {
    opacity: 1;
}

.quick-view-btn,
.bookmark-btn {
    width: 45px;
    height: 45px;
    border-radius: 50%;
    background: white;
    border: none;
    color: var(--brown-primary);
    font-size: 1.1rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
    transform: translateY(20px);
}

.book-card:hover .quick-view-btn,
.book-card:hover .bookmark-btn {
    transform: translateY(0);
}

.quick-view-btn:hover,
.bookmark-btn:hover {
    background: var(--brown-primary);
    color: white;
    transform: translateY(-3px) scale(1.1);
}

.bookmark-btn.active {
    background: var(--gold-accent);
    color: white;
}

/* Book Badges */
.book-badge {
    position: absolute;
    top: 15px;
    right: 15px;
    padding: 0.4rem 0.75rem;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 600;
    color: white;
    z-index: 2;
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

.book-badge.new {
    background: linear-gradient(135deg, #4CAF50, #45a049);
}

.book-badge.verified {
    background: linear-gradient(135deg, #2196F3, #1976D2);
}

.book-badge.featured {
    background: linear-gradient(135deg, var(--gold-accent), var(--gold-light));
}

.book-badge.updated {
    background: linear-gradient(135deg, #FF9800, #F57C00);
}

/* Book Content */
.book-content {
    padding: 1.5rem;
    flex: 1;
    display: flex;
    flex-direction: column;
}

.book-title {
    font-size: 1.15rem;
    font-weight: 600;
    color: var(--text-dark);
    margin-bottom: 0.75rem;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    /* overflow: hidden; */
    transition: var(--transition-fast);
}

.book-card:hover .book-title {
    color: var(--brown-primary);
}

.book-author {
    font-size: 0.95rem;
    color: var(--text-medium);
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

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

.book-meta {
    display: flex;
    gap: 1rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}

.meta-item {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.85rem;
    color: var(--text-light);
}

.meta-item i {
    color: var(--brown-secondary);
    font-size: 0.8rem;
}

/* Book Categories */
.book-categories {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}

.category-tag {
    padding: 0.3rem 0.75rem;
    background: var(--bg-pattern);
    border: 1px solid var(--border-decorative);
    border-radius: 15px;
    font-size: 0.8rem;
    color: var(--text-medium);
    font-weight: 500;
    transition: var(--transition-fast);
}

.category-tag:hover {
    background: var(--brown-primary);
    border-color: var(--brown-primary);
    color: white;
}

/* Book Actions */
.book-actions {
    display: flex;
    gap: 0.75rem;
    margin-top: auto;
}

.btn-primary,
.btn-secondary {
    flex: 1;
    padding: 0.7rem 1rem;
    border: none;
    border-radius: 8px;
    font-weight: 600;
    font-size: 0.9rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    transition: var(--transition);
}

.btn-primary {
    background: linear-gradient(135deg, var(--brown-primary), var(--brown-secondary));
    color: white;
    box-shadow: 0 4px 12px rgba(19, 95, 122, 0.3);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 18px rgba(19, 95, 122, 0.4);
}

.btn-secondary {
    background: var(--bg-pattern);
    color: var(--brown-primary);
    border: 1px solid var(--border-decorative);
}

.btn-secondary:hover {
    background: var(--brown-primary);
    color: white;
    border-color: var(--brown-primary);
    transform: translateY(-2px);
}

/* No-PDF state — buttons remain visible and clickable but visually muted */
.btn-primary.no-pdf,
.btn-secondary.no-pdf {
    opacity: 0.4;
    cursor: not-allowed;
    filter: grayscale(60%);
}

.btn-primary.no-pdf:hover,
.btn-secondary.no-pdf:hover {
    transform: none !important;
    box-shadow: none !important;
}

.quick-view-btn.no-pdf {
    opacity: 0.35;
    cursor: not-allowed;
    filter: grayscale(60%);
}

.quick-view-btn.no-pdf:hover {
    transform: none !important;
    background: white !important;
    color: var(--brown-primary) !important;
}

/* List View Styles */
.results-container.list-view .book-card {
    flex-direction: row;
    max-height: 250px;
}

.results-container.list-view .book-image-wrapper {
    width: 200px;
    height: 100%;
    flex-shrink: 0;
}

.results-container.list-view .book-content {
    flex: 1;
    padding: 1.5rem 2rem;
}

.results-container.list-view .book-title {
    font-size: 1.3rem;
    -webkit-line-clamp: 1;
    line-clamp: 1;
}

.results-container.list-view .book-actions {
    flex-direction: row;
    max-width: 300px;
}

/* ========================================
   Pagination
   ======================================== */

.pagination-wrapper {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
    margin-top: 3rem;
}

.pagination {
    display: flex;
    list-style: none;
    gap: 0.5rem;
    margin: 0;
    padding: 0;
}

.page-item {
    list-style: none;
}

.page-link {
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 40px;
    height: 40px;
    padding: 0.5rem 0.75rem;
    background: white;
    color: var(--text-dark);
    text-decoration: none;
    border: 1px solid var(--border-decorative);
    border-radius: 8px;
    font-weight: 500;
    transition: var(--transition-fast);
}

.page-link:hover {
    background: var(--brown-primary);
    color: white;
    border-color: var(--brown-primary);
    transform: translateY(-2px);
}

.page-item.active .page-link {
    background: linear-gradient(135deg, var(--brown-primary), var(--brown-secondary));
    color: white;
    border-color: var(--brown-primary);
    box-shadow: 0 4px 12px rgba(19, 95, 122, 0.3);
}

.page-item.disabled .page-link {
    opacity: 0.5;
    cursor: not-allowed;
    pointer-events: none;
}

.page-item.dots .page-link {
    border: none;
    background: transparent;
    cursor: default;
}

.page-item.dots .page-link:hover {
    background: transparent;
    transform: none;
}

.page-info {
    font-size: 0.95rem;
    color: var(--text-medium);
    font-weight: 500;
}

/* ========================================
   Responsive Design
   ======================================== */

@media (max-width: 1200px) {
    .results-container.grid-view {
        grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    }
}

@media (max-width: 991px) {
    .filters-sidebar {
        position: static;
        margin-bottom: 2rem;
        max-height: none;
    }

    .stats-quick {
        justify-content: center;
        margin-top: 2rem;
    }

    .category-header {
        text-align: center;
    }

    .breadcrumb-nav {
        justify-content: center;
    }
}

@media (max-width: 768px) {
    .category-page {
        padding: 1rem 0 2rem;
    }

    .category-header {
        padding: 2rem 1.5rem;
    }

    .page-title {
        font-size: 1.8rem;
    }

    .page-title i {
        font-size: 1.6rem;
    }

    .stats-quick {
        flex-direction: column;
        gap: 1rem;
    }

    .stats-quick .stat-item {
        width: 100%;
    }

    .results-toolbar {
        flex-direction: column;
        align-items: flex-start;
    }

    .toolbar-left,
    .toolbar-right {
        width: 100%;
    }

    .toolbar-right {
        justify-content: space-between;
    }

    .results-container.grid-view {
        grid-template-columns: 1fr;
    }

    .results-container.list-view .book-card {
        flex-direction: column;
        max-height: none;
    }

    .results-container.list-view .book-image-wrapper {
        width: 100%;
        height: 250px;
    }

    .pagination-wrapper {
        flex-direction: column;
        text-align: center;
    }

    .pagination {
        flex-wrap: wrap;
        justify-content: center;
    }
}

@media (max-width: 576px) {
    .page-title {
        font-size: 1.5rem;
        flex-direction: column;
        gap: 0.5rem;
    }

    .filters-sidebar {
        padding: 1rem;
    }

    .book-actions {
        flex-direction: column;
    }

    .book-badge {
        font-size: 0.75rem;
        padding: 0.3rem 0.6rem;
    }
}

/* ========================================
   Dark Mode Support
   ======================================== */

[data-theme="dark"] .category-header {
    background: linear-gradient(135deg, #1a2332 0%, #243447 100%);
}

[data-theme="dark"] .filters-sidebar,
[data-theme="dark"] .results-toolbar,
[data-theme="dark"] .book-card,
[data-theme="dark"] .page-link,
[data-theme="dark"] .sort-menu {
    background: #1a1f2e;
    border-color: var(--border-decorative);
}

[data-theme="dark"] .filter-search-input,
[data-theme="dark"] .filter-search {
    background: #242b3d;
    color: var(--text-dark);
    border-color: var(--border-decorative);
}

[data-theme="dark"] .checkmark,
[data-theme="dark"] .radio-mark {
    background: #242b3d;
    border-color: var(--border-decorative);
}

[data-theme="dark"] .view-toggle {
    background: #242b3d;
}

[data-theme="dark"] .view-btn:hover,
[data-theme="dark"] .view-btn.active {
    background: var(--brown-primary);
}

[data-theme="dark"] .sort-toggle {
    background: #242b3d;
    border-color: var(--border-decorative);
}

[data-theme="dark"] .book-image-wrapper {
    background: #242b3d;
}

[data-theme="dark"] .book-image {
    filter: brightness(0.9);
}

[data-theme="dark"] .category-tag,
[data-theme="dark"] .btn-secondary {
    background: #242b3d;
    border-color: var(--border-decorative);
}

[data-theme="dark"] .page-link {
    background: #242b3d;
}

/* ========================================
   Performance Optimizations
   ======================================== */

/* Use will-change for animated elements */
.book-card,
.view-btn,
.page-link,
.filter-option {
    will-change: transform;
}

/* GPU acceleration for smooth animations */
.book-image,
.book-overlay,
.sort-menu {
    transform: translateZ(0);
    backface-visibility: hidden;
}

/* Reduce motion for accessibility */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Loading state */
.book-card.loading {
    pointer-events: none;
    opacity: 0.6;
}

.book-card.loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 40px;
    height: 40px;
    border: 3px solid var(--border-decorative);
    border-top-color: var(--brown-primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: translate(-50%, -50%) rotate(360deg); }
}

/* Scroll to top on page change */
html {
    scroll-behavior: smooth;
}

/* ========================================
   Back to Top Button
   ======================================== */

.back-to-top {
    position: fixed;
    bottom: 30px;
    left: 30px;
    width: 50px;
    height: 50px;
    background: linear-gradient(135deg, var(--brown-primary), var(--brown-secondary));
    color: white;
    border: none;
    border-radius: 50%;
    font-size: 1.2rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 15px var(--shadow-medium);
    transition: var(--transition);
    opacity: 0;
    visibility: hidden;
    transform: translateY(20px);
    z-index: 1000;
}

.back-to-top.visible {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.back-to-top:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 25px var(--shadow-heavy);
}

.back-to-top:active {
    transform: translateY(-2px);
}

html[dir="rtl"] .back-to-top {
    left: auto;
    right: 30px;
}

@media (max-width: 768px) {
    .back-to-top {
        width: 45px;
        height: 45px;
        bottom: 20px;
        left: 20px;
    }

    html[dir="rtl"] .back-to-top {
        left: auto;
        right: 20px;
    }
}
