{% from 'common/macros.html' import format_size %}

{% macro conversation_storage(conversation_count, message_count, attachment_count, total_size, recent_conversations) %}
<div class="masonry-card">
  <div class="card shadow-sm">
    <div class="card-body">
      <div class="d-flex justify-content-between align-items-center mb-3">
        <h5 class="card-title mb-0"><i class="fas fa-comments me-2"></i>Conversation Storage</h5>
        <a href="{{ url_for('conversations.conversations') }}" class="btn btn-primary btn-sm">View All</a>
      </div>
      <div class="d-flex flex-column">
        <div class="d-flex justify-content-between align-items-center mb-3">
          <div class="d-flex align-items-center">
            <i class="fas fa-comments me-2 icon-primary"></i>
            <span class="text-muted">Conversations:</span>
          </div>
          <div class="fw-bold text-primary">{{ conversation_count }}</div>
        </div>
        <div class="d-flex justify-content-between align-items-center mb-3">
          <div class="d-flex align-items-center">
            <i class="fas fa-comment me-2 icon-primary"></i>
            <span class="text-muted">Messages:</span>
          </div>
          <div class="fw-bold text-primary">{{ message_count }}</div>
        </div>
        <div class="d-flex justify-content-between align-items-center mb-3">
          <div class="d-flex align-items-center">
            <i class="fas fa-paperclip me-2 icon-primary"></i>
            <span class="text-muted">Attachments:</span>
          </div>
          <div class="fw-bold text-primary">{{ attachment_count }}</div>
        </div>
        <div class="d-flex justify-content-between align-items-center mb-3">
          <div class="d-flex align-items-center">
            <i class="fas fa-hdd me-2 icon-primary"></i>
            <span class="text-muted">Total Size:</span>
          </div>
          <div class="fw-bold text-primary">{{ format_size(total_size) }}</div>
        </div>
      </div>

      {% if recent_conversations %}
      <hr class="my-3">
      <div class="d-flex justify-content-between align-items-center mb-2">
        <h6 class="mb-0 text-muted">Recent Activity</h6>
      </div>
      <div class="list-group list-group-flush">
        {% for conversation in recent_conversations %}
        <a href="{{ url_for('conversations.conversation', conversation_id=conversation.id) }}" class="list-group-item list-group-item-action px-0">
          <div class="d-flex justify-content-between align-items-center">
            <div>
              <div class="fw-bold text-primary">{{ conversation.name }}</div>
              <small class="text-muted">
                {{ conversation.messages|length }} messages
                {% if conversation.messages|length > 0 %}
                • Last message {{ conversation.messages[-1].created_at.strftime('%Y-%m-%d %H:%M') }}
                {% endif %}
              </small>
            </div>
            <i class="fas fa-chevron-right text-muted"></i>
          </div>
        </a>
        {% endfor %}
      </div>
      {% endif %}
    </div>
  </div>
</div>
{% endmacro %} 