{% extends 'settings/index.html' %}

{% block header_text %}<h1><i class="fa-solid fa-database"></i> Repositories</h1>{% endblock %}

{% block main %}
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>Repositories - List</title>
  <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.2/css/all.min.css">
  <style>
    .actions {
      display: flex;
      gap: 0.5rem;
      justify-content: center;
      flex-wrap: wrap;
    }
    .repo-list {
      display: flex;
      flex-direction: column;
      gap: 1rem;
    }
    .repo-row {
      display: flex;
      align-items: center;
      justify-content: space-between;
      padding: 1rem;
      border-radius: 8px;
      flex-wrap: wrap;
    }
    .repo-info {
      display: flex;
      align-items: center;
      gap: 1rem;
      flex: 1;
      min-width: 220px;
    }
    .repo-name {
      font-size: 1.1rem;
      font-weight: 600;
    }
    @media (max-width: 600px) {
      .repo-row { flex-direction: column; align-items: stretch; }
      .actions { justify-content: flex-start; }
    }
    .topbar {
      display: flex;
    /*  justify-content: flex-end;*/
      margin-bottom: 1rem;
    }
    button, a.button {
      background: #198754; color: #fff; border: none; border-radius: 5px;
      padding: 0.4rem 0.8rem; text-decoration: none; cursor: pointer;
      transition: background 0.2s;
      font-size: 1rem; display: inline-flex; align-items: center; gap: 0.4rem;
    }
    .button.delete { background: #dc3545; }
    .button.edit { background: #0d6efd; }
    .button.clone { background: #6c757d; }
    .button.browse { background: #ffc107; color: #212529; }
    .button.create { background: #20c997; margin-left: 0.5rem; }
  </style>
</head>
<body>
  <div class="container">
      
    <div class="topbar">
      <a class="button create" href="/settings/repositories/create.html">
        <i class="fa-solid fa-plus"></i> New Repository
      </a>
    </div>
    <section class="repo-list">
      <!-- Example repository entries; replace with your templating/iteration -->
      {% for repo in repositories %}
      <div class="repo-row">
        <div class="repo-info">
            <span class="repo-name"><i class="fa-solid fa-book"></i> {{ repo.name }}</span>
        
<span title="Public">
    <i class="fa-solid {% if repo.is_private %}fa-lock{% else %}fa-lock-open{% endif %}"></i>
    {% if repo.is_private %}Private{% else %}Public{% endif %}
</span>
        </div>
        <div class="actions">
            <a class="button browse" href="/repository/{{ user.username.value }}/{{ repo.name }}" target="_blank">
            <i class="fa-solid fa-folder-open"></i> Browse
          </a>
          <a class="button clone" href="/git/{{ user.uid.value }}/{{ repo.name.value }}">
            <i class="fa-solid fa-code-branch"></i> Clone
          </a>
          <a class="button edit" href="/settings/repositories/repository/{{ repo.name }}/update.html">
            <i class="fa-solid fa-pen"></i> Edit
          </a>
          <a class="button delete" href="/settings/repositories/repository/{{ repo.name }}/delete.html">
            <i class="fa-solid fa-trash"></i> Delete
          </a>
        </div>
      </div>
      {% endfor %}
      <!-- ... -->
    </section>
  </div>
</body>
</html>
{% endblock %}
