<!DOCTYPE html>
<html lang="de">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Artikel bearbeiten - <%= typeof item !== 'undefined' ? item.name : 'Frühstückskonten' %></title>
    <link rel="stylesheet" href="/styles.css">
</head>
<body>
    <div class="container">
        <header>
            <h1>Frühstückskonten Verwaltung</h1>
            <% if (typeof user !== 'undefined' && user) { %>
                <nav>
                    <span>Angemeldet als: <strong><%= user.username %></strong> (<%= user.role %>) | 
                    <a href="/dashboard">Dashboard</a> |
                    <a href="/accounts">Konten</a>
                    <% if (user.role === 'admin') { %>
                        | <a href="/items">Artikel</a>
                        | <a href="/users">Benutzer</a>
                    <% } %>
                    | <a href="/logout">Abmelden</a>
                    </span>
                </nav>
            <% } %>
        </header>
        
        <main>
            <% if (typeof item !== 'undefined' && item) { %>
                <h2>Artikel bearbeiten: <%= item.name %></h2>
                
                <% if (typeof error !== 'undefined' && error) { %>
                    <div class="error"><%= error %></div>
                <% } %>
                
                <form action="/items/<%= item.id %>", method="POST">
                    <div class="form-group">
                        <label for="name">Name:</label>
                        <input type="text" id="name" name="name" required autofocus
                               value="<%= item.name %>">
                    </div>
                    <div class="form-group">
                        <label for="price">Preis (€):</label>
                        <input type="number" id="price" name="price" step="0.01" min="0.01" required
                               value="<%= item.price.toFixed(2) %>">
                    </div>
                    <div class="form-group">
                        <label for="description">Beschreibung (optional):</label>
                        <input type="text" id="description" name="description"
                               value="<%= item.description || '' %>">
                    </div>
                    <button type="submit" class="btn">Speichern</button>
                    <a href="/items" class="btn secondary">Abbrechen</a>
                </form>
            <% } else { %>
                <p>Artikel nicht gefunden.</p>
            <% } %>
        </main>
        
        <footer>
            <p>&copy; 2024 Frühstückskonten Verwaltung</p>
        </footer>
    </div>
</body>
</html>
