{#
  Copyright 2024-2026 Simply.IN Sp. z o.o.
  Licensed under the EUPL-1.2 or later.

  Renders the BO settings form with the classic PrestaShop HelperForm look
  (panels, col-lg-3/9 grid, prestashop-switch toggles) on top of the Symfony form.
#}
{% form_theme form '@Modules/simplyin/views/templates/admin/_form_theme.html.twig' %}

{{ form_start(form, {'attr': {'class': 'defaultForm form-horizontal', 'id': 'module_form'}}) }}

<div class="panel">
    <div class="panel-heading">
        <i class="icon-cogs"></i> {{ 'Settings'|trans({}, 'Modules.Simplyin.Admin') }}
    </div>
    <div class="form-wrapper">
        <div class="form-group">
            <label class="control-label col-lg-3" for="{{ form.secret_key.vars.id }}">
                {{ form.secret_key.vars.label|trans({}, 'Modules.Simplyin.Admin') }}
            </label>
            <div class="col-lg-9">
                <div class="input-group simplyin-key-group">
                    {{ form_widget(form.secret_key, {'value': secret_key_value, 'attr': {'placeholder': 'Leave blank to keep the current key'|trans({}, 'Modules.Simplyin.Admin')}}) }}
                    <span class="input-group-btn">
                        <button type="button" class="btn btn-default simplyin-toggle" tabindex="-1" title="{{ 'Show / hide'|trans({}, 'Modules.Simplyin.Admin') }}">
                            <i class="material-icons">visibility</i>
                        </button>
                    </span>
                </div>
            </div>
        </div>
    </div>
</div>

<div class="panel">
    <div class="panel-heading">
        <i class="icon-cogs"></i> {{ 'Carrier settings'|trans({}, 'Modules.Simplyin.Admin') }}
    </div>
    <div class="form-wrapper">
        {% for name in ['dpd_carrier_id', 'dhl_carrier_id', 'fedex_carrier_id', 'inpost_carrier_id', 'orlen_carrier_id', 'ups_carrier_id', 'default_carrier_id'] %}
            <div class="form-group">
                <label class="control-label col-lg-3" for="{{ form[name].vars.id }}">
                    {{ form[name].vars.label|trans({}, 'Modules.Simplyin.Admin') }}
                </label>
                <div class="col-lg-9">
                    {{ form_widget(form[name]) }}
                </div>
            </div>
        {% endfor %}
    </div>
</div>

<div class="panel">
    <div class="panel-heading">
        <i class="icon-cogs"></i> {{ 'Payment settings'|trans({}, 'Modules.Simplyin.Admin') }}
    </div>
    <div class="form-wrapper">
        {% for name in ['payments_enabled', 'payment_status_pending', 'payment_status_canceled'] %}
            <div class="form-group">
                <label class="control-label col-lg-3" for="{{ form[name].vars.id }}">
                    {{ form[name].vars.label|trans({}, 'Modules.Simplyin.Admin') }}
                </label>
                <div class="col-lg-9">
                    {{ form_widget(form[name]) }}
                </div>
            </div>
        {% endfor %}
    </div>
</div>

<div class="panel">
    <div class="panel-heading">
        <i class="icon-cogs"></i> {{ 'Additional settings'|trans({}, 'Modules.Simplyin.Admin') }}
    </div>
    <div class="form-wrapper">
        {% for name in ['save_checkbox', 'bar_enabled', 'bar_color', 'badge_color', 'accent_color', 'font_color'] %}
            <div class="form-group">
                <label class="control-label col-lg-3" for="{{ form[name].vars.id }}">
                    {{ form[name].vars.label|trans({}, 'Modules.Simplyin.Admin') }}
                </label>
                <div class="col-lg-9">
                    {% if name in ['accent_color', 'font_color'] %}
                        <div class="simplyin-color">
                            {{ form_widget(form[name], {'attr': {'class': 'simplyin-color-swatch'}}) }}
                            <input type="text" class="form-control simplyin-color-hex" value="{{ form[name].vars.value }}" maxlength="7" spellcheck="false" aria-label="{{ form[name].vars.label|trans({}, 'Modules.Simplyin.Admin') }}">
                        </div>
                    {% else %}
                        {{ form_widget(form[name]) }}
                    {% endif %}
                    {% if form[name].vars.help is defined and form[name].vars.help %}
                        <p class="help-block">{{ form[name].vars.help|trans({}, 'Modules.Simplyin.Admin') }}</p>
                    {% endif %}
                </div>
            </div>
        {% endfor %}

        <div class="form-group">
            <label class="control-label col-lg-3">
                {{ 'Cron URL'|trans({}, 'Modules.Simplyin.Admin') }}
            </label>
            <div class="col-lg-9">
                <input type="text" class="form-control" value="{{ cron_link }}" disabled>
                <p class="help-block">
                    {{ 'Below is the link to use when configuring cron on your server. Recommended frequency: once a day. The cron is used to update order statuses and settings.'|trans({}, 'Modules.Simplyin.Admin') }}
                </p>
            </div>
        </div>
    </div>
</div>

<div class="panel-footer">
    <button type="submit" name="submitSimplyinModule" class="btn btn-primary pull-right">
        <i class="process-icon-save"></i> {{ 'Save'|trans({}, 'Modules.Simplyin.Admin') }}
    </button>
</div>

{{ form_end(form) }}
