<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title th:text="#{error.page.title}">Error - Reitti</title>
    <link rel="icon" th:href="@{/img/logo.svg}">
    <link rel="apple-touch-icon" th:href="@{/img/logo.svg}">
    <link rel="shortcut icon" type="image/x-icon" th:href="@{/img/logo.svg}">
    <link rel="stylesheet" href="/css/main.css">
    <link rel="stylesheet" href="/css/lineicons.css">
    <style>
        .error-container {
            min-height: 100vh;
            display: flex;
            align-items: center;
            justify-content: center;
            background: var(--color-background-dark);
            padding: 2rem;
        }

        .error-content {
            background: var(--color-background-dark-light);
            border-radius: 12px;
            padding: 3rem;
            max-width: 600px;
            width: 100%;
            box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
            text-align: center;
            border: 1px solid var(--color-highlight);
        }

        .error-header h1 {
            color: var(--color-text-white);
            font-size: 2rem;
            margin: 1rem 0 0 0;
            font-weight: 600;
            font-family: "Fraunces", serif;
        }

        .error-code {
            font-size: 4rem;
            color: #ff6a5b;;
            margin-bottom: 1rem;
            font-family: "Fraunces", serif;
        }

        .error-message {
            font-size: 1.2rem;
            color: var(--color-text-white);
            margin-bottom: 1rem;
        }

        .error-description {
            color: var(--color-text-white);
            opacity: 0.8;
            margin-bottom: 2rem;
            font-size: 0.95rem;
        }

        .error-debug {
            margin: 2rem 0;
            text-align: left;
        }

        .error-actions {
            display: flex;
            gap: 1rem;
            justify-content: center;
            flex-wrap: wrap;
        }

        .error-actions .btn {
            display: inline-flex;
            align-items: center;
            gap: 0.5rem;
            padding: 0.75rem 1.5rem;
            border: 1px solid var(--color-highlight);
            border-radius: 6px;
            text-decoration: none;
            font-weight: 500;
            cursor: pointer;
            transition: all 0.2s ease;
            background-color: var(--color-background-dark);
            color: var(--color-text-white);
        }

        .error-actions .btn:hover {
            background-color: var(--color-highlight);
            color: var(--color-background-dark);
            transform: translateY(-1px);
        }

        @media (max-width: 768px) {
            .error-container {
                padding: 1rem;
            }

            .error-content {
                padding: 2rem;
            }

            .error-code {
                font-size: 3rem;
            }

            .error-actions {
                flex-direction: column;
            }

            .error-actions .btn {
                width: 100%;
                justify-content: center;
            }
        }
    </style>
</head>
<body>
<div class="error-container">
    <div class="error-content">
        <div class="error-header">
            <img class="logo" th:src="@{/img/logo.svg}" alt="reitti logo" title="reitti" src="/img/logo.svg">
            <h1 th:text="#{error.title}">Oops! Something went wrong</h1>
        </div>

        <div class="error-details">
            <div class="error-code">
                <span th:text="${status}" th:if="${status}">500</span>
                <span th:unless="${status}">Error</span>
            </div>

            <div class="error-message">
                <p th:text="${error}" th:if="${error}">Internal Server Error</p>
                <p th:unless="${error}" th:text="#{error.generic.message}">An unexpected error occurred. Please try
                    again later.</p>
            </div>

            <div class="error-description" th:if="${message}">
                <p th:text="${message}"></p>
            </div>

            <!-- Show additional details only in development -->
            <div class="error-debug" th:if="${trace}">
                <details>
                    <summary th:text="#{error.technical.details}">Technical Details</summary>
                    <pre th:text="${trace}"></pre>
                </details>
            </div>
        </div>

        <div class="error-actions">
            <div th:if="${status == 403}">
                <form action="/logout" method="post" style="display: inline;">
                    <button type="submit" class="btn" th:text="#{nav.logout}">
                        <i class="lni lni-exit"></i> Logout
                    </button>
                </form>
            </div>
            <div th:unless="${status == 403}">
                <a href="/" class="btn" th:text="#{error.action.home}">
                    <i class="lni lni-home"></i> Go Home
                </a>
            </div>
            <button onclick="history.back()" class="btn" th:text="#{error.action.back}">
                <i class="lni lni-arrow-left"></i> Go Back
            </button>
            <button onclick="location.reload()" class="btn" th:text="#{error.action.retry}">
                <i class="lni lni-reload"></i> Try Again
            </button>
        </div>
    </div>
</div>

</body>
</html>
