<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Results</title>
    <link rel="icon" type="image/x-icon" href="../static/images/flavicon.png">
    <style>
        body {
            font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
            display: flex;
            justify-content: center;
            background-color: #f8f9fa;
            align-items: center;
            margin: 0;
            padding: 20px;
            flex-direction: column;
        }
        .container {
            background-color: #fff;
            padding: 20px;
            border-radius: 8px;
            box-shadow: 0 2px 10px rgba(0,0,0,0.1);
            text-align: center;
            max-width: 800px;
            width: 100%;
            position: relative;
        }
        .header {
            width: 100%;
            display: flex;
            justify-content: space-between;
            align-items: center;
            margin-bottom: 20px;
        }
        .logo {
            max-height: 60px;
        }
        h1 {
            margin-bottom: 20px;
            font-size: 24px;
            color: #333;
        }
        .error-message {
            color: red;
            margin-bottom: 20px;
            white-space: pre-wrap;
        }
        table {
            width: 100%;
            border-collapse: collapse;
            margin-bottom: 20px;
        }
        table, th, td {
            border: 1px solid #ddd;
        }
        th, td {
            padding: 8px;
            text-align: left;
        }
        th {
            background-color: #f2f2f2;
        }
        .btn {
            background-color: #007bff;
            color: #fff;
            border: none;
            padding: 10px 20px;
            border-radius: 4px;
            cursor: pointer;
            transition: background-color 0.3s;
            margin: 10px 0;
        }
        .btn:hover {
            background-color: #0056b3;
        }
        .btn-link {
            text-decoration: none;
        }
        .loader {
            position: absolute;
            top: 50%;
            left: 50%;
            transform: translate(-50%, -50%);
            display: none;
        }
        .loader img {
            width: 100px;
            height: 100px;
            animation: fadeInOut 2s infinite;
        }
        @keyframes fadeInOut {
            0% { opacity: 0; }
            50% { opacity: 1; }
            100% { opacity: 0; }
        }
    </style>
</head>
<body>
    <div class="header">
        <img src="{{ url_for('static', filename='images/logo1.png') }}" alt="Logo 1" class="logo">
        <a href="https://3d.bk.tudelft.nl/"><img src="../static/images/logo2.png" alt="Logo 2" class="logo"></a>
    </div>
    <div class="container">

        {% if message %}
        <pre class="error-message">{{ message | safe }}</pre>
        {% endif %}
        <h1>IFCProjectedCRS Data</h1>
        {{ table_f | safe }}

        <h1>IFCMapConversion Data</h1>
        {{ table_g | safe }}

        <form method="POST" action="{{ url_for('visualize', filename=filename) }}" onsubmit="showLoader()">
            <input type="submit" value="Show on Map" class="btn">
        </form>

        {% if download_available %}
        <a href="{{ url_for('download', filename=filename) }}" download class="btn-link">
            <button class="btn">Download Georeferenced IFC</button>
        </a>
        {% endif %}
        
        <div class="loader" id="loader">
            <img src="{{ url_for('static', filename='images/loading.png') }}" alt="Loading...">
        </div>
    </div>

    <script>
        function showLoader() {
            document.getElementById('loader').style.display = 'block';
        }
    </script>
</body>
</html>
