body {
    background-color: #f8f9fa;
}

/* Hero Section Optimization */
.hero-section {
    /* Fallback background that closely matches the book-themed image */
    background: linear-gradient(rgba(0, 123, 255, 0.7), rgba(0, 123, 255, 0.7)), linear-gradient(135deg, #5a4e42 0%, #3d5a27 50%, #2c3e22 100%);
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    min-height: 70vh;
    display: flex;
    align-items: center;
    color: white;
    text-shadow: 0 2px 4px rgba(0,0,0,0.5);
    margin: -2rem -15px 0 -15px;
    /* Remove transition to eliminate visual delay */
}

.hero-section.loaded {
    background-image: linear-gradient(rgba(0, 123, 255, 0.7), rgba(0, 123, 255, 0.7)), url('/img/annie-spratt-GWCvnsMtiBg-unsplash.jpg');
}

.jumbotron {
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.card {
    transition: transform 0.2s;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
}

.navbar-brand {
    font-weight: bold;
    font-size: 1.5rem;
}

.book-card {
    border: none;
    border-radius: 10px;
    overflow: hidden;
}

.book-cover {
    height: 200px;
    background-color: #e9ecef;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 3rem;
    color: #6c757d;
}

.rating {
    color: #ffc107;
}

.status-badge {
    font-size: 0.8rem;
}

.btn-group-actions {
    display: flex;
    gap: 0.5rem;
}

.form-floating {
    margin-bottom: 1rem;
}

.auth-card {
    max-width: 400px;
    margin: 2rem auto;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.stats-card {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
}

.stats-card .card-body {
    padding: 2rem;
}

/* Enhanced Library UI Styles */
.view-btn.active {
    background-color: var(--bs-secondary);
    color: white;
    border-color: var(--bs-secondary);
}

.filter-pill.active {
    background-color: var(--bs-primary);
    color: white;
    border-color: var(--bs-primary);
}

.book-cover {
    height: 200px;
    background-color: #e9ecef;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 3rem;
    color: #6c757d;
    overflow: hidden;
}

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

.book-cover-placeholder {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 3rem;
    color: #6c757d;
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
}

.book-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.3s ease;
}

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

.book-actions {
    display: flex;
    gap: 0.5rem;
}

.book-actions .btn {
    border-radius: 50%;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(4px);
}

/* List View Styles */
.view-list .book-card {
    max-height: 160px;
    overflow: hidden;
}

.view-list .book-cover {
    height: 160px;
    border-radius: 8px 0 0 8px;
}

.book-card-list {
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.book-card-list:hover {
    transform: translateX(5px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

/* Compact View Styles */
.view-compact .book-item-compact {
    transition: background-color 0.2s ease;
}

.view-compact .book-item-compact:hover {
    background-color: rgba(0, 123, 255, 0.05);
}

.book-card-compact {
    padding: 0.75rem 1rem;
    border-radius: 8px;
    border: 1px solid #dee2e6;
}

.book-card-compact .card-body {
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
}

/* Enhanced Search Styles */
.input-group-text {
    background: transparent;
    border-color: #ced4da;
}

.form-control:focus {
    border-color: #86b7fe;
    box-shadow: 0 0 0 0.25rem rgba(13, 110, 253, 0.25);
}

/* Loading States */
.books-container {
    min-height: 400px;
}

#loading-state, #no-results-state {
    min-height: 400px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

/* Enhanced Status Badges */
.badge.bg-info {
    background-color: #0dcaf0 !important;
}

.badge.bg-warning {
    background-color: #ffc107 !important;
    color: #000 !important;
}

.badge.bg-success {
    background-color: #198754 !important;
}

/* Rating Stars */
.rating {
    font-size: 0.9rem;
}

.rating .fas.fa-star {
    color: #ffc107;
}

.rating .far.fa-star {
    color: #dee2e6;
}

/* Responsive Improvements */
@media (max-width: 768px) {
    .view-btn {
        padding: 0.375rem 0.5rem;
    }
    
    .filter-pill {
        font-size: 0.75rem;
        padding: 0.25rem 0.5rem;
    }
    
    .book-actions {
        flex-direction: column;
    }
    
    .view-list .book-cover {
        width: 80px !important;
        min-width: 80px !important;
        height: 120px !important;
    }
}

/* Empty State Styling */
.empty-state {
    background: linear-gradient(135deg, #f8f9fa 0%, #ffffff 100%);
    border-radius: 12px;
    margin: 2rem 0;
    padding: 3rem 2rem;
}

.empty-state .btn {
    min-width: 200px;
}

/* Fix dropdown z-index issues - target the specific filter card */
.row.mb-4 .card,
.row.mb-4 .card-body {
    z-index: 10000 !important;
    position: relative !important;
}

.card-body .dropdown,
.card-body .btn-group {
    z-index: 10001 !important;
    position: relative !important;
}

.card-body .dropdown-menu {
    z-index: 10002 !important;
    position: absolute !important;
}

/* Fix Sort dropdown specifically - it's in btn-group within card-body */
.card-body .btn-group .dropdown-menu {
    z-index: 10003 !important;
    position: absolute !important;
}

/* Lower z-index for the entire filter pills row so sort dropdown appears above */
.card-body .row:last-child,
.card-body .d-flex.flex-wrap.align-items-center {
    z-index: 100 !important;
    position: relative !important;
}

/* Export Dropdown - target header area specifically */
.d-flex.justify-content-between .btn-group .dropdown-menu {
    z-index: 10002 !important;
    position: absolute !important;
}

.d-flex.justify-content-between .btn-group {
    z-index: 10001 !important;
    position: relative !important;
}

/* Fix navbar user dropdown z-index */
.navbar .dropdown-menu {
    z-index: 10500 !important;
    position: absolute !important;
}

.navbar .dropdown {
    z-index: 10500 !important;
    position: relative !important;
}

/* Fix add book page button z-index issues */
.card-header .btn-group,
.card-header .btn,
.card-header {
    z-index: 1 !important;
    position: relative !important;
}

/* Ensure the entire card on add book page has low z-index */
.col-lg-8 .card {
    z-index: 1 !important;
    position: relative !important;
}

/* But ensure modals and dropdowns are much higher */
.modal,
.dropdown-menu,
.modal-dialog {
    z-index: 10600 !important;
}

/* Export Dropdown */
.dropdown {
    z-index: 9999 !important;
    position: relative !important;
}

.dropdown-menu {
    box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15);
    border: none;
    border-radius: 8px;
    z-index: 9999 !important;
    position: absolute !important;
}

.dropdown-item {
    padding: 0.75rem 1.25rem;
    transition: background-color 0.2s ease;
}

.dropdown-item:hover {
    background-color: rgba(0, 123, 255, 0.1);
}

.dropdown-item i {
    width: 20px;
    text-align: center;
}

/* Barcode Scanner Styles */
#barcode-scanner {
    border-radius: 8px;
    border: 2px dashed #dee2e6;
}

#barcode-scanner canvas,
#barcode-scanner video {
    width: 100% !important;
    height: 100% !important;
    object-fit: cover;
    border-radius: 6px;
}

.scanner-overlay {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    border: 2px solid #007bff;
    width: 200px;
    height: 100px;
    border-radius: 8px;
    pointer-events: none;
}

.scanner-overlay::before {
    content: '';
    position: absolute;
    top: -2px;
    left: -2px;
    right: -2px;
    bottom: -2px;
    border: 2px solid rgba(0, 123, 255, 0.3);
    border-radius: 8px;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% {
        opacity: 1;
        transform: scale(1);
    }
    50% {
        opacity: 0.5;
        transform: scale(1.05);
    }
    100% {
        opacity: 1;
        transform: scale(1);
    }
}

/* Alert animations */
.alert {
    animation: slideIn 0.3s ease-out;
}

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

/* Scanner button styles */
#scan-barcode-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

/* Modal control buttons - make them more touch-friendly */
#barcode-scanner-modal .btn {
    min-height: 48px;
    padding: 12px 16px;
    font-size: 16px;
    touch-action: manipulation;
}

/* Prevent modal from being dismissible by backdrop */
.modal-backdrop {
    pointer-events: none;
}

.modal-lg {
    max-width: 600px;
}

/* Book Search Styles */
.book-search-result {
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
}

.book-search-result:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.book-search-result .card-title {
    font-size: 0.9rem;
    line-height: 1.3;
    min-height: 2.6rem;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.book-search-result .card-text {
    min-height: 1.2rem;
}

.modal-xl .modal-body {
    max-height: 70vh;
    overflow-y: auto;
}

#search-results .card-img-top img {
    border-radius: 4px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

/* Profile Page Styles */
.profile-avatar {
    margin-bottom: 1rem;
}

.stat-item {
    padding: 0.5rem;
}

.stat-number {
    font-size: 2rem;
    font-weight: bold;
    line-height: 1;
}

.stat-label {
    font-size: 0.875rem;
    color: #6c757d;
    margin-top: 0.25rem;
}

.reading-progress {
    background: #f8f9fa;
    padding: 1rem;
    border-radius: 0.5rem;
}

.achievement-badge {
    padding: 1rem;
    border: 2px solid #dee2e6;
    border-radius: 0.75rem;
    background: #f8f9fa;
    transition: all 0.3s ease;
    position: relative;
    display: flex;
    align-items: center;
    min-height: 80px;
}

.achievement-badge.unlocked {
    background: linear-gradient(135deg, #e7f3ff 0%, #f0f8ff 100%);
    border-color: #0d6efd;
    color: #0d6efd;
    box-shadow: 0 4px 8px rgba(13, 110, 253, 0.1);
    transform: translateY(-2px);
}

.achievement-badge.unlocked:hover {
    transform: translateY(-4px);
    box-shadow: 0 6px 12px rgba(13, 110, 253, 0.15);
}

.achievement-badge.locked {
    color: #6c757d;
    opacity: 0.5;
    background: #f1f3f4;
    border-color: #e9ecef;
}

.achievement-badge .fas:first-child {
    font-size: 1.5rem;
    margin-right: 0.75rem;
}

.achievement-badge .achievement-title {
    font-weight: 600;
    font-size: 1rem;
}

.achievement-badge.unlocked .fas.fa-check-circle {
    color: #28a745;
    margin-left: auto;
    font-size: 1.2rem;
}

.achievement-badge.locked .fas.fa-lock {
    color: #6c757d;
    margin-left: auto;
    font-size: 1rem;
}

/* Reading Goal Styles */
.reading-goal-circle {
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    border: 3px solid #0d6efd;
    border-radius: 50%;
    width: 120px;
    height: 120px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    position: relative;
}

.goal-number {
    font-size: 2rem;
    font-weight: bold;
    color: #0d6efd;
    line-height: 1;
}

.goal-target {
    font-size: 0.9rem;
    color: #6c757d;
    line-height: 1;
}

.goal-label {
    font-size: 0.7rem;
    color: #6c757d;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.goal-stat {
    padding: 0.5rem;
}

.goal-stat .stat-number {
    font-size: 1.5rem;
    font-weight: bold;
    line-height: 1;
}

.goal-stat .stat-label {
    font-size: 0.8rem;
    color: #6c757d;
    margin-top: 0.25rem;
}