/* Custom Animations */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes float {

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

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

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

    100% {
        background-position: 1000px 0;
    }
}

/* Animation Classes */
.animate-fade-in-up {
    animation: fadeInUp 0.8s ease-out both;
}

.animate-float {
    animation: float 3s ease-in-out infinite;
}

/* Loading Shimmer Effect */
.shimmer {
    background: linear-gradient(to right, #f0f0f0 8%, #e0e0e0 18%, #f0f0f0 33%);
    background-size: 2000px 104px;
    animation: shimmer 2s infinite;
}

/* Custom Scrollbar */
::-webkit-scrollbar {
    width: 10px;
}

::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 10px;
}

::-webkit-scrollbar-thumb {
    background: #3b82f6;
    border-radius: 10px;
}

::-webkit-scrollbar-thumb:hover {
    background: #2563eb;
}

/* Smooth transitions for all interactive elements */
a,
button,
.transition-all {
    transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
}

/* Glassmorphism effect */
.glass {
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

/* Book card premium effects */
.book-card {
    position: relative;
    overflow: hidden;
    background: rgba(255, 255, 255, 0.7);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.5);
    box-shadow:
        0 4px 6px -1px rgba(0, 0, 0, 0.05),
        0 2px 4px -1px rgba(0, 0, 0, 0.03),
        inset 0 0 0 1px rgba(255, 255, 255, 0.5);
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.book-card:hover {
    transform: translateY(-8px) scale(1.02) rotate3d(1, 1, 0, 2deg);
    box-shadow:
        0 20px 25px -5px rgba(0, 0, 0, 0.1),
        0 10px 10px -5px rgba(0, 0, 0, 0.04),
        inset 0 0 0 1px rgba(255, 255, 255, 0.6);
    background: rgba(255, 255, 255, 0.85);
}

.book-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg,
            transparent,
            rgba(255, 255, 255, 0.6),
            transparent);
    transition: left 0.6s ease;
    z-index: 10;
    pointer-events: none;
}

.book-card:hover::before {
    left: 100%;
}

/* Modal Backdrop Blur */
.modal-backdrop {
    backdrop-filter: blur(8px);
    background: rgba(0, 0, 0, 0.6);
}

/* Cart Badge Animation */
.cart-badge {
    animation: bounce 0.5s ease-in-out;
}

@keyframes bounce {

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

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

/* Preview Page Flip Animation */
.page-transition {
    animation: pageFlip 0.3s ease-in-out;
}

@keyframes pageFlip {
    0% {
        transform: rotateY(0deg);
        opacity: 0.8;
    }

    50% {
        transform: rotateY(90deg);
        opacity: 0.5;
    }

    100% {
        transform: rotateY(0deg);
        opacity: 1;
    }
}

/* Mobile Menu Animations */
.mobile-menu-enter {
    animation: slideInDown 0.3s ease-out;
}

.mobile-menu-leave {
    animation: slideOutUp 0.3s ease-in;
}

@keyframes slideInDown {
    from {
        transform: translateY(-100%);
        opacity: 0;
    }

    to {
        transform: translateY(0);
        opacity: 1;
    }
}

@keyframes slideOutUp {
    from {
        transform: translateY(0);
        opacity: 1;
    }

    to {
        transform: translateY(-100%);
        opacity: 0;
    }
}

/* Profile layout fallback so sidebar stays on the left on large screens */
.profile-layout {
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

@media (min-width: 1024px) {
    .profile-layout {
        flex-direction: row;
        align-items: flex-start;
    }

    .profile-sidebar {
        width: 100%;
        max-width: 320px;
        flex-shrink: 0;
    }

    .profile-main {
        flex: 1;
        min-width: 0;
    }
}

/* Focus styles for accessibility */
button:focus,
a:focus {
    outline: 2px solid #3b82f6;
    outline-offset: 2px;
}

/* Quantity Controls */
.quantity-btn {
    width: 32px;
    height: 32px;
    border: 1px solid #d1d5db;
    background: white;
    border-radius: 6px;
    font-weight: bold;
    color: #374151;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.quantity-btn:hover {
    background: #3b82f6;
    color: white;
    border-color: #3b82f6;
}

.quantity-input {
    width: 50px;
    height: 32px;
    text-align: center;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-weight: 600;
    color: #374151;
}

.quantity-input:focus {
    outline: 2px solid #3b82f6;
    border-color: #3b82f6;
}

/* Print styles for downloaded books */
@media print {
    .no-print {
        display: none !important;
    }
}

/* Featured Books Enhanced Styles */
.line-clamp-3 {
    display: -webkit-box;
    -webkit-line-clamp: 3;
    line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* Pulse animation for badges */
@keyframes pulse-glow {

    0%,
    100% {
        box-shadow: 0 0 10px rgba(59, 130, 246, 0.5);
    }

    50% {
        box-shadow: 0 0 20px rgba(59, 130, 246, 0.8);
    }
}

.featured-badge {
    animation: pulse-glow 2s infinite;
}

/* Book cover hover effect */
.book-cover-hover {
    transition: all 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

.book-cover-hover:hover {
    filter: brightness(1.1);
    transform: scale(1.05) rotate(-2deg);
}

/* Price highlight effect */
@keyframes price-highlight {

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

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

.price-highlight:hover {
    animation: price-highlight 0.5s ease-in-out;
}

/* Call-to-action button shine effect */
@keyframes button-shine {
    0% {
        left: -100%;
    }

    100% {
        left: 100%;
    }
}

.btn-shine {
    position: relative;
    overflow: hidden;
}

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

.btn-shine:hover::after {
    left: 100%;
}

/* Featured section gradient background */
#featured {
    position: relative;
}

#featured::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: radial-gradient(circle at 30% 50%, rgba(59, 130, 246, 0.05) 0%, transparent 50%),
        radial-gradient(circle at 70% 50%, rgba(251, 191, 36, 0.05) 0%, transparent 50%);
    pointer-events: none;
    z-index: 0;
}

#featured>* {
    position: relative;
    z-index: 1;
}

/* Premium Button Styles */
.premium-button::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg,
            transparent,
            rgba(255, 255, 255, 0.3),
            transparent);
    transition: left 0.7s ease;
    z-index: 1;
}

.premium-button:hover::before {
    left: 100%;
}

.premium-button {
    font-family: 'Fredoka', 'Nunito', sans-serif;
    letter-spacing: 0.5px;
}

.premium-button-secondary::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg,
            transparent,
            rgba(99, 102, 241, 0.15),
            transparent);
    transition: left 0.7s ease;
    z-index: 1;
}

.premium-button-secondary:hover::before {
    left: 100%;
}

.premium-button-secondary {
    font-family: 'Fredoka', 'Nunito', sans-serif;
    letter-spacing: 0.5px;
}

/* Custom scrollbar for avatar modal */
.custom-scrollbar::-webkit-scrollbar {
    width: 8px;
}

.custom-scrollbar::-webkit-scrollbar-track {
    background: #f1f5f9;
    border-radius: 10px;
}

.custom-scrollbar::-webkit-scrollbar-thumb {
    background: linear-gradient(180deg, #8b5cf6, #6366f1);
    border-radius: 10px;
}

.custom-scrollbar::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(180deg, #7c3aed, #4f46e5);
}

/* Hide scrollbar for Chrome, Safari and Opera */
.hide-scrollbar::-webkit-scrollbar {
    display: none;
}

/* Hide scrollbar for IE, Edge and Firefox */
.hide-scrollbar {
    -ms-overflow-style: none;
    /* IE and Edge */
    scrollbar-width: none;
    /* Firefox */
}

/* =========================================
   Refactored Styles from HTML files
   ========================================= */

/* From index.html - Category Toggle */
#toggleCategoriesBtn {
    display: none;
}

#toggleCategoriesBtn .toggle-icon {
    display: inline-flex;
    transition: transform 0.3s ease;
}

#toggleCategoriesBtn.expanded .toggle-icon {
    transform: rotate(180deg);
}

@media (max-width: 768px) {
    .categories-grid.collapsed .category-card:nth-child(n+7) {
        display: none;
    }

    #toggleCategoriesBtn {
        display: inline-flex;
    }
}

@media (min-width: 769px) {
    #toggleCategoriesBtn {
        display: none;
    }
}

/* From profile.html - Avatar Modal */
body.modal-open {
    overflow: hidden;
}

#avatarModal .avatar-modal-panel {
    max-height: calc(100vh - 2rem);
    width: min(90vw, 36rem);
    display: flex;
    flex-direction: column;
}

#avatarModal .avatar-modal-body {
    flex: 1;
    overflow-y: auto;
}

#avatarModal .avatar-modal-grid {
    max-height: none;
}

#avatarModal .avatar-modal-actions {
    border-top: 1px solid rgba(15, 23, 42, 0.05);
}

@media (max-width: 640px) {
    #avatarModal .avatar-modal-panel {
        width: calc(100vw - 1.5rem);
        max-height: calc(100vh - 1.5rem);
    }

    #avatarModal .avatar-modal-body {
        padding: 1.25rem 1rem 1.75rem 1rem;
    }
}

/* From catalog.html - Search & Filter */
.catalog-search-wrapper {
    position: relative;
}

.catalog-search-input {
    padding: 1rem 1.5rem 1rem 3.5rem;
    /* keep text clear of the icon */
}

.catalog-search-icon {
    position: absolute;
    top: 50%;
    left: 1.25rem;
    transform: translateY(-50%);
    color: rgb(96 165 250);
    pointer-events: none;
    transition: opacity 0.2s ease, transform 0.2s ease, color 0.2s ease;
    display: flex;
    align-items: center;
}

.catalog-search-icon svg {
    width: 1.25rem;
    height: 1.25rem;
}

.catalog-search-input:focus~.catalog-search-icon {
    color: rgb(59 130 246);
}

.category-toolbar {
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.92), rgba(244, 244, 255, 0.88));
    border-radius: 9999px;
    padding: 0.85rem 1.5rem;
    border: 1px solid rgba(15, 23, 42, 0.08);
    box-shadow: 0 20px 45px rgba(15, 23, 42, 0.08);
    backdrop-filter: blur(6px);
}

.category-btn {
    position: relative;
    padding: 0.65rem 1.4rem;
    border-radius: 9999px;
    background: linear-gradient(135deg, rgba(248, 250, 252, 0.95), rgba(241, 245, 249, 0.9));
    color: #1f2937;
    font-weight: 600;
    font-size: 0.9rem;
    font-family: "Fredoka", "Nunito", sans-serif;
    letter-spacing: 0.02em;
    cursor: pointer;
    transition: all 0.3s ease;
    border: 1px solid rgba(148, 163, 184, 0.6);
    box-shadow: 0 10px 25px rgba(15, 23, 42, 0.08);
    overflow: hidden;
}

.category-btn::after {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: inherit;
    background: linear-gradient(120deg, rgba(59, 130, 246, 0.15), rgba(147, 51, 234, 0.15));
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
}

.category-btn:hover {
    transform: translateY(-2px) scale(1.01);
    box-shadow: 0 12px 30px rgba(59, 130, 246, 0.22);
    color: #0f172a;
}

.category-btn:hover::after {
    opacity: 1;
}

.category-btn:focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.35);
}

.category-btn.active {
    background: linear-gradient(135deg, #60a5fa, #7c3aed);
    color: white;
    border-color: rgba(255, 255, 255, 0.7);
    box-shadow: 0 15px 35px rgba(99, 102, 241, 0.35);
}

.category-btn.active::after {
    opacity: 1;
    background: linear-gradient(120deg, rgba(255, 255, 255, 0.35), rgba(252, 211, 77, 0.35));
}

@media (max-width: 640px) {
    .category-toolbar {
        border-radius: 2rem;
        padding: 0.75rem 1rem;
    }

    .category-btn {
        font-size: 0.85rem;
        padding: 0.55rem 1.1rem;
        box-shadow: 0 6px 15px rgba(15, 23, 42, 0.08);
    }
}

/* Premium Payment UI */
.font-outfit {
    font-family: 'Outfit', sans-serif;
}

.payment-card-premium {
    position: relative;
    background: white;
    border-radius: 1.5rem;
    /* rounded-3xl */
    border: 1px solid #f3f4f6;
    padding: 1.5rem;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -1px rgba(0, 0, 0, 0.03);
    overflow: hidden;
    height: 100%;
    display: flex;
    flex-direction: column;
}

.payment-card-premium:hover {
    transform: translateY(-4px);
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    border-color: #e5e7eb;
}

.payment-card-premium.selected {
    border-color: #8b5cf6;
    /* primary-500/purple-500 */
    box-shadow: 0 0 0 2px #8b5cf6, 0 20px 25px -5px rgba(139, 92, 246, 0.15);
}

.payment-card-premium .check-icon {
    position: absolute;
    top: 1.25rem;
    right: 1.25rem;
    opacity: 0;
    transform: scale(0.5);
    transition: all 0.3s ease;
    color: #8b5cf6;
}

.payment-card-premium.selected .check-icon {
    opacity: 1;
    transform: scale(1);
}

.payment-card-premium .card-icon-wrapper {
    width: 3.5rem;
    height: 3.5rem;
    border-radius: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 1rem;
    transition: transform 0.3s ease;
}

.payment-card-premium:hover .card-icon-wrapper {
    transform: scale(1.1) rotate(-3deg);
}

.recommendation-badge {
    position: absolute;
    top: 0;
    right: 0;
    background: linear-gradient(135deg, #10b981, #059669);
    color: white;
    font-size: 0.75rem;
    font-weight: 700;
    padding: 0.25rem 0.75rem;
    border-bottom-left-radius: 1rem;
    box-shadow: -2px 2px 4px rgba(0, 0, 0, 0.1);
    z-index: 10;
}