/* Animation Keyframes */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translate3d(0, 30px, 0);
    }

    to {
        opacity: 1;
        transform: translate3d(0, 0, 0);
    }
}

@keyframes slideInLeft {
    from {
        opacity: 0;
        transform: translate3d(-30px, 0, 0);
    }

    to {
        opacity: 1;
        transform: translate3d(0, 0, 0);
    }
}

@keyframes pulse {

    0%,
    100% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.05);
    }
}

@keyframes bookFloat {

    0%,
    100% {
        transform: translateY(0px);
    }

    50% {
        transform: translateY(-5px);
    }
}

@keyframes shimmer {
    0% {
        background-position: -200px 0;
    }

    100% {
        background-position: calc(200px + 100%) 0;
    }
}

@keyframes flipIn {
    from {
        transform: perspective(400px) rotateY(90deg);
        opacity: 0;
    }

    to {
        transform: perspective(400px) rotateY(0deg);
        opacity: 1;
    }
}

/* Main Layout Styles */
body {
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    overflow-x: hidden;
    min-width: 320px;
}

/* Hero and Search Section */
.hero-section {
    background: linear-gradient(135deg, #ffffff 0%, #f8f9fa 100%);
    padding: clamp(40px, 8vh, 80px) 0 clamp(30px, 6vh, 60px);
    margin-top: 76px;
    margin-bottom: 40px;
    border-bottom: 1px solid #eee;
    position: relative;
    overflow: hidden;
}

.hero-section::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    /* background: radial-gradient(circle at 80% 20%, rgba(1, 47, 179, 0.05) 0%, transparent 50%); */
    pointer-events: none;
}

.hero-section h1 {
    color: #333;
    font-size: clamp(1.8rem, 5vw, 3.2rem);
    margin-bottom: 1rem;
    font-weight: 700;
    animation: fadeInUp 0.8s ease-out;
}

.hero-section .lead {
    color: #666;
    font-size: clamp(1rem, 2.5vw, 1.3rem);
    margin-bottom: 2.5rem;
    animation: fadeInUp 0.8s ease-out 0.2s both;
}

/* Book Display */
.books-section {
    padding-top: 40px;
    min-height: 60vh;
}

.bookshelf {
    text-align: center;
    padding: 0px;
    margin-bottom: 60px !important;
    animation: fadeInUp 0.6s ease-out;
}

.bookshelf .covers {
    width: 100%;
    height: auto;
    z-index: 99;
    position: relative;
    text-align: center;
    padding: 40px 0 20px;
    overflow: visible;
}

.bookshelf .thumb {
    display: inline-block;
    cursor: pointer;
    margin: 0px 0.8%;
    width: clamp(80px, 15%, 140px) !important;
    max-width: 140px;
    transition: transform 0.3s ease;
    border-radius: 8px;
    overflow: visible;
    position: relative;
    animation-fill-mode: both;
    /* Ensure minimum size on high zoom */
    min-width: 80px;
}

.bookshelf .thumb:nth-child(1) {
    animation-delay: 0s;
}

.bookshelf .thumb:nth-child(2) {
    animation-delay: 0s;
}

.bookshelf .thumb:nth-child(3) {
    animation-delay: 0s;
}

.bookshelf .thumb:nth-child(4) {
    animation-delay: 0s;
}

.bookshelf .thumb:nth-child(5) {
    animation-delay: 0s;
}

.bookshelf .thumb::before {
    display: none;
}

.bookshelf .thumb:hover {
    transform: translateY(-10px);
    box-shadow: none;
    animation: none;
}

.bookshelf .thumb img {
    width: 100%;
    display: block;
    vertical-align: top;
    transition: none;
    border-radius: 8px;
}

.bookshelf .thumb:hover img {
    transform: none;
}

.bookshelf .shelf-img {
    z-index: 0;
    height: auto;
    max-width: 100%;
    vertical-align: top;
    margin-top: -12px;
    opacity: 0.9;
    transition: opacity 0.3s ease;
}

.bookshelf:hover .shelf-img {
    opacity: 1;
}

/* Search Form */
#searchForm {
    max-width: 700px;
    margin: 0 auto;
    padding: 0 clamp(10px, 3vw, 15px);
    animation: fadeInUp 0.8s ease-out 0.4s both;
}

#searchForm .input-group {
    border: 2px solid #012FB3;
    border-radius: 50px;
    overflow: hidden;
    box-shadow: 0 4px 25px rgba(1, 47, 179, 0.15);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    background: white;
    position: relative;
}

#searchForm .input-group.focused {
    box-shadow: 0 8px 35px rgba(1, 47, 179, 0.25);
    transform: translateY(-3px);
}

#searchForm .form-control {
    border: none;
    padding: clamp(0.5rem, 2vw, 0.75rem) clamp(1rem, 3vw, 1.75rem);
    height: clamp(48px, 8vw, 58px);
    font-size: clamp(0.9rem, 2.2vw, 1.1rem);
    line-height: 1.5;
    background: transparent;
    transition: all 0.3s ease;
}

#searchForm .form-control:focus {
    box-shadow: none;
    background: rgba(1, 47, 179, 0.02);
}

#searchForm .btn {
    padding: clamp(0.5rem, 2vw, 0.75rem) clamp(1.5rem, 4vw, 2.5rem);
    background: linear-gradient(135deg, #012FB3 0%, #1E43B0 100%);
    color: white;
    border: none;
    min-width: clamp(100px, 20vw, 140px);
    font-weight: 600;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
    font-size: clamp(0.8rem, 2vw, 1rem);
}

#searchForm .btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
    transition: left 0.5s;
}

#searchForm .btn:hover::before {
    left: 100%;
}

#searchForm .btn:hover {
    background: linear-gradient(135deg, #1E43B0 0%, #012FB3 100%);
    transform: translateX(-3px);
}

#searchForm .btn:active {
    transform: scale(0.98);
}

/* Pagination */
.pagination {
    margin-top: 50px;
    justify-content: center;
}

.pagination .page-item {
    margin: 0 3px;
}

.pagination .page-link {
    border-radius: 8px;
    border: 2px solid #e9ecef;
    color: #012FB3;
    font-weight: 500;
    padding: 0.75rem 1rem;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
}

.pagination .page-link:hover {
    background: #012FB3;
    color: white;
    border-color: #012FB3;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(1, 47, 179, 0.3);
}

.pagination .page-item.active .page-link {
    background: linear-gradient(135deg, #012FB3 0%, #1E43B0 100%);
    border-color: #012FB3;
    box-shadow: 0 4px 15px rgba(1, 47, 179, 0.4);
}

/* Navbar Styles */
.navbar {
    padding: 15px 0;
    background: rgba(255, 255, 255, 0.95) !important;
    backdrop-filter: blur(10px);
    box-shadow: 0 2px 20px rgba(0, 0, 0, 0.08);
    transition: all 0.3s ease;
}

.navbar.scrolled {
    padding: 10px 0;
    background: rgba(255, 255, 255, 0.98) !important;
}

.navbar-brand {
    padding: 0;
    margin-right: 3rem;
    transition: transform 0.3s ease;
}

.navbar-brand:hover {
    transform: scale(1.05);
}

.navbar-brand img {
    height: 46px;
    width: auto;
    filter: none;
}

.navbar-nav .nav-item {
    margin-right: 1rem;
}

.navbar-nav .nav-link {
    color: #333 !important;
    font-weight: 500;
    padding: 0.5rem 1rem;
    border-radius: 6px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
}

.navbar-nav .nav-link::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(1, 47, 179, 0.1), transparent);
    transition: left 0.5s;
}

.navbar-nav .nav-link:hover::before {
    left: 100%;
}

.navbar-nav .nav-link:hover {
    color: #012FB3 !important;
    background: rgba(1, 47, 179, 0.05);
    transform: translateY(-2px);
}

.navbar-nav .active .nav-link {
    color: #012FB3 !important;
    background: rgba(1, 47, 179, 0.1);
}

.nav-buttons .btn {
    padding: 0.5rem 1.5rem;
    font-weight: 500;
    border-radius: 6px;
    transition: all 0.3s ease;
    margin: 0 0.25rem;
}

.nav-buttons .btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

/* Loading States */
.loading-state {
    animation: fadeInUp 0.6s ease-out;
}

.loading-shimmer {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200px 100%;
    animation: shimmer 1.5s infinite;
    border-radius: 8px;
    height: 200px;
}

.spinner-border {
    animation: pulse 1s ease-in-out infinite;
}

/* Alert Animations */
.alert {
    animation: slideInLeft 0.5s ease-out;
    border: none;
    border-radius: 12px;
}

/* Page Transitions */
.bookshelf-page {
    animation: fadeInUp 0.6s ease-out;
}

/* Search Button Loading State */
.btn-searching {
    background: linear-gradient(135deg, #6c757d 0%, #495057 100%) !important;
    pointer-events: none;
}

.btn-searching::before {
    display: none;
}

/* Mobile Responsive */
@media (max-width: 1400px) {
    .hero-section {
        margin-top: 70px;
    }
}

@media (max-width: 1200px) {
    .bookshelf .thumb {
        width: clamp(90px, 18%, 130px) !important;
        margin: 0px 1%;
    }
}

@media (max-width: 991px) {
    .hero-section {
        padding: 60px 0 40px;
        margin-top: 70px;
    }

    .bookshelf .thumb {
        width: clamp(85px, 18%, 120px) !important;
        margin: 0px 1%;
    }

    .navbar-nav .nav-item {
        margin-right: 0;
        margin-bottom: 0.5rem;
    }

    .nav-buttons {
        margin-top: 1rem;
    }

    .nav-buttons .btn {
        display: block;
        width: 100%;
        margin: 0.25rem 0;
    }
}

@media (max-width: 768px) {
    .hero-section {
        padding: 40px 0 30px;
    }

    .bookshelf .covers {
        padding: 35px 0 15px;
    }

    .bookshelf .thumb {
        width: clamp(80px, 22%, 100px) !important;
        margin: 0px 1.5%;
        max-width: 100px;
    }

    .bookshelf .thumb:hover {
        transform: translateY(-6px);
    }

    #searchForm {
        padding: 0 1rem;
    }

    #searchForm .form-control {
        height: 52px;
        font-size: 1rem;
        padding: 0.6rem 1.2rem;
    }

    #searchForm .btn {
        padding: 0.6rem 2rem;
        min-width: 120px;
    }

    .bookshelf {
        margin-bottom: 40px !important;
    }

    .pagination .page-link {
        padding: 0.5rem 0.75rem;
        font-size: 0.9rem;
    }
}

@media (max-width: 576px) {
    .hero-section {
        padding: 30px 0 20px;
    }

    .bookshelf .thumb {
        width: clamp(75px, 28%, 90px) !important;
        margin: 2px 2%;
        max-width: 90px;
    }

    .bookshelf .covers {
        padding: 30px 0 15px;
    }

    #searchForm .btn {
        padding: 0.6rem 1.5rem;
        min-width: 100px;
        font-size: 0.9rem;
    }

    .books-section {
        padding-top: 20px;
    }
}

@media (max-width: 480px) {
    .bookshelf .thumb {
        width: clamp(100px, 44%, 120px) !important;
        margin: 3px 3%;
        display: inline-block;
        max-width: 120px;
    }

    .bookshelf .covers {
        text-align: center;
        padding: 25px 0 10px;
    }
}

/* Touch device optimizations */
@media (hover: none) and (pointer: coarse) {
    .bookshelf .thumb:hover {
        transform: none;
        animation: none;
    }

    .navbar-nav .nav-link:hover {
        transform: none;
    }

    .nav-buttons .btn:hover {
        transform: none;
    }

    .pagination .page-link:hover {
        transform: none;
    }
}

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

/* Focus states for better accessibility */
.btn:focus,
.form-control:focus {
    outline: 2px solid #012FB3;
    outline-offset: 2px;
}

/* Empty state styling */
.empty-state {
    padding: 60px 20px;
    text-align: center;
    animation: fadeInUp 0.6s ease-out;
}

.empty-state h3 {
    color: #012FB3;
    margin-bottom: 1rem;
}

.empty-state p {
    color: #666;
    font-size: 1.1rem;
}

/* Book Title Tooltip - FIXED FLICKERING */
.book-tooltip {
    position: absolute;
    bottom: 120%;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(1, 47, 179, 0.95);
    color: white;
    padding: 10px 14px;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 600;
    white-space: nowrap;
    z-index: 1001;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s ease, visibility 0.2s ease;
    box-shadow: 0 4px 12px rgba(1, 47, 179, 0.3);
    backdrop-filter: blur(10px);
    max-width: 250px;
    text-overflow: ellipsis;
    overflow: hidden;
    pointer-events: none;
    text-align: center;
    line-height: 1.2;
}

.book-tooltip::before {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 8px solid transparent;
    border-top-color: rgba(1, 47, 179, 0.95);
}

/* Show tooltip on hover */
.bookshelf .thumb:hover .book-tooltip {
    opacity: 1;
    visibility: visible;
}

/* Mobile Responsive */
@media (max-width: 768px) {
    .book-tooltip {
        font-size: 0.8rem;
        padding: 8px 12px;
        max-width: 200px;
        bottom: 115%;
    }

    .book-tooltip::before {
        border-width: 6px;
    }

    .bookshelf .thumb:hover {
        transform: translateY(-8px);
    }
}

@media (max-width: 576px) {
    .book-tooltip {
        font-size: 0.75rem;
        padding: 6px 10px;
        max-width: 180px;
        bottom: 110%;
    }

    .book-tooltip::before {
        border-width: 5px;
    }

    .bookshelf .thumb:hover {
        transform: translateY(-6px);
    }
}

/* Touch device optimizations */
@media (hover: none) and (pointer: coarse) {
    .book-tooltip {
        display: none;
    }
}