{% extends "base.html" %}
{% block head_extra %}
<style>
    .people-page {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 32px;
        max-width: 1000px;
    }
    .people-form-card, .people-list-card {
        background: #f8f9fa;
        padding: 20px;
        border-radius: 8px;
        border: 1px solid #e0e0e0;
    }
    .people-form-card h3, .people-list-card h3 {
        margin-top: 0;
        padding-bottom: 12px;
        border-bottom: 1px solid #dee2e6;
    }
    .form-group {
        margin-bottom: 16px;
    }
    .form-group label {
        display: block;
        font-weight: 600;
        margin-bottom: 4px;
        font-size: 14px;
    }
    .form-group input, .form-group textarea {
        width: 100%;
        padding: 8px 10px;
        border: 1px solid #ccc;
        border-radius: 4px;
        font-size: 14px;
        font-family: inherit;
    }
    .form-group input:focus, .form-group textarea:focus {
        outline: none;
        border-color: #007bff;
        box-shadow: 0 0 5px rgba(0, 123, 255, 0.2);
    }
    .form-group textarea {
        resize: vertical;
        min-height: 80px;
    }
    .btn-primary {
        padding: 10px 24px;
        background: #007bff;
        color: white;
        border: none;
        border-radius: 4px;
        cursor: pointer;
        font-size: 14px;
    }
    .btn-primary:hover {
        background: #0056b3;
    }
    .people-list {
        list-style: none;
        padding: 0;
        margin: 0;
    }
    .people-list li {
        padding: 10px 0;
        border-bottom: 1px solid #dee2e6;
        display: flex;
        justify-content: space-between;
        align-items: center;
    }
    .people-list li:last-child {
        border-bottom: none;
    }
    .people-list .person-name {
        font-weight: 500;
    }
    .people-list .person-links a {
        font-size: 13px;
        margin-left: 8px;
    }
</style>
{% endblock %}
{% block content %}
<main class="col-md-4 ms-sm-auto col-lg-10 px-md-4">
    <div class="d-flex justify-content-between flex-wrap flex-md-nowrap align-items-center pt-3 pb-2 mb-3 border-bottom">
        <h1 class="h2">People</h1>
    </div>

    <div class="people-page">
        <div class="people-form-card">
            <h3>Add Person</h3>
            <form method="post">
                {% csrf_token %}
                {% for field in form %}
                    <div class="form-group">
                        <label for="{{ field.id_for_label }}">{{ field.label }}</label>
                        {{ field }}
                        {% if field.errors %}
                            <small class="text-danger">{{ field.errors.0 }}</small>
                        {% endif %}
                    </div>
                {% endfor %}
                <button type="submit" class="btn-primary">Save</button>
            </form>
        </div>

        <div class="people-list-card">
            <h3>Your People</h3>
            <ul class="people-list">
                {% for person in people %}
                <li>
                    <span class="person-name">{{ person.name }}</span>
                    {% if person.scrobble_count > 0 %}
                    <small class="text-muted">({{ person.scrobble_count }} scrobbles)</small>
                    {% endif %}
                    <span class="person-links">
                        <a href="{% url 'people:person_edit' person.pk %}">Edit</a>
                    </span>
                </li>
                {% empty %}
                <li>No people yet.</li>
                {% endfor %}
            </ul>
        </div>
    </div>
</main>
{% endblock %}
