{% extends "base.html" %}
{% load static i18n %}
{% block title %}{% trans "Update Zoom Meeting" %} - {{ block.super }}{% endblock %}

{% block customCSS %}
<style>
    /* UI Variables for the KAAT-S Theme */
    :root {
        --kaauh-teal: #00636e;
        --kaauh-teal-dark: #004a53;
        --kaauh-border: #eaeff3;
        --kaauh-primary-text: #343a40;
        --kaauh-gray: #6c757d;

        /* Status Colors for alerts/messages */
        --kaauh-success: var(--kaauh-teal);
        --kaauh-danger: #dc3545;
        --kaauh-info: #17a2b8;
    }

    /* CONTAINER AND CARD STYLING */
    .container {
        padding: 2rem 1rem;
    }
    .card {
        border: 1px solid var(--kaauh-border);
        border-radius: 0.75rem;
        box-shadow: 0 4px 12px rgba(0,0,0,0.06);
        max-width: 600px;
        margin: 0 auto; /* Center the card */
        padding: 1.5rem;
    }

    /* HEADER STYLING (The section outside the card) */
    .header {
        text-align: center;
        margin-bottom: 2rem;
    }
    .header h1 {
        font-size: 2rem;
        color: var(--kaauh-teal-dark);
        font-weight: 700;
        margin-bottom: 0.25rem;
    }
    .header p {
        color: var(--kaauh-gray);
        font-size: 1rem;
    }
    
    /* CARD TITLE STYLING */
    .card-title {
        font-size: 1.25rem;
        color: var(--kaauh-teal-dark);
        font-weight: 600;
        border-bottom: 1px solid var(--kaauh-border);
        padding-bottom: 0.75rem;
        margin-bottom: 1.5rem;
    }

    /* FORM STYLING */
    .form-row {
        margin-bottom: 1.5rem;
    }
    .form-label {
        display: block;
        font-weight: 600;
        color: var(--kaauh-gray);
        margin-bottom: 0.5rem;
        font-size: 0.9rem;
    }
    .form-input {
        display: block;
        width: 100%;
        padding: 0.75rem 1rem;
        font-size: 1rem;
        line-height: 1.5;
        color: var(--kaauh-primary-text);
        background-color: #fff;
        background-clip: padding-box;
        border: 1px solid var(--kaauh-border);
        border-radius: 0.5rem;
        transition: border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
    }
    .form-input:focus {
        border-color: var(--kaauh-teal);
        outline: 0;
        box-shadow: 0 0 0 0.1rem rgba(0, 99, 110, 0.25);
    }
    input[type="datetime-local"] {
        font-family: inherit;
    }

    /* MESSAGES/ALERTS STYLING */
    .messages {
        max-width: 600px;
        margin: 0 auto 1.5rem auto;
    }
    .alert {
        padding: 1rem;
        border-radius: 0.5rem;
        margin-bottom: 0.5rem;
        font-weight: 500;
    }
    .alert-success {
        color: white;
        background-color: var(--kaauh-success);
        border-color: var(--kaauh-success);
    }
    .alert-danger {
        color: white;
        background-color: var(--kaauh-danger);
        border-color: var(--kaauh-danger);
    }
    .alert-info {
        color: white;
        background-color: var(--kaauh-info);
        border-color: var(--kaauh-info);
    }

    /* BUTTON STYLING */
    .actions {
        margin-top: 1.5rem;
        display: flex;
        gap: 1rem;
    }
    .btn-base {
        display: inline-flex;
        align-items: center;
        gap: 0.5rem;
        text-align: center;
        vertical-align: middle;
        cursor: pointer;
        user-select: none;
        padding: 0.5rem 1rem;
        font-size: 1rem;
        line-height: 1.5;
        border-radius: 0.5rem;
        font-weight: 600;
        border: 1px solid transparent;
        transition: all 0.2s ease;
        text-decoration: none;
    }
    
    /* Primary Action Button (Update) */
    .btn-main-action { 
        background-color: var(--kaauh-teal);
        border-color: var(--kaauh-teal);
        color: white;
    }
    .btn-main-action:hover {
        background-color: var(--kaauh-teal-dark);
        border-color: var(--kaauh-teal-dark);
        box-shadow: 0 4px 8px rgba(0,0,0,0.15);
        color: white;
    }

    /* Secondary Button (Cancel) */
    .btn-kaats-outline-secondary {
        color: var(--kaauh-secondary);
        border-color: var(--kaauh-secondary);
        background-color: transparent;
    }
    .btn-kaats-outline-secondary:hover {
        background-color: var(--kaauh-secondary);
        color: white;
        border-color: var(--kaauh-secondary);
    }
</style>
{% endblock %}

{% block content %}
    <div class="container">
        <div class="header">
            <h1>{% trans "Update Zoom Meeting" %}</h1>
            <p>{% trans "Modify the details of your scheduled meeting" %}</p>
        </div>

        {# Apply KAAT-S theme styles to Django messages #}
        {% if messages %}
            <div class="messages">
                {% for message in messages %}
                    {# Use message tags to map to alert classes: success, danger, info #}
                    <div class="alert alert-{{ message.tags|default:'info' }}">
                        {{ message }}
                    </div>
                {% endfor %}
            </div>
        {% endif %}

        <div class="card">
            <h2 class="card-title">{% trans "Meeting Information" %}</h2>

            <form method="post" action="{% url 'update_meeting' meeting.pk %}">
                {% csrf_token %}

                <div class="form-row">
                    <label for="topic" class="form-label">{% trans "Topic:" %}</label>
                    <input type="text" id="topic" name="topic" class="form-input" value="{{ meeting.topic }}" required>
                </div>

                <div class="form-row">
                    <label for="start_time" class="form-label">{% trans "Start Time (ISO 8601):" %}</label>
                    {# Note: Django template filter for datetime-local needs to be precise Y-m-d\TH:i #}
                    <input type="datetime-local" id="start_time" name="start_time" class="form-input"
                           value="{{ meeting.start_time|slice:'0:16' }}" required>
                </div>

                <div class="form-row">
                    <label for="duration" class="form-label">{% trans "Duration (minutes):" %}</label>
                    <input type="number" id="duration" name="duration" class="form-input" value="{{ meeting.duration }}" required>
                </div>

                <div class="actions">
                    <button type="submit" class="btn-base btn-main-action">
                        <svg class="heroicon" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg" style="width: 1.25rem;">
                            <path d="M5 13l4 4L19 7" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"></path>
                        </svg>
                        {% trans "Update Meeting" %}
                    </button>
                    {# Using custom secondary button for 'Cancel' link #}
                    <a href="{% url 'meeting_details' meeting.pk %}" class="btn-base btn-kaats-outline-secondary">
                        {% trans "Cancel" %}
                    </a>
                </div>
            </form>
        </div>
    </div>
{% endblock %}