@extends('layouts.super-admin', ['title' => 'Email Settings - Booklio Super Admin', 'pageTitle' => 'Email Settings', 'active' => 'email'])

@section('content')
    <div class="space-y-5">
        @if (session('status'))
            <div class="rounded-lg border border-emerald-100 bg-emerald-50 px-4 py-3 text-sm font-bold text-emerald-700">{{ session('status') }}</div>
        @endif

        <x-ui.card title="Global Email Settings" description="Platform mail settings used for super admin notices, billing, and fallback tenant delivery.">
            <form method="POST" action="{{ $formAction }}" class="space-y-5">
                @csrf
                <div class="grid gap-4 md:grid-cols-2 xl:grid-cols-3">
                    <x-form.input name="smtp_host" label="SMTP host" value="{{ $settings['smtp_host'] ?? '' }}" />
                    <x-form.input name="smtp_port" type="number" label="SMTP port" value="{{ $settings['smtp_port'] ?? 587 }}" />
                    <x-form.input name="smtp_username" label="SMTP username" value="{{ $settings['smtp_username'] ?? '' }}" />
                    <x-form.input name="smtp_password" type="password" label="SMTP password" value="{{ $settings['smtp_password'] ?? '' }}" help="Stored as a platform setting placeholder. Encrypt before production secrets go live." />
                    <x-form.select name="encryption" label="Encryption" value="{{ $settings['encryption'] ?? 'tls' }}" :options="['tls' => 'TLS', 'ssl' => 'SSL', 'none' => 'None']" />
                    <x-form.input name="from_email" label="From email" value="{{ $settings['from_email'] ?? '' }}" />
                    <x-form.input name="from_name" label="From name" value="{{ $settings['from_name'] ?? 'Booklio' }}" />
                    <x-form.input name="test_email" label="Test email" value="{{ $settings['test_email'] ?? '' }}" />
                </div>
                <div class="flex flex-col gap-3 sm:flex-row sm:justify-end">
                    <x-ui.button type="button" variant="secondary">Send Test Email</x-ui.button>
                    <x-ui.button type="submit">Save Email Settings</x-ui.button>
                </div>
            </form>
        </x-ui.card>
    </div>
@endsection
