<!doctype html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Syft Plugin Manager</title>
    <script src="https://cdn.jsdelivr.net/npm/axios/dist/axios.min.js"></script>
    <link
      href="https://fonts.googleapis.com/css2?family=Roboto:wght@300;400;700&display=swap"
      rel="stylesheet"
    />
    <link rel="stylesheet" href="static/css/style.css" />
    <style>
      body {
        background-color: #1e1e1e;
        color: #e0e0e0;
        font-family: "Roboto", sans-serif;
      }
      h1,
      h2,
      h3 {
        color: #ffffff;
      }
      .container,
      .state-viewer,
      .datasite-manager {
        background-color: #2d2d2d;
        border-radius: 8px;
        padding: 20px;
        margin-bottom: 20px;
      }
      input[type="text"],
      textarea {
        background-color: #3d3d3d;
        border: 1px solid #555;
        color: #e0e0e0;
        padding: 8px;
        border-radius: 4px;
      }
      button {
        background-color: #4caf50;
        color: white;
        border: none;
        padding: 10px 15px;
        cursor: pointer;
        border-radius: 4px;
      }
      button:hover {
        background-color: #45a049;
      }
      #stateDisplay,
      #datasiteList,
      #pluginList,
      #runningPlugins {
        background-color: #3d3d3d;
        padding: 10px;
        border-radius: 4px;
      }
      .column {
        background-color: #2d2d2d;
        padding: 15px;
        border-radius: 8px;
        margin-bottom: 15px;
      }
      ul {
        list-style-type: none;
        padding: 0;
      }
      li {
        background-color: #3d3d3d;
        margin-bottom: 8px;
        padding: 10px;
        border-radius: 4px;
      }
      /* New styles for pluginList and plugin-item */
      #pluginList {
        background-color: #2d2d2d;
      }
      .plugin-item {
        background-color: #3d3d3d;
        border: 1px solid #555;
        margin-bottom: 10px;
        padding: 15px;
        border-radius: 4px;
      }
      .plugin-item h3 {
        margin-top: 0;
        color: #ffffff;
      }
      .plugin-item p {
        color: #e0e0e0;
      }
      .plugin-item input[type="number"] {
        background-color: #2d2d2d;
        color: #e0e0e0;
        border: 1px solid #555;
        padding: 5px;
        border-radius: 3px;
      }
      /* New styles for runningPlugins and running-item */
      #runningPlugins {
        background-color: #2d2d2d;
      }
      .running-item {
        background-color: #3d3d3d;
        border: 1px solid #555;
        margin-bottom: 10px;
        padding: 15px;
        border-radius: 4px;
      }
      .running-item h3 {
        margin-top: 0;
        color: #ffffff;
      }
      .running-item p {
        color: #e0e0e0;
      }
    </style>
  </head>
  <body>
    <h1>Syft Plugin Manager</h1>
    <div class="container">
      <div class="column">
        <h2>Available Plugins</h2>
        <div id="pluginList">Loading plugins...</div>
      </div>
      <div class="column">
        <h2>Running Plugins</h2>
        <div id="runningPlugins">Loading running plugins...</div>
      </div>
    </div>
    <div class="state-viewer">
      <h2>Shared State</h2>
      <div>
        <label for="syftbox_folderInput">SyftBox Folder:</label>
        <input type="text" id="syftbox_folderInput" />
        <button onclick="updateSharedStateField('syftbox_folder')">
          Update
        </button>
      </div>
      <div>
        <label for="syft_folderInput">Syft Folder:</label>
        <input type="text" id="syft_folderInput" />
        <button onclick="updateSharedStateField('syft_folder')">Update</button>
      </div>
      <button onclick="viewSharedState()">Refresh Shared State</button>
      <div id="stateDisplay"></div>
    </div>

    <!-- New section for managing datasites -->
    <div class="datasite-manager">
      <h2>Manage Datasites</h2>
      <div>
        <input
          type="text"
          id="newDatasiteInput"
          placeholder="Enter new datasite name"
        />
        <button onclick="addDatasite()">Add Datasite</button>
      </div>
      <h3>Existing Datasites</h3>
      <ul id="datasiteList">
        <!-- Datasites will be dynamically added here -->
      </ul>
    </div>

    <script src="static/js/script.js"></script>
  </body>
</html>
