/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    /* Enhanced Color Palette */
    --primary-gradient: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --secondary-gradient: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    --success-gradient: linear-gradient(135deg, #4ecdc4 0%, #44a08d 100%);
    --accent-gradient: linear-gradient(135deg, #ffecd2 0%, #fcb69f 100%);
    --warning-gradient: linear-gradient(135deg, #fdbb2d 0%, #22c1c3 100%);
    
    /* Text Colors */
    --text-primary: #1a202c;
    --text-secondary: #4a5568;
    --text-light: #718096;
    --text-white: #ffffff;
    
    /* Background Colors */
    --bg-primary: #ffffff;
    --bg-secondary: #f7fafc;
    --bg-accent: #edf2f7;
    --bg-overlay: rgba(0, 0, 0, 0.6);
    
    /* Shadows */
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.1), 0 1px 2px rgba(0, 0, 0, 0.06);
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.07), 0 2px 4px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.1), 0 4px 6px rgba(0, 0, 0, 0.05);
    --shadow-xl: 0 20px 25px rgba(0, 0, 0, 0.1), 0 10px 10px rgba(0, 0, 0, 0.04);
    --shadow-2xl: 0 25px 50px rgba(0, 0, 0, 0.25);
    
    /* Spacing */
    --space-xs: 0.25rem;
    --space-sm: 0.5rem;
    --space-md: 1rem;
    --space-lg: 1.5rem;
    --space-xl: 2rem;
    --space-2xl: 3rem;
    --space-3xl: 4rem;
    
    /* Border Radius */
    --radius-sm: 6px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 24px;
    --radius-full: 9999px;
    
    /* Transitions */
    --transition-fast: all 0.15s ease;
    --transition-normal: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-slow: all 0.5s cubic-bezier(0.4, 0, 0.2, 1);
    
    /* Typography */
    --font-size-xs: 0.75rem;
    --font-size-sm: 0.875rem;
    --font-size-base: 1rem;
    --font-size-lg: 1.125rem;
    --font-size-xl: 1.25rem;
    --font-size-2xl: 1.5rem;
    --font-size-3xl: 1.875rem;
    --font-size-4xl: 2.25rem;
    --font-size-5xl: 3rem;
}

/* Base Styles */
html {
    scroll-behavior: smooth;
    font-size: 16px;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    line-height: 1.6;
    color: var(--text-primary);
    background: linear-gradient(135deg, #f8fafc 0%, #e2e8f0 100%);
    min-height: 100vh;
    font-size: var(--font-size-base);
    overflow-x: hidden;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 var(--space-lg);
}

/* Enhanced Header Styles */
.header {
    background: var(--primary-gradient);
    color: var(--text-white);
    padding: var(--space-3xl) 0;
    text-align: center;
    position: relative;
    overflow: hidden;
}

.header::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle, rgba(255,255,255,0.1) 0%, transparent 70%);
    animation: float 20s ease-in-out infinite;
}

@keyframes float {
    0%, 100% { transform: translateY(0px) rotate(0deg); }
    50% { transform: translateY(-20px) rotate(180deg); }
}

.header-content {
    position: relative;
    z-index: 2;
    margin-bottom: var(--space-xl);
}

.site-title {
    font-family: 'Playfair Display', serif;
    font-size: clamp(var(--font-size-3xl), 6vw, var(--font-size-5xl));
    font-weight: 700;
    margin-bottom: var(--space-sm);
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.2);
    letter-spacing: -0.02em;
}

.site-subtitle {
    font-size: clamp(var(--font-size-lg), 3vw, var(--font-size-xl));
    opacity: 0.9;
    margin-bottom: var(--space-lg);
    font-weight: 300;
}

.back-link {
    display: inline-flex;
    align-items: center;
    gap: var(--space-sm);
    color: var(--text-white);
    text-decoration: none;
    padding: var(--space-md) var(--space-xl);
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: var(--radius-full);
    transition: var(--transition-normal);
    font-weight: 500;
    backdrop-filter: blur(10px);
    background: rgba(255, 255, 255, 0.1);
}

.back-link:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

/* Enhanced Search Section */
.search-section {
    padding: var(--space-2xl) 0;
    background: var(--bg-primary);
    box-shadow: var(--shadow-md);
    position: sticky;
    top: 0;
    z-index: 100;
    backdrop-filter: blur(10px);
}

.search-controls {
    display: flex;
    flex-direction: column;
    gap: var(--space-xl);
    margin-bottom: var(--space-lg);
}

.search-bar {
    position: relative;
    max-width: 600px;
    margin: 0 auto;
    width: 100%;
}

.search-bar input {
    width: 100%;
    padding: var(--space-lg) var(--space-xl);
    border: 2px solid var(--bg-accent);
    border-radius: var(--radius-full);
    font-size: var(--font-size-lg);
    transition: var(--transition-normal);
    background: var(--bg-secondary);
    font-family: inherit;
    box-shadow: var(--shadow-sm);
}

.search-bar input:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 4px rgba(102, 126, 234, 0.1), var(--shadow-md);
    background: var(--bg-primary);
}

.search-bar input::placeholder {
    color: var(--text-light);
}

.clear-btn {
    position: absolute;
    right: var(--space-lg);
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    font-size: var(--font-size-xl);
    cursor: pointer;
    color: var(--text-light);
    transition: var(--transition-fast);
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: none;
    align-items: center;
    justify-content: center;
}

.clear-btn:hover {
    color: #e53e3e;
    background: rgba(229, 62, 62, 0.1);
}

.filter-buttons {
    display: flex;
    justify-content: center;
    gap: var(--space-md);
    flex-wrap: wrap;
}

.filter-btn {
    padding: var(--space-md) var(--space-xl);
    border: 2px solid var(--bg-accent);
    background: var(--bg-primary);
    border-radius: var(--radius-full);
    cursor: pointer;
    transition: var(--transition-normal);
    font-weight: 500;
    color: var(--text-primary);
    font-size: var(--font-size-sm);
    box-shadow: var(--shadow-sm);
    white-space: nowrap;
}

.filter-btn:hover {
    border-color: #667eea;
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.filter-btn.active {
    background: var(--primary-gradient);
    color: var(--text-white);
    border-color: transparent;
    box-shadow: var(--shadow-lg);
}

.search-results {
    text-align: center;
    color: var(--text-secondary);
    font-weight: 500;
    font-size: var(--font-size-sm);
}

/* Enhanced Books Section */
.books-section {
    padding: var(--space-2xl) 0 var(--space-3xl);
    min-height: 60vh;
}

.loading-spinner {
    text-align: center;
    padding: var(--space-3xl);
}

.spinner {
    width: 48px;
    height: 48px;
    border: 4px solid var(--bg-accent);
    border-top: 4px solid #667eea;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto var(--space-lg);
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.books-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: var(--space-xl);
    animation: fadeIn 0.6s ease-out;
}

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

/* Enhanced Book Cards */
.book-card {
    background: var(--bg-primary);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    overflow: hidden;
    transition: var(--transition-normal);
    cursor: pointer;
    opacity: 0;
    transform: translateY(30px);
    animation: slideUp 0.6s ease-out forwards;
    display: flex;
    flex-direction: column;
    height: fit-content;
    border: 1px solid var(--bg-accent);
    position: relative;
}

.book-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(145deg, transparent 0%, rgba(102, 126, 234, 0.05) 100%);
    opacity: 0;
    transition: var(--transition-normal);
    pointer-events: none;
    z-index: 1;
}

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

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

.book-card:hover {
    transform: translateY(-12px) scale(1.02);
    box-shadow: var(--shadow-2xl);
    border-color: rgba(102, 126, 234, 0.2);
}

.book-image {
    position: relative;
    width: 100%;
    aspect-ratio: 3/4;
    overflow: hidden;
    background: linear-gradient(145deg, #f8fafc 0%, #e2e8f0 100%);
    display: flex;
    align-items: center;
    justify-content: center;
}

.book-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;
    transition: var(--transition-slow);
    filter: brightness(1.02) contrast(1.05);
}

.book-card:hover .book-image img {
    transform: scale(1.05);
    filter: brightness(1.05) contrast(1.1);
}

.book-placeholder {
    width: 100%;
    height: 100%;
    background: var(--accent-gradient);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-white);
    font-size: var(--font-size-lg);
    font-weight: 600;
    text-align: center;
    padding: var(--space-lg);
    line-height: 1.3;
}

.status-badge {
    position: absolute;
    top: var(--space-md);
    right: var(--space-md);
    padding: var(--space-sm);
    border-radius: 50%;
    font-weight: 700;
    font-size: var(--font-size-xs);
    box-shadow: var(--shadow-lg);
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
    backdrop-filter: blur(10px);
}

.status-badge.owned {
    background: var(--success-gradient);
    color: var(--text-white);
}

.status-badge.wanted {
    background: var(--secondary-gradient);
    color: var(--text-white);
}

.book-info {
    padding: var(--space-lg);
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
    flex-grow: 1;
    position: relative;
    z-index: 2;
}

.book-title {
    font-size: var(--font-size-base);
    font-weight: 600;
    line-height: 1.4;
    color: var(--text-primary);
    min-height: 2.8rem;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    margin-bottom: var(--space-sm);
}

.book-author {
    font-size: var(--font-size-sm);
    color: var(--text-secondary);
    font-weight: 400;
    line-height: 1.3;
    display: -webkit-box;
    -webkit-line-clamp: 1;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.book-status {
    display: inline-block;
    padding: var(--space-xs) var(--space-md);
    border-radius: var(--radius-full);
    font-size: var(--font-size-xs);
    font-weight: 600;
    margin-top: auto;
    align-self: flex-start;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.book-status.owned {
    background: linear-gradient(135deg, #e6fffa 0%, #b2f5ea 100%);
    color: #00a085;
    border: 1px solid #4ecdc4;
}

.book-status.wanted {
    background: linear-gradient(135deg, #fed7e2 0%, #fbb6ce 100%);
    color: #d53f8c;
    border: 1px solid #f093fb;
}

/* Enhanced Modal Styles */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1000;
    display: none;
    align-items: center;
    justify-content: center;
    padding: var(--space-lg);
}

.modal.active {
    display: flex;
}

.modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--bg-overlay);
    backdrop-filter: blur(8px);
    animation: fadeIn 0.3s ease-out;
}

.modal-content {
    position: relative;
    background: var(--bg-primary);
    border-radius: var(--radius-xl);
    max-width: 700px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow-2xl);
    animation: slideIn 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
    border: 1px solid var(--bg-accent);
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(50px) scale(0.9);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.modal-close {
    position: absolute;
    top: var(--space-lg);
    right: var(--space-lg);
    background: rgba(0, 0, 0, 0.6);
    color: var(--text-white);
    border: none;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    font-size: var(--font-size-xl);
    z-index: 10;
    transition: var(--transition-normal);
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(10px);
}

.modal-close:hover {
    background: rgba(0, 0, 0, 0.8);
    transform: scale(1.1);
}

.modal-body {
    display: flex;
    flex-direction: column;
}

.modal-image {
    height: 300px;
    background: var(--bg-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    border-radius: var(--radius-xl) var(--radius-xl) 0 0;
}

.modal-image img {
    width: auto;
    height: 100%;
    max-width: 100%;
    object-fit: contain;
    object-position: center;
    filter: brightness(1.02) contrast(1.05);
}

.modal-info {
    padding: var(--space-2xl);
}

.modal-info h2 {
    font-family: 'Playfair Display', serif;
    font-size: var(--font-size-2xl);
    font-weight: 700;
    margin-bottom: var(--space-md);
    color: var(--text-primary);
    line-height: 1.3;
}

.modal-info p {
    color: var(--text-secondary);
    margin-bottom: var(--space-lg);
    font-size: var(--font-size-lg);
    font-weight: 400;
}

.modal-description {
    margin: var(--space-xl) 0;
    line-height: 1.7;
    color: var(--text-primary);
    font-size: var(--font-size-base);
}

.shopping-links {
    margin-top: var(--space-2xl);
    padding-top: var(--space-xl);
    border-top: 2px solid var(--bg-accent);
}

.shopping-links h4 {
    margin-bottom: var(--space-lg);
    color: var(--text-primary);
    font-size: var(--font-size-lg);
    font-weight: 600;
}

.shop-buttons {
    display: flex;
    gap: var(--space-md);
    flex-wrap: wrap;
}

.shop-btn {
    padding: var(--space-md) var(--space-xl);
    border-radius: var(--radius-full);
    text-decoration: none;
    font-weight: 600;
    transition: var(--transition-normal);
    flex: 1;
    text-align: center;
    min-width: 120px;
    font-size: var(--font-size-sm);
    box-shadow: var(--shadow-md);
}

.shop-btn.amazon {
    background: linear-gradient(135deg, #ff9900 0%, #ff7700 100%);
    color: var(--text-white);
}

.shop-btn.flipkart {
    background: linear-gradient(135deg, #047bd5 0%, #0056b3 100%);
    color: var(--text-white);
}

.shop-btn.meesho {
    background: linear-gradient(135deg, #f43397 0%, #d12570 100%);
    color: var(--text-white);
}

.shop-btn:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-xl);
}

/* No Results State */
.no-results {
    text-align: center;
    padding: var(--space-3xl);
    color: var(--text-light);
}

.no-results h3 {
    font-size: var(--font-size-2xl);
    margin-bottom: var(--space-lg);
    color: var(--text-primary);
    font-weight: 600;
}

.no-results p {
    font-size: var(--font-size-lg);
}

/* Enhanced Footer */
.footer {
    background: var(--text-primary);
    color: var(--text-white);
    text-align: center;
    padding: var(--space-2xl) 0;
    margin-top: var(--space-3xl);
}

.footer p {
    margin-bottom: var(--space-sm);
    opacity: 0.8;
    font-size: var(--font-size-sm);
}

.footer p:last-child {
    margin-bottom: 0;
}

/* Responsive Design */
@media (max-width: 1024px) {
    .container {
        padding: 0 var(--space-md);
    }
    
    .books-grid {
        grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
        gap: var(--space-lg);
    }
}

@media (max-width: 768px) {
    .header {
        padding: var(--space-2xl) 0;
    }
    
    .search-section {
        padding: var(--space-xl) 0;
    }
    
    .search-controls {
        gap: var(--space-lg);
    }
    
    .filter-buttons {
        gap: var(--space-sm);
    }
    
    .filter-btn {
        padding: var(--space-sm) var(--space-lg);
        font-size: var(--font-size-xs);
    }
    
    .books-grid {
        grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
        gap: var(--space-lg);
    }
    
    .book-info {
        padding: var(--space-md);
    }
    
    .modal-content {
        margin: var(--space-md);
        max-height: calc(100vh - 2rem);
    }
    
    .modal-image {
        height: 250px;
    }
    
    .modal-info {
        padding: var(--space-xl);
    }
    
    .shop-buttons {
        flex-direction: column;
    }
    
    .shop-btn {
        min-width: auto;
    }
}

@media (max-width: 480px) {
    .container {
        padding: 0 var(--space-sm);
    }
    
    .header {
        padding: var(--space-xl) 0;
    }
    
    .search-bar input {
        padding: var(--space-md) var(--space-lg);
        font-size: var(--font-size-base);
    }
    
    .books-grid {
        grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
        gap: var(--space-md);
    }
    
    .book-info {
        padding: var(--space-sm) var(--space-md);
    }
    
    .book-title {
        font-size: var(--font-size-sm);
        min-height: 2.4rem;
    }
    
    .book-author {
        font-size: var(--font-size-xs);
    }
    
    .status-badge {
        width: 28px;
        height: 28px;
        font-size: 10px;
        top: var(--space-sm);
        right: var(--space-sm);
    }
    
    .modal {
        padding: var(--space-sm);
    }
    
    .modal-info {
        padding: var(--space-lg);
    }
    
    .modal-info h2 {
        font-size: var(--font-size-xl);
    }
}

/* Accessibility Improvements */
.book-card:focus,
.filter-btn:focus,
.search-bar input:focus,
.shop-btn:focus,
.modal-close:focus {
    outline: 3px solid rgba(102, 126, 234, 0.5);
    outline-offset: 2px;
}

/* Animation delays for staggered effect */
.book-card:nth-child(1) { animation-delay: 0.1s; }
.book-card:nth-child(2) { animation-delay: 0.15s; }
.book-card:nth-child(3) { animation-delay: 0.2s; }
.book-card:nth-child(4) { animation-delay: 0.25s; }
.book-card:nth-child(5) { animation-delay: 0.3s; }
.book-card:nth-child(6) { animation-delay: 0.35s; }
.book-card:nth-child(7) { animation-delay: 0.4s; }
.book-card:nth-child(8) { animation-delay: 0.45s; }

/* Scrollbar Styling */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-secondary);
}

::-webkit-scrollbar-thumb {
    background: var(--primary-gradient);
    border-radius: var(--radius-full);
}

::-webkit-scrollbar-thumb:hover {
    background: var(--secondary-gradient);
}

/* Loading States */
.book-card.loading {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: loading 1.5s infinite;
}

@keyframes loading {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* Print Styles */
@media print {
    .header,
    .search-section,
    .modal,
    .footer {
        display: none;
    }
    
    .books-grid {
        grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
        gap: var(--space-sm);
    }
    
    .book-card {
        box-shadow: none;
        border: 1px solid #ccc;
    }
}