@extends('layouts.app')
@section('title', __('WhatsApp templates'))

@section('content')
<h1 class="h4 fw-bold mb-1">✏️ {{ __('WhatsApp templates') }}</h1>
<p class="mb-muted small mb-3">{{ __('Customize the automated messages your clinic sends, in Arabic and English. Use the tokens shown under each template.') }}</p>

@foreach($templates as $t)
<div class="mb-card p-4 mb-3">
    <form method="POST" action="{{ route('tenant.whatsapp.templates.update', $t['key']) }}">
        @csrf @method('PUT')
        <div class="d-flex flex-wrap justify-content-between align-items-center gap-2 mb-2">
            <h2 class="h6 fw-semibold mb-0">{{ $t['label'] }}</h2>
            <div class="form-check form-switch">
                <input type="hidden" name="enabled" value="0">
                <input class="form-check-input" type="checkbox" name="enabled" value="1" @checked($t['enabled']) id="en-{{ $t['key'] }}">
                <label class="form-check-label small" for="en-{{ $t['key'] }}">{{ __('Enabled') }}</label>
            </div>
        </div>
        <div class="mb-2">
            @foreach($t['tokens'] as $token)
                <code class="badge text-bg-light">{{ '{'.$token.'}' }}</code>
            @endforeach
        </div>
        <div class="row g-2">
            <div class="col-md-6">
                <label class="form-label small">{{ __('Arabic') }}</label>
                <textarea name="body_ar" dir="rtl" rows="3" class="form-control" required>{{ $t['body_ar'] }}</textarea>
            </div>
            <div class="col-md-6">
                <label class="form-label small">{{ __('English') }}</label>
                <textarea name="body_en" dir="ltr" rows="3" class="form-control" required>{{ $t['body_en'] }}</textarea>
            </div>
        </div>
        <div class="text-end mt-2">
            <button class="btn mb-btn-primary btn-sm">{{ __('Save') }}</button>
        </div>
    </form>
</div>
@endforeach
@endsection
