{{-- Durum --}}
<div class="form-card">
    <div class="fsh">
        <div class="fsh-icon" style="background:#f1f5f9;color:#64748b"><i
                class="fas fa-cog"></i></div>
        <div class="fsh-title">Durum & Atama</div>
    </div>
    <div class="fsb">
        <div class="fl mb-3">
            <div class="fl mb-3"><label>Durum <span class="req">*</span></label>
            <select name="status" class="fi">
                @foreach([
                    'potential' => 'Potansiyel',
                    'offer_sent' => 'Teklif Verildi',
                    'revised' => 'Revize Edildi',
                    'confirmed' => 'Satış Tamamlandı',
                    'in_progress' => 'Devam Ediyor',
                    'completed' => 'Kapanan',
                    'cancelled' => 'İptal Edildi',
                    'refunded' => 'İade Edildi'
                ] as $v => $l)
                    <option value="{{ $v }}" {{ old('status', $reservation->status) === $v ? 'selected' : '' }}>{{ $l }}
                </option>@endforeach
            </select>
        </div>
        <div class="fl mb-3">
            <label>Ödeme Durumu <span style="color:#ef4444">*</span></label>
            <select name="payment_status" class="field-input">
                @foreach(['unpaid' => 'Ödenmedi', 'partial' => 'Kısmi Ödendi', 'paid' => 'Ödendi', 'refunded' => 'İade'] as $v => $l)
                    <option value="{{ $v }}" {{ old('payment_status', $reservation->payment_status) === $v ? 'selected' : '' }}>
                        {{ $l }}</option>
                @endforeach
            </select>
        </div>
        <div class="fl">
            <label>Atanan Temsilci</label>
            <select name="assigned_to" class="field-input">
                <option value="">— Seçin —</option>
                @foreach($agents as $a)
                    <option value="{{ $a->id }}" {{ old('assigned_to', $reservation->assigned_to) == $a->id ? 'selected' : '' }}>
                        {{ $a->first_name }} {{ $a->last_name }}</option>
                @endforeach
            </select>
        </div>
    </div>
</div>

{{-- Müşteri Bilgileri --}}
<div class="form-card" id="customerDetailsCard" style="display:none; margin-bottom:1.5rem">
    <div class="fsh">
        <div class="fsh-icon" style="background:#ede9fe;color:#8b5cf6"><i class="fas fa-user-check"></i></div>
        <div class="fsh-title">Müşteri Bilgileri</div>
    </div>
    <div class="fsb" id="customerSummaryHtml" style="font-size: 0.82rem; color: #475569;">
    </div>
</div>

{{-- Fiyatlandırma --}}
<div class="form-card">
    <div class="fsh">
        <div class="fsh-icon" style="background:#d1fae5;color:#10b981"><i
                class="fas fa-lira-sign"></i></div>
        <div class="fsh-title">Fiyatlandırma</div>
    </div>
    <div class="fsb">
        <div class="fl mb-3">
            <label>Yetişkin Birim Fiyat</label>
            <input type="number" step="0.01" name="unit_price"
                value="{{ old('unit_price', $reservation->unit_price) }}" class="field-input"
                id="unitPrice" oninput="calcPrice()">
        </div>
        <div class="fg-2 mb-3">
            <div class="fl">
                <label>Çocuk Fiyatı</label>
                <input type="number" step="0.01" name="child_price"
                    value="{{ old('child_price', $reservation->child_price) }}"
                    class="field-input" id="childPrice" oninput="calcPrice()">
            </div>
            <div class="fl">
                <label>Bebek Fiyatı</label>
                <input type="number" step="0.01" name="infant_price"
                    value="{{ old('infant_price', $reservation->infant_price) }}"
                    class="field-input" id="infantPrice" oninput="calcPrice()">
            </div>
        </div>
        <div class="fg-2 mb-3">
            <div class="fl">
                <label>İndirim (%)</label>
                <input type="number" step="0.01" name="discount_rate"
                    value="{{ old('discount_rate', $reservation->discount_rate) }}"
                    class="field-input" id="discountRate" oninput="calcPrice()">
            </div>
            <div class="fl">
                <label>KDV (₺)</label>
                <input type="number" step="0.01" name="tax_amount"
                    value="{{ old('tax_amount', $reservation->tax_amount) }}"
                    class="field-input" id="taxAmount" oninput="calcPrice()">
            </div>
        </div>
        <div class="fl mb-3">
            <label>Tahsil Edilen</label>
            <input type="number" step="0.01" name="paid_amount"
                value="{{ old('paid_amount', $reservation->paid_amount) }}" class="field-input"
                id="paidAmount" oninput="calcPrice()">
        </div>

        <div class="price-panel">
            <div class="pr-row"><span>Ara Toplam</span><span
                    id="displaySubtotal">{{ number_format($reservation->subtotal ?? 0, 2) }}</span>
            </div>
            <div class="pr-row" style="color:#fde68a"><span>İndirim</span><span
                    id="displayDiscount">-
                    {{ number_format($reservation->discount_amount, 2) }}</span></div>
            <div class="pr-row"><span>KDV</span><span id="displayTax">+
                    {{ number_format($reservation->tax_amount, 2) }}</span></div>
            <hr class="pr-div">
            <div class="pr-row pr-total"><span>Toplam</span><span
                    id="displayTotal">{{ number_format($reservation->total_amount ?? 0, 2) }}
                    {{ $reservation->currency }}</span></div>
            <div class="pr-row" style="color:#fda4af"><span>Kalan</span><span
                    id="displayRemaining">{{ number_format($reservation->remaining_amount ?? 0, 2) }}</span>
            </div>

            <input type="hidden" name="total_amount" id="hiddenTotal"
                value="{{ $reservation->total_amount }}">
            <input type="hidden" name="remaining_amount" id="hiddenRemaining"
                value="{{ $reservation->remaining_amount }}">
            <input type="hidden" name="subtotal" id="hiddenSubtotal"
                value="{{ $reservation->subtotal }}">
            <input type="hidden" name="discount_amount" id="hiddenDiscountAmt"
                value="{{ $reservation->discount_amount }}">
        </div>

        <div class="fl mt-3">
            <label>Para Birimi</label>
            <select name="currency" class="field-input">
                <option value="TRY" {{ old('currency', $reservation->currency) === 'TRY' ? 'selected' : '' }}>₺ TRY
                </option>
                <option value="USD" {{ old('currency', $reservation->currency) === 'USD' ? 'selected' : '' }}>$ USD
                </option>
                <option value="EUR" {{ old('currency', $reservation->currency) === 'EUR' ? 'selected' : '' }}>€ EUR
                </option>
            </select>
        </div>
    </div>
</div>
