<!DOCTYPE html>
<html lang="tr">
<head>
    <meta charset="UTF-8">
    <title>{{ $job->title }} — Başvuru Formu</title>
    <style>
        * { margin: 0; padding: 0; box-sizing: border-box; }
        body { font-family: DejaVu Sans, sans-serif; font-size: 10.5px; color: #1f2937; background: #fff; }

        /* ── Sayfa kırılma önleme ── */
        .section        { page-break-inside: avoid; break-inside: avoid; margin: 12px 28px; }
        .form-field     { page-break-inside: avoid; break-inside: avoid; margin-bottom: 10px; }
        .two-col        { page-break-inside: avoid; break-inside: avoid; display: table; width: 100%; }
        .consent-box    { page-break-inside: avoid; break-inside: avoid; margin: 12px 28px; }
        .signature-section { page-break-inside: avoid; break-inside: avoid; margin: 12px 28px; }
        .required-docs  { page-break-inside: avoid; break-inside: avoid; margin: 12px 28px; }

        /* ── Header ── */
        .header { padding: 16px 28px; border-bottom: 3px solid {{ $settings->primary_color ?? '#ff7b00' }}; display: flex; justify-content: space-between; align-items: center; }
        .company-info h2 { font-size: 15px; font-weight: bold; color: {{ $settings->primary_color ?? '#ff7b00' }}; }
        .company-info p  { font-size: 8.5px; color: #6b7280; margin-top: 2px; }
        .form-title { text-align: right; }
        .form-title h1 { font-size: 13px; font-weight: bold; color: #1f2937; }
        .form-title p  { font-size: 8.5px; color: #6b7280; margin-top: 2px; }

        /* ── İlan bilgi kutusu ── */
        .job-info-box { background: #fff7ed; border: 1px solid {{ $settings->primary_color ?? '#ff7b00' }}; border-radius: 5px; padding: 10px 16px; margin: 12px 28px; page-break-inside: avoid; }
        .job-info-box h3 { font-size: 12px; font-weight: bold; color: {{ $settings->primary_color ?? '#ff7b00' }}; margin-bottom: 5px; }
        .job-meta { display: flex; gap: 16px; flex-wrap: wrap; }
        .job-meta-item { font-size: 8.5px; color: #6b7280; }
        .job-meta-item strong { color: #1f2937; }

        /* ── Bölüm başlığı ── */
        .section-title { font-size: 11px; font-weight: bold; color: {{ $settings->primary_color ?? '#ff7b00' }}; border-bottom: 1px solid #fed7aa; padding-bottom: 4px; margin-bottom: 8px; }

        /* ── Form alanları ── */
        .form-field label { display: block; font-size: 9px; font-weight: bold; color: #374151; margin-bottom: 3px; }
        .form-field label .required { color: #ef4444; }
        .form-field .field-box       { border: 1px solid #d1d5db; border-radius: 3px; padding: 6px 8px; min-height: 24px; background: #f9fafb; }
        .form-field .field-box-large { border: 1px solid #d1d5db; border-radius: 3px; padding: 6px 8px; min-height: 60px; background: #f9fafb; }

        /* ── İki sütun ── */
        .col { display: table-cell; width: 50%; padding-right: 10px; }
        .col:last-child { padding-right: 0; padding-left: 10px; }

        /* ── Gerekli belgeler ── */
        .required-docs { background: #fffbeb; border: 1px solid #fcd34d; border-radius: 5px; padding: 10px 14px; }
        .required-docs h4 { font-size: 10px; font-weight: bold; color: #92400e; margin-bottom: 6px; }
        .doc-item { font-size: 9px; color: #78350f; margin-bottom: 3px; padding-left: 12px; position: relative; }
        .doc-item::before { content: "✓"; position: absolute; left: 0; color: #d97706; font-weight: bold; }

        /* ── KVKK ── */
        .consent-box { background: #f9fafb; border: 1px solid #e5e7eb; border-radius: 5px; padding: 10px 14px; }
        .consent-box p { font-size: 8.5px; color: #6b7280; line-height: 1.5; }
        .consent-check { margin-top: 6px; display: flex; align-items: flex-start; gap: 6px; }
        .checkbox-box { width: 11px; height: 11px; border: 1px solid #9ca3af; border-radius: 2px; flex-shrink: 0; margin-top: 1px; }
        .consent-check span { font-size: 8.5px; color: #374151; }

        /* ── İmza ── */
        .sig-row { display: table; width: 100%; }
        .sig-cell { display: table-cell; width: 50%; padding-right: 14px; }
        .sig-cell:last-child { padding-right: 0; padding-left: 14px; }
        .sig-label { font-size: 8.5px; color: #6b7280; margin-bottom: 3px; }
        .sig-line { border-bottom: 1px solid #9ca3af; height: 28px; }

        /* ── Footer ── */
        .footer { margin-top: 16px; padding: 8px 28px; border-top: 1px solid #e5e7eb; font-size: 7.5px; color: #9ca3af; text-align: center; }
    </style>
</head>
<body>

{{-- Header --}}
<div class="header">
    <div class="company-info">
        <h2>{{ $settings->company_name ?? 'Şirket Adı' }}</h2>
        @if($settings->company_address)
        <p>{{ $settings->company_address }}</p>
        @endif
        @if($settings->company_phone || $settings->company_email)
        <p>
            @if($settings->company_phone) {{ $settings->company_phone }} @endif
            @if($settings->company_phone && $settings->company_email) · @endif
            @if($settings->company_email) {{ $settings->company_email }} @endif
        </p>
        @endif
    </div>
    <div class="form-title">
        <h1>İş Başvuru Formu</h1>
        <p>Tarih: {{ now()->format('d.m.Y') }}</p>
        @if($settings->company_website)
        <p>{{ $settings->company_website }}</p>
        @endif
    </div>
</div>

{{-- İlan Bilgisi --}}
<div class="job-info-box">
    <h3>{{ $job->title }}</h3>
    <div class="job-meta">
        <div class="job-meta-item">Departman: <strong>{{ $job->department }}</strong></div>
        <div class="job-meta-item">Konum: <strong>{{ $job->location }}</strong></div>
        <div class="job-meta-item">Çalışma Tipi: <strong>{{ $job->employment_type }}</strong></div>
        @if($job->closes_at)
        <div class="job-meta-item">Son Başvuru: <strong>{{ $job->closes_at->format('d.m.Y') }}</strong></div>
        @endif
        @if($job->salary_range)
        <div class="job-meta-item">Maaş Aralığı: <strong>{{ $job->salary_range }}</strong></div>
        @endif
    </div>
</div>

{{-- 1. Kişisel Bilgiler --}}
<div class="section">
    <div class="section-title">1. Kişisel Bilgiler</div>

    <div class="two-col">
        <div class="col">
            <div class="form-field">
                <label>Ad Soyad <span class="required">*</span></label>
                <div class="field-box"></div>
            </div>
        </div>
        <div class="col">
            <div class="form-field">
                <label>Doğum Tarihi</label>
                <div class="field-box"></div>
            </div>
        </div>
    </div>

    <div class="two-col">
        <div class="col">
            <div class="form-field">
                <label>E-posta Adresi <span class="required">*</span></label>
                <div class="field-box"></div>
            </div>
        </div>
        <div class="col">
            <div class="form-field">
                <label>Telefon Numarası <span class="required">*</span></label>
                <div class="field-box"></div>
            </div>
        </div>
    </div>

    <div class="form-field">
        <label>İkametgah Adresi</label>
        <div class="field-box"></div>
    </div>

    <div class="two-col">
        <div class="col">
            <div class="form-field">
                <label>LinkedIn Profili</label>
                <div class="field-box"></div>
            </div>
        </div>
        <div class="col">
            <div class="form-field">
                <label>Portföy / Web Sitesi</label>
                <div class="field-box"></div>
            </div>
        </div>
    </div>
</div>

{{-- 2. Eğitim --}}
<div class="section">
    <div class="section-title">2. Eğitim Bilgileri</div>

    <div class="two-col">
        <div class="col">
            <div class="form-field">
                <label>En Yüksek Eğitim Seviyesi</label>
                <div class="field-box"></div>
            </div>
        </div>
        <div class="col">
            <div class="form-field">
                <label>Mezun Olunan Okul / Bölüm</label>
                <div class="field-box"></div>
            </div>
        </div>
    </div>

    <div class="two-col">
        <div class="col">
            <div class="form-field">
                <label>Mezuniyet Yılı</label>
                <div class="field-box"></div>
            </div>
        </div>
        <div class="col">
            <div class="form-field">
                <label>GPA / Not Ortalaması</label>
                <div class="field-box"></div>
            </div>
        </div>
    </div>
</div>

{{-- 3. İş Deneyimi --}}
<div class="section">
    <div class="section-title">3. İş Deneyimi</div>

    <div class="two-col">
        <div class="col">
            <div class="form-field">
                <label>Toplam Deneyim Süresi</label>
                <div class="field-box"></div>
            </div>
        </div>
        <div class="col">
            <div class="form-field">
                <label>Son Çalıştığı Şirket</label>
                <div class="field-box"></div>
            </div>
        </div>
    </div>

    <div class="two-col">
        <div class="col">
            <div class="form-field">
                <label>Son Pozisyon / Unvan</label>
                <div class="field-box"></div>
            </div>
        </div>
        <div class="col">
            <div class="form-field">
                <label>Çalışma Dönemi</label>
                <div class="field-box"></div>
            </div>
        </div>
    </div>
</div>

{{-- 4. Ön Yazı --}}
<div class="section">
    <div class="section-title">4. Ön Yazı / Motivasyon</div>
    <div class="form-field">
        <label>Bu pozisyona neden başvuruyorsunuz? Kendinizi kısaca tanıtın.</label>
        <div class="field-box-large"></div>
    </div>
</div>

{{-- 5. Görüşmeye Gelirken Getirilmesi Gereken Belgeler --}}
@if($job->required_documents)
@php
    $docs = array_filter(array_map('trim', explode("\n", $job->required_documents)));
@endphp
@if(count($docs) > 0)
<div class="required-docs">
    <h4>Görüşmeye Gelirken Getirilmesi Gereken Belgeler</h4>
    @foreach($docs as $doc)
    <div class="doc-item">{{ $doc }}</div>
    @endforeach
</div>
@endif
@endif

{{-- KVKK --}}
<div class="consent-box">
    @if($settings->form_footer_text)
    <p>{{ $settings->form_footer_text }}</p>
    @else
    <p>Kişisel verileriniz, 6698 sayılı Kişisel Verilerin Korunması Kanunu (KVKK) kapsamında, işe alım süreçlerinin yürütülmesi amacıyla işlenecektir. Verileriniz üçüncü taraflarla paylaşılmayacak ve yasal saklama süreleri sonunda silinecektir.</p>
    @endif
    <div class="consent-check">
        <div class="checkbox-box"></div>
        <span>Yukarıdaki aydınlatma metnini okudum ve kişisel verilerimin işlenmesine onay veriyorum.</span>
    </div>
</div>

{{-- İmza --}}
<div class="signature-section">
    <div class="sig-row">
        <div class="sig-cell">
            <div class="sig-label">Başvuran Adı Soyadı</div>
            <div class="sig-line"></div>
        </div>
        <div class="sig-cell">
            <div class="sig-label">İmza &amp; Tarih</div>
            <div class="sig-line"></div>
        </div>
    </div>
</div>

<div class="footer">
    {{ $settings->company_name ?? '' }} · {{ $job->title }} Pozisyonu Başvuru Formu · {{ now()->format('d.m.Y') }}
    @if($settings->company_website) · {{ $settings->company_website }} @endif
</div>

</body>
</html>