<!-- index.html -->
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>MTG Card CSV Generator</title>
    
    <!-- Stylesheets -->
    <link rel="stylesheet" href="css/base.css">
    <link rel="stylesheet" href="css/themes.css">
    <link rel="stylesheet" href="css/components.css">
    <link rel="manifest" href="manifest.json">
    <link href="https://fonts.googleapis.com/css2?family=Sorts+Mill+Goudy&display=swap" rel="stylesheet">
    <link rel="icon" href="assets/icon.png" type="image/png">
    <link href="https://cdn.jsdelivr.net/npm/mana-font@latest/css/mana.css" rel="stylesheet" type="text/css" />
</head>
<body>
    <div class="container">
        <div class="menu">
            <div class="hamburger-menu" id="hamburger-menu">☰</div>
            <div id="menu-content" class="menu-content">
                <label>Select Theme:</label>
                <div id="theme-selector">
                    <span class="mana-icon" data-theme="" onclick="setTheme('')">&#xe623;</span> <!-- Colorless -->
                    <span class="mana-icon" data-theme="theme-white" onclick="setTheme('theme-white')">&#xe600;</span> <!-- White -->
                    <span class="mana-icon" data-theme="theme-blue" onclick="setTheme('theme-blue')">&#xe601;</span> <!-- Blue -->
                    <span class="mana-icon" data-theme="theme-black" onclick="setTheme('theme-black')">&#xe602;</span> <!-- Black -->
                    <span class="mana-icon" data-theme="theme-red" onclick="setTheme('theme-red')">&#xe603;</span> <!-- Red -->
                    <span class="mana-icon" data-theme="theme-green" onclick="setTheme('theme-green')">&#xe604;</span> <!-- Green -->
                </div>
                <label for="sound-threshold">Sound Threshold (USD):</label>
                <input type="number" id="sound-threshold" min="0.01" step="0.01" value="1.00">
            </div>
        </div>

        <h1>MTG Card CSV Generator</h1>

        <form id="card-form">
            <div>
                <label for="card-name">Card Name:</label>
                <input type="text" id="card-name" autocomplete="off" required>
                <div id="suggestions"></div>
            </div>
            <div>
                <label for="set-code">Set Code:</label>
                <input type="text" id="set-code" required>
            </div>
            <div>
                <label for="card-id">Card ID:</label>
                <input type="text" id="card-id" required>
            </div>
            <div>
                <label for="quantity">Quantity:</label>
                <input type="number" id="quantity" min="1" value="1" required>
            </div>
            <div>
                <label for="foil">Is it Foil?</label>
                <select id="foil">
                    <option value="No">No</option>
                    <option value="Yes">Yes</option>
                </select>
            </div>
            <button type="button" id="add-card-button">Add Card</button>
        </form>

        <div class="action-buttons">
            <button id="download-csv-button">Download CSV</button>
            <button id="save-collection-button">Save Collection</button>
            <button id="clear-collection-button">Clear Collection</button>
        </div>

        <textarea id="csv-output" readonly></textarea>

        <div id="card-popup" class="card-popup">
            <img id="card-popup-image" src="" alt="Card Image">
        </div>

        <div id="zoom-modal" class="zoom-modal">
            <span id="close-modal" class="close-modal">&times;</span>
            <img id="zoomed-image" class="zoomed-image" src="" alt="">
        </div>
    </div>

    <footer>
        <p>
            <a href="https://github.com/cfultz/mtgcsv" target="_blank">View on GitHub.com</a> | 
            This app is not affiliated with Wizards of the Coast or Hasbro. All rights and trademarks are owned by their respective owners.
        </p>
    </footer>

    <!-- Scripts -->
    <script type="module" src="js/theme.js"></script>
    <script type="module" src="js/main.js"></script>
    <script type="module" src="js/card.js"></script>
    <script type="module" src="js/storage.js"></script>
    <script type="module" src="js/csv.js"></script>
    <script type="module" src="js/popup.js"></script>

    <script>
        if ('serviceWorker' in navigator) {
            navigator.serviceWorker.register('js/sw.js').then(function(registration) {
                console.log('Service Worker registered with scope:', registration.scope);
            }).catch(function(error) {
                console.error('Service Worker registration failed:', error);
            });
        }
    </script>
</body>
</html>