<%- include('../partials/header') %>
<%- include('../partials/sidebar') %>

<div class="dashboard-header" style="display: flex; justify-content: space-between; align-items: center; margin-bottom: 30px;">
  <div>
    <h1 class="text-gradient">Playlists</h1>
    <p style="color: var(--text-muted);">Organize suas músicas em playlists.</p>
  </div>
  <a href="/admin/playlists/nova" class="btn btn-primary">
    <i class="fas fa-plus"></i> Nova Playlist
  </a>
</div>

<div class="card">
  <div style="overflow-x: auto;">
    <table style="width: 100%; border-collapse: collapse; text-align: left;">
      <thead>
        <tr style="border-bottom: 1px solid var(--border-color);">
          <th style="padding: 15px; color: var(--text-muted); font-weight: 500;">Nome</th>
          <th style="padding: 15px; color: var(--text-muted); font-weight: 500;">Descrição</th>
          <th style="padding: 15px; color: var(--text-muted); font-weight: 500;">Ações</th>
        </tr>
      </thead>
      <tbody>
        <% if (playlists.length > 0) { %>
          <% playlists.forEach(playlist => { %>
            <tr style="border-bottom: 1px solid rgba(42, 52, 74, 0.5); transition: background 0.3s;" onmouseover="this.style.background='rgba(0,240,255,0.02)'" onmouseout="this.style.background='transparent'">
              <td style="padding: 15px; font-weight: 600;"><i class="fas fa-list text-gradient" style="margin-right: 10px;"></i> <%= playlist.nome %></td>
              <td style="padding: 15px; color: var(--text-muted);"><%= playlist.descricao || '--' %></td>
              <td style="padding: 15px;">
                <form action="/admin/playlists/delete/<%= playlist.id %>" method="POST" style="display:inline;" onsubmit="return confirm('Tem certeza que deseja excluir esta playlist?');">
                  <button type="submit" class="btn btn-danger" style="padding: 8px 15px; font-size: 0.8rem;">
                    <i class="fas fa-trash"></i>
                  </button>
                </form>
              </td>
            </tr>
          <% }) %>
        <% } else { %>
          <tr>
            <td colspan="3" style="padding: 30px; text-align: center; color: var(--text-muted);">
              Nenhuma playlist criada.
            </td>
          </tr>
        <% } %>
      </tbody>
    </table>
  </div>
</div>
<%- include('../partials/footer') %>
