@props([
    'video',
    'tag' => 'button',   // 'button' or 'a'
])

{{-- Canonical "Save to playlist" trigger. Opens the single
     <x-add-to-playlist-modal/> (included once in layouts/app.blade.php) via
     openAddToPlaylistModal(numericId). Always passes $video->id, never the
     route key — the backend validates against videos.id. --}}
@php
    $onclick = "openAddToPlaylistModal({$video->id})";
@endphp

@if($tag === 'a')
    <a href="javascript:void(0)" {{ $attributes }} onclick="{{ $onclick }}">
        @if($slot->isEmpty())
            <i class="bi bi-bookmark"></i> Save to playlist
        @else
            {{ $slot }}
        @endif
    </a>
@else
    <button type="button" {{ $attributes }} onclick="{{ $onclick }}">
        @if($slot->isEmpty())
            <i class="bi bi-bookmark"></i> <span>Save to playlist</span>
        @else
            {{ $slot }}
        @endif
    </button>
@endif
