File size: 4,011 Bytes
0bfd444
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
// Theme management
const themeManager = {
    init() {
        this.loadTheme();
        this.bindEvents();
    },
    
    loadTheme() {
        const savedTheme = localStorage.getItem('theme') || 'system';
        this.applyTheme(savedTheme);
    },
    
    applyTheme(theme) {
        const root = document.documentElement;
        
        if (theme === 'dark') {
            root.classList.add('dark');
        } else if (theme === 'light') {
            root.classList.remove('dark');
        } else {
            // System preference
            const prefersDark = window.matchMedia('(prefers-color-scheme: dark)').matches;
            if (prefersDark) {
                root.classList.add('dark');
            } else {
                root.classList.remove('dark');
            }
        }
        
        // Update theme toggle
        const themeToggle = document.querySelector('custom-theme-toggle');
        if (themeToggle) {
            themeToggle.setAttribute('current-theme', theme);
        }
    },
    
    setTheme(theme) {
        localStorage.setItem('theme', theme);
        this.applyTheme(theme);
    },
    
    bindEvents() {
        window.matchMedia('(prefers-color-scheme: dark)').addEventListener('change', () => {
            if (localStorage.getItem('theme') === 'system') {
                this.applyTheme('system');
            }
        });
    }
};

// Pricing toggle functionality
const pricingManager = {
    init() {
        this.isYearly = false;
        this.bindEvents();
    },
    
    bindEvents() {
        const monthlyBtn = document.getElementById('monthly-btn');
        const yearlyBtn = document.getElementById('yearly-btn');
        const toggle = document.getElementById('billing-toggle');
        
        if (monthlyBtn && yearlyBtn) {
            monthlyBtn.addEventListener('click', () => this.setBilling(false));
            yearlyBtn.addEventListener('click', () => this.setBilling(true));
        }
    },
    
    setBilling(yearly) {
        this.isYearly = yearly;
        const monthlyBtn = document.getElementById('monthly-btn');
        const yearlyBtn = document.getElementById('yearly-btn');
        const toggle = document.getElementById('billing-toggle');
        
        if (yearly) {
            toggle.classList.add('yearly');
            monthlyBtn.classList.remove('text-white');
            yearlyBtn.classList.add('text-white');
        } else {
            toggle.classList.remove('yearly');
            monthlyBtn.classList.add('text-white');
            yearlyBtn.classList.remove('text-white');
        }
        
        // Update pricing cards
        const pricingCards = document.querySelectorAll('custom-pricing-card');
        pricingCards.forEach(card => {
            card.setAttribute('yearly', yearly);
        });
    }
};

// Smooth scrolling
const smoothScroll = {
    init() {
        document.querySelectorAll('a[href^="#"]').forEach(anchor => {
            anchor.addEventListener('click', function (e) {
                e.preventDefault();
                const target = document.querySelector(this.getAttribute('href'));
                if (target) {
                    target.scrollIntoView({
                        behavior: 'smooth',
                        block: 'start'
                    });
                }
            });
        });
    }
};

// Initialize everything
document.addEventListener('DOMContentLoaded', () => {
    themeManager.init();
    pricingManager.init();
    smoothScroll.init();
});

// Intersection Observer for animations
const observerOptions = {
    threshold: 0.1,
    rootMargin: '0px 0px -100px 0px'
};

const observer = new IntersectionObserver((entries) => {
    entries.forEach(entry => {
        if (entry.isIntersecting) {
            entry.target.classList.add('animate-in');
        }
    });
}, observerOptions);

document.addEventListener('DOMContentLoaded', () => {
    document.querySelectorAll('.feature-card').forEach(el => observer.observe(el));
});