{# tag_me/templates/tag_me/tag_me_select_search_bar_mobile.html #}
{% comment %}
  MOBILE SEARCH BAR ACTIONS - CONTEXT AWARE
  Shows ONE big, clear action button based on current state
  Priority: Creating > Can Add > Has Search > Has Selected Tags
{% endcomment %}
<!-- Context-Aware Action Button (Mobile) -->
<div class="tm:relative">
    <!-- PRIORITY 1: Loading/Creating Tag -->
    <div x-show="isCreatingTag"
         class="tm:inline-flex tm:items-center tm:px-2"
         x-transition:enter="transition ease-out duration-150"
         x-transition:enter-start="opacity-0 scale-90"
         x-transition:enter-end="opacity-100 scale-100"
         x-transition:leave="transition ease-in duration-150"
         x-transition:leave-start="opacity-100 scale-100"
         x-transition:leave-end="opacity-0 scale-90">
        <svg class="tm:animate-spin tm:h-6 tm:w-6 tm:text-primary-lib"
             xmlns="http://www.w3.org/2000/svg"
             fill="none"
             viewBox="0 0 24 24">
            <circle class="tm:opacity-25" cx="12" cy="12" r="10" stroke="currentColor" stroke-width="4"></circle>
            <path class="tm:opacity-75" fill="currentColor" d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z">
            </path>
        </svg>
    </div>
    <!-- PRIORITY 2: Add Tag Button (when can add new tag) -->
    <button type="button"
            x-show="canAddTag && !isCreatingTag"
            x-transition:enter="transition ease-out duration-150"
            x-transition:enter-start="opacity-0 scale-90"
            x-transition:enter-end="opacity-100 scale-100"
            x-transition:leave="transition ease-in duration-150"
            x-transition:leave-start="opacity-100 scale-100"
            x-transition:leave-end="opacity-0 scale-90"
            @click.stop="openBottomSheet()"
            class="tm:inline-flex tm:items-center tm:justify-center tm:w-[44px] tm:h-[44px] tm:text-on-primary-lib tm:bg-primary-lib tm:rounded-lg tm:transition-all tm:duration-150 hover:tm:bg-primary-lib hover:tm:opacity-90 tm:active:scale-95 tm:focus:outline-none tm:focus:ring-2 tm:focus:ring-primary-lib tm:focus:ring-offset-2 tm:focus:ring-offset-surface-container-high-lib"
            aria-label="Add new tag">
        <svg xmlns="http://www.w3.org/2000/svg"
             class="tm:h-5 tm:w-5"
             fill="none"
             viewBox="0 0 24 24"
             stroke="currentColor"
             stroke-width="2.5">
            <path stroke-linecap="round" stroke-linejoin="round" d="M12 4.5v15m7.5-7.5h-15" />
        </svg>
    </button>
    <!-- PRIORITY 3: Clear Search Button (when search has text) -->
    <button type="button"
            x-show="search.length > 0 && !canAddTag && !isCreatingTag"
            x-transition:enter="transition ease-out duration-150"
            x-transition:enter-start="opacity-0 scale-90"
            x-transition:enter-end="opacity-100 scale-100"
            x-transition:leave="transition ease-in duration-150"
            x-transition:leave-start="opacity-100 scale-100"
            x-transition:leave-end="opacity-0 scale-90"
            @click.stop="clearSearch()"
            class="tm:inline-flex tm:items-center tm:justify-center tm:w-[44px] tm:h-[44px] tm:text-on-surface-variant-lib tm:bg-surface-container-highest-lib tm:rounded-lg tm:transition-all tm:duration-150 hover:tm:bg-surface-container-highest-lib hover:tm:text-on-surface-lib tm:active:scale-95 tm:focus:outline-none tm:focus:ring-2 tm:focus:ring-primary-lib tm:focus:ring-offset-2 tm:focus:ring-offset-surface-container-high-lib"
            aria-label="Clear search">
        <svg xmlns="http://www.w3.org/2000/svg"
             class="tm:h-5 tm:w-5"
             fill="none"
             viewBox="0 0 24 24"
             stroke="currentColor"
             stroke-width="2.5">
            <path stroke-linecap="round" stroke-linejoin="round" d="m6 6 12 12m3-6a9 9 0 1 1-18 0 9 9 0 0 1 18 0Z" />
        </svg>
    </button>
    <!-- PRIORITY 4: Remove All Tags Button (when tags selected and no search) -->
    <button type="button"
            x-show="selectedTags.size > 0 && search.length === 0 && !canAddTag && !isCreatingTag"
            x-transition:enter="transition ease-out duration-150"
            x-transition:enter-start="opacity-0 scale-90"
            x-transition:enter-end="opacity-100 scale-100"
            x-transition:leave="transition ease-in duration-150"
            x-transition:leave-start="opacity-100 scale-100"
            x-transition:leave-end="opacity-0 scale-90"
            @click.stop="deselectAll()"
            class="tm:relative tm:inline-flex tm:items-center tm:justify-center tm:w-[44px] tm:h-[44px] tm:p-2 tm:text-on-surface-variant-lib tm:bg-surface-container-highest-lib tm:rounded-lg tm:transition-all tm:duration-150 hover:tm:bg-surface-container-highest-lib hover:tm:text-on-surface-lib tm:active:scale-95 tm:focus:outline-none tm:focus:ring-2 tm:focus:ring-primary-lib tm:focus:ring-offset-2 tm:focus:ring-offset-surface-container-high-lib"
            :aria-label="'Remove ' + selectedTags.size + ' tags'">
        <svg xmlns="http://www.w3.org/2000/svg"
             class="tm:h-5 tm:w-5"
             fill="none"
             viewBox="0 0 24 24"
             stroke="currentColor"
             stroke-width="2.5">
            <path stroke-linecap="round" stroke-linejoin="round" d="M5 7h14m-9 3v8m4-8v8M10 3h4a1 1 0 0 1 1 1v3H9V4a1 1 0 0 1 1-1ZM6 7h12v13a1 1 0 0 1-1 1H7a1 1 0 0 1-1-1V7Z" />
        </svg>
        <!-- Badge showing count -->
        <span class="tm:absolute tm:-top-0.5 tm:-right-0.5 tm:inline-flex tm:items-center tm:justify-center tm:px-1.5 tm:py-0.5 tm:text-[10px] tm:font-bold tm:leading-none tm:text-on-primary-lib tm:bg-primary-lib tm:rounded-full tm:min-w-[1rem]"
              x-text="selectedTags.size"></span>
    </button>
</div>
{% comment %}
TEMPLATE CLASS MIGRATION - MOBILE SEARCH BAR (MD3 REFACTOR v3.0)
=================================================================
Date: December 06, 2025
Migration: MD3 Elevation Alignment with Datetime Component

CHANGES APPLIED:
✅ All buttons (3 instances with surface backgrounds):
   1. bg-surface-container-high-lib → bg-surface-container-highest-lib [3→4]
      - Dropdown is now at [3], buttons should be at [4] for prominence
   2. ring-offset-surface-container-lib → ring-offset-surface-container-high-lib [1→3]
      - Parent dropdown is now at surface-container-high-lib [3]
      - Ring offset must match parent surface

AFFECTED ELEMENTS:
1. Add tag button (primary bg - unchanged, only ring offset updated)
2. Clear search button (surface bg updated + ring offset)
3. Remove all tags button (surface bg updated + ring offset)

ELEVATION CONTEXT:
- These buttons sit inside the dropdown search section
- Dropdown is now at surface-container-high-lib [3]
- Surface buttons use surface-container-highest-lib [4] for prominence
- Ring offset matches dropdown background [3]

NO OTHER CHANGES:
- Alpine.js: unchanged
- HTMX: unchanged
- HTML structure: unchanged
- Spacing/layout: unchanged
- Non-MD3 classes: unchanged
{% endcomment %}
