{% extends "base.html" %}

{% block title %}{{ team.name }} - Team Space{% endblock %}

{% block content %}
<nav aria-label="breadcrumb">
  <ol class="breadcrumb">
    <li class="breadcrumb-item"><a href="{% url 'team-list' %}">Teams</a></li>
    <li class="breadcrumb-item active" aria-current="page">{{ team.name }}</li>
  </ol>
</nav>

<div class="row mb-4">
    <div class="col-md-12">
        <div class="d-flex justify-content-between align-items-center">
            <h1>{{ team.name }}</h1>
            <span class="badge bg-primary">{{ team.members.count }} Members</span>
        </div>
        <p class="text-muted">{{ team.description }}</p>
    </div>
</div>

<h3 class="mb-4">Shared Bookmarks</h3>

<div class="row">
    {% for bookmark in shared_bookmarks %}
    <div class="col-md-12 mb-3">
        <div class="card p-3">
            <div class="d-flex justify-content-between align-items-start">
                <div>
                    <h5 class="card-title mb-1">
                        <a href="{% url 'bookmark-detail' bookmark.pk %}" class="text-decoration-none">{{ bookmark.title|default:bookmark.url }}</a>
                    </h5>
                    <p class="text-muted small mb-2">{{ bookmark.url }}</p>
                    <div class="mt-2">
                        {% for tag in bookmark.tags.all %}
                            <span class="badge bg-light text-dark border">{{ tag.name }}</span>
                        {% endfor %}
                    </div>
                </div>
                <div class="text-end">
                    <span class="text-muted small d-block mb-1">Shared by {{ bookmark.shares.first.shared_by.username }}</span>
                    <span class="text-muted small">{{ bookmark.shares.first.shared_at|date:"M d, Y" }}</span>
                </div>
            </div>
        </div>
    </div>
    {% empty %}
    <div class="col-12 text-center py-5">
        <div class="alert alert-info">
            No bookmarks have been shared with this team yet.
        </div>
    </div>
    {% endfor %}
</div>
{% endblock %}
