@extends('layouts.public')

@section('title', 'Mülakat Simülasyonu')

@section('content')
<style>
    .sim-page { max-width: 900px; margin: 0 auto; padding: 40px 20px; }

    .sim-header { margin-bottom: 36px; }
    .sim-header h1 { font-size: 28px; font-weight: 800; color: #111827; margin-bottom: 8px; }
    .sim-header p { font-size: 15px; color: #6b7280; }

    .sim-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 20px; margin-bottom: 36px; }
    @media (max-width: 768px) { .sim-grid { grid-template-columns: 1fr; } }

    .sim-card { background: #fff; border-radius: 14px; border: 1px solid #e5e7eb; padding: 24px; transition: box-shadow .15s, border-color .15s; }
    .sim-card:hover { box-shadow: 0 4px 12px rgba(0,0,0,.08); border-color: #bfdbfe; }

    .sim-card-inner { display: flex; gap: 16px; align-items: flex-start; }
    .sim-card-icon { font-size: 36px; line-height: 1; flex-shrink: 0; }
    .sim-card-content { flex: 1; }
    .sim-card h3 { font-size: 17px; font-weight: 700; color: #111827; margin-bottom: 6px; }
    .sim-card p { font-size: 13px; color: #6b7280; margin-bottom: 14px; line-height: 1.6; }

    .sim-meta { display: flex; gap: 16px; margin-bottom: 14px; }
    .sim-meta-item { display: flex; align-items: center; gap: 5px; font-size: 12px; color: #9ca3af; }
    .sim-meta-icon { width: 16px; height: 16px; }

    .sim-btn { display: inline-flex; align-items: center; gap: 7px; background: #1d4ed8; color: #fff; padding: 10px 20px; border-radius: 10px; font-size: 14px; font-weight: 600; text-decoration: none; border: none; cursor: pointer; transition: background .15s; }
    .sim-btn:hover { background: #1e40af; color: #fff; text-decoration: none; }
    .sim-btn svg { width: 16px; height: 16px; }

    .sim-history { background: #fff; border-radius: 14px; border: 1px solid #e5e7eb; overflow: hidden; box-shadow: 0 1px 4px rgba(0,0,0,.05); }
    .sim-history-header { padding: 16px 22px; border-bottom: 1px solid #f3f4f6; background: #f9fafb; }
    .sim-history-header h2 { font-size: 17px; font-weight: 700; color: #111827; margin: 0; }

    .sim-history-item { padding: 16px 22px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid #f3f4f6; transition: background .15s; }
    .sim-history-item:last-child { border-bottom: none; }
    .sim-history-item:hover { background: #f9fafb; }

    .sim-history-left { display: flex; align-items: center; gap: 14px; }
    .sim-score-icon { width: 38px; height: 38px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 16px; font-weight: 700; flex-shrink: 0; }
    .sim-score-icon.good { background: #d1fae5; color: #059669; }
    .sim-score-icon.avg { background: #fef3c7; color: #d97706; }
    .sim-history-name { font-size: 14px; font-weight: 600; color: #111827; }
    .sim-history-date { font-size: 12px; color: #9ca3af; margin-top: 2px; }

    .sim-history-right { display: flex; align-items: center; gap: 12px; }
    .sim-score-badge { padding: 4px 12px; border-radius: 20px; font-size: 12px; font-weight: 600; }
    .sim-score-badge.good { background: #d1fae5; color: #059669; }
    .sim-score-badge.avg { background: #fef3c7; color: #d97706; }
    .sim-detail-link { color: #1d4ed8; font-size: 13px; font-weight: 600; text-decoration: none; }
    .sim-detail-link:hover { color: #1e40af; text-decoration: none; }

    .sim-pagination { padding: 14px 22px; border-top: 1px solid #f3f4f6; background: #f9fafb; }
</style>

<div class="sim-page">

    {{-- Header --}}
    <div class="sim-header">
        <h1>Askeri Mülakat Simülasyonu</h1>
        <p>Subay, Astsubay, Uzman Erbaş ve Sözleşmeli Er alımları için gerçekçi mülakat pratiği</p>
    </div>

    {{-- Scenarios Grid --}}
    <div class="sim-grid">
        @foreach($scenarios as $scenario)
        <div class="sim-card">
            <div class="sim-card-inner">
                <div class="sim-card-icon">{{ $scenario['icon'] }}</div>
                <div class="sim-card-content">
                    <h3>{{ $scenario['name'] }}</h3>
                    <p>{{ $scenario['description'] }}</p>
                    <div class="sim-meta">
                        <span class="sim-meta-item">
                            <svg class="sim-meta-icon" fill="none" viewBox="0 0 24 24" stroke="currentColor">
                                <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M8.228 9c.549-1.165 2.03-2 3.772-2 2.21 0 4 1.343 4 3 0 1.4-1.278 2.575-3.006 2.907-.542.104-.994.54-.994 1.093m0 3h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"/>
                            </svg>
                            {{ $scenario['questions'] }} Soru
                        </span>
                        <span class="sim-meta-item">
                            <svg class="sim-meta-icon" fill="none" viewBox="0 0 24 24" stroke="currentColor">
                                <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 8v4l3 3m6-3a9 9 0 11-18 0 9 9 0 0118 0z"/>
                            </svg>
                            {{ $scenario['duration'] }}
                        </span>
                    </div>
                    <a href="{{ route('ai.start_simulation', $scenario['slug']) }}" class="sim-btn">
                        <svg fill="none" viewBox="0 0 24 24" stroke="currentColor">
                            <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2.5" d="M14.752 11.168l-3.197-2.132A1 1 0 0010 9.87v4.263a1 1 0 001.555.832l3.197-2.132a1 1 0 000-1.664z"/>
                            <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2.5" d="M21 12a9 9 0 11-18 0 9 9 0 0118 0z"/>
                        </svg>
                        Başla
                    </a>
                </div>
            </div>
        </div>
        @endforeach
    </div>

    {{-- My Simulations --}}
    @if(auth()->check() && $mySimulations->count() > 0)
    <div class="sim-history">
        <div class="sim-history-header">
            <h2>Geçmiş Simülasyonlarım</h2>
        </div>
        @foreach($mySimulations as $sim)
        <div class="sim-history-item">
            <div class="sim-history-left">
                <div class="sim-score-icon {{ $sim->score >= 70 ? 'good' : 'avg' }}">
                    {{ $sim->score >= 70 ? '✓' : '!' }}
                </div>
                <div>
                    <div class="sim-history-name">{{ $sim->scenario }}</div>
                    <div class="sim-history-date">{{ $sim->created_at->format('d.m.Y H:i') }}</div>
                </div>
            </div>
            <div class="sim-history-right">
                @if($sim->score)
                    <span class="sim-score-badge {{ $sim->score >= 70 ? 'good' : 'avg' }}">
                        {{ $sim->score }}/100
                    </span>
                @endif
                <a href="{{ route('ai.simulation_result', $sim) }}" class="sim-detail-link">Detay</a>
            </div>
        </div>
        @endforeach
        @if($mySimulations->hasPages())
        <div class="sim-pagination">
            {{ $mySimulations->appends(['sort' => request('sort')])->links() }}
        </div>
        @endif
    </div>
    @endif

</div>
@endsection
