{% extends 'base.html' %}
{% load static %}

{% block title %}CRM Dashboard{% endblock %}

{% block head %}
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet">
{% endblock %}

{% block content %}
<div class="d-flex">
    <div class="sidebar vh-100 p-3">
        <h3 class="text-white">CRM</h3>
        <ul class="nav flex-column">
            <li class="nav-item">
                <a class="nav-link active text-white" href="#">Dashboard</a>
            </li>
            <li class="nav-item">
                <a class="nav-link text-white" href="#">Clients</a>
            </li>
        </ul>
    </div>
    <div class="main-content flex-grow-1 p-4">
        <div class="container-fluid">
            <div class="hero-section rounded p-5 mb-4">
                <h1 class="display-5 fw-bold text-white">Welcome to your CRM</h1>
                <p class="col-md-8 fs-4 text-white">Manage your clients and leads effectively.</p>
            </div>

            <div class="row">
                <div class="col-md-4">
                    <div class="card">
                        <div class="card-body">
                            <h5 class="card-title">Add New Client</h5>
                            <form method="post">
                                {% csrf_token %}
                                {{ form.as_p }}
                                <button type="submit" class="btn btn-primary">Add Client</button>
                            </form>
                        </div>
                    </div>
                </div>
                <div class="col-md-8">
                    <div class="card">
                        <div class="card-body">
                            <h5 class="card-title">Clients</h5>
                            <table class="table table-hover">
                                <thead>
                                    <tr>
                                        <th>Name</th>
                                        <th>Email</th>
                                        <th>Phone</th>
                                        <th>Status</th>
                                    </tr>
                                </thead>
                                <tbody>
                                    {% for client in clients %}
                                    <tr>
                                        <td>{{ client.first_name }} {{ client.last_name }}</td>
                                        <td>{{ client.email }}</td>
                                        <td>{{ client.phone }}</td>
                                        <td><span class="badge bg-primary">{{ client.get_status_display }}</span></td>
                                    </tr>
                                    {% endfor %}
                                </tbody>
                            </table>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
{% endblock %}
