{% extends "base.html" %}

{% block title %}Edit Visitor{% endblock %}
{% block page_id %}visitors-edit{% endblock %}
{% block page_title %}Edit Visitor{% endblock %}
{% block eyebrow %}Management{% endblock %}

{% block content %}
<section class="panel-stack">
    <article class="glass-card panel-card">
        <div class="panel-header">
            <div>
                <p class="eyebrow">Visitor #{{ visitor.id }}</p>
                <h3>Edit Visitor Details</h3>
            </div>
        </div>

        <div class="panel-body">
            <form method="post" action="{{ url_for('admin.edit_visitor', visitor_id=visitor.id) }}" class="edit-form">
                <div class="form-grid">
                    <div class="field-group">
                        <label class="field-label" for="name">Name *</label>
                        <input id="name" name="name" type="text" placeholder="Enter visitor name" value="{{ visitor.name }}" required>
                    </div>

                    <div class="field-group">
                        <label class="field-label" for="mobile_number">Mobile Number</label>
                        <input id="mobile_number" name="mobile_number" type="text" placeholder="Enter mobile number" value="{{ visitor.mobile_number or '' }}">
                    </div>

                    <div class="field-group">
                        <label class="field-label" for="email">Email</label>
                        <input id="email" name="email" type="email" placeholder="Enter email address" value="{{ visitor.email or '' }}">
                    </div>
                </div>

                <div class="form-actions">
                    <a href="{{ url_for('admin.visitors_page') }}" class="ve-cancel-btn">Cancel</a>
                    <button class="ve-save-btn" type="submit">Save Changes</button>
                </div>
            </form>
        </div>
    </article>
</section>
{% endblock %}

{% block head %}
<style>
    .panel-card { background: #ffffff !important; }
    .panel-body { padding: 24px; }

    .form-grid {
        display: grid;
        grid-template-columns: 1fr;
        gap: 20px;
        margin-bottom: 24px;
    }
    @media (min-width: 768px) {
        .form-grid { grid-template-columns: 1fr 1fr; }
    }

    .field-group { display: flex; flex-direction: column; gap: 8px; }
    .field-label { font-size: 14px; font-weight: 600; color: #475569 !important; }
    .field-group input {
        padding: 12px 16px;
        border: 1.5px solid #cbd5e1 !important;
        border-radius: 12px;
        background: #ffffff !important;
        color: #0f172a !important;
        font-size: 14px;
        transition: all 0.2s;
        width: 100%;
        box-sizing: border-box;
    }
    .field-group input::placeholder { color: #94a3b8 !important; }
    .field-group input:focus {
        outline: none;
        border-color: #2c7da0 !important;
        box-shadow: 0 0 0 3px rgba(44, 125, 160, 0.1);
    }
    .field-group input:hover { border-color: #94a3b8 !important; }

    .form-actions {
        display: flex;
        gap: 12px;
        justify-content: flex-end;
        padding-top: 20px;
        border-top: 1px solid #e2e8f0;
    }

    /* Cancel button — gray border, dark text */
    .ve-cancel-btn {
        padding: 12px 28px;
        border: 1.5px solid #cbd5e1;
        border-radius: 10px;
        background: #ffffff;
        color: #475569 !important;
        font-size: 14px;
        font-weight: 600;
        text-decoration: none;
        cursor: pointer;
        transition: all 0.2s;
        display: inline-flex;
        align-items: center;
    }
    .ve-cancel-btn:hover {
        background: #f1f5f9;
        border-color: #94a3b8;
        color: #0f172a !important;
    }

    /* Save button — solid blue, white text */
    .ve-save-btn {
        padding: 12px 28px;
        border: none;
        border-radius: 10px;
        background: #2c7da0;
        color: blue !important;
        font-size: 14px;
        font-weight: 700;
        cursor: pointer;
        transition: all 0.2s;
    }
    .ve-save-btn:hover {
        background: #1a5f7a;
        transform: translateY(-1px);
        box-shadow: 0 4px 12px rgba(44, 125, 160, 0.3);
    }
</style>
{% endblock %}
