<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org" lang="en">
<head>
    <meta charset="UTF-8">
    <title>SynergyMed – Уреди производи</title>
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <th:block th:replace="fragments/header :: headerStyles"></th:block>
    <style>
        :root { --teal-1:#20b2aa; --teal-2:#48d1cc; --muted:#6c757d; --text:#1f2937;
            --shadow:0 20px 40px rgba(0,0,0,0.10); --shadow-sm:0 6px 18px rgba(0,0,0,0.08); }
        *{margin:0;padding:0;box-sizing:border-box}
        body{font-family:'Segoe UI',Tahoma,Geneva,Verdana,sans-serif;min-height:100vh;
            background:linear-gradient(135deg,#a4ecba 0%,#fefeff 100%);color:var(--text)}
        .site-header{position:sticky;top:0;left:0;right:0;width:100%;border-radius:0;z-index:1000;background:#fff;box-shadow:0 2px 10px rgba(0,0,0,.1)}
        .page{width:100%;max-width:1200px;margin:0 auto;padding:24px}
        .card{background:#fff;border-radius:18px;box-shadow:var(--shadow);overflow:hidden;margin-bottom:28px}
        .card-header{background:linear-gradient(135deg,var(--teal-1),var(--teal-2));color:#fff;padding:20px 24px;
            display:flex;align-items:center;justify-content:space-between}
        .card-body{padding:22px}
        .actions{display:flex;gap:12px;flex-wrap:wrap}
        .btn{display:inline-block;border:none;cursor:pointer;text-decoration:none;padding:10px 16px;border-radius:12px;font-weight:600}
        .btn-primary{background:linear-gradient(135deg,var(--teal-1),var(--teal-2));color:#fff;box-shadow:0 10px 20px rgba(32,178,170,.25)}
        .btn-secondary{background:#fff;color:#111;border:2px solid rgba(32,178,170,.25)}
        table{width:100%;border-collapse:collapse}
        th, td{padding:12px 10px;border-bottom:1px solid #eef2f7;text-align:left}
        th{font-weight:700}
        .muted{color:var(--muted)}
    </style>
</head>
<body>
<th:block th:replace="fragments/header :: siteHeader('Каталог')"></th:block>

<div class="page">
    <div class="card">
        <div class="card-header">
            <span>Измен ја достапноста на лековите</span>
            <div class="actions">
                <a class="btn btn-secondary" th:href="@{/catalog}">Назад</a>
            </div>
        </div>
        <div class="card-body">
            <form th:action="@{/catalog/edit}" method="post">
                <input type="hidden" th:if="${_csrf != null}" th:name="${_csrf.parameterName}" th:value="${_csrf.token}">
                <table>
                    <thead>
                    <tr>
                        <th style="width:48px;">Достапен</th>
                        <th>Име</th>
                        <th class="muted">Форма</th>
                        <th class="muted">Цена</th>
                    </tr>
                    </thead>
                    <tbody>
                    <tr th:each="m : ${medicines}">
                        <td>
                            <input type="checkbox" name="ids" th:value="${m.id}"
                                   th:checked="${selectedIds != null and selectedIds.contains(m.id)}">
                        </td>
                        <td th:text="${m.name}">Лек</td>
                        <td class="muted" th:text="${m.dosageForm}">Форма</td>
                        <td class="muted" th:text="${#numbers.formatDecimal(m.price, 1, 'COMMA', 2, 'POINT') + ' ден.'}">0.00 ден.</td>
                    </tr>
                    </tbody>
                </table>
                <div class="actions" style="margin-top:16px;">
                    <button type="submit" class="btn btn-primary">Зачувај</button>
                    <a class="btn btn-secondary" th:href="@{/catalog}">Откажи</a>
                </div>
            </form>
        </div>
    </div>
</div>

<th:block th:replace="fragments/header :: headerScripts"></th:block>
</body>
</html>
