<!DOCTYPE html>
<html lang="en" data-theme="light">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Enhanced COVID-19 Dashboard</title>
    <script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
    <style>
        /* Dark mode variables */
        :root[data-theme="light"] {
            --bg-color: #f0f2f5;
            --card-bg: white;
            --text-color: #333;
            --shadow: rgba(0,0,0,0.1);
        }

        :root[data-theme="dark"] {
            --bg-color: #1a1a1a;
            --card-bg: #2d2d2d;
            --text-color: #ffffff;
            --shadow: rgba(255,255,255,0.1);
        }

        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
            font-family: 'Arial', sans-serif;
        }

        body {
            background-color: var(--bg-color);
            padding: 20px;
            color: var(--text-color);
            transition: all 0.3s ease;
        }

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

        .header {
            text-align: center;
            margin-bottom: 30px;
            display: flex;
            justify-content: space-between;
            align-items: center;
            padding: 0 20px;
        }

        .theme-toggle {
            background: none;
            border: 2px solid var(--text-color);
            color: var(--text-color);
            padding: 8px 16px;
            border-radius: 20px;
            cursor: pointer;
            transition: all 0.3s ease;
        }

        .theme-toggle:hover {
            opacity: 0.8;
        }

        .stats-grid {
            display: grid;
            grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
            gap: 20px;
            margin-bottom: 30px;
        }

        .stat-card {
            background: var(--card-bg);
            padding: 20px;
            border-radius: 10px;
            box-shadow: 0 2px 5px var(--shadow);
            text-align: center;
            transition: transform 0.3s ease;
        }

        .stat-card:hover {
            transform: translateY(-5px);
        }

        .stat-card h3 {
            color: var(--text-color);
            margin-bottom: 10px;
        }

        .stat-card .number {
            font-size: 24px;
            font-weight: bold;
        }

        .cases { color: #FF9800; }
        .recovered { color: #4CAF50; }
        .deaths { color: #f44336; }
        .active { color: #2196F3; }
        .vaccinated { color: #9C27B0; }

        .search-container {
            margin-bottom: 20px;
            position: relative;
        }

        .search-input {
            width: 100%;
            padding: 12px;
            border: 1px solid #ddd;
            border-radius: 5px;
            font-size: 16px;
            background: var(--card-bg);
            color: var(--text-color);
        }

        .search-results {
            position: absolute;
            top: 100%;
            left: 0;
            right: 0;
            background: var(--card-bg);
            border-radius: 5px;
            box-shadow: 0 2px 5px var(--shadow);
            z-index: 1000;
            max-height: 300px;
            overflow-y: auto;
            display: none;
        }

        .search-result-item {
            padding: 10px;
            cursor: pointer;
            border-bottom: 1px solid var(--shadow);
        }

        .search-result-item:hover {
            background: var(--shadow);
        }

        .chart-container {
            background: var(--card-bg);
            padding: 20px;
            border-radius: 10px;
            box-shadow: 0 2px 5px var(--shadow);
            margin-bottom: 30px;
        }

        .notification-bar {
            background: var(--card-bg);
            padding: 15px;
            margin-bottom: 20px;
            border-radius: 10px;
            box-shadow: 0 2px 5px var(--shadow);
            display: none;
        }

        .tabs {
            display: flex;
            margin-bottom: 20px;
            background: var(--card-bg);
            padding: 10px;
            border-radius: 10px;
            gap: 10px;
        }

        .tab {
            padding: 10px 20px;
            cursor: pointer;
            border-radius: 5px;
            background: var(--bg-color);
            color: var(--text-color);
            border: none;
        }

        .tab.active {
            background: #2196F3;
            color: white;
        }

        .feedback-form {
            background: var(--card-bg);
            padding: 20px;
            border-radius: 10px;
            margin-top: 20px;
        }

        .feedback-form input,
        .feedback-form textarea {
            width: 100%;
            padding: 10px;
            margin-bottom: 10px;
            border-radius: 5px;
            border: 1px solid #ddd;
            background: var(--bg-color);
            color: var(--text-color);
        }

        .feedback-form button {
            background: #2196F3;
            color: white;
            padding: 10px 20px;
            border: none;
            border-radius: 5px;
            cursor: pointer;
        }

        @keyframes pulse {
            0% { transform: scale(1); }
            50% { transform: scale(1.05); }
            100% { transform: scale(1); }
        }

        .pulse {
            animation: pulse 2s infinite;
        }
    </style>
</head>
<body>
    <div class="container">
        <div class="header">
            <h1>COVID-19 Dashboard</h1>
            <button class="theme-toggle" id="themeToggle">🌓 Toggle Theme</button>
        </div>

        <div class="notification-bar" id="notificationBar"></div>

        <div class="search-container">
            <input type="text" class="search-input" id="searchInput" placeholder="Search for a country...">
            <div class="search-results" id="searchResults"></div>
        </div>

        <div class="tabs">
            <button class="tab active" data-tab="cases">Cases</button>
            <button class="tab" data-tab="vaccination">Vaccination</button>
        </div>

        <div class="stats-grid" id="casesStats">
            <div class="stat-card">
                <h3>Total Cases</h3>
                <div class="number cases" id="totalCases">-</div>
            </div>
            <div class="stat-card">
                <h3>Today's Cases</h3>
                <div class="number cases" id="todayCases">-</div>
            </div>
            <div class="stat-card">
                <h3>Recovered</h3>
                <div class="number recovered" id="recovered">-</div>
            </div>
            <div class="stat-card">
                <h3>Active Cases</h3>
                <div class="number active" id="active">-</div>
            </div>
            <div class="stat-card">
                <h3>Deaths</h3>
                <div class="number deaths" id="deaths">-</div>
            </div>
        </div>

        <div class="stats-grid" id="vaccinationStats" style="display: none;">
            <div class="stat-card">
                <h3>Total Vaccinations</h3>
                <div class="number vaccinated" id="totalVaccinations">-</div>
            </div>
            <div class="stat-card">
                <h3>People Vaccinated</h3>
                <div class="number vaccinated" id="peopleVaccinated">-</div>
            </div>
            <div class="stat-card">
                <h3>People Fully Vaccinated</h3>
                <div class="number vaccinated" id="peopleFullyVaccinated">-</div>
            </div>
        </div>

        <div class="chart-container">
            <canvas id="casesChart"></canvas>
        </div>

        <div class="feedback-form">
            <h3>Report Misinformation or Send Feedback</h3>
            <input type="text" id="feedbackTitle" placeholder="Title">
            <textarea id="feedbackContent" placeholder="Describe the issue..." rows="4"></textarea>
            <button onclick="submitFeedback()">Submit</button>
        </div>

        <div class="last-updated" id="lastUpdated"></div>
    </div>

    <script>
        let chart;
        let currentCountry = 'all';

        // Theme Toggle
        const themeToggle = document.getElementById('themeToggle');
        themeToggle.addEventListener('click', () => {
            const html = document.documentElement;
            const currentTheme = html.getAttribute('data-theme');
            const newTheme = currentTheme === 'light' ? 'dark' : 'light';
            html.setAttribute('data-theme', newTheme);
            localStorage.setItem('theme', newTheme);
        });

        // Load saved theme
        const savedTheme = localStorage.getItem('theme') || 'light';
        document.documentElement.setAttribute('data-theme', savedTheme);

        // Tab switching
        document.querySelectorAll('.tab').forEach(tab => {
            tab.addEventListener('click', () => {
                document.querySelectorAll('.tab').forEach(t => t.classList.remove('active'));
                tab.classList.add('active');
                
                const tabName = tab.dataset.tab;
                document.getElementById('casesStats').style.display = tabName === 'cases' ? 'grid' : 'none';
                document.getElementById('vaccinationStats').style.display = tabName === 'vaccination' ? 'grid' : 'none';
            });
        });

        // Search functionality
        const searchInput = document.getElementById('searchInput');
        const searchResults = document.getElementById('searchResults');
        let countries = [];

        searchInput.addEventListener('input', async (e) => {
            const searchTerm = e.target.value.toLowerCase();
            if (searchTerm.length < 2) {
                searchResults.style.display = 'none';
                return;
            }

            const filteredCountries = countries.filter(country => 
                country.country.toLowerCase().includes(searchTerm)
            );

            searchResults.innerHTML = '';
            filteredCountries.forEach(country => {
                const div = document.createElement('div');
                div.className = 'search-result-item';
                div.textContent = country.country;
                div.addEventListener('click', () => {
                    currentCountry = country.country;
                    fetchData(country.country);
                    searchResults.style.display = 'none';
                    searchInput.value = country.country;
                });
                searchResults.appendChild(div);
            });
            searchResults.style.display = 'block';
        });

        // Close search results when clicking outside
        document.addEventListener('click', (e) => {
            if (!searchResults.contains(e.target) && e.target !== searchInput) {
                searchResults.style.display = 'none';
            }
        });

        async function fetchCountries() {
            try {
                const response = await fetch('https://disease.sh/v3/covid-19/countries');
                countries = await response.json();
            } catch (error) {
                console.error('Error fetching countries:', error);
                showNotification('Error fetching countries data', 'error');
            }
        }

        async function fetchData(country = 'all') {
            try {
                const url = country === 'all' 
                    ? 'https://disease.sh/v3/covid-19/all'
                    : `https://disease.sh/v3/covid-19/countries/${country}`;
                
                const vaccineUrl = country === 'all'
                    ? 'https://disease.sh/v3/covid-19/vaccine/coverage?lastdays=1'
                    : `https://disease.sh/v3/covid-19/vaccine/coverage/countries/${country}?lastdays=1`;

                const [dataResponse, vaccineResponse] = await Promise.all([
                    fetch(url),
                    fetch(vaccineUrl)
                ]);

                const data = await dataResponse.json();
                const vaccineData = await vaccineResponse.json();

                updateDashboard(data);
                updateVaccinationData(vaccineData);
                await fetchHistoricalData(country);
                showNotification('Data updated successfully', 'success');
            } catch (error) {
                console.error('Error fetching data:', error);
                showNotification('Error fetching data', 'error');
            }
        }

        function updateVaccinationData(data) {
            // Update vaccination stats here based on the API response
            document.getElementById('totalVaccinations').textContent = numberWithCommas(data.total || 0);
            document.getElementById('peopleVaccinated').textContent = numberWithCommas(data.people || 0);
            document.getElementById('peopleFullyVaccinated').textContent = numberWithCommas(data.completed || 0);
        }

        function showNotification(message, type) {
            const notificationBar = document.getElementById('notificationBar');
            notificationBar.textContent = message;
            notificationBar.style.display = 'block';
            notificationBar.style.backgroundColor = type === 'error' ? '#f44336' : '#4CAF50';
            notificationBar.style.color = 'white';

            setTimeout(() => {
                notificationBar.style.display = 'none';
            }, 3000);
        }

        function submitFeedback() {
            const title = document.getElementById('feedbackTitle').value;
            const content = document.getElementById('feedbackContent').value;
            
            if (!title || !content) {
                showNotification('Please fill in all fields', 'error');
                return;
            }

            // Here you would typically send this to a server
            showNotification('Feedback submitted successfully', 'success');
            document.getElementById('feedbackTitle').value = '';
            document.getElementById('feedbackContent').value = '';
        }

        // Initialize
        fetchCountries();
        fetchData();

        // Auto refresh every 5 minutes
        setInterval(() => {
            fetchData(currentCountry);
        }, 300000);

        // Keep the existing functions from the previous code
        // (updateDashboard, updateChart, numberWithCommas, etc.)
    </script>
</body>
</html>
design more attractive background Covid logo add maps and most advanced feature AI