{% extends "base.html" %}

{% block title %}Contact Messages | Admin Dashboard{% endblock %}

{% block head %}
<style>
    .admin-container {
        max-width: 1200px;
        margin: 2rem auto;
        padding: 0 1rem;
    }

    .dashboard-card {
        background: white;
        border-radius: 12px;
        padding: 2rem;
        box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
        border: 1px solid var(--border-color);
    }

    .dashboard-header {
        display: flex;
        justify-content: space-between;
        align-items: center;
        margin-bottom: 2rem;
        border-bottom: 1px solid var(--border-color);
        padding-bottom: 1rem;
    }

    .dashboard-title {
        font-size: 1.75rem;
        font-weight: 700;
        color: var(--slack-purple);
        display: flex;
        align-items: center;
        gap: 0.75rem;
    }

    .dashboard-title i {
        font-size: 1.5rem;
    }

    .contact-table-container {
        overflow-x: auto;
    }

    .contact-table {
        width: 100%;
        border-collapse: collapse;
        margin-top: 1rem;
    }

    .contact-table th {
        text-align: left;
        padding: 1rem;
        background-color: #f8f9fa;
        color: #5a6c7d;
        font-weight: 600;
        font-size: 0.85rem;
        text-transform: uppercase;
        letter-spacing: 0.05em;
        border-bottom: 2px solid #e9ecef;
    }

    .contact-table td {
        padding: 1.25rem 1rem;
        border-bottom: 1px solid #e9ecef;
        vertical-align: top;
        color: #2c3e50;
    }

    .contact-table tr:hover {
        background-color: #fcfcfd;
    }

    .user-info {
        display: flex;
        flex-direction: column;
        gap: 0.25rem;
    }

    .user-name {
        font-weight: 600;
        font-size: 1rem;
    }

    .user-email {
        font-size: 0.85rem;
        color: #6c757d;
    }

    .message-text {
        line-height: 1.5;
        max-width: 500px;
        white-space: pre-wrap;
        font-size: 0.95rem;
    }

    .date-badge {
        display: inline-block;
        padding: 0.25rem 0.75rem;
        background-color: #e9ecef;
        border-radius: 20px;
        font-size: 0.8rem;
        color: #495057;
        white-space: nowrap;
    }

    .empty-state {
        text-align: center;
        padding: 4rem 2rem;
        color: #6c757d;
    }

    .empty-icon {
        font-size: 3rem;
        margin-bottom: 1rem;
        opacity: 0.5;
    }

    @media (max-width: 768px) {
        .dashboard-header {
            flex-direction: column;
            align-items: flex-start;
            gap: 1rem;
        }

        .contact-table th,
        .contact-table td {
            padding: 0.75rem;
        }
    }
</style>
{% endblock %}

{% block content %}
<div class="admin-container">
    <div class="dashboard-card">
        <div class="dashboard-header">
            <h1 class="dashboard-title">
                <span>📬</span> Contact Messages
            </h1>
            <div class="stats-badge"
                style="background: var(--slack-purple); color: white; padding: 0.5rem 1rem; border-radius: 8px; font-weight: 600; font-size: 0.9rem;">
                Total: {{ contacts|length }}
            </div>
        </div>

        <div class="contact-table-container">
            {% if contacts %}
            <table class="contact-table">
                <thead>
                    <tr>
                        <th style="width: 250px;">From</th>
                        <th>Message</th>
                        <th style="width: 180px;">Date</th>
                    </tr>
                </thead>
                <tbody>
                    {% for contact in contacts %}
                    <tr>
                        <td>
                            <div class="user-info">
                                <span class="user-name">{{ contact.full_name }}</span>
                                <span class="user-email">{{ contact.email }}</span>
                            </div>
                        </td>
                        <td>
                            <div class="message-text">{{ contact.message }}</div>
                        </td>
                        <td>
                            <span class="date-badge">
                                {{ contact.created_at.strftime('%b %d, %Y %I:%M %p') }}
                            </span>
                        </td>
                    </tr>
                    {% endfor %}
                </tbody>
            </table>
            {% else %}
            <div class="empty-state">
                <div class="empty-icon">📂</div>
                <h3>No messages yet</h3>
                <p>When users contact you, their messages will appear here.</p>
            </div>
            {% endif %}
        </div>
    </div>
</div>
{% endblock %}
