@extends('admin.layouts.app')

@section('content')
<div class="container-fluid px-4">
    <x-admin.page-header title="Edit Brand" icon="fas fa-tags"
        :buttons="[['label' => __('admin/common.back'), 'route' => route('admin.brands.index'), 'icon' => 'fas fa-arrow-left', 'color' => 'outline-secondary']]" />
    <x-admin.alert />
    <form method="POST" action="{{ route('admin.brands.update', $brand) }}">
        @csrf
        @method('PUT')
        <div class="row">
            <div class="col-lg-8">
                <x-admin.card>
                    <div class="mb-3">
                        <label class="form-label">Name <span class="text-danger">*</span></label>
                        <input type="text" class="form-control" name="name" value="{{ old('name', $brand->name) }}" required>
                    </div>
                    <div class="row">
                        <div class="col-md-6 mb-3">
                            <label class="form-label">Slug</label>
                            <input type="text" class="form-control" name="slug" value="{{ old('slug', $brand->slug) }}">
                        </div>
                        <div class="col-md-6 mb-3">
                            <label class="form-label">Domain</label>
                            <input type="text" class="form-control" name="domain" value="{{ old('domain', $brand->domain) }}">
                        </div>
                    </div>
                    <div class="row">
                        <div class="col-md-6 mb-3">
                            <label class="form-label">Logo URL</label>
                            <input type="text" class="form-control" name="logo" value="{{ old('logo', $brand->logo) }}">
                        </div>
                        <div class="col-md-6 mb-3">
                            <label class="form-label">Favicon URL</label>
                            <input type="text" class="form-control" name="favicon" value="{{ old('favicon', $brand->favicon) }}">
                        </div>
                    </div>
                    <div class="row">
                        <div class="col-md-4 mb-3">
                            <label class="form-label">Theme</label>
                            <input type="text" class="form-control" name="theme" value="{{ old('theme', $brand->theme) }}">
                        </div>
                        <div class="col-md-4 mb-3">
                            <label class="form-label">Language</label>
                            <input type="text" class="form-control" name="default_language" value="{{ old('default_language', $brand->default_language) }}">
                        </div>
                        <div class="col-md-4 mb-3">
                            <label class="form-label">Currency</label>
                            <input type="text" class="form-control" name="default_currency" value="{{ old('default_currency', $brand->default_currency) }}">
                        </div>
                    </div>
                    <div class="mb-3">
                        <label class="form-label">Custom CSS</label>
                        <textarea class="form-control" name="custom_css" rows="3">{{ old('custom_css', $brand->custom_css) }}</textarea>
                    </div>
                    <div class="mb-3">
                        <label class="form-label">Custom JS</label>
                        <textarea class="form-control" name="custom_js" rows="3">{{ old('custom_js', $brand->custom_js) }}</textarea>
                    </div>
                </x-admin.card>

                {{-- PRC-556 — Per-brand SEO overrides. Bos birakilan her alan global
                     SEO ayarina (Settings > SEO) duser. Gorseller URL-only. --}}
                @php $seoOv = old('seo_overrides', $brand->seo_overrides ?? []); @endphp
                <x-admin.card>
                    <x-slot:header>
                        <h5 class="card-title mb-0">{{ __('admin/settings.tabs_seo') }} — {{ __('admin/common.optional') ?? 'Optional' }}</h5>
                        <div class="form-text small">{{ __('admin/settings.seo_section_organization_help') }}</div>
                    </x-slot:header>
                    <div class="row">
                        <div class="col-md-6 mb-3">
                            <label class="form-label">{{ __('admin/settings.seo_google_verification') }}</label>
                            <input type="text" class="form-control" name="seo_overrides[seo_google_verification]" value="{{ data_get($seoOv, 'seo_google_verification', '') }}">
                        </div>
                        <div class="col-md-6 mb-3">
                            <label class="form-label">{{ __('admin/settings.seo_bing_verification') }}</label>
                            <input type="text" class="form-control" name="seo_overrides[seo_bing_verification]" value="{{ data_get($seoOv, 'seo_bing_verification', '') }}">
                        </div>
                        <div class="col-md-6 mb-3">
                            <label class="form-label">{{ __('admin/settings.seo_pinterest_verification') }}</label>
                            <input type="text" class="form-control" name="seo_overrides[seo_pinterest_verification]" value="{{ data_get($seoOv, 'seo_pinterest_verification', '') }}">
                        </div>
                        <div class="col-md-6 mb-3">
                            <label class="form-label">{{ __('admin/settings.seo_fb_app_id') }}</label>
                            <input type="text" class="form-control" name="seo_overrides[seo_fb_app_id]" value="{{ data_get($seoOv, 'seo_fb_app_id', '') }}">
                        </div>
                        <div class="col-md-6 mb-3">
                            <label class="form-label">{{ __('admin/settings.seo_twitter_site') }}</label>
                            <input type="text" class="form-control" name="seo_overrides[seo_twitter_site]" value="{{ data_get($seoOv, 'seo_twitter_site', '') }}" placeholder="@example">
                        </div>
                        <div class="col-md-6 mb-3">
                            <label class="form-label">{{ __('admin/settings.seo_twitter_creator') }}</label>
                            <input type="text" class="form-control" name="seo_overrides[seo_twitter_creator]" value="{{ data_get($seoOv, 'seo_twitter_creator', '') }}" placeholder="@example">
                        </div>
                        <div class="col-md-6 mb-3">
                            <label class="form-label">{{ __('admin/settings.seo_theme_color') }}</label>
                            <input type="text" class="form-control" name="seo_overrides[seo_theme_color]" value="{{ data_get($seoOv, 'seo_theme_color', '') }}" placeholder="#0d6efd">
                        </div>
                        <div class="col-md-6 mb-3">
                            <label class="form-label">{{ __('admin/settings.seo_apple_touch_icon') }}</label>
                            <input type="text" class="form-control" name="seo_overrides[seo_apple_touch_icon]" value="{{ data_get($seoOv, 'seo_apple_touch_icon', '') }}" placeholder="https://...">
                        </div>
                        <div class="col-md-6 mb-3">
                            <label class="form-label">{{ __('admin/settings.seo_org_name') }}</label>
                            <input type="text" class="form-control" name="seo_overrides[seo_org_name]" value="{{ data_get($seoOv, 'seo_org_name', '') }}">
                        </div>
                        <div class="col-md-6 mb-3">
                            <label class="form-label">{{ __('admin/settings.seo_org_url') }}</label>
                            <input type="text" class="form-control" name="seo_overrides[seo_org_url]" value="{{ data_get($seoOv, 'seo_org_url', '') }}" placeholder="https://...">
                        </div>
                        <div class="col-md-6 mb-3">
                            <label class="form-label">{{ __('admin/settings.seo_org_logo') }}</label>
                            <input type="text" class="form-control" name="seo_overrides[seo_org_logo]" value="{{ data_get($seoOv, 'seo_org_logo', '') }}" placeholder="https://...">
                        </div>
                        <div class="col-md-6 mb-3">
                            <label class="form-label">{{ __('admin/settings.seo_org_contact_phone') }}</label>
                            <input type="text" class="form-control" name="seo_overrides[seo_org_contact_phone]" value="{{ data_get($seoOv, 'seo_org_contact_phone', '') }}">
                        </div>
                        <div class="col-12 mb-3">
                            <label class="form-label">{{ __('admin/settings.seo_org_sameas') }}</label>
                            <textarea class="form-control" name="seo_overrides[seo_org_sameas]" rows="3" placeholder="https://...">{{ is_array(data_get($seoOv, 'seo_org_sameas')) ? implode("\n", data_get($seoOv, 'seo_org_sameas')) : data_get($seoOv, 'seo_org_sameas', '') }}</textarea>
                            <div class="form-text small">{{ __('admin/settings.seo_org_sameas_help') }}</div>
                        </div>
                        <div class="col-md-6 mb-3">
                            <div class="form-check form-switch">
                                <input class="form-check-input" type="checkbox" name="seo_overrides[seo_searchaction_enabled]" value="1" id="brand_seo_searchaction_enabled" {{ data_get($seoOv, 'seo_searchaction_enabled') ? 'checked' : '' }}>
                                <label class="form-check-label" for="brand_seo_searchaction_enabled">{{ __('admin/settings.seo_searchaction_enabled') }}</label>
                            </div>
                        </div>
                        <div class="col-md-6 mb-3">
                            <label class="form-label">{{ __('admin/settings.seo_searchaction_target') }}</label>
                            <input type="text" class="form-control" name="seo_overrides[seo_searchaction_target]" value="{{ data_get($seoOv, 'seo_searchaction_target', '') }}" placeholder="https://example.com/search?q={search_term_string}">
                        </div>
                    </div>
                </x-admin.card>
            </div>
            <div class="col-lg-4">
                <x-admin.card>
                    <div class="mb-3">
                        <div class="form-check">
                            <input class="form-check-input" type="checkbox" name="is_active" value="1" id="is_active" {{ old('is_active', $brand->is_active) ? 'checked' : '' }}>
                            <label class="form-check-label" for="is_active">Active</label>
                        </div>
                    </div>
                    <div class="mb-3">
                        <div class="form-check">
                            <input class="form-check-input" type="checkbox" name="is_default" value="1" id="is_default" {{ old('is_default', $brand->is_default) ? 'checked' : '' }}>
                            <label class="form-check-label" for="is_default">Default Brand</label>
                        </div>
                    </div>
                    <x-slot:footer>
                        <x-admin.form-actions :cancel-url="route('admin.brands.index')" />
                    </x-slot:footer>
                </x-admin.card>
            </div>
        </div>
    </form>
</div>
@endsection
