<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8"/>
    <meta name="viewport" content="width=device-width, initial-scale=1.0"/>
    <title>PiSoft</title>
    <!-- <link rel="icon" th:href="@{/images/images/small.png}" type="image/x-icon"> -->
    <link rel="icon" href="/images/images/pi-icon.png" type="image/x-icon">
    <style>
        /* ── LIGHT (default) ── */
        :root {
            --bg: #f8fafc; 
            --surface: #ffffff; 
            --surface2: #f1f5f9;
            --primary: #2563eb; 
            --primary-hover: #1d4ed8;
            --text-main: #0f172a; 
            --text-muted: #64748b; 
            --border: #e2e8f0;
            --danger: #ef4444;
            --shadow: 0 10px 15px -3px rgba(0,0,0,0.05), 0 4px 6px -4px rgba(0,0,0,0.05);
            --ta-header-bg: #f8fafc;
        }

        /* ── DARK ── */
        html.dark {
            --bg: #0f172a; 
            --surface: #1e293b; 
            --surface2: #334155;
            --primary: #3b82f6; 
            --primary-hover: #60a5fa;
            --text-main: #f8fafc; 
            --text-muted: #94a3b8; 
            --border: #334155;
            --danger: #f87171;
            --shadow: 0 10px 15px -3px rgba(0,0,0,0.3);
            --ta-header-bg: #1e293b;
        }

        *, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
        html { scroll-behavior: smooth; transition: background 0.3s; }

        body {
            font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
            background: var(--bg);
            color: var(--text-main);
            min-height: 100vh;
            display: flex;
            justify-content: center;
            align-items: flex-start;
            padding: 24px 16px 40px;
            line-height: 1.5;
            transition: background 0.3s, color 0.3s;
        }

        .container { 
            width: 100%; 
            max-width: 680px; 
            display: flex; 
            flex-direction: column; 
            gap: 1rem; 
        }

        /* ── TOP BAR ── */
        .top-bar {
            background: var(--surface);
            border: 1px solid var(--border);
            border-radius: 12px;
            padding: 1rem 1.25rem;
            display: flex;
            align-items: center;
            justify-content: space-between;
            gap: 1rem;
            box-shadow: var(--shadow);
            transition: background 0.3s, border-color 0.3s, box-shadow 0.3s;
        }

        .top-bar-left { display: flex; align-items: center; gap: 0.75rem; flex-wrap: wrap; min-width: 0; }

        .brand-dot {
            width: 10px; height: 10px; background: var(--primary); border-radius: 50%; flex-shrink: 0;
            box-shadow: 0 0 8px var(--primary);
        }

        .top-bar h2 {
            font-size: 1rem;
            font-weight: 600;
            color: var(--text-main);
        }
        .top-bar h2 span { color: var(--primary); }

        .expiry-notice {
            display: inline-flex; align-items: center; gap: 0.4rem;
            margin-top: 0.4rem;
            font-size: 0.75rem;
            color: var(--danger);
            background: rgba(239, 68, 68, 0.1); 
            border: 1px solid rgba(239, 68, 68, 0.2);
            border-radius: 9999px; 
            padding: 0.2rem 0.6rem;
            font-weight: 500;
        }

        /* ── THEME TOGGLE ── */
        .theme-toggle {
            flex-shrink: 0;
            display: flex;
            align-items: center;
            background: var(--surface2);
            border: 1px solid var(--border);
            border-radius: 9999px;
            padding: 3px;
            gap: 2px;
        }
        .theme-toggle button {
            display: flex; align-items: center; gap: 4px;
            padding: 4px 10px;
            font-size: 0.75rem; 
            font-weight: 600; 
            border: none; 
            border-radius: 9999px; 
            cursor: pointer;
            transition: background 0.2s, color 0.2s;
            background: transparent;
            color: var(--text-muted);
        }
        .theme-toggle button.active {
            background: var(--surface);
            color: var(--text-main);
            box-shadow: 0 1px 3px rgba(0,0,0,0.1);
        }

        /* ── CARD ── */
        .card {
            background: var(--surface); 
            border: 1px solid var(--border);
            border-radius: 16px; 
            padding: 1.5rem;
            display: flex; 
            flex-direction: column; 
            gap: 1.25rem;
            box-shadow: var(--shadow);
            transition: background 0.3s, border-color 0.3s;
        }

        /* ── SELECT ── */
        .select-wrap { position: relative; }
        .select-wrap::after {
            content: '▾'; 
            position: absolute; 
            right: 14px; 
            top: 50%; 
            transform: translateY(-50%);
            color: var(--text-muted); 
            pointer-events: none; 
            font-size: 0.85rem;
        }
        select {
            width: 100%; 
            padding: 10px 36px 10px 14px;
            font-size: 0.875rem; 
            font-weight: 500;
            color: var(--text-main); 
            background: var(--surface2);
            border: 1px solid var(--border); 
            border-radius: 8px;
            outline: none; 
            appearance: none; 
            cursor: pointer;
            transition: border-color 0.2s, background 0.3s, color 0.3s;
        }
        select:focus { border-color: var(--primary); }

        /* ── LINK BTN ── */
        .link-btn {
            display: inline-flex; 
            align-items: center; 
            gap: 0.5rem;
            padding: 8px 14px;
            background: rgba(37, 99, 235, 0.1); 
            color: var(--primary);
            border: 1px solid rgba(37, 99, 235, 0.2); 
            border-radius: 6px;
            font-size: 0.85rem; 
            font-weight: 600;
            text-decoration: none; 
            align-self: flex-start;
            transition: background 0.2s, color 0.2s;
        }
        .link-btn:hover { background: var(--primary); color: #ffffff; }

        /* ── TEXTAREA ── */
        .textarea-wrap { position: relative; }
        textarea {
            width: 100%; 
            height: 280px; 
            padding: 14px; 
            padding-top: 48px;
            font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
            font-size: 0.875rem; 
            line-height: 1.6;
            color: var(--text-main); 
            background: var(--surface2);
            border: 1px solid var(--border); 
            border-radius: 12px;
            resize: vertical; 
            outline: none;
            transition: border-color 0.2s, background 0.3s, color 0.3s;
        }
        textarea::placeholder { color: var(--text-muted); }
        textarea:focus { border-color: var(--primary); }

        .textarea-header {
            position: absolute; 
            top: 0; 
            left: 0; 
            right: 0;
            padding: 8px 14px;
            display: flex; 
            align-items: center; 
            justify-content: space-between;
            border-bottom: 1px solid var(--border);
            background: var(--ta-header-bg);
            border-radius: 12px 12px 0 0;
            pointer-events: none;
        }
        .textarea-dots { display: flex; gap: 6px; }
        .textarea-dots span { width: 10px; height: 10px; border-radius: 50%; }
        .dot-r { background: #ef4444; } .dot-y { background: #f59e0b; } .dot-g { background: #10b981; }

        #copyButton {
            pointer-events: all;
            padding: 4px 10px;
            font-size: 0.75rem; 
            font-weight: 600;
            color: var(--text-main); 
            background: var(--surface);
            border: 1px solid var(--border); 
            border-radius: 6px; 
            cursor: pointer;
            transition: background 0.2s, color 0.2s;
        }
        #copyButton:hover { background: var(--primary); color: #ffffff; border-color: var(--primary); }

        .meta-bar { display: flex; align-items: center; padding: 0 2px; }
        .word-count { font-size: 0.75rem; color: var(--text-muted); }

        .submit-btn {
            width: 100%; 
            padding: 12px;
            background: var(--primary); 
            color: #ffffff;
            border: none; 
            border-radius: 8px;
            font-size: 0.95rem; 
            font-weight: 600;
            cursor: pointer;
            transition: background 0.2s ease;
        }
        .submit-btn:hover { background: var(--primary-hover); }

        /* ── RESPONSIVE ── */
        @media (max-width: 600px) {
            body { padding: 16px 10px 24px; }
            .card { padding: 1.25rem 1rem; }
            textarea { height: 220px; }
            .top-bar { flex-direction: column; align-items: flex-start; gap: 0.75rem; }
            .theme-toggle { align-self: flex-end; }
        }
    </style>
    <script>
        function setTheme(mode) {
            const html = document.documentElement;
            if (mode === 'dark') { html.classList.add('dark'); }
            else { html.classList.remove('dark'); }
            localStorage.setItem('pisoft-theme', mode);
            document.getElementById('btn-dark').classList.toggle('active', mode === 'dark');
            document.getElementById('btn-light').classList.toggle('active', mode === 'light');
            document.querySelectorAll('select option').forEach(o => {
                o.style.background = mode === 'dark' ? '#1e293b' : '#ffffff';
                o.style.color = mode === 'dark' ? '#f8fafc' : '#0f172a';
            });
        }

        function copyToClipboard() {
            var ta = document.getElementById("contentTextarea");
            ta.select();
            document.execCommand("copy");
            var btn = document.getElementById("copyButton");
            btn.innerText = "Copied!";
            setTimeout(function () {
                btn.innerText = "Copy";
            }, 2000);
        }

        function updateWordCount() {
            var ta = document.getElementById("contentTextarea");
            var words = ta.value.trim().split(/\s+/);
            var wc = ta.value.length > 0 ? words.length : 0;
            document.getElementById("wordCount").innerText = "Words: " + wc + "  ·  Chars: " + ta.value.length;
        }

        window.onload = function () {
            var saved = localStorage.getItem('pisoft-theme') || 'light';
            setTheme(saved);
            updateWordCount();
        };
    </script>
</head>
<body>
<div class="container">

    <!-- TOP BAR -->
    <div class="top-bar">
        <div class="top-bar-left">
            <div class="brand-dot"></div>
            <div>
                <h2><span>PiSoft</span> — Share Instantly</h2>
                
            </div>
        </div>

        <!-- THEME TOGGLE -->
        <div class="theme-toggle">
            <button id="btn-light" class="active" onclick="setTheme('light')">☀️ Light</button>
            <button id="btn-dark" onclick="setTheme('dark')">🌙 Dark</button>
        </div>
    </div>

    <!-- MAIN FORM CARD -->
    <form action="/sitemap.xml" method="POST">
        <div class="card">

            <!-- EXPIRY SELECT -->
            <div class="select-wrap">
                <select name="expiryTime" required>
                    <option value="1">Destroy PiSoft link in 1 minute</option>
                    <option value="10">Destroy PiSoft link in 10 minutes</option>
                    <option value="60">Destroy PiSoft link in 1 Hour</option>
                    <option value="1550">Destroy PiSoft link in 1 Day</option>
                    <option value="10080">Destroy PiSoft link in 1 Week</option>
                    <option value="43800">Destroy PiSoft link in 1 Month</option>
                </select>
            </div>

            <!-- DETECTED LINK BUTTON -->
            

            <!-- TEXTAREA -->
            <div class="textarea-wrap">
                <div class="textarea-header">
                    <div class="textarea-dots">
                        <span class="dot-r"></span>
                        <span class="dot-y"></span>
                        <span class="dot-g"></span>
                    </div>
                    
                </div>
                <textarea
                    placeholder="Paste in anything you want..."
                    name="content"
                    id="contentTextarea"
                    oninput="updateWordCount()"
                ></textarea>
            </div>

            <div class="meta-bar">
                <div id="wordCount" class="word-count">Words: 0  ·  Chars: 0</div>
            </div>

            <!-- SUBMIT -->
            <button type="submit" class="submit-btn">Create PiSoft Link</button>

        </div>
    </form>

</div>
</body>
</html>