{# app/modules/loyalty/templates/loyalty/store/pins.html #}
{% extends "store/base.html" %}
{% from 'shared/macros/headers.html' import page_header_flex, refresh_button %}
{% from 'shared/macros/alerts.html' import loading_state, error_state %}

{% block title %}{{ _('loyalty.store.pins.title') }}{% endblock %}

{% block i18n_modules %}['loyalty']{% endblock %}

{% block alpine_data %}storeLoyaltyPins(){% endblock %}

{% block content %}
<!-- Page Header -->
{% call page_header_flex(title=_('loyalty.store.pins.title'), subtitle=_('loyalty.store.pins.subtitle')) %}
    <div class="flex items-center gap-3">
        {{ refresh_button(loading_var='loading', onclick='loadPins()', variant='secondary') }}
        <button @click="openCreateModal()" x-show="program"
                class="flex items-center px-4 py-2 text-sm font-medium text-white bg-purple-600 rounded-lg hover:bg-purple-700">
            <span x-html="$icon('plus', 'w-4 h-4 mr-2')"></span>
            {{ _('loyalty.shared.pins.create_pin') }}
        </button>
    </div>
{% endcall %}

{{ loading_state(_('loyalty.store.pins.loading')) }}
{{ error_state(_('loyalty.store.pins.error_loading')) }}

<!-- No Program Setup Notice (same pattern as cards.html) -->
<div x-show="!loading && !program" class="mb-6 px-4 py-5 bg-yellow-50 border border-yellow-200 rounded-lg dark:bg-yellow-900/20 dark:border-yellow-800">
    <div class="flex items-start">
        <span x-html="$icon('exclamation-triangle', 'w-6 h-6 text-yellow-500 mr-3 flex-shrink-0')"></span>
        <div>
            <h3 class="text-sm font-semibold text-yellow-800 dark:text-yellow-200">{{ _('loyalty.common.program_not_setup') }}</h3>
            <p class="mt-1 text-sm text-yellow-700 dark:text-yellow-300">{{ _('loyalty.common.program_not_setup_desc') }}</p>
        </div>
    </div>
</div>

{% set pins_api_prefix = '/store/loyalty' %}
{% set show_store_filter = false %}
{% set show_crud = true %}
{% include 'loyalty/shared/pins-list.html' %}

{% endblock %}

{% block extra_scripts %}
<script defer src="{{ url_for('loyalty_static', path='shared/js/loyalty-pins-list.js') }}"></script>
<script defer src="{{ url_for('loyalty_static', path='store/js/loyalty-pins.js') }}"></script>
{% endblock %}
