:root {
    /* Light Theme */
    --light-primary: #8e44ad;
    --light-secondary: #9b59b6;
    --light-accent: #e74c3c;
    --light-bg: #f5f7fa;
    --light-text: #2c3e50;
    --light-card: rgba(255, 255, 255, 0.9);
    --light-border: rgba(0, 0, 0, 0.1);
    
    /* Dark Theme */
    --dark-primary: #9b59b6;
    --dark-secondary: #8e44ad;
    --dark-accent: #e74c3c;
    --dark-bg: #1a1a2e;
    --dark-text: #e6e6e6;
    --dark-card: rgba(26, 26, 46, 0.8);
    --dark-border: rgba(255, 255, 255, 0.1);
    
    /* Common */
    --shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
    --transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.1);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Poppins', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: var(--dark-bg);
    color: var(--dark-text);
    line-height: 1.7;
    overflow-x: hidden;
    transition: var(--transition);
}

body[data-theme="light"] {
    background-color: var(--light-bg);
    color: var(--light-text);
}

.gradient-bg {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%);
    z-index: -2;
    opacity: 1;
    transition: var(--transition);
}

body[data-theme="light"] .gradient-bg {
    background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
    opacity: 0.8;
}

/* Glass Morphism Effect */
.glass-header, .glass-card, .glass-footer {
    background: rgba(255, 255, 255, 0.05);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: var(--shadow);
}

body[data-theme="light"] .glass-header,
body[data-theme="light"] .glass-card,
body[data-theme="light"] .glass-footer {
    background: rgba(255, 255, 255, 0.7);
    border: 1px solid rgba(255, 255, 255, 0.3);
}

/* Header Styles */
header {
    padding: 0.3rem 2rem;
    position: sticky;
    top: 0;
    z-index: 1000;
    transition: var(--transition);
}

.header-content {
    max-width: 1400px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo-wrapper {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.logo-icon {
    font-size: 2rem;
    color: var(--dark-primary);
    text-shadow: 0 0 10px rgba(142, 68, 173, 0.5);
    transition: var(--transition);
}

body[data-theme="light"] .logo-icon {
    color: var(--light-primary);
}

.logo-text {
    font-size: 1.8rem;
    font-weight: 700;
    background: linear-gradient(45deg, var(--dark-primary), var(--dark-accent));
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    transition: var(--transition);
}

body[data-theme="light"] .logo-text {
    background: linear-gradient(45deg, var(--light-primary), var(--light-accent));
}

.logo-text span {
    font-weight: 300;
}

/* Theme Toggle */
.theme-toggle {
    position: relative;
}

.toggle-checkbox {
    display: none;
}

.toggle-label {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 60px;
    height: 30px;
    background: var(--dark-card);
    border-radius: 50px;
    padding: 5px;
    cursor: pointer;
    position: relative;
    transition: var(--transition);
}

.toggle-label i {
    font-size: 0.9rem;
    z-index: 1;
}

.toggle-label .fa-sun {
    color: #f1c40f;
}

.toggle-label .fa-moon {
    color: #f5f6fa;
}

.toggle-ball {
    position: absolute;
    top: 2px;
    left: 2px;
    width: 26px;
    height: 26px;
    background: linear-gradient(145deg, #ffffff, #e6e6e6);
    border-radius: 50%;
    transition: transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
}

.toggle-checkbox:checked + .toggle-label .toggle-ball {
    transform: translateX(30px);
}

/* Main Content */
main {
    max-width: 1400px;
    margin: 2rem auto;
    padding: 0 2rem;
    position: relative;
    z-index: 1;
}

.search-container {
    border-radius: 20px;
    padding: 2rem;
    margin-bottom: 2rem;
    transition: var(--transition);
}

.search-box {
    display: flex;
    max-width: 800px;
    margin: 0 auto;
    position: relative;
}

#search {
    flex: 1;
    padding: 1.2rem 1.5rem;
    border-radius: 50px;
    border: none;
    background: rgba(255, 255, 255, 0.1);
    color: var(--dark-text);
    font-size: 1rem;
    backdrop-filter: blur(5px);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.1);
    transition: var(--transition);
}

body[data-theme="light"] #search {
    background: rgba(255, 255, 255, 0.7);
    color: var(--light-text);
}

#search:focus {
    outline: none;
    background: rgba(255, 255, 255, 0.15);
    box-shadow: 0 4px 25px rgba(0, 0, 0, 0.2);
}

#search-btn {
    position: absolute;
    right: 5px;
    top: 50%;
    transform: translateY(-50%);
    background: linear-gradient(45deg, var(--dark-primary), var(--dark-secondary));
    color: white;
    border: none;
    border-radius: 50px;
    padding: 0.8rem 1.5rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 600;
    transition: var(--transition);
    box-shadow: 0 4px 15px rgba(142, 68, 173, 0.3);
}

#search-btn:hover {
    transform: translateY(-50%) scale(1.05);
    box-shadow: 0 6px 20px rgba(142, 68, 173, 0.4);
}

.glow-on-hover {
    position: relative;
    z-index: 0;
}

.glow-on-hover::before {
    content: '';
    background: linear-gradient(
        45deg,
        #ff0000, #ff7300, #fffb00, #48ff00,
        #00ffd5, #002bff, #7a00ff, #ff00c8, #ff0000
    );
    position: absolute;
    top: -2px;
    left: -2px;
    background-size: 400%;
    z-index: -1;
    filter: blur(5px);
    width: calc(100% + 4px);
    height: calc(100% + 4px);
    opacity: 0;
    border-radius: 50px;
    transition: opacity 0.3s ease-in-out;
    animation: glowing 20s linear infinite;
}

.glow-on-hover:hover::before {
    opacity: 0.7;
}

@keyframes glowing {
    0% { background-position: 0 0; }
    50% { background-position: 400% 0; }
    100% { background-position: 0 0; }
}

.typing-animation {
    text-align: center;
    margin-top: 1rem;
    color: var(--dark-secondary);
    font-style: italic;
    opacity: 0.8;
    height: 20px;
}

body[data-theme="light"] .typing-animation {
    color: var(--light-secondary);
}

/* Filter Options */
.filter-options {
    display: flex;
    justify-content: center;
    gap: 1rem;
    margin-bottom: 2rem;
    flex-wrap: wrap;
}

.filter-btn {
    padding: 0.8rem 1.5rem;
    background: rgba(255, 255, 255, 0.1);
    color: var(--dark-text);
    border: none;
    border-radius: 50px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.9rem;
    transition: var(--transition);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

body[data-theme="light"] .filter-btn {
    background: rgba(255, 255, 255, 0.7);
    color: var(--light-text);
}

.filter-btn i {
    font-size: 0.9rem;
}

.filter-btn.active {
    background: linear-gradient(45deg, var(--dark-primary), var(--dark-secondary));
    color: white;
    transform: translateY(-3px);
    box-shadow: 0 6px 20px rgba(142, 68, 173, 0.3);
}

.filter-btn:hover:not(.active) {
    background: rgba(255, 255, 255, 0.2);
    transform: translateY(-2px);
}

/* Books Grid */
.books-container {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 2rem;
    margin-top: 2rem;
}

.book {
    background: var(--dark-card);
    border-radius: 15px;
    overflow: hidden;
    box-shadow: var(--shadow);
    transition: var(--transition);
    cursor: pointer;
    position: relative;
    transform: translateY(0);
    will-change: transform;
}

body[data-theme="light"] .book {
    background: var(--light-card);
}

.book::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(45deg, transparent, rgba(142, 68, 173, 0.1), transparent);
    opacity: 0;
    transition: var(--transition);
}

.book:hover {
    transform: translateY(-10px) scale(1.02);
    box-shadow: 0 15px 30px rgba(0, 0, 0, 0.3);
}

.book:hover::before {
    opacity: 1;
}

.book-cover {
    width: 100%;
    height: 320px;
    object-fit: cover;
    transition: var(--transition);
}

.book:hover .book-cover {
    transform: scale(1.05);
}

.book-info {
    padding: 1.5rem;
    position: relative;
    z-index: 1;
}

.book-title {
    font-size: 1.2rem;
    margin-bottom: 0.5rem;
    color: var(--dark-text);
    font-weight: 600;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.book-author {
    font-size: 0.9rem;
    color: var(--dark-secondary);
    margin-bottom: 0.5rem;
    font-weight: 500;
}

body[data-theme="light"] .book-author {
    color: var(--light-secondary);
}

.book-published {
    font-size: 0.8rem;
    color: rgba(255, 255, 255, 0.7);
    margin-top: auto;
}

body[data-theme="light"] .book-published {
    color: rgba(0, 0, 0, 0.6);
}

/* Loading Animation */
.loading {
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 3rem;
}

.spinner {
    width: 50px;
    height: 50px;
    border: 5px solid rgba(255, 255, 255, 0.1);
    border-radius: 50%;
    border-top-color: var(--dark-primary);
    animation: spin 1s ease-in-out infinite;
    margin-bottom: 1rem;
}

body[data-theme="light"] .spinner {
    border-top-color: var(--light-primary);
}

.loading-text {
    color: var(--dark-secondary);
    font-style: italic;
    animation: pulse 2s infinite;
}

body[data-theme="light"] .loading-text {
    color: var(--light-secondary);
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

@keyframes pulse {
    0%, 100% { opacity: 0.6; }
    50% { opacity: 1; }
}

/* Footer */
footer {
    margin-top: 4rem;
    padding: 3rem 2rem 1.5rem;
    position: relative;
}

.footer-content {
    max-width: 1400px;
    margin: 0 auto;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 2rem;
    margin-bottom: 2rem;
}

.footer-section h3 {
    font-size: 1.2rem;
    margin-bottom: 1rem;
    color: var(--dark-text);
    position: relative;
    display: inline-block;
}

.footer-section h3::after {
    content: '';
    position: absolute;
    bottom: -5px;
    left: 0;
    width: 50%;
    height: 2px;
    background: linear-gradient(90deg, var(--dark-primary), transparent);
}

body[data-theme="light"] .footer-section h3::after {
    background: linear-gradient(90deg, var(--light-primary), transparent);
}

.footer-section ul {
    list-style: none;
}

.footer-section ul li {
    margin-bottom: 0.5rem;
}

.footer-section ul li a {
    color: rgba(255, 255, 255, 0.7);
    text-decoration: none;
    transition: var(--transition);
}

body[data-theme="light"] .footer-section ul li a {
    color: rgba(0, 0, 0, 0.7);
}

.footer-section ul li a:hover {
    color: var(--dark-primary);
    padding-left: 5px;
}

body[data-theme="light"] .footer-section ul li a:hover {
    color: var(--light-primary);
}

.social-links {
    display: flex;
    gap: 1rem;
    margin-top: 1rem;
}

.social-links a {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.1);
    color: var(--dark-text);
    transition: var(--transition);
}

.social-links a:hover {
    background: var(--dark-primary);
    color: white;
    transform: translateY(-3px);
}

body[data-theme="light"] .social-links a:hover {
    background: var(--light-primary);
}

.footer-bottom {
    max-width: 1400px;
    margin: 0 auto;
    padding-top: 1.5rem;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

body[data-theme="light"] .footer-bottom {
    border-top: 1px solid rgba(0, 0, 0, 0.1);
}

.footer-bottom p {
    color: rgba(255, 255, 255, 0.5);
    font-size: 0.9rem;
}

body[data-theme="light"] .footer-bottom p {
    color: rgba(0, 0, 0, 0.5);
}

.back-to-top {
    width: 40px;
    height: 40px;
    background: linear-gradient(45deg, var(--dark-primary), var(--dark-secondary));
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: var(--transition);
    box-shadow: 0 4px 15px rgba(142, 68, 173, 0.3);
}

.back-to-top:hover {
    transform: translateY(-3px) scale(1.1);
    box-shadow: 0 6px 20px rgba(142, 68, 173, 0.4);
}

/* Responsive Design */
@media (max-width: 1024px) {
    .books-container {
        grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    }
}

@media (max-width: 768px) {
    .header-content {
        flex-direction: column;
        gap: 1rem;
    }
    
    .search-box {
        flex-direction: column;
        gap: 1rem;
    }
    
    #search {
        width: 100%;
        border-radius: 50px;
    }
    
    #search-btn {
        position: relative;
        right: auto;
        top: auto;
        transform: none;
        width: 100%;
        border-radius: 50px;
    }
    
    .filter-options {
        gap: 0.5rem;
    }
    
    .filter-btn {
        padding: 0.6rem 1rem;
    }
}

@media (max-width: 480px) {
    main {
        padding: 0 1rem;
    }
    
    .search-container {
        padding: 1.5rem;
    }
    
    .books-container {
        grid-template-columns: 1fr;
    }
    
    .footer-content {
        grid-template-columns: 1fr;
    }
    
    .footer-bottom {
        flex-direction: column;
        gap: 1rem;
    }
}

/* Animations */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

.book {
    animation: fadeIn 0.6s ease forwards;
    opacity: 0;
}

.book:nth-child(1) { animation-delay: 0.1s; }
.book:nth-child(2) { animation-delay: 0.2s; }
.book:nth-child(3) { animation-delay: 0.3s; }
.book:nth-child(4) { animation-delay: 0.4s; }
.book:nth-child(5) { animation-delay: 0.5s; }
.book:nth-child(6) { animation-delay: 0.6s; }
.book:nth-child(7) { animation-delay: 0.7s; }
.book:nth-child(8) { animation-delay: 0.8s; }
.book:nth-child(9) { animation-delay: 0.9s; }
.book:nth-child(10) { animation-delay: 1.0s; }