<!DOCTYPE html>
<html lang="hr">
<head>
  <meta charset="UTF-8" />
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
  <title>Todo App za djecu</title>
  <style>
    body {
      font-family: Arial, sans-serif;
      background: #f0f4f8;
      display: flex;
      justify-content: center;
      align-items: center;
      height: 100vh;
      margin: 0;
    }

    .app {
      background: white;
      padding: 20px;
      border-radius: 12px;
      box-shadow: 0 10px 25px rgba(0,0,0,0.1);
      width: 320px;
    }

    h1 {
      text-align: center;
    }

    .input-group {
      display: flex;
      gap: 10px;
    }

    input {
      flex: 1;
      padding: 10px;
      border-radius: 8px;
      border: 1px solid #ccc;
    }

    button {
      padding: 10px;
      border: none;
      border-radius: 8px;
      background: #4CAF50;
      color: white;
      cursor: pointer;
    }

    ul {
      list-style: none;
      padding: 0;
      margin-top: 20px;
    }

    li {
      background: #eef2f7;
      padding: 10px;
      margin-bottom: 8px;
      border-radius: 8px;
      display: flex;
      justify-content: space-between;
      align-items: center;
    }

    li.done {
      text-decoration: line-through;
      opacity: 0.6;
    }

    .delete {
      background: red;
      padding: 5px 8px;
      border-radius: 6px;
    }
  </style>
</head>
<body>
  <div class="app">
    <h1>📝 Moj Todo</h1>
    <div class="input-group">
      <input type="text" id="taskInput" placeholder="Unesi zadatak..." />
      <button onclick="addTask()">Dodaj</button>
    </div>

    <ul id="taskList"></ul>
  </div>

  <script>
    function addTask() {
      const input = document.getElementById('taskInput');
      const text = input.value.trim();

      if (text === '') {
        alert('Upiši zadatak!');
        return;
      }

      const li = document.createElement('li');
      li.textContent = text;

      // klik = označi kao završeno
      li.onclick = function() {
        li.classList.toggle('done');
      };

      // dugme za brisanje
      const delBtn = document.createElement('button');
      delBtn.textContent = 'X';
      delBtn.className = 'delete';
      delBtn.onclick = function(e) {
        e.stopPropagation();
        li.remove();
      };

      li.appendChild(delBtn);
      document.getElementById('taskList').appendChild(li);

      input.value = '';
    }
  </script>
</body>
</html>