<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Pasta dos vídeos</title>
    <style>
        body {
            margin: 0;
            padding: 0;
            height: 100vh;
            width: 100vw;
            background: #222;
            display: flex;
            justify-content: center;
            align-items: center;
            position: relative;
            overflow: hidden;
            font-family: Arial, Helvetica, sans-serif;
        }
        body::before {
            content: "";
            position: absolute;
            top: 0; left: 0; right: 0; bottom: 0;
            z-index: 0;
            background: url('/background/{{bg_img}}') center center no-repeat fixed;
            background-size: cover;
            filter: blur(32px) brightness(0.5) saturate(1.7);
        }
        #setupbox {
            background: rgba(0,0,0,0.7);
            padding: 40px 30px;
            border-radius: 20px;
            text-align: center;
            box-shadow: 0 0 20px #55075c;
            z-index: 1;
            position: relative;
        }
        input[type="text"] {
            font-size: 1.3em;
            padding: 10px;
            border-radius: 8px;
            border: 1px solid #888;
            width: 350px;
            margin-bottom: 18px;
        }
        button {
            font-size: 1.2em;
            padding: 10px 30px;
            border-radius: 8px;
            background: #55075c;
            color: #fff;
            border: none;
            cursor: pointer;
        }
        #video-dir-status {
            color: #fff;
            margin-top: 12px;
        }
    </style>
</head>
<body>
    <div id="setupbox">
        <h2 style="color:#fff;">Configure a pasta dos vídeos</h2>
        <form id="video-dir-form">
            <input type="text" id="video-dir-input" name="video_dir" placeholder="Digite o caminho completo" required>
            <br>
            <button type="submit">Salvar pasta</button>
        </form>
        <div id="video-dir-status"></div>
    </div>
    <script>
      document.getElementById('video-dir-form').onsubmit = async function(e) {
        e.preventDefault();
        const dir = document.getElementById('video-dir-input').value;
        const res = await fetch('/setup_video_dir', {
          method: 'POST',
          headers: {'Content-Type': 'application/x-www-form-urlencoded'},
          body: 'video_dir=' + encodeURIComponent(dir)
        });
        const data = await res.json();
        if (data.status === 'success') {
          window.location.href = '/';
        } else {
          document.getElementById('video-dir-status').textContent = 'Error: ' + data.message;
        }
      };
    </script>
</body>
</html>
