<!DOCTYPE html>
<html lang="tr">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>{{ $job->title }} — İlan Detayı</title>
    <style>
        * { margin: 0; padding: 0; box-sizing: border-box; }
        body { font-family: DejaVu Sans, sans-serif; font-size: 11px; color: #1f2937; background: #fff; }
        .header { background: #ff7b00; color: white; padding: 24px 32px; }
        .header h1 { font-size: 20px; font-weight: bold; margin-bottom: 4px; }
        .header .subtitle { font-size: 12px; opacity: 0.85; }
        .badge { display: inline-block; padding: 3px 10px; border-radius: 20px; font-size: 10px; font-weight: bold; }
        .badge-published { background: #d1fae5; color: #065f46; }
        .badge-draft { background: #f3f4f6; color: #374151; }
        .badge-closed { background: #fee2e2; color: #991b1b; }
        .meta-bar { background: #fff7ed; border-bottom: 2px solid #ff7b00; padding: 12px 32px; display: flex; gap: 24px; flex-wrap: wrap; }
        .meta-item { font-size: 10px; color: #6b7280; }
        .meta-item strong { color: #1f2937; font-size: 11px; }
        .content { padding: 24px 32px; }
        .section { margin-bottom: 24px; }
        .section-title { font-size: 13px; font-weight: bold; color: #ff7b00; border-bottom: 1px solid #fed7aa; padding-bottom: 6px; margin-bottom: 12px; }
        .section-body { font-size: 11px; line-height: 1.7; color: #374151; white-space: pre-wrap; }
        .info-grid { display: table; width: 100%; border-collapse: collapse; margin-bottom: 20px; }
        .info-row { display: table-row; }
        .info-cell { display: table-cell; padding: 6px 8px; border: 1px solid #e5e7eb; font-size: 10px; }
        .info-cell.label { background: #f9fafb; font-weight: bold; color: #6b7280; width: 30%; }
        .info-cell.value { color: #1f2937; }
        .footer { margin-top: 32px; padding: 12px 32px; border-top: 1px solid #e5e7eb; font-size: 9px; color: #9ca3af; text-align: center; }
        .status-row { margin-bottom: 12px; }
    </style>
</head>
<body>

<div class="header">
    <div class="status-row">
        @php
            $statusLabel = match($job->status) {
                'published' => 'Yayında',
                'draft' => 'Taslak',
                'closed' => 'Kapalı',
                default => $job->status,
            };
            $badgeClass = match($job->status) {
                'published' => 'badge-published',
                'draft' => 'badge-draft',
                'closed' => 'badge-closed',
                default => 'badge-draft',
            };
        @endphp
        <span class="badge {{ $badgeClass }}">{{ $statusLabel }}</span>
    </div>
    <h1>{{ $job->title }}</h1>
    <div class="subtitle">{{ $job->department }} · {{ $job->location }} · {{ $job->employment_type }}</div>
</div>

<div class="meta-bar">
    <div class="meta-item">Oluşturulma: <strong>{{ $job->created_at->format('d.m.Y') }}</strong></div>
    @if($job->published_at)
    <div class="meta-item">Yayın Tarihi: <strong>{{ $job->published_at->format('d.m.Y') }}</strong></div>
    @endif
    @if($job->closes_at)
    <div class="meta-item">Son Başvuru: <strong>{{ $job->closes_at->format('d.m.Y') }}</strong></div>
    @endif
    @if($job->salary_range)
    <div class="meta-item">Maaş Aralığı: <strong>{{ $job->salary_range }}</strong></div>
    @endif
    @if($job->working_hours)
    <div class="meta-item">Çalışma Saatleri: <strong>{{ $job->working_hours }}</strong></div>
    @endif
</div>

<div class="content">

    <div class="section">
        <div class="section-title">İlan Bilgileri</div>
        <table class="info-grid" style="width:100%; border-collapse:collapse;">
            <tr>
                <td class="info-cell label">Departman</td>
                <td class="info-cell value">{{ $job->department }}</td>
                <td class="info-cell label">Konum</td>
                <td class="info-cell value">{{ $job->location }}</td>
            </tr>
            <tr>
                <td class="info-cell label">Çalışma Tipi</td>
                <td class="info-cell value">{{ $job->employment_type }}</td>
                <td class="info-cell label">Durum</td>
                <td class="info-cell value">{{ $statusLabel }}</td>
            </tr>
            @if($job->salary_range)
            <tr>
                <td class="info-cell label">Maaş Aralığı</td>
                <td class="info-cell value">{{ $job->salary_range }}</td>
                <td class="info-cell label">Çalışma Saatleri</td>
                <td class="info-cell value">{{ $job->working_hours ?? '—' }}</td>
            </tr>
            @endif
        </table>
    </div>

    <div class="section">
        <div class="section-title">Pozisyon Açıklaması</div>
        <div class="section-body">{{ $job->description }}</div>
    </div>

    <div class="section">
        <div class="section-title">Aranan Nitelikler</div>
        <div class="section-body">{{ $job->requirements }}</div>
    </div>

</div>

@if(isset($settings) && ($settings->application_url || $settings->company_email || $settings->company_phone))
<div style="margin: 0 32px 0 32px; padding: 16px 20px; background: #fff7ed; border: 1px solid #fed7aa; border-radius: 8px; border-left: 4px solid #ff7b00;">
    <div style="font-size: 12px; font-weight: bold; color: #ff7b00; margin-bottom: 10px; text-transform: uppercase; letter-spacing: 0.5px;">Nasıl Başvurulur?</div>
    <table style="width:100%; border-collapse:collapse;">
        <tr>
            <td style="vertical-align:top; padding:0; width:60%;">
                @if($settings->application_url)
                <div style="font-size:10px; color:#6b7280; margin-bottom:3px;">Başvuru Linki</div>
                <div style="font-size:12px; font-weight:bold; color:#1f2937; margin-bottom:8px;">{{ $settings->application_url }}</div>
                @endif
                @if($settings->company_email)
                <div style="font-size:10px; color:#6b7280; margin-bottom:3px;">E-posta</div>
                <div style="font-size:11px; color:#374151; margin-bottom:8px;">{{ $settings->company_email }}</div>
                @endif
                @if($settings->company_phone)
                <div style="font-size:10px; color:#6b7280; margin-bottom:3px;">Telefon</div>
                <div style="font-size:11px; color:#374151;">{{ $settings->company_phone }}</div>
                @endif
            </td>
            <td style="vertical-align:top; padding:0; text-align:right;">
                @if($job->closes_at && !$job->closes_at->isPast())
                <div style="display:inline-block; background:#ff7b00; color:#fff; font-size:10px; font-weight:bold; padding:6px 14px; border-radius:20px;">
                    Son Basvuru: {{ $job->closes_at->format('d.m.Y') }}
                </div>
                @elseif($job->closes_at && $job->closes_at->isPast())
                <div style="display:inline-block; background:#fee2e2; color:#991b1b; font-size:10px; font-weight:bold; padding:6px 14px; border-radius:20px; border:1px solid #fca5a5;">
                    ⚠ Son basvuru tarihi gecti
                </div>
                @endif
            </td>
        </tr>
    </table>
</div>
@endif

<div class="footer">
    Bu belge {{ now()->format('d.m.Y H:i') }} tarihinde Markamama Kariyer Yönetim Paneli tarafından oluşturulmuştur.
    @if($job->closes_at && $job->closes_at->isPast())
    · ⚠ Son başvuru tarihi geçmiştir.
    @endif
</div>

</body>
</html>