<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@taglib uri="http://www.springframework.org/tags" prefix="spring"%>
<%@taglib uri="http://www.springframework.org/security/tags" prefix="sec" %>
<html>
<head>
    <title>Car Dealer Shop</title>
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha2/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-aFq/bzH65dt+w6FI2ooMVUpc+21e0SRygnTpmBvdBgSdnuTN7QbdgL+OapgHtvPp" crossorigin="anonymous">
    <style>
        body {
            padding-top: 60px; /* Adjust the top padding to account for the fixed navbar */
            background-image: url("https://example.com/image.jpghttps://i.postimg.cc/NMg5qPf5/showroom-blur.webp");
            background-size: cover;
            background-position: center;

        }
        .car-list-item {
            margin-bottom: 20px;
            border: 1px solid #ccc;
            padding: 10px;
            border-radius: 5px;
        }
        .car-image {
            max-width: 100%;
            height: auto;
        }
    </style>
</head>
<body>
<header data-bs-theme="dark">
    <nav class="navbar navbar-expand-md navbar-dark fixed-top bg-dark">
        <div class="container-fluid">
            <a class="navbar-brand" href="/">Car Dealer Shop</a>
            <button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarCollapse" aria-controls="navbarCollapse" aria-expanded="false" aria-label="Toggle navigation">
                <span class="navbar-toggler-icon"></span>
            </button>
            <div class="collapse navbar-collapse" id="navbarCollapse">
                <ul class="navbar-nav me-auto mb-2 mb-md-0">
                    <sec:authorize access="isAnonymous()">
                        <li class="nav-item">
                            <a class="nav-link" href="/login"><spring:message code="label.login"/></a>
                        </li>
                        <li class="nav-item">
                            <a class="nav-link" href="/register"><spring:message code="label.register"/></a>
                        </li>
                    </sec:authorize>
                    <sec:authorize access="hasAnyRole('ROLE_USER', 'ROLE_ADMIN')">
                        <li class="nav-item">
                            <a class="nav-link" href="/appCars"><spring:message code="label.addCar"/></a>
                        </li>
                    </sec:authorize>
                    <li class="nav-item">
                        <a class="nav-link" href="/appCarList"><spring:message code="label.carheader"/></a>
                    </li>
                    <sec:authorize access="hasRole('ROLE_ADMIN')">
                        <li class="nav-item">
                            <a class="nav-link" href="/appUsers"><spring:message code="label.addAppUser"/></a>
                        </li>
                        <li class="nav-item">
                            <a class="nav-link" href="appUserRole"><spring:message code="label.role"/></a>
                        </li>
                    </sec:authorize>
                    <sec:authorize access="hasRole('ROLE_USER')">
                        <li class="nav-item">
                            <a class="nav-link" href="/exampleOne"><spring:message code="label.example"/> 1</a>
                        </li>
                    </sec:authorize>
                    <sec:authorize access="hasRole('ROLE_STUDENT')">
                        <li class="nav-item">
                            <a class="nav-link" href="exampleThree"><spring:message code="label.example"/> 3</a>
                        </li>
                    </sec:authorize>
                </ul>
                <form class="d-flex" role="search">
                    <!-- Search bar removed -->
                </form>
                <ul class="navbar-nav ms-auto">
                    <li class="nav-item">
                        <a class="nav-link" href="?lang=pl">pl</a>
                    </li>
                    <li class="nav-item">
                        <a class="nav-link" href="?lang=en">en</a>
                    </li>
                    <li class="nav-item">
                        <a class="nav-link" href="?lang=de">de</a>
                    </li>
                    <sec:authorize access="isAuthenticated()">
                        <li class="nav-item">
                            <a class="nav-link" href="javascript:formSubmit()">Logout</a>
                        </li>
                    </sec:authorize>
                </ul>
            </div>
        </div>
    </nav>
</header>

<main>
    <div class="container">
        <h3><spring:message code="label.welcomeCar"/></h3>

        <div class="car-list-item">
            <div class="row">
                <div class="col-md-4">
                    <img src="https://i.postimg.cc/zfDVnFf1/fastcar-formula-roadster-sportcar-sportscar-super-supercar-icon-1320086843548443192.png" alt="Car 1" class="car-image">
                </div>
                <div class="col-md-8">
                    <h4><spring:message code="label.car1"/></h4>
                    <p><spring:message code="label.description1"/></p>
                </div>
            </div>
        </div>

        <div class="car-list-item">
            <div class="row">
                <div class="col-md-4">
                    <img src="https://i.postimg.cc/FKsF8F3t/car-icon-red.png" alt="Car 2" class="car-image">
                </div>
                <div class="col-md-8">
                    <h4><spring:message code="label.car2"/></h4>
                    <p><spring:message code="label.description1"/></p>
                </div>
            </div>
        </div>

        <div class="car-list-item">
            <div class="row">
                <div class="col-md-4">
                    <img src="https://i.postimg.cc/s2gzgnTb/147125.png" alt="Car 3" class="car-image">
                </div>
                <div class="col-md-8">
                    <h4><spring:message code="label.car3"/></h4>
                    <p><spring:message code="label.description1"/></p>
                </div>
            </div>
        </div>

        <script>
            function formSubmit() {
                document.getElementById("logoutForm").submit();
            }
        </script>

        <!-- csrf for log out-->
        <form action="/logout" method="post" id="logoutForm">
            <input type="hidden" name="${_csrf.parameterName}" value="${_csrf.token}" />
        </form>

        <br/>
        ${serverTime}

    </div>
</main>

<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha2/dist/js/bootstrap.bundle.min.js" integrity="sha384-qKXV1j0HvMUeCBQ+QVp7JcfGl760yU08IQ+GpUo5hlbpg51QRiuqHAJz8+BrxE/N" crossorigin="anonymous"></script>
</body>
</html>
