<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>{{.Title}} - FITRA - File transfer API</title>
    <link rel="stylesheet" href="/static/main.css">

    <script
            src="https://a.adhd.sh/api/script.js"
            data-site-id="8"
            defer
    ></script>
</head>
<body>
    {{block "content" .}}{{end}}

    <script>
        async function loadStorageInfo() {
            try {
                const response = await fetch('/storage');
                const data = await response.json();
                const storage = data.storage;
                
                document.getElementById('storage-used').textContent = `${storage.used_gb.toFixed(2)} GB used`;
                document.getElementById('storage-percent').textContent = `${storage.usage_percent.toFixed(1)}% full`;
                document.getElementById('storage-total').textContent = `${storage.max_gb} GB total`;
                document.getElementById('progress-fill').style.width = `${storage.usage_percent}%`;
            } catch (error) {
                document.getElementById('storage-used').textContent = 'Error loading storage info';
                document.getElementById('storage-percent').textContent = '';
                document.getElementById('storage-total').textContent = '';
            }
        }

        loadStorageInfo();

        function copyToClipboard(text) {
            navigator.clipboard.writeText(text).then(() => {
                const button = event.target;
                const originalText = button.innerHTML;
                button.innerHTML = '✅ Copied!';
                button.style.background = 'linear-gradient(135deg, #28a745, #20c997)';
                
                setTimeout(() => {
                    button.innerHTML = originalText;
                    button.style.background = 'linear-gradient(135deg, #667eea, #764ba2)';
                }, 2000);
            }).catch(() => {
                const button = event.target;
                const originalText = button.innerHTML;
                button.innerHTML = '❌ Failed';
                button.style.background = 'linear-gradient(135deg, #dc3545, #c82333)';
                
                setTimeout(() => {
                    button.innerHTML = originalText;
                    button.style.background = 'linear-gradient(135deg, #667eea, #764ba2)';
                }, 2000);
            });
        }
    </script>
</body>
</html>