<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Morsalin Browser</title>
    <style>
        body {
            font-family: Arial, sans-serif;
            margin: 0;
            padding: 20px;
            background-color: #f0f0f0;
            color: #333;
            transition: background-color 0.3s, color 0.3s;
        }
        .dark-mode {
            background-color: #333;
            color: #f0f0f0;
        }
        h1 {
            text-align: center;
            font-family: 'Courier New', Courier, monospace; /* Stylish font */
            font-size: 2.5em;
            margin-bottom: 20px;
        }
        form {
            display: flex;
            flex-direction: column;
            align-items: center;
            margin-bottom: 20px;
        }
        .input-group {
            display: flex;
            align-items: center;
            margin-bottom: 10px;
        }
        input[type="text"] {
            width: 100%;
            max-width: 300px;
            padding: 10px;
            border: 1px solid #ccc;
            border-radius: 5px;
            margin-right: 10px; /* Space between input and button */
        }
        input[type="submit"], button {
            padding: 10px 15px;
            border: none;
            border-radius: 5px;
            cursor: pointer;
            background-color: #007bff;
            color: white;
            transition: background-color 0.3s;
        }
        input[type="submit"]:hover, button:hover {
            background-color: #0056b3;
        }
        .iframe-container {
            position: relative;
            width: 100%;
            height: 500px;
            border: 1px solid #ccc;
            border-radius: 5px;
            overflow: hidden;
        }
        .iframe-container iframe {
            width: 100%;
            height: 100%;
            border: none;
        }
        @media (max-width: 600px) {
            input[type="text"] {
                width: 90%;
            }
        }
        .button-row {
            display: flex;
            justify-content: center;
            gap: 10px; /* Space between buttons */
        }
        footer {
            text-align: center;
            margin-top: 20px;
            font-size: 0.9em;
            color: #666;
        }
    </style>
</head>
<body>

    <h1>Morsalin Browser</h1>
    <form id="urlForm" class="desktop-view">
        <div class="input-group">
            <input type="text" id="urlInput" placeholder="Enter URL" required>
            <input type="submit" value="Open URL">
        </div>
        <div class="button-row">
            <button type="button" id="refreshButton">Refresh</button>
            <button type="button" id="toggleDarkMode">Toggle Dark Mode</button>
            <button type="button" id="toggleView">Switch to Mobile View</button>
        </div>
    </form>

    <div class="iframe-container">
        <iframe id="urlIframe" src="" title="Iframe Viewer"></iframe>
    </div>

    <footer>
        © Morsalin
    </footer>

    <script>
        const form = document.getElementById('urlForm');
        const urlInput = document.getElementById('urlInput');
        const urlIframe = document.getElementById('urlIframe');
        const toggleDarkMode = document.getElementById('toggleDarkMode');
        const refreshButton = document.getElementById('refreshButton');
        const toggleView = document.getElementById('toggleView');
        const body = document.body;

        let isMobileView = false;

        form.addEventListener('submit', function(event) {
            event.preventDefault();
            const url = urlInput.value;
            // Ensure the URL starts with http or https
            if (!/^https?:\/\//i.test(url)) {
                alert('Please enter a valid URL starting with http:// or https://');
                return;
            }
            urlIframe.src = url; // Set the iframe source to the entered URL
        });

        refreshButton.addEventListener('click', function() {
            urlIframe.src = urlIframe.src; // Refresh the iframe
        });

        toggleDarkMode.addEventListener('click', function() {
            body.classList.toggle('dark-mode');
        });

        toggleView.addEventListener('click', function() {
            isMobileView = !isMobileView;
            if (isMobileView) {
                form.classList.remove('desktop-view');
                form.classList.add('mobile-view');
                toggleView.textContent = 'Switch to Desktop View';
            } else {
                form.classList.remove('mobile-view');
                form.classList.add('desktop-view');
                toggleView.textContent = 'Switch to Mobile View';
            }
        });
    </script>

</body>
</html>