<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Terabox Video Player</title>
    <link rel="icon" href="favicon.ico" type="image/x-icon">
    <style>
        /* Dark gradient background animation */
        body {
            font-family: Arial, sans-serif;
            margin: 0;
            padding: 0;
            background: linear-gradient(135deg, #0d1b2a, #1e3a5f, #121212);
            background-size: 400% 400%;
            animation: gradient 10s ease infinite;
            min-height: 100vh;
            display: flex;
            flex-direction: column;
            color: #fff;
        }

        @keyframes gradient {
            0% {
                background-position: 0% 50%;
            }

            50% {
                background-position: 100% 50%;
            }

            100% {
                background-position: 0% 50%;
            }
        }

        h1 {
            font-size: 2.5rem;
            margin-bottom: 20px;
            text-shadow: 0 0 10px rgba(0, 123, 255, 0.7);
            text-align: center;
        }

        /* Container styling */
        .container {
            width: 100%;
            max-width: 800px;
            padding: 20px;
            background-color: rgba(0, 0, 0, 0.8);
            border-radius: 12px;
            box-shadow: 0 0 20px rgba(0, 0, 0, 0.7);
            text-align: center;
            margin: 0 auto;
        }

        input[type="text"] {
            width: 80%;
            padding: 15px;
            margin-bottom: 20px;
            font-size: 1.2rem;
            border-radius: 8px;
            border: 2px solid #007bff;
            background-color: #121212;
            color: #fff;
            box-shadow: 0 0 10px rgba(0, 123, 255, 0.7);
            text-align: center;
            transition: all 0.3s ease;
        }

        input[type="text"]:focus {
            outline: none;
            border-color: #00aeff;
            box-shadow: 0 0 20px rgba(0, 123, 255, 1);
        }

        button {
            padding: 15px 30px;
            font-size: 1.2rem;
            background-color: #007bff;
            border: none;
            border-radius: 8px;
            color: white;
            cursor: pointer;
            box-shadow: 0 4px rgba(0, 123, 255, 0.7);
            transition: all 0.3s ease;
        }

        button:hover {
            background-color: #00aeff;
            box-shadow: 0 4px rgba(0, 123, 255, 1);
            transform: scale(1.05);
        }

        .video-container {
            margin-top: 20px;
            width: 100%;
            max-width: 800px;
            height: 450px;
            position: relative;
            display: none;
        }

        .video-container iframe {
            position: absolute;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            border: none;
            border-radius: 8px;
            box-shadow: 0 0 15px rgba(0, 0, 0, 0.7);
        }

        /* Footer styling */
        .footer {
            margin-top: auto;
            padding: 10px 0;
            text-align: center;
            width: 100%;
            background-color: rgba(0, 0, 0, 0.7);
            color: #888;
            font-size: 0.7rem; /* Reduced font size */
            position: fixed;
            bottom: 0;
            left: 0;
        }

        .footer a {
            color: #00aeff;
            text-decoration: none;
            font-weight: bold;
        }

        .footer a:hover {
            text-decoration: underline;
        }

        /* Logo at the top-right */
        .logo {
            position: absolute;
            top: 10px;
            right: 10px;
        }

        .logo img {
            width: 80px; /* Make the logo small */
            height: auto;
            border-radius: 4px;
            cursor: pointer;
        }

        @media (max-width: 768px) {
            h1 {
                font-size: 2rem;
            }

            input[type="text"] {
                font-size: 1rem;
            }

            button {
                font-size: 1rem;
                padding: 12px 24px;
            }

            .video-container {
                height: 300px;
            }

            .logo img {
                width: 60px; /* Adjust logo size for smaller screens */
            }
        }

        @media (max-width: 480px) {
            h1 {
                font-size: 1.8rem;
            }

            input[type="text"] {
                font-size: 0.9rem;
            }

            button {
                font-size: 0.9rem;
                padding: 10px 20px;
            }

            .video-container {
                height: 220px;
            }

            .logo img {
                width: 50px; /* Further reduce logo size for mobile screens */
            }
        }
    </style>
</head>

<body>

    <!-- Logo at the top-right corner -->
    <div class="logo">
        <a href="https://t.me/infoaimbot" target="_blank">
            <img src="https://iili.io/dLeY8ga.md.jpg" alt="Terabox Bot Logo">
        </a>
    </div>

    <h1>Terabox Video Player</h1>

    <div class="container">
        <input type="text" id="videoUrl" placeholder="Enter Terabox URL or text containing URL">
        <button onclick="playVideo()">Play Video</button>

        <!-- Video container where the API embedded video will be shown -->
        <div class="video-container" id="videoContainer"></div>
    </div>

    <!-- Footer with clickable link -->
    <div class="footer">
        Made by <a href="https://t.me/infoaimbot" target="_blank">Aimbotaxe</a>
    </div>

    <script>
        function extractLink(text) {
            // Regex pattern to extract URLs
            const urlPattern = /https?:\/\/[^\s]+/g;
            const urls = text.match(urlPattern);
            return urls ? urls[0] : null;
        }

        function playVideo() {
            const input = document.getElementById('videoUrl').value;
            const videoContainer = document.getElementById('videoContainer');

            // Extract the first valid link from the user's input
            const extractedUrl = extractLink(input);

            if (!extractedUrl) {
                alert('Please enter a valid Terabox URL.');
                return;
            }

            // Use the watch API to directly embed the video using the extracted URL
            const apiUrl = `https://terabox-watch.netlify.app/api2.html?url=${encodeURIComponent(extractedUrl)}`;

            // Set the iframe to embed the video from the watch API
            videoContainer.innerHTML = `<iframe src="${apiUrl}" allowfullscreen></iframe>`;
            videoContainer.style.display = 'block'; // Show the video container
        }
    </script>

</body>

</html>
