<!DOCTYPE html>
<html lang="en" data-bs-theme="light">

<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, shrink-to-fit=no">
    <meta name="description" content="Add new transaction to FinanceTracker">
    <title>FinanceTracker | Add Transaction</title>

    <link rel="stylesheet" th:href="@{/assets/bootstrap/css/bootstrap.min.css}">

    <link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">

    <style>
        body {
            background-color: #f8f9fc;
        }

        .card {
            border: none;
            border-radius: 0.75rem;
        }

        .card-header {
            background: transparent;
            border-bottom: 1px solid rgba(0, 0, 0, 0.05);
        }

        .material-icons {
            vertical-align: middle;
            font-size: 20px;
        }

        .input-group-text {
            background-color: #f8f9fc;
            border-right: none;
            color: #4e73df;
        }

        .form-control, .form-select {
            border-left: none;
        }

        .form-control:focus, .form-select:focus {
            box-shadow: none;
            border-color: #dee2e6;
        }

        .input-group:focus-within .input-group-text {
            border-color: #86b7fe;
        }

        label {
            font-weight: 600;
            color: #495057;
            margin-bottom: 0.4rem;
            font-size: 0.85rem;
        }

        .scroll-to-top {
            position: fixed;
            right: 1rem;
            bottom: 1rem;
            width: 40px;
            height: 40px;
            background-color: #0d6efd;
            color: #fff;
            display: flex;
            align-items: center;
            justify-content: center;
            text-decoration: none;
        }
    </style>
</head>

<body id="page-top">
    <div id="wrapper">
        <div th:replace="~{fragments/sidebar-nav :: sidebar-nav}"></div>

        <div id="content-wrapper" class="d-flex flex-column">
            <div id="content">
                <div th:replace="~{fragments/topbar :: topbar}"></div>

                <div class="container-fluid px-4">
                    
                    <div class="d-flex justify-content-between align-items-center mb-4">
                        <h3 class="mb-0">Add Transaction</h3>
                        <button class="btn btn-sm btn-outline-primary" data-bs-toggle="modal" data-bs-target="#exampleModal">
                            <span class="material-icons me-1">upload_file</span>
                            Bulk Upload
                        </button>
                    </div>

                    <div class="card shadow mb-4">
                        <div class="card-header d-flex align-items-center gap-2 py-3">
                            <span class="material-icons text-primary">add_circle</span>
                            <h6 class="fw-bold text-primary mb-0">Transaction Details</h6>
                        </div>

                        <div class="card-body p-4">
                            <form th:action="@{/addTranaction}" th:object="${transaction}" method="post">
                                <div class="row g-4">
                                    <div class="col-lg-4 col-md-6">
                                        <label>Transaction Date</label>
                                        <div class="input-group">
                                            <span class="input-group-text"><span class="material-icons">calendar_today</span></span>
                                            <input name="date" th:field="*{date}" type="date" class="form-control" required>
                                        </div>
                                    </div>

                                    <div class="col-lg-4 col-md-6">
                                        <label>Amount</label>
                                        <div class="input-group">
                                            <span class="input-group-text"><span class="material-icons">payments</span></span>
                                            <input name="moneyIn" th:field="*{moneyIn}" type="number" step="0.01"
                                                class="form-control" placeholder="0.00" required>
                                        </div>
                                    </div>

                                    <div class="col-lg-4 col-md-6">
                                        <label>Category</label>
                                        <div class="input-group">
                                            <span class="input-group-text"><span class="material-icons">category</span></span>
                                            <select name="category" th:field="*{category}" class="form-select">
                                                <option th:each="category : ${categories}" th:value="${category}"
                                                    th:text="${category}"></option>
                                            </select>
                                        </div>
                                    </div>

                                    <div class="col-lg-4 col-md-6">
                                        <label>Associated Fees</label>
                                        <div class="input-group">
                                            <span class="input-group-text"><span class="material-icons">money_off</span></span>
                                            <input name="fee" th:field="*{fee}" type="number" step="0.01" 
                                                class="form-control" placeholder="0.00">
                                        </div>
                                    </div>

                                    <div class="col-md-12">
                                        <label>Description</label>
                                        <div class="input-group">
                                            <span class="input-group-text"><span class="material-icons">notes</span></span>
                                            <textarea name="description" th:field="*{description}" class="form-control"
                                                rows="2" maxlength="60" placeholder="Brief description of the transaction..."></textarea>
                                        </div>
                                    </div>

                                    <div class="col-12 mt-4 pt-2 border-top">
                                        <div class="d-flex gap-2 justify-content-end">
                                            <button type="reset" class="btn btn-light px-4">Clear</button>
                                            <button type="submit" class="btn btn-primary px-5">Save Transaction</button>
                                        </div>
                                    </div>
                                </div>
                            </form>
                        </div>
                    </div>
                </div>
            </div>

            <div th:replace="~{fragments/footer :: footer}"></div>

            <div class="modal fade" id="exampleModal" tabindex="-1" aria-hidden="true">
                <div class="modal-dialog modal-dialog-centered">
                    <div class="modal-content border-0 shadow">
                        <div class="modal-header border-bottom-0">
                            <h5 class="modal-title fw-bold">Import CSV</h5>
                            <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
                        </div>
                        <div class="modal-body py-4">
                            <p class="text-muted small">Select a .csv or .xlsx file to import multiple transactions at once.</p>
                            <div class="input-group">
                                <input type="file" class="form-control" id="inputGroupFile02" style="border-left: 1px solid #dee2e6;">
                            </div>
                        </div>
                        <div class="modal-footer border-top-0">
                            <button type="button" class="btn btn-light" data-bs-dismiss="modal">Cancel</button>
                            <button type="button" class="btn btn-primary">Process Upload</button>
                        </div>
                    </div>
                </div>
            </div>
        </div>

        <a class="scroll-to-top rounded" href="#page-top">
            <span class="material-icons">keyboard_arrow_up</span>
        </a>
    </div>

    <script src="https://cdn.jsdelivr.net/npm/htmx.org@2.0.8/dist/htmx.min.js"></script>
    <script th:src="@{/assets/bootstrap/js/bootstrap.min.js}"></script>
    <script th:src="@{/assets/js/bs-init.js}"></script>
    <script th:src="@{/assets/js/theme.js}"></script>

</body>

</html>