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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    line-height: 1.6;
    color: #333;
    background-color: #fff;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

/* Header and Navigation */
.header {
    background: #fff;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    position: sticky;
    top: 0;
    z-index: 1000;
}

.nav-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 20px;
    max-width: 1200px;
    margin: 0 auto;
}

.logo {
    display: flex;
    align-items: center;
    text-decoration: none;
    color: #2c3e50;
    font-weight: 700;
    font-size: 1.2rem;
}

.logo img {
    width: 32px;
    height: 32px;
    margin-right: 10px;
}

.nav-menu {
    display: flex;
    list-style: none;
    gap: 2rem;
}

.nav-link {
    text-decoration: none;
    color: #555;
    font-weight: 500;
    transition: color 0.3s ease;
}

.nav-link:hover,
.nav-link.active {
    color: #3498db;
}

.nav-toggle {
    display: none;
    flex-direction: column;
    background: none;
    border: none;
    cursor: pointer;
}

.nav-toggle span {
    width: 25px;
    height: 3px;
    background: #333;
    margin: 3px 0;
    transition: 0.3s;
}

/* Hero Section */
.hero {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 4rem 0;
    text-align: center;
    position: relative;
    overflow: hidden;
}

.hero::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: url('/assets/hero-bg.svg') center/cover;
    opacity: 0.1;
}

.hero-content {
    position: relative;
    z-index: 2;
    max-width: 600px;
    margin: 0 auto;
    padding: 0 20px;
}

.hero h1 {
    font-size: 3rem;
    margin-bottom: 1rem;
    font-weight: 700;
}

.hero p {
    font-size: 1.2rem;
    margin-bottom: 2rem;
    opacity: 0.9;
}

/* Buttons */
.btn-primary,
.btn-secondary {
    display: inline-block;
    padding: 12px 24px;
    border-radius: 6px;
    text-decoration: none;
    font-weight: 600;
    transition: all 0.3s ease;
    border: none;
    cursor: pointer;
    font-size: 1rem;
}

.btn-primary {
    background: #3498db;
    color: white;
}

.btn-primary:hover {
    background: #2980b9;
    transform: translateY(-2px);
}

.btn-secondary {
    background: transparent;
    color: #3498db;
    border: 2px solid #3498db;
}

.btn-secondary:hover {
    background: #3498db;
    color: white;
}

/* Page Headers */
.page-header {
    background: #f8f9fa;
    padding: 3rem 0;
    text-align: center;
}

.page-header h1 {
    font-size: 2.5rem;
    color: #2c3e50;
    margin-bottom: 1rem;
}

.page-header p {
    font-size: 1.1rem;
    color: #666;
    max-width: 600px;
    margin: 0 auto;
}

/* Book Grids */
.books-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 2rem;
    margin: 2rem 0;
}

.book-card {
    background: white;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.1);
    padding: 1.5rem;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    text-decoration: none;
    color: inherit;
    display: block;
}

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

.book-image {
    width: 100%;
    height: 200px;
    object-fit: cover;
    border-radius: 8px;
    margin-bottom: 1rem;
}

.book-card h3 {
    font-size: 1.3rem;
    color: #2c3e50;
    margin-bottom: 0.5rem;
    line-height: 1.3;
}

.book-author {
    color: #666;
    font-style: italic;
    margin-bottom: 0.5rem;
}

.book-category {
    display: inline-block;
    background: #e3f2fd;
    color: #1976d2;
    padding: 0.25rem 0.75rem;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 500;
    margin-bottom: 1rem;
}

.book-description {
    color: #555;
    font-size: 0.95rem;
    line-height: 1.5;
}

/* Book Details */
.book-details {
    padding: 2rem 0;
}

.book-detail-container {
    max-width: 1000px;
    margin: 0 auto;
    padding: 0 20px;
}

.book-detail-header {
    display: grid;
    grid-template-columns: 300px 1fr;
    gap: 3rem;
    margin-bottom: 3rem;
}

.book-detail-image {
    width: 100%;
    height: 400px;
    object-fit: cover;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.1);
}

.book-detail-info h1 {
    font-size: 2.5rem;
    color: #2c3e50;
    margin-bottom: 1rem;
    line-height: 1.2;
}

.book-detail-meta {
    margin-bottom: 2rem;
}

.book-detail-meta p {
    margin-bottom: 0.5rem;
    color: #666;
}

.book-detail-meta strong {
    color: #333;
}

.book-links {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
    margin-top: 2rem;
}

.book-link {
    padding: 10px 20px;
    background: #3498db;
    color: white;
    text-decoration: none;
    border-radius: 6px;
    font-weight: 600;
    transition: background 0.3s ease;
}

.book-link:hover {
    background: #2980b9;
}

.book-detail-content {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 3rem;
}

.book-detail-main h2 {
    color: #2c3e50;
    margin-bottom: 1rem;
    margin-top: 2rem;
}

.book-detail-main h2:first-child {
    margin-top: 0;
}

.book-detail-main p {
    margin-bottom: 1rem;
    line-height: 1.6;
    color: #555;
}

.book-detail-main ul {
    margin-bottom: 1.5rem;
    padding-left: 1.5rem;
}

.book-detail-main li {
    margin-bottom: 0.5rem;
    line-height: 1.5;
    color: #555;
}

.book-detail-sidebar {
    background: #f8f9fa;
    padding: 2rem;
    border-radius: 12px;
    height: fit-content;
    position: sticky;
    top: 100px;
}

.disclaimer-box {
    background: #fff3cd;
    border: 1px solid #ffeaa7;
    border-radius: 8px;
    padding: 1rem;
    margin-bottom: 2rem;
}

.disclaimer-box p {
    margin: 0;
    font-size: 0.9rem;
    color: #856404;
}

/* Categories */
.categories-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 2rem;
    margin: 2rem 0;
}

.category-card {
    background: white;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.1);
    padding: 2rem;
    text-align: center;
    transition: transform 0.3s ease;
    text-decoration: none;
    color: inherit;
}

.category-card:hover {
    transform: translateY(-3px);
}

.category-card h3 {
    color: #2c3e50;
    margin-bottom: 1rem;
    font-size: 1.4rem;
}

.category-card p {
    color: #666;
    margin-bottom: 1rem;
}

.category-count {
    color: #3498db;
    font-weight: 600;
}

.categories-detailed {
    display: grid;
    gap: 3rem;
    margin: 2rem 0;
}

.category-section {
    background: white;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.1);
    padding: 2rem;
}

.category-section h2 {
    color: #2c3e50;
    margin-bottom: 1rem;
    font-size: 1.8rem;
}

.category-section p {
    color: #666;
    margin-bottom: 2rem;
    line-height: 1.6;
}

/* Filters */
.filters {
    display: flex;
    gap: 1rem;
    margin-bottom: 2rem;
    flex-wrap: wrap;
}

.search-box input {
    padding: 12px 16px;
    border: 2px solid #ddd;
    border-radius: 6px;
    font-size: 1rem;
    width: 300px;
    max-width: 100%;
}

.search-box input:focus {
    outline: none;
    border-color: #3498db;
}

.category-filter select {
    padding: 12px 16px;
    border: 2px solid #ddd;
    border-radius: 6px;
    font-size: 1rem;
    background: white;
    cursor: pointer;
}

.category-filter select:focus {
    outline: none;
    border-color: #3498db;
}

.no-results {
    text-align: center;
    padding: 3rem 0;
    color: #666;
}

/* Content Sections */
.content-section {
    padding: 3rem 0;
}

.content-grid {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 3rem;
}

.content-main h2 {
    color: #2c3e50;
    margin-bottom: 1rem;
    margin-top: 2rem;
}

.content-main h2:first-child {
    margin-top: 0;
}

.content-main p {
    margin-bottom: 1rem;
    line-height: 1.6;
    color: #555;
}

.content-main ul {
    margin-bottom: 1.5rem;
    padding-left: 1.5rem;
}

.content-main li {
    margin-bottom: 0.5rem;
    line-height: 1.5;
    color: #555;
}

.content-sidebar {
    background: #f8f9fa;
    padding: 2rem;
    border-radius: 12px;
    height: fit-content;
    position: sticky;
    top: 100px;
}

.sidebar-box {
    margin-bottom: 2rem;
}

.sidebar-box:last-child {
    margin-bottom: 0;
}

.sidebar-box h3 {
    color: #2c3e50;
    margin-bottom: 1rem;
    font-size: 1.2rem;
}

.sidebar-box p {
    color: #666;
    line-height: 1.5;
    margin-bottom: 1rem;
}

.sidebar-box ul {
    list-style: none;
    padding: 0;
}

.sidebar-box li {
    margin-bottom: 0.5rem;
}

.sidebar-box a {
    color: #3498db;
    text-decoration: none;
}

.sidebar-box a:hover {
    text-decoration: underline;
}

/* Contact Form */
.contact-section {
    padding: 3rem 0;
}

.contact-grid {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 3rem;
}

.contact-form {
    background: white;
    padding: 2rem;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.1);
}

.contact-form h2 {
    color: #2c3e50;
    margin-bottom: 2rem;
}

.form-group {
    margin-bottom: 1.5rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 600;
    color: #333;
}

.form-group input,
.form-group textarea {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid #ddd;
    border-radius: 6px;
    font-size: 1rem;
    font-family: inherit;
}

.form-group input:focus,
.form-group textarea:focus {
    outline: none;
    border-color: #3498db;
}

.form-group textarea {
    resize: vertical;
    min-height: 120px;
}

.form-message {
    padding: 1rem;
    border-radius: 6px;
    margin-top: 1rem;
}

.form-message.success {
    background: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.contact-info {
    background: #f8f9fa;
    padding: 2rem;
    border-radius: 12px;
}

.contact-info h2 {
    color: #2c3e50;
    margin-bottom: 2rem;
}

.contact-item {
    margin-bottom: 2rem;
}

.contact-item:last-child {
    margin-bottom: 0;
}

.contact-item h3 {
    color: #2c3e50;
    margin-bottom: 0.5rem;
    font-size: 1.1rem;
}

.contact-item p {
    color: #666;
    line-height: 1.5;
}

.contact-item a {
    color: #3498db;
    text-decoration: none;
}

.contact-item a:hover {
    text-decoration: underline;
}

/* Legal Content */
.legal-content {
    max-width: 800px;
    margin: 0 auto;
    padding: 0 20px;
}

.legal-content h2 {
    color: #2c3e50;
    margin-bottom: 1rem;
    margin-top: 2rem;
    font-size: 1.5rem;
}

.legal-content h2:first-child {
    margin-top: 0;
}

.legal-content p {
    margin-bottom: 1rem;
    line-height: 1.6;
    color: #555;
}

.legal-content ul {
    margin-bottom: 1.5rem;
    padding-left: 1.5rem;
}

.legal-content li {
    margin-bottom: 0.5rem;
    line-height: 1.5;
    color: #555;
}

.legal-content a {
    color: #3498db;
    text-decoration: none;
}

.legal-content a:hover {
    text-decoration: underline;
}

/* Error Messages */
.error-message {
    text-align: center;
    padding: 3rem 0;
}

.error-message h1 {
    color: #2c3e50;
    margin-bottom: 1rem;
}

.error-message p {
    color: #666;
    margin-bottom: 2rem;
}

/* Cookie Banner */
.cookie-banner {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: #2c3e50;
    color: white;
    padding: 1rem 0;
    z-index: 10000;
    box-shadow: 0 -2px 10px rgba(0,0,0,0.1);
}

.cookie-content {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
}

.cookie-content p {
    margin: 0;
    flex: 1;
}

.cookie-content button {
    background: #3498db;
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 600;
    white-space: nowrap;
}

.cookie-content button:hover {
    background: #2980b9;
}

/* Footer */
.footer {
    background: #2c3e50;
    color: white;
    padding: 3rem 0 1rem;
    margin-top: 4rem;
}

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

.footer-section h3,
.footer-section h4 {
    margin-bottom: 1rem;
    color: white;
}

.footer-section p {
    color: #bdc3c7;
    line-height: 1.6;
    margin-bottom: 0.5rem;
}

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

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

.footer-section a {
    color: #bdc3c7;
    text-decoration: none;
    transition: color 0.3s ease;
}

.footer-section a:hover {
    color: white;
}

.footer-bottom {
    border-top: 1px solid #34495e;
    padding-top: 1rem;
    text-align: center;
    color: #bdc3c7;
}

/* Featured Sections */
.featured-books,
.categories-preview {
    padding: 4rem 0;
    background: #f8f9fa;
}

.featured-books:nth-child(odd),
.categories-preview:nth-child(odd) {
    background: white;
}

.featured-books h2,
.categories-preview h2 {
    text-align: center;
    color: #2c3e50;
    margin-bottom: 3rem;
    font-size: 2.5rem;
}

/* Responsive Design */
@media (max-width: 768px) {
    .nav-menu {
        position: fixed;
        left: -100%;
        top: 70px;
        flex-direction: column;
        background-color: white;
        width: 100%;
        text-align: center;
        transition: 0.3s;
        box-shadow: 0 10px 27px rgba(0,0,0,0.05);
        padding: 2rem 0;
    }

    .nav-menu.active {
        left: 0;
    }

    .nav-toggle {
        display: flex;
    }

    .hero h1 {
        font-size: 2rem;
    }

    .hero p {
        font-size: 1rem;
    }

    .page-header h1 {
        font-size: 2rem;
    }

    .books-grid {
        grid-template-columns: 1fr;
        gap: 1.5rem;
    }

    .book-detail-header {
        grid-template-columns: 1fr;
        gap: 2rem;
    }

    .book-detail-image {
        height: 300px;
    }

    .book-detail-info h1 {
        font-size: 2rem;
    }

    .book-detail-content {
        grid-template-columns: 1fr;
        gap: 2rem;
    }

    .book-detail-sidebar {
        position: static;
    }

    .content-grid {
        grid-template-columns: 1fr;
        gap: 2rem;
    }

    .content-sidebar {
        position: static;
    }

    .contact-grid {
        grid-template-columns: 1fr;
        gap: 2rem;
    }

    .filters {
        flex-direction: column;
    }

    .search-box input {
        width: 100%;
    }

    .cookie-content {
        flex-direction: column;
        text-align: center;
        gap: 1rem;
    }

    .footer-content {
        grid-template-columns: 1fr;
        gap: 2rem;
    }

    .book-links {
        flex-direction: column;
    }

    .book-link {
        text-align: center;
    }
}

@media (max-width: 480px) {
    .container {
        padding: 0 15px;
    }

    .nav-container {
        padding: 1rem 15px;
    }

    .hero {
        padding: 2rem 0;
    }

    .hero h1 {
        font-size: 1.8rem;
    }

    .page-header {
        padding: 2rem 0;
    }

    .page-header h1 {
        font-size: 1.8rem;
    }

    .book-card,
    .category-card,
    .category-section,
    .contact-form,
    .contact-info {
        padding: 1.5rem;
    }

    .book-detail-info h1 {
        font-size: 1.8rem;
    }

    .featured-books h2,
    .categories-preview h2 {
        font-size: 2rem;
    }
}

/* FILE: assets/app.js -->
// Book Prosperity Digital - Main Application JavaScript

// Book Data
const BOOKS_DATA = {
    1: {
        id: 1,
        title: "The Lean Startup",
        author: "Eric Ries",
        category: "Business",
        shortDesc: "A revolutionary approach to building and launching successful startups using validated learning and rapid experimentation.",
        longDesc: "The Lean Startup methodology teaches entrepreneurs how to drive a startup-how to steer, when to turn, and when to persevere-and grow a business with maximum acceleration. It is a principled approach to new product development that emphasizes rapid iteration, customer feedback, and a scientific approach to creating and managing successful startups in an age when companies need to innovate more than ever.",
        keyTakeaways: [
            "Build-Measure-Learn feedback loop for rapid iteration",
            "Minimum Viable Product (MVP) development strategy",
            "Validated learning through customer experimentation",
            "Pivot or persevere decision-making framework",
            "Innovation accounting for measuring progress"
        ],
        whoItsFor: "Entrepreneurs, startup founders, product managers, and anyone interested in building innovative products or services.",
        publicationYear: 2011,
        externalLinks: {
            amazon: "https://www.amazon.com/Lean-Startup-Entrepreneurs-Continuous-Innovation/dp/0307887898",
            audible: "https://www.audible.com/pd/The-Lean-Startup-Audiobook/B005LXV0HI",
            googleBooks: "https://books.google.com/books?id=r9x-OXdzpPcC"
        },
        image: "/assets/book-01.svg"
    },
    2: {
        id: 2,
        title: "Thinking, Fast and Slow",
        author: "Daniel Kahneman",
        category: "Economics",
        shortDesc: "A groundbreaking exploration of the two systems that drive the way we think and make decisions.",
        longDesc: "Nobel Prize winner Daniel Kahneman takes us on a groundbreaking tour of the mind and explains the two systems that drive the way we think. System 1 is fast, intuitive, and emotional; System 2 is slower, more deliberative, and more logical. The impact of overconfidence on corporate strategies, the difficulties of predicting what will make us happy in the future, the profound effect of cognitive biases on everything from playing the stock market to planning our next vacation-each of these can be understood only by knowing how the two systems shape our judgments and decisions.",
        keyTakeaways: [
            "Understanding System 1 (fast) and System 2 (slow) thinking",
            "Recognition of cognitive biases in decision-making",
            "The concept of loss aversion and prospect theory",
            "Anchoring effects and availability heuristic",
            "The planning fallacy and overconfidence bias"
        ],
        whoItsFor: "Business leaders, investors, psychologists, and anyone interested in understanding human decision-making processes.",
        publicationYear: 2011,
        externalLinks: {
            amazon: "https://www.amazon.com/Thinking-Fast-Slow-Daniel-Kahneman/dp/0374533555",
            audible: "https://www.audible.com/pd/Thinking-Fast-and-Slow-Audiobook/B005Z9GAJG",
            googleBooks: "https://books.google.com/books?id=ZuKTvERuPG8C"
        },
        image: "/assets/book-02.svg"
    },
    3: {
        id: 3,
        title: "The Innovator's Dilemma",
        author: "Clayton M. Christensen",
        category: "Technology",
        shortDesc: "Why successful companies fail to innovate and how disruptive technologies reshape industries.",
        longDesc: "Clayton Christensen demonstrates how successful, outstanding companies can do everything 'right' and still lose their market leadership or even fail as new, unexpected competitors rise and take over the market. The Innovator's Dilemma is the revolutionary business book that has forever changed corporate America. Based on a truly radical idea-that great companies can fail by doing everything right-this Wall Street Journal, Business Week and New York Times Business bestseller is one of the most provocative and important business books ever written.",
        keyTakeaways: [
            "Sustaining vs. disruptive innovation concepts",
            "Why market leaders often miss disruptive opportunities",
            "The importance of creating autonomous units for innovation",
            "Value networks and performance trajectories",
            "Strategies for managing disruptive change"
        ],
        whoItsFor: "CEOs, technology leaders, strategists, and anyone involved in innovation management.",
        publicationYear: 1997,
        externalLinks: {
            amazon: "https://www.amazon.com/Innovators-Dilemma-Technologies-Management-Innovation/dp/1633691780",
            audible: "https://www.audible.com/pd/The-Innovators-Dilemma-Audiobook/B012VMLTQE",
            googleBooks: "https://books.google.com/books?id=SIexi_qgq2gC"
        },
        image: "/assets/book-03.svg"
    },
    4: {
        id: 4,
        title: "Getting Things Done",
        author: "David Allen",
        category: "Productivity",
        shortDesc: "The art of stress-free productivity through a comprehensive personal organization system.",
        longDesc: "In Getting Things Done, veteran coach and management consultant David Allen shares the breakthrough methods for stress-free performance that he has introduced to tens of thousands of people across the country. Allen's premise is simple: our productivity is directly proportional to our ability to relax. Only when our minds are clear and our thoughts are organized can we achieve effective productivity and unleash our creative potential.",
        keyTakeaways: [
            "The five-step GTD workflow: Capture, Clarify, Organize, Reflect, Engage",
            "Two-minute rule for immediate action items",
            "Weekly review process for maintaining system integrity",
            "Context-based task organization",
            "Mind like water concept for stress-free productivity"
        ],
        whoItsFor: "Professionals, managers, students, and anyone seeking to improve their personal productivity and organization.",
        publicationYear: 2001,
        externalLinks: {
            amazon: "https://www.amazon.com/Getting-Things-Done-Stress-Free-Productivity/dp/0143126563",
            audible: "https://www.audible.com/pd/Getting-Things-Done-Audiobook/B01B6WSK5C",
            googleBooks: "https://books.google.com/books?id=LAx_xQEACAAJ"
        },
        image: "/assets/book-04.svg"
    },
    5: {
        id: 5,
        title: "Atomic Habits",
        author: "James Clear",
        category: "Personal Development",
        shortDesc: "An easy and proven way to build good habits and break bad ones through small, incremental changes.",
        longDesc: "No matter your goals, Atomic Habits offers a proven framework for improving--every day. James Clear, one of the world's leading experts on habit formation, reveals practical strategies that will teach you exactly how to form good habits, break bad ones, and master the tiny behaviors that lead to remarkable results. If you're having trouble changing your habits, the problem isn't you. The problem is your system. Bad habits repeat themselves again and again not because you don't want to change, but because you have the wrong system for change.",
        keyTakeaways: [
            "The four laws of behavior change",
            "1% better every day compound effect",
            "Identity-based habit formation",
            "Environment design for habit success",
            "Habit stacking and implementation intentions"
        ],
        whoItsFor: "Anyone looking to build better habits, improve personal performance, or create lasting positive change in their life.",
        publicationYear: 2018,
        externalLinks: {
            amazon: "https://www.amazon.com/Atomic-Habits-Proven-Build-Break/dp/0735211299",
            audible: "https://www.audible.com/pd/Atomic-Habits-Audiobook/1524779261",
            googleBooks: "https://books.google.com/books?id=XfFvDwAAQBAJ"
        },
        image: "/assets/book-05.svg"
    },
    6: {
        id: 6,
        title: "Good to Great",
        author: "Jim Collins",
        category: "Business",
        shortDesc: "Why some companies make the leap to exceptional performance while others don't.",
        longDesc: "Built to Last, the defining management study of the nineties, showed how great companies triumph over time and how long-term sustained performance can be engineered into the DNA of an enterprise from the very beginning. But what about the company that is not born with great DNA? How can good companies, mediocre companies, even bad companies achieve enduring greatness? The Study: Five years ago, Jim Collins asked the question, 'Can a good company become a great company and if so, how?' In Good to Great Collins, the author of Built to Last, concludes that it is possible, but finds there are no silver bullets.",
        keyTakeaways: [
            "Level 5 Leadership characteristics",
            "First Who, Then What - getting the right people",
            "Hedgehog Concept - three intersecting circles",
            "Culture of Discipline and Technology Accelerators",
            "Flywheel Effect for sustained momentum"
        ],
        whoItsFor: "Business leaders, executives, managers, and entrepreneurs seeking to transform their organizations.",
        publicationYear: 2001,
        externalLinks: {
            amazon: "https://www.amazon.com/Good-Great-Some-Companies-Others/dp/0066620996",
            audible: "https://www.audible.com/pd/Good-to-Great-Audiobook/B003VXI5MS",
            googleBooks: "https://books.google.com/books?id=yohuPwAACAAJ"
        },
        image: "/assets/book-06.svg"
    },
    7: {
        id: 7,
        title: "Deep Work",
        author: "Cal Newport",
        category: "Productivity",
        shortDesc: "Rules for focused success in a distracted world through cultivating the ability to focus on cognitively demanding tasks.",
        longDesc: "Deep work is the ability to focus without distraction on a cognitively demanding task. It's a skill that allows you to quickly master complicated information and produce better results in less time. Deep Work will make you better at what you do and provide the sense of true fulfillment that comes from craftsmanship. In short, deep work is like a super power in our increasingly competitive twenty-first century economy. And yet, most people have lost the ability to go deep-spending their days instead in a frantic blur of e-mail and social media, not even realizing there's a better way.",
        keyTakeaways: [
            "Four philosophies of deep work scheduling",
            "Strategies for minimizing shallow work",
            "Digital minimalism and attention management",
            "The importance of boredom and downtime",
            "Building deep work habits and rituals"
        ],
        whoItsFor: "Knowledge workers, professionals, students, and anyone seeking to improve focus and productivity in a distracted world.",
        publicationYear: 2016,
        externalLinks: {
            amazon: "https://www.amazon.com/Deep-Work-Focused-Success-Distracted/dp/1455586692",
            audible: "https://www.audible.com/pd/Deep-Work-Audiobook/B0189PVAWY",
            googleBooks: "https://books.google.com/books?id=lZpKCwAAQBAJ"
        },
        image: "/assets/book-07.svg"
    },
    8: {
        id: 8,
        title: "Mindset",
        author: "Carol S. Dweck",
        category: "Personal Development",
        shortDesc: "The new psychology of success through developing a growth mindset instead of a fixed mindset.",
        longDesc: "After decades of research, world-renowned Stanford University psychologist Carol S. Dweck, Ph.D., discovered a simple but groundbreaking idea: the power of mindset. In this brilliant book, she shows how success in school, work, sports, the arts, and almost every area of human endeavor can be dramatically influenced by how we think about our talents and abilities. People with a fixed mindset-those who believe that abilities are fixed-are less likely to flourish than those with a growth mindset-those who believe that abilities can be developed.",
        keyTakeaways: [
            "Fixed vs. Growth mindset concepts",
            "The power of 'yet' in learning and development",
            "How praise affects mindset development",
            "Mindset in relationships, parenting, and leadership",
            "Strategies for developing a growth mindset"
        ],
        whoItsFor: "Educators, parents, leaders, athletes, and anyone interested in personal development and maximizing potential.",
        publicationYear: 2006,
        externalLinks: {
            amazon: "https://www.amazon.com/Mindset-Psychology-Carol-S-Dweck/dp/0345472322",
            audible: "https://www.audible.com/pd/Mindset-Audiobook/B003K16PUU",
            googleBooks: "https://books.google.com/books?id=fdjqz0TPL2wC"
        },
        image: "/assets/book-08.svg"
    }
};

// Categories Configuration
const CATEGORIES = {
    'Business': {
        name: 'Business',
        description: 'Strategic insights and management principles for building successful organizations.',
        books: []
    },
    'Economics': {
        name: 'Economics',
        description: 'Understanding economic principles, behavioral economics, and market dynamics.',
        books: []
    },
    'Technology': {
        name: 'Technology',
        description: 'Innovation, disruption, and the future of technology in business and society.',
        books: []
    },
    'Productivity': {
        name: 'Productivity',
        description: 'Systems and strategies for maximizing efficiency and achieving more with less effort.',
        books: []
    },
    'Personal Development': {
        name: 'Personal Development',
        description: 'Growth mindset, habits, and strategies for continuous self-improvement.',
        books: []
    }
};

// Initialize categories with books
function initializeCategories() {
    // Reset categories
    Object.keys(CATEGORIES).forEach(cat => {
        CATEGORIES[cat].books = [];
    });
    
    // Populate categories with books
    Object.values(BOOKS_DATA).forEach(book => {
        if (CATEGORIES[book.category]) {
            CATEGORIES[book.category].books.push(book);
        }
    });
}

// Utility Functions
function getBookById(id) {
    return BOOKS_DATA[parseInt(id)] || null;
}

function getAllBooks() {
    return Object.values(BOOKS_DATA);
}

function getBooksByCategory(category) {
    return getAllBooks().filter(book => book.category === category);
}

function searchBooks(query, category = '') {
    let books = getAllBooks();
    
    if (category) {
        books = books.filter(book => book.category === category);
    }
    
    if (query) {
        const searchTerm = query.toLowerCase();
        books = books.filter(book => 
            book.title.toLowerCase().includes(searchTerm) ||
            book.author.toLowerCase().includes(searchTerm) ||
            book.shortDesc.toLowerCase().includes(searchTerm)
        );
    }
    
    return books;
}

// Render Functions
function renderBookCard(book) {
    return `
        <a href="/book/?id=${book.id}" class="book-card">
            <img src="${book.image}" alt="${book.title}" class="book-image">
            <div class="book-category">${book.category}</div>
            <h3>${book.title}</h3>
            <div class="book-author">by ${book.author}</div>
            <p class="book-description">${book.shortDesc}</p>
        </a>
    `;
}

function renderCategoryCard(categoryName, category) {
    return `
        <div class="category-card">
            <h3>${category.name}</h3>
            <p>${category.description}</p>
            <div class="category-count">${category.books.length} books</div>
        </div>
    `;
}

function renderCategorySection(categoryName, category) {
    const booksHtml = category.books.map(book => renderBookCard(book)).join('');
    return `
        <div class="category-section">
            <h2>${category.name}</h2>
            <p>${category.description}</p>
            <div class="books-grid">
                ${booksHtml}
            </div>
        </div>
    `;
}

function renderBookDetails(book) {
    const keyTakeawaysHtml = book.keyTakeaways.map(takeaway => `<li>${takeaway}</li>`).join('');
    
    return `
        <div class="book-detail-container">
            <div class="book-detail-header">
                <img src="${book.image}" alt="${book.title}" class="book-detail-image">
                <div class="book-detail-info">
                    <h1>${book.title}</h1>
                    <div class="book-detail-meta">
                        <p><strong>Author:</strong> ${book.author}</p>
                        <p><strong>Category:</strong> ${book.category}</p>
                        <p><strong>Published:</strong> ${book.publicationYear}</p>
                    </div>
                    <div class="disclaimer-box">
                        <p><strong>Please Note:</strong> This book is sold by third-party platforms. We do not sell or distribute books.</p>
                    </div>
                    <div class="book-links">
                        <a href="${book.externalLinks.amazon}" target="_blank" rel="noopener noreferrer" class="book-link">View on Amazon</a>
                        <a href="${book.externalLinks.audible}" target="_blank" rel="noopener noreferrer" class="book-link">Listen on Audible</a>
                        <a href="${book.externalLinks.googleBooks}" target="_blank" rel="noopener noreferrer" class="book-link">Google Books</a>
                    </div>
                </div>
            </div>
            <div class="book-detail-content">
                <div class="book-detail-main">
                    <h2>About This Book</h2>
                    <p>${book.longDesc}</p>
                    
                    <h2>Key Takeaways</h2>
                    <ul>
                        ${keyTakeawaysHtml}
                    </ul>
                    
                    <h2>Who It's For</h2>
                    <p>${book.whoItsFor}</p>
                </div>
                <div class="book-detail-sidebar">
                    <div class="sidebar-box">
                        <h3>Book Information</h3>
                        <p><strong>Author:</strong> ${book.author}</p>
                        <p><strong>Category:</strong> ${book.category}</p>
                        <p><strong>Published:</strong> ${book.publicationYear}</p>
                    </div>
                    <div class="sidebar-box">
                        <h3>More in ${book.category}</h3>
                        <p><a href="/books/?category=${encodeURIComponent(book.category)}">View all ${book.category} books</a></p>
                    </div>
                </div>
            </div>
        </div>
    `;
}

// Page-specific Functions
function initHomePage() {
    // Render featured books (first 6 books)
    const featuredBooks = getAllBooks().slice(0, 6);
    const featuredBooksGrid = document.getElementById('featured-books-grid');
    if (featuredBooksGrid) {
        featuredBooksGrid.innerHTML = featuredBooks.map(book => renderBookCard(book)).join('');
    }
    
    // Render categories preview
    const categoriesGrid = document.getElementById('categories-grid');
    if (categoriesGrid) {
        const categoriesHtml = Object.keys(CATEGORIES).map(categoryName => 
            renderCategoryCard(categoryName, CATEGORIES[categoryName])
        ).join('');
        categoriesGrid.innerHTML = categoriesHtml;
    }
}

function initBooksPage() {
    const booksResults = document.getElementById('books-results');
    const categoryFilter = document.getElementById('category-filter');
    const searchInput = document.getElementById('search-input');
    const noResults = document.getElementById('no-results');
    
    if (!booksResults || !categoryFilter || !searchInput) return;
    
    // Populate category filter
    Object.keys(CATEGORIES).forEach(categoryName => {
        const option = document.createElement('option');
        option.value = categoryName;
        option.textContent = categoryName;
        categoryFilter.appendChild(option);
    });
    
    // Check for URL parameters
    const urlParams = new URLSearchParams(window.location.search);
    const initialCategory = urlParams.get('category') || '';
    if (initialCategory && CATEGORIES[initialCategory]) {
        categoryFilter.value = initialCategory;
    }
    
    function updateResults() {
        const searchQuery = searchInput.value.trim();
        const selectedCategory = categoryFilter.value;
        const results = searchBooks(searchQuery, selectedCategory);
        
        if (results.length === 0) {
            booksResults.style.display = 'none';
            noResults.style.display = 'block';
        } else {
            booksResults.style.display = 'grid';
            noResults.style.display = 'none';
            booksResults.innerHTML = results.map(book => renderBookCard(book)).join('');
        }
    }
    
    // Event listeners
    searchInput.addEventListener('input', updateResults);
    categoryFilter.addEventListener('change', updateResults);
    
    // Initial render
    updateResults();
}

function initBookDetailsPage() {
    const bookDetails = document.getElementById('book-details');
    const bookNotFound = document.getElementById('book-not-found');
    
    if (!bookDetails || !bookNotFound) return;
    
    const urlParams = new URLSearchParams(window.location.search);
    const bookId = urlParams.get('id');
    
    if (!bookId) {
        bookDetails.style.display = 'none';
        bookNotFound.style.display = 'block';
        return;
    }
    
    const book = getBookById(bookId);
    
    if (!book) {
        bookDetails.style.display = 'none';
        bookNotFound.style.display = 'block';
        return;
    }
    
    // Update page title and meta description
    document.title = `${book.title} by ${book.author} - Book Prosperity Digital`;
    const metaDesc = document.querySelector('meta[name="description"]');
    if (metaDesc) {
        metaDesc.content = book.shortDesc;
    }
    
    bookDetails.innerHTML = renderBookDetails(book);
}

function initCategoriesPage() {
    const categoriesList = document.getElementById('categories-list');
    if (!categoriesList) return;
    
    const categoriesHtml = Object.keys(CATEGORIES).map(categoryName => 
        renderCategorySection(categoryName, CATEGORIES[categoryName])
    ).join('');
    
    categoriesList.innerHTML = categoriesHtml;
}

function initContactPage() {
    const contactForm = document.getElementById('contact-form');
    const formSuccess = document.getElementById('form-success');
    
    if (!contactForm || !formSuccess) return;
    
    contactForm.addEventListener('submit', function(e) {
        e.preventDefault();
        
        // Hide form and show success message
        contactForm.style.display = 'none';
        formSuccess.style.display = 'block';
        
        // Reset form after a delay
        setTimeout(() => {
            contactForm.reset();
            contactForm.style.display = 'block';
            formSuccess.style.display = 'none';
        }, 5000);
    });
}

// Cookie Banner Functions
function initCookieBanner() {
    const cookieBanner = document.getElementById('cookie-banner');
    const acceptButton = document.getElementById('accept-cookies');
    
    if (!cookieBanner || !acceptButton) return;
    
    // Check if cookies have been accepted
    const cookiesAccepted = localStorage.getItem('cookies-accepted');
    
    if (!cookiesAccepted) {
        cookieBanner.style.display = 'block';
    }
    
    acceptButton.addEventListener('click', function() {
        localStorage.setItem('cookies-accepted', 'true');
        cookieBanner.style.display = 'none';
    });
}

// Mobile Navigation
function initMobileNav() {
    const navToggle = document.querySelector('.nav-toggle');
    const navMenu = document.querySelector('.nav-menu');
    
    if (!navToggle || !navMenu) return;
    
    navToggle.addEventListener('click', function() {
        navMenu.classList.toggle('active');
    });
    
    // Close mobile menu when clicking on a link
    const navLinks = document.querySelectorAll('.nav-link');
    navLinks.forEach(link => {
        link.addEventListener('click', () => {
            navMenu.classList.remove('active');
        });
    });
}

// Main Initialization
function init() {
    // Initialize categories with book data
    initializeCategories();
    
    // Initialize cookie banner
    initCookieBanner();
    
    // Initialize mobile navigation
    initMobileNav();
    
    // Initialize page-specific functionality
    const currentPath = window.location.pathname;
    
    if (currentPath === '/' || currentPath === '/index/' || currentPath.includes('/index/')) {
        initHomePage();
    } else if (currentPath === '/books/' || currentPath.includes('/books/')) {
        initBooksPage();
    } else if (currentPath === '/book/' || currentPath.includes('/book/')) {
        initBookDetailsPage();
    } else if (currentPath === '/categories/' || currentPath.includes('/categories/')) {
        initCategoriesPage();
    } else if (currentPath === '/contact/' || currentPath.includes('/contact/')) {
        initContactPage();
    }
}

// Initialize when DOM is loaded
document.addEventListener('DOMContentLoaded', init);