{% extends "admin/base_site.html" %}
{% load unfold %}
{% load i18n admin_urls static admin_modify %}

{% block extrahead %}{{ block.super }}
    <script src="{% url 'admin:jsi18n' %}"></script>
    {{ media }}
{% endblock %}

{% block bodyclass %}{{ block.super }} app-{{ opts.app_label }} model-{{ opts.model_name }} change-form{% endblock %}

{% if not is_popup %}
    {% block breadcrumbs %}
        <div class="px-4 lg:px-8">
            <div class="container mb-6 mx-auto -my-3 lg:mb-12">
                <ul class="flex flex-wrap">
                    {% url 'admin:index' as link %}
                    {% trans 'Home' as name %}
                    {% include 'unfold/helpers/breadcrumb_item.html' with link=link name=name %}

                    {% url 'admin:app_list' app_label=opts.app_label as link %}
                    {% include 'unfold/helpers/breadcrumb_item.html' with link=link name=opts.app_config.verbose_name %}

                    {% if has_view_permission %}
                        {% url opts|admin_urlname:'changelist' as link %}
                        {% include 'unfold/helpers/breadcrumb_item.html' with link=link  name=opts.verbose_name_plural|capfirst %}
                    {% else %}
                        {% include 'unfold/helpers/breadcrumb_item.html' with link='' name=opts.verbose_name_plural|capfirst %}
                    {% endif %}

                    {% if add %}
                        {% blocktranslate trimmed with name=opts.verbose_name asvar breadcrumb_name %}
                            Add {{ name }}
                        {% endblocktranslate %}

                        {% include 'unfold/helpers/breadcrumb_item.html' with link='' name=breadcrumb_name %}
                    {% else %}
                        {% include 'unfold/helpers/breadcrumb_item.html' with link='' name=original|truncatewords:'18' %}
                    {% endif %}
                </ul>
            </div>
        </div>
    {% endblock %}
{% endif %}

{% block nav-global %}{% spaceless %}
    {% if change and not is_popup %}
        {% block object-tools-items %}
            {% change_form_object_tools %}
        {% endblock %}
    {% endif %}
{% endspaceless %}{% endblock %}

{% block nav-global-side %}
    {% if has_add_permission %}
        {% include "unfold/helpers/add_link.html" %}
    {% endif %}
{% endblock %}

{% block content %}
    <div id="content-main" class="flex flex-col gap-4">
        {% block form_before %}{% endblock %}
        
        {% if  original.title %}
            
<div dir='rtl' class="bg-base-50 border border-base-200 border-dashed flex flex-col gap-4 p-4 rounded dark:bg-white/[.02] dark:border-base-700 lg:flex-row lg:justify-between w-full shrink-0 lg:items-center" style="justify-content: space-between;">
    <div class="flex flex-col lg:flex-row lg:items-center">
        <h2 class="font-semibold text-font-important-light text-base dark:text-font-important-dark flex items-center">
            <span class="material-symbols-outlined md-18 mr-3 w-4.5 align-middle">{{original.icon}}</span>
            <span class="align-middle" style="margin-right: 8px;">اموزش بخش {{original.content_type}}</span>
        </h2>
    </div>

    <div class="flex lg:flex-row lg:items-center">
        {% component "unfold/components/flex.html" with class="flex-col gap-4 lg:flex-row" %}
            {% component "unfold/components/button.html" with href=original.section_url %}
                نمایش بخش مربوطه
            {% endcomponent %} 
        {% endcomponent %}
    </div>
</div>
{% endif %}
        {% if adminform.model_admin.change_form_outer_before_template %}
            {% include adminform.model_admin.change_form_outer_before_template %}
        {% endif %}
        
        {% if  original.title %}
        
            
        <div class="border border-base-200 border-dashed mb-4 p-3 rounded dark:border-base-700 gap-1.5">
            {% if original and original.video %}
            <h3 style="display: flex; justify-content: center; align-items: center; width: 100%; padding: 5px 0;">

                <a href="{{original.section_url}}" style="color: rgb(var(--color-primary-500)); margin-right: 5px;">
                    {{original.content_type}}
                </a>
                آموزش بخش 
            </h3>
                <div style="display: flex;justify-content: center;align-items: center;width: 100%;padding: 25px 0px;">
                    <video controls style="border-radius: var(--border-radius,6px);width: 100%;max-width: 800px;">
                        <source src="{{ original.video.url }}" type="video/mp4">
                    </video>
                </div>
            {% else %}
                <p>no video available.</p>
            {% endif %}
        </div>
        {% endif %}


        {% if request.user.video_uploader %}
        <form {% if has_file_field %}enctype="multipart/form-data" {% endif %}{% if form_url %}action="{{ form_url }}" {% endif %}method="post" id="{{ opts.model_name }}_form" {% if adminform.model_admin.warn_unsaved_form %}class="warn-unsaved-form"{% endif %} novalidate>
            {% csrf_token %}

            {% if adminform.model_admin.change_form_before_template %}
                {% include adminform.model_admin.change_form_before_template %}
            {% endif %}

            {% block form_top %}{% endblock %}

            <div>
                {% if is_popup %}
                    <input type="hidden" name="{{ is_popup_var }}" value="1">
                {% endif %}

                {% if to_field %}
                    <input type="hidden" name="{{ to_field_var }}" value="{{ to_field }}">
                {% endif %}

                {% include "unfold/helpers/messages/errornote.html" with errors=errors %}
                {% include "unfold/helpers/messages/error.html" with errors=adminform.form.non_field_errors %}

                {% block field_sets %}
                    {% for fieldset in adminform %}
                        {% if "tab" not in fieldset.classes %}
                            {% include 'admin/includes/fieldset.html' %}
                        {% endif %}
                    {% endfor %}

                    {% include "unfold/helpers/fieldsets_tabs.html" %}
                {% endblock %}

                {% block after_field_sets %}{% endblock %}

                {% block inline_field_sets %}
                    {% for inline_admin_formset in inline_admin_formsets %}
                        {% include inline_admin_formset.opts.template %}
                    {% endfor %}
                {% endblock %}

                {% block after_related_objects %}{% endblock %}

                {% if adminform.model_admin.change_form_after_template %}
                    {% include adminform.model_admin.change_form_after_template %}
                {% endif %}

                {% block submit_buttons_bottom %}{% submit_row %}{% endblock %}

                {% block admin_change_form_document_ready %}
                    <script id="django-admin-form-add-constants" src="{% static 'admin/js/change_form.js' %}"{% if adminform and add %} data-model-name="{{ opts.model_name }}"{% endif %} async></script>
                {% endblock %}

                {% prepopulated_fields_js %}
            </div>
        </form>
        {% endif %}
        {% if adminform.model_admin.change_form_outer_after_template %}
            {% include adminform.model_admin.change_form_outer_after_template %}
        {% endif %}

        {% block form_after %}{% endblock %}
    </div>
{% endblock %}