<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>S3 Cloud Uploader</title>
    <!-- Modern Google Font -->
    <link rel="preconnect" href="https://fonts.googleapis.com">
    <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
    <link href="https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;600;700&display=swap" rel="stylesheet">
    <style>
        :root {
            --bg-gradient: linear-gradient(135deg, #0f172a 0%, #1e1b4b 50%, #311042 100%);
            --card-bg: rgba(30, 41, 59, 0.4);
            --card-border: rgba(255, 255, 255, 0.08);
            --text-primary: #f8fafc;
            --text-secondary: #94a3b8;
            --accent: #a855f7;
            --accent-hover: #c084fc;
            --accent-glow: rgba(168, 85, 247, 0.4);
            --success: #10b981;
            --error: #ef4444;
        }

        * {
            box-sizing: border-box;
            margin: 0;
            padding: 0;
        }

        body {
            font-family: 'Outfit', sans-serif;
            background: var(--bg-gradient);
            color: var(--text-primary);
            min-height: 100vh;
            display: flex;
            align-items: center;
            justify-content: center;
            padding: 20px;
            overflow-x: hidden;
        }

        /* Beautiful glowing background blobs */
        .blob {
            position: absolute;
            width: 500px;
            height: 500px;
            border-radius: 50%;
            background: radial-gradient(circle, var(--accent-glow) 0%, rgba(0,0,0,0) 70%);
            z-index: 0;
            pointer-events: none;
            filter: blur(40px);
            animation: float 20s infinite alternate;
        }

        .blob-1 {
            top: -10%;
            left: -10%;
        }

        .blob-2 {
            bottom: -10%;
            right: -10%;
            animation-delay: -10s;
        }

        @keyframes float {
            0% { transform: translate(0, 0) scale(1); }
            100% { transform: translate(50px, 50px) scale(1.1); }
        }

        .container {
            position: relative;
            z-index: 1;
            width: 100%;
            max-width: 540px;
        }

        .card {
            background: var(--card-bg);
            backdrop-filter: blur(16px);
            -webkit-backdrop-filter: blur(16px);
            border: 1px solid var(--card-border);
            border-radius: 24px;
            padding: 40px;
            box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
            transition: transform 0.3s ease, box-shadow 0.3s ease;
        }

        .card:hover {
            transform: translateY(-2px);
            box-shadow: 0 30px 60px -15px rgba(168, 85, 247, 0.15);
        }

        .header {
            text-align: center;
            margin-bottom: 30px;
        }

        .header h1 {
            font-size: 2.2rem;
            font-weight: 700;
            background: linear-gradient(to right, #f8fafc, #c084fc);
            -webkit-background-clip: text;
            -webkit-text-fill-color: transparent;
            margin-bottom: 8px;
        }

        .header p {
            color: var(--text-secondary);
            font-size: 0.95rem;
        }

        /* Upload area styling */
        .dropzone {
            border: 2px dashed rgba(168, 85, 247, 0.3);
            border-radius: 16px;
            padding: 40px 20px;
            text-align: center;
            background: rgba(168, 85, 247, 0.02);
            cursor: pointer;
            transition: all 0.3s ease;
            position: relative;
            margin-bottom: 24px;
        }

        .dropzone:hover {
            border-color: var(--accent);
            background: rgba(168, 85, 247, 0.05);
            box-shadow: 0 0 15px rgba(168, 85, 247, 0.1);
        }

        .dropzone input[type="file"] {
            position: absolute;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            opacity: 0;
            cursor: pointer;
        }

        .upload-icon {
            font-size: 3rem;
            color: var(--accent);
            margin-bottom: 12px;
            transition: transform 0.3s ease;
        }

        .dropzone:hover .upload-icon {
            transform: translateY(-5px);
        }

        .file-name-display {
            margin-top: 10px;
            font-size: 0.9rem;
            color: var(--accent-hover);
            font-weight: 600;
            word-break: break-all;
        }

        .submit-btn {
            width: 100%;
            background: linear-gradient(135deg, var(--accent) 0%, #7c3aed 100%);
            border: none;
            border-radius: 12px;
            color: white;
            padding: 14px 28px;
            font-size: 1rem;
            font-weight: 600;
            cursor: pointer;
            transition: all 0.3s ease;
            box-shadow: 0 4px 12px rgba(168, 85, 247, 0.3);
        }

        .submit-btn:hover {
            background: linear-gradient(135deg, var(--accent-hover) 0%, #8b5cf6 100%);
            box-shadow: 0 6px 20px var(--accent-glow);
            transform: translateY(-1px);
        }

        .submit-btn:active {
            transform: translateY(1px);
        }

        /* Message Boxes */
        .alert {
            border-radius: 12px;
            padding: 16px;
            margin-bottom: 24px;
            font-size: 0.95rem;
            line-height: 1.5;
            animation: fadeIn 0.4s ease-out;
        }

        .alert-success {
            background: rgba(16, 185, 129, 0.1);
            border: 1px solid rgba(16, 185, 129, 0.2);
            color: #a7f3d0;
        }

        .alert-danger {
            background: rgba(239, 68, 68, 0.1);
            border: 1px solid rgba(239, 68, 68, 0.2);
            color: #fca5a5;
        }

        @keyframes fadeIn {
            from { opacity: 0; transform: translateY(-10px); }
            to { opacity: 1; transform: translateY(0); }
        }

        /* Result details section */
        .result-details {
            margin-top: 15px;
            padding-top: 15px;
            border-top: 1px solid rgba(255, 255, 255, 0.1);
            text-align: left;
        }

        .result-item {
            margin-bottom: 10px;
        }

        .result-label {
            font-size: 0.8rem;
            color: var(--text-secondary);
            text-transform: uppercase;
            letter-spacing: 0.05em;
            margin-bottom: 4px;
        }

        .result-value {
            font-size: 0.9rem;
            color: var(--text-primary);
            background: rgba(0, 0, 0, 0.2);
            padding: 8px 12px;
            border-radius: 6px;
            word-break: break-all;
            font-family: monospace;
            display: flex;
            justify-content: space-between;
            align-items: center;
        }

        .link-icon {
            color: var(--accent-hover);
            text-decoration: none;
            margin-left: 10px;
            font-weight: bold;
        }

        .link-icon:hover {
            text-decoration: underline;
        }
    </style>
</head>
<body>
    <div class="blob blob-1"></div>
    <div class="blob blob-2"></div>

    <div class="container">
        <div class="card">
            <div class="header">
                <h1>S3 Cloud Uploader</h1>
                <p>Securely upload your files directly to Amazon S3</p>
            </div>

            <!-- Success Alert -->
            @if(session('success'))
                <div class="alert alert-success">
                    <strong>Success!</strong> {{ session('success') }}
                    <div class="result-details">
                        <div class="result-item">
                            <div class="result-label">S3 Path</div>
                            <div class="result-value">{{ session('file_path') }}</div>
                        </div>
                        <div class="result-item">
                            <div class="result-label">Access URL</div>
                            <div class="result-value">
                                <span style="overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 320px;">{{ session('file_url') }}</span>
                                <a href="{{ session('file_url') }}" target="_blank" class="link-icon">Open Link &nearr;</a>
                            </div>
                        </div>
                    </div>
                </div>
            @endif

            <!-- Error Alerts -->
            @if($errors->any())
                <div class="alert alert-danger">
                    <strong>Error!</strong>
                    <ul style="list-style: none; margin-top: 5px;">
                        @foreach ($errors->all() as $error)
                            <li>{{ $error }}</li>
                        @endforeach
                    </ul>
                </div>
            @endif

            <!-- Form -->
            <form action="{{ route('upload.submit') }}" method="POST" enctype="multipart/form-data">
                @csrf
                <div class="dropzone" id="dropzone">
                    <div class="upload-icon">&#8682;</div>
                    <p style="font-weight: 600; margin-bottom: 4px;">Choose a file or drag it here</p>
                    <p style="font-size: 0.8rem; color: var(--text-secondary);">Supports files up to 10MB</p>
                    <div class="file-name-display" id="file-name">No file selected</div>
                    <input type="file" name="file" id="file-input" required>
                </div>

                <button type="submit" class="submit-btn">Upload to S3</button>
            </form>
        </div>
    </div>

    <script>
        const fileInput = document.getElementById('file-input');
        const fileNameDisplay = document.getElementById('file-name');
        const dropzone = document.getElementById('dropzone');

        fileInput.addEventListener('change', (e) => {
            if (e.target.files.length > 0) {
                fileNameDisplay.textContent = e.target.files[0].name;
            } else {
                fileNameDisplay.textContent = 'No file selected';
            }
        });

        // Simple visual feedback for drag and drop
        ['dragenter', 'dragover'].forEach(eventName => {
            dropzone.addEventListener(eventName, () => {
                dropzone.style.borderColor = 'var(--accent)';
                dropzone.style.background = 'rgba(168, 85, 247, 0.05)';
            }, false);
        });

        ['dragleave', 'drop'].forEach(eventName => {
            dropzone.addEventListener(eventName, () => {
                dropzone.style.borderColor = 'rgba(168, 85, 247, 0.3)';
                dropzone.style.background = 'rgba(168, 85, 247, 0.02)';
            }, false);
        });
    </script>
</body>
</html>
