{% load i18n admin_urls %}

<div {% if not is_popup %}id="submit-row"{% endif %} class="relative {% if not is_popup %}lg:mt-16{% endif %} z-20">
    <div class="{% if not is_popup %}max-w-full lg:bottom-0 lg:fixed lg:left-0 lg:right-0{% endif %}" {% if not is_popup %}x-bind:class="{'xl:left-0': !sidebarDesktopOpen, 'xl:left-72': sidebarDesktopOpen}" x-bind:style="'width: ' + mainWidth + 'px'"{% endif %}>
        <div class="backdrop-blur-sm bg-white/80 pb-4 dark:bg-base-900/80 {% if not is_popup %}lg:border-t lg:border-base-200 lg:py-4 relative lg:scrollable-top lg:px-8 dark:border-base-800{% endif %}">
            <div class="flex flex-col-reverse gap-3 items-center mx-auto lg:flex-row-reverse">
                {% block submit-row %}
                    {% if show_save %}
                        <button type="submit" name="_save" class="bg-primary-600 block border border-transparent font-medium px-3 py-2 rounded text-white w-full lg:w-auto">
                            {% translate 'Save' %}
                        </button>
                    {% endif %}

                    {% for action in actions_submit_line %}
                        <button type="submit" {% if not action.attrs.name %}name="{{ action.action_name }}"{% endif %} class="border border-base-200 flex font-medium gap-2 items-center px-3 py-2 rounded transition-all w-full hover:bg-base-50 lg:w-auto dark:border-base-700 dark:hover:text-base-200 dark:hover:bg-base-900" {% include "unfold/helpers/attrs.html" with attrs=action.attrs %}>
                            {% if action.icon %}
                                <span class="material-symbols-outlined">
                                    {{ action.icon }}
                                </span>
                            {% endif %}

                            {{ action.description }}
                        </button>
                    {% endfor %}

                    {% if show_save_and_continue %}
                        <button type="submit" name="_continue" class="border border-base-200 font-medium px-3 py-2 rounded transition-all w-full hover:bg-base-50 lg:block lg:w-auto dark:border-base-700  dark:hover:text-base-200 dark:hover:bg-base-900">
                            {% if can_change %}
                                {% translate 'Save and continue editing' %}
                            {% else %}
                                {% translate 'Save and view' %}
                            {% endif %}
                        </button>
                    {% endif %}

                    {% if show_save_and_add_another %}
                        <button type="submit" name="_addanother" class="border border-base-200 font-medium px-3 py-2 rounded transition-all w-full hover:bg-base-50 lg:block lg:w-auto dark:border-base-700  dark:hover:text-base-200 dark:hover:bg-base-900">
                            {% translate 'Save and add another' %}
                        </button>
                    {% endif %}

                    {% if show_save_as_new %}
                        <button type="submit" name="_saveasnew" class="border border-base-200 font-medium px-3 py-2 rounded transition-all w-full hover:bg-base-50 lg:block lg:w-auto dark:border-base-700  dark:hover:text-base-200 dark:hover:bg-base-900">
                            {% translate 'Save as new' %}
                        </button>
                    {% endif %}

                    <div class="flex flex-col gap-3 mr-auto w-full lg:flex-row lg:w-auto">
                        {% if show_close or adminform.model_admin.change_form_show_cancel_button %}
                            {% url opts|admin_urlname:'changelist' as changelist_url %}

                            <a href="{% add_preserved_filters changelist_url %}" class="border border-base-200 font-medium px-3 py-2 rounded text-center transition-all w-full hover:bg-base-50 lg:block lg:w-auto dark:border-base-700  dark:hover:text-base-200 dark:hover:bg-base-900">
                                {% translate 'Close' %}
                            </a>
                        {% endif %}

                        {% if show_delete_link and original %}
                            {% url opts|admin_urlname:'delete' original.pk|admin_urlquote as delete_url %}


                            <a href="{% add_preserved_filters delete_url %}" class="bg-red-600 flex items-center justify-center font-medium h-9.5 ml-auto px-3 py-2 rounded text-center text-white w-full lg:w-auto dark:bg-red-500/20 dark:text-red-500">
                                {% translate "Delete" %} {{ opts.verbose_name }}
                            </a>
                        {% endif %}
                    </div>
                {% endblock %}
            </div>
        </div>
    </div>
</div>
