<%- include("../partials/page-header", {
  user,
  title: t.companySettings.title,
  subtitle: "",
  showUserName: true
}) %>

<div class="content p-4">

  <%- include("../partials/flash") %>

  <div class="container-fluid">
    <div class="card shadow-sm">
      <div class="card-body">

        <h5 class="mb-4">
          <i class="bi bi-building"></i>
          <%= t.companySettings.title %>
        </h5>

        <form method="POST" action="/admin/company-settings" enctype="multipart/form-data">

          <div class="row g-3">

            <div class="col-md-6">
              <label class="form-label"><%= t.companySettings.companyname %></label>
              <input class="form-control" name="company_name"
                value="<%= settings.company_name || '' %>" required>
            </div>

            <div class="col-md-6">
              <label class="form-label"><%= t.companySettings.legalform %></label>
              <input class="form-control" name="company_legal_form"
                value="<%= settings.company_legal_form || '' %>">
            </div>

            <div class="col-md-6">
              <label class="form-label"><%= t.companySettings.owner %></label>
              <input class="form-control" name="company_owner"
                value="<%= settings.company_owner || '' %>">
            </div>

            <div class="col-md-6">
              <label class="form-label"><%= t.companySettings.email %></label>
              <input class="form-control" name="email"
                value="<%= settings.email || '' %>">
            </div>

            <div class="col-md-8">
              <label class="form-label"><%= t.companySettings.street %></label>
              <input class="form-control" name="street"
                value="<%= settings.street || '' %>">
            </div>

            <div class="col-md-4">
              <label class="form-label"><%= t.companySettings.housenumber %></label>
              <input class="form-control" name="house_number"
                value="<%= settings.house_number || '' %>">
            </div>

            <div class="col-md-4">
              <label class="form-label"><%= t.companySettings.zip %></label>
              <input class="form-control" name="postal_code"
                value="<%= settings.postal_code || '' %>">
            </div>

            <div class="col-md-8">
              <label class="form-label"><%= t.companySettings.city %></label>
              <input class="form-control" name="city"
                value="<%= settings.city || '' %>">
            </div>

            <div class="col-md-6">
              <label class="form-label"><%= t.companySettings.country %></label>
              <input class="form-control" name="country"
                value="<%= settings.country || 'Deutschland' %>">
            </div>

            <div class="col-md-6">
              <label class="form-label"><%= t.companySettings.taxid %></label>
              <input class="form-control" name="vat_id"
                value="<%= settings.vat_id || '' %>">
            </div>

            <div class="col-md-6">
              <label class="form-label"><%= t.companySettings.bank %></label>
              <input class="form-control" name="bank_name"
                value="<%= settings.bank_name || '' %>">
            </div>

            <div class="col-md-6">
              <label class="form-label"><%= t.companySettings.iban %></label>
              <input class="form-control" name="iban"
                value="<%= settings.iban || '' %>">
            </div>

            <div class="col-md-6">
              <label class="form-label"><%= t.companySettings.bic %></label>
              <input class="form-control" name="bic"
                value="<%= settings.bic || '' %>">
            </div>

            <div class="col-12">
              <label class="form-label"><%= t.companySettings.invoicefooter %></label>
              <textarea class="form-control" rows="3" name="invoice_footer_text"
              ><%= settings.invoice_footer_text || '' %></textarea>
            </div>

            <div class="col-12">
              <label class="form-label"><%= t.companySettings.companylogo %></label>
              <input type="file" name="logo" class="form-control"
                accept="image/png, image/jpeg">
              <% if (settings.invoice_logo_path) { %>
                <div class="mt-2">
                  <small class="text-muted"><%= t.companySettings.currentlogo %></small><br>
                  <img src="<%= settings.invoice_logo_path %>"
                    style="max-height:80px; border:1px solid #ccc; padding:4px;">
                </div>
              <% } %>
            </div>

          </div>

          <div class="mt-4 d-flex gap-2">
            <button class="btn btn-primary">
              <i class="bi bi-save"></i> <%= t.global.save %>
            </button>
            <a href="/dashboard" class="btn btn-secondary">
              <%= t.companySettings.back %>
            </a>
          </div>

        </form>

      </div>
    </div>
  </div>
</div>
