@extends('layout')

@section('title', 'Yeni Site')

@section('content')
<div class="container py-5">
    <x-clientarea.page-header
        icon="fas fa-globe"
        title="Yeni Site"
    >
        <a href="{{ route('store.auth.reseller.sites.index') }}" class="btn btn-outline-secondary">
            <i class="fas fa-arrow-left me-1"></i>Sitelerime Dön
        </a>
    </x-clientarea.page-header>

    @if(session('error'))
        <div class="alert alert-danger">{{ session('error') }}</div>
    @endif

    <form method="POST" action="{{ route('store.auth.reseller.sites.store') }}">
        @csrf
        <div class="row">
            <div class="col-lg-8">
                <div class="card shadow-sm border-0 mb-4">
                    <div class="card-header"><h6 class="mb-0">Genel Bilgiler</h6></div>
                    <div class="card-body">
                        <div class="mb-3">
                            <label class="form-label">Site Adı <span class="text-danger">*</span></label>
                            <input type="text" class="form-control @error('name') is-invalid @enderror"
                                   name="name" value="{{ old('name') }}" required>
                            @error('name') <div class="invalid-feedback">{{ $message }}</div> @enderror
                        </div>
                        <div class="mb-3">
                            <label class="form-label">Domain</label>
                            <input type="text" class="form-control @error('domain') is-invalid @enderror"
                                   name="domain" value="{{ old('domain') }}" placeholder="store.example.com">
                            @error('domain') <div class="invalid-feedback">{{ $message }}</div> @enderror
                            <div class="form-text small">Domain'i daha sonra da ekleyebilirsiniz.</div>
                        </div>
                        <div class="row">
                            <div class="col-md-6 mb-3">
                                <label class="form-label">İletişim E-posta</label>
                                <input type="email" class="form-control" name="contact_email" value="{{ old('contact_email') }}">
                            </div>
                            <div class="col-md-6 mb-3">
                                <label class="form-label">İletişim Telefon</label>
                                <input type="text" class="form-control" name="contact_phone" value="{{ old('contact_phone') }}">
                            </div>
                        </div>
                        <div class="mb-3">
                            <label class="form-label">Footer Yazısı</label>
                            <input type="text" class="form-control" name="footer_text" value="{{ old('footer_text') }}">
                        </div>
                    </div>
                </div>

                <div class="card shadow-sm border-0 mb-4">
                    <div class="card-header"><h6 class="mb-0">Görünüm</h6></div>
                    <div class="card-body">
                        <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') }}">
                            </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') }}">
                            </div>
                        </div>
                        <div class="row">
                            <div class="col-md-6 mb-3">
                                <label class="form-label">Birincil Renk</label>
                                <input type="color" class="form-control form-control-color" name="primary_color" value="{{ old('primary_color', '#6366f1') }}">
                            </div>
                            <div class="col-md-6 mb-3">
                                <label class="form-label">İkincil Renk</label>
                                <input type="color" class="form-control form-control-color" name="secondary_color" value="{{ old('secondary_color', '#4f46e5') }}">
                            </div>
                        </div>
                        <div class="mb-3">
                            <label class="form-label">Özel CSS</label>
                            <textarea class="form-control" name="custom_css" rows="4">{{ old('custom_css') }}</textarea>
                        </div>
                        <div class="mb-3">
                            <label class="form-label">Özel JavaScript</label>
                            <textarea class="form-control" name="custom_js" rows="3">{{ old('custom_js') }}</textarea>
                        </div>
                    </div>
                </div>
            </div>

            <div class="col-lg-4">
                <div class="card shadow-sm border-0 mb-4">
                    <div class="card-header"><h6 class="mb-0">Görünür Ürün Grupları</h6></div>
                    <div class="card-body">
                        <div class="form-text small mb-2">Boş bırakırsanız tüm ürünler gösterilir.</div>
                        @foreach($productGroups as $pg)
                        <div class="form-check">
                            <input class="form-check-input" type="checkbox" name="visible_product_groups[]"
                                   value="{{ $pg->id }}" id="pg{{ $pg->id }}">
                            <label class="form-check-label" for="pg{{ $pg->id }}">{{ $pg->name }}</label>
                        </div>
                        @endforeach
                    </div>
                </div>

                <div class="card shadow-sm border-0 mb-4">
                    <div class="card-header"><h6 class="mb-0">Görünür TLD'ler</h6></div>
                    <div class="card-body" style="max-height: 200px; overflow-y: auto;">
                        <div class="form-text small mb-2">Boş bırakırsanız tüm TLD'ler gösterilir.</div>
                        @foreach($tlds as $tld)
                        <div class="form-check">
                            <input class="form-check-input" type="checkbox" name="visible_tlds[]"
                                   value="{{ $tld->tld }}" id="tld{{ $tld->id }}">
                            <label class="form-check-label" for="tld{{ $tld->id }}">.{{ $tld->tld }}</label>
                        </div>
                        @endforeach
                    </div>
                </div>

                <div class="d-grid">
                    <button type="submit" class="btn btn-primary">
                        <i class="fas fa-save me-1"></i>Site Oluştur
                    </button>
                </div>
            </div>
        </div>
    </form>
</div>
@endsection
