@extends('layouts/base_view')
@section('title')
{!! $variables['header_routes'] !!}
@endsection
@section('content')
<section class="content">
    <div class="container-fluid">
        <div class="row">
            <div class="col-12">
                <div class="card card-outline card-warning">
                    <div class="card-header">
                        <div class="row align-items-center">
                            <div class="col">
                                <h3 class="card-title mb-0">{{ $variables['judul'] }}</h3>
                            </div>
                            <div class="col-auto">
                                <a href="{{ route('shipment_suppliers.edit', $data->id) }}" class="btn btn-sm btn-warning button-cek-permission" data-permission="shipment_suppliers.edit">
                                    <i class="fas fa-edit"></i> Ubah
                                </a>
                                <a href="{{ route('shipment_suppliers.index') }}" class="btn btn-sm btn-warning ml-2">
                                    <i class="fas fa-arrow-left"></i> Kembali ke Daftar
                                </a>
                            </div>
                        </div>
                    </div>
                    <div class="card-body">
                        <!-- Shipment Supplier Header Info -->
                        <div class="row">
                            <div class="col-md-6">
                                <table class="table table-borderless">
                                    <tr>
                                        <td width="40%"><strong>Kode</strong></td>
                                        <td>: <span class="badge badge-info">{{ $data->code }}</span></td>
                                    </tr>
                                    <tr>
                                        <td><strong>Nama</strong></td>
                                        <td>: {{ $data->name }}</td>
                                    </tr>
                                    <tr>
                                        <td><strong>Kontak Person</strong></td>
                                        <td>: {{ $data->contact_person ?: '-' }}</td>
                                    </tr>
                                    <tr>
                                        <td><strong>Telepon</strong></td>
                                        <td>: {{ $data->phone ?: '-' }}</td>
                                    </tr>
                                    <tr>
                                        <td><strong>Email</strong></td>
                                        <td>: {{ $data->email ?: '-' }}</td>
                                    </tr>
                                    <tr>
                                        <td><strong>Status</strong></td>
                                        <td>: <span class="badge {{ $data->status_badge }}">{{ $data->status }}</span></td>
                                    </tr>
                                </table>
                            </div>
                            <div class="col-md-6">
                                <table class="table table-borderless">
                                    <tr>
                                        <td width="40%"><strong>Hari Kontak</strong></td>
                                        <td>: {{ $data->contact_days_string }}</td>
                                    </tr>
                                    <tr>
                                        <td><strong>Waktu Kontak</strong></td>
                                        <td>: {{ $data->contact_window }}</td>
                                    </tr>
                                    <tr>
                                        <td><strong>Lead Time</strong></td>
                                        <td>: {{ $data->lead_time_days }} hari</td>
                                    </tr>
                                    <tr>
                                        <td><strong>Dapat Dihubungi Hari Ini</strong></td>
                                        <td>: 
                                            @if($data->canContactToday())
                                            <span class="badge badge-success">Ya</span>
                                            @else
                                            <span class="badge badge-secondary">Tidak</span>
                                            @endif
                                        </td>
                                    </tr>
                                    <tr>
                                        <td><strong>Tanggal Kontak Berikutnya</strong></td>
                                        <td>: 
                                            @php
                                            $nextContact = $data->getNextContactDate();
                                            @endphp
                                            @if($nextContact)
                                            <span class="badge badge-info">{{ $nextContact->format('D, M j Y') }}</span>
                                            @else
                                            <span class="badge badge-secondary">Tidak Diatur</span>
                                            @endif
                                        </td>
                                    </tr>
                                    <tr>
                                        <td><strong>Estimasi Pengiriman</strong></td>
                                        <td>: 
                                            @php
                                            $estimatedDelivery = $data->getEstimatedDeliveryDate();
                                            @endphp
                                            @if($estimatedDelivery)
                                            <span class="badge badge-primary">{{ $estimatedDelivery->format('D, M j Y') }}</span>
                                            @else
                                            <span class="badge badge-secondary">Tidak Diatur</span>
                                            @endif
                                        </td>
                                    </tr>
                                </table>
                            </div>
                        </div>

                        <div class="row">
                            <div class="col-12">
                                <table class="table table-borderless">
                                    <tr>
                                        <td width="20%"><strong>Alamat</strong></td>
                                        <td>: {{ $data->address ?: '-' }}</td>
                                    </tr>
                                </table>
                            </div>
                        </div>

                        @if($data->notes)
                        <div class="row">
                            <div class="col-12">
                                <table class="table table-borderless">
                                    <tr>
                                        <td width="20%"><strong>Catatan</strong></td>
                                        <td>: {{ $data->notes }}</td>
                                    </tr>
                                </table>
                            </div>
                        </div>
                        @endif

                        <!-- System Information -->
                        <div class="row mt-3">
                            <div class="col-12">
                                <table class="table table-borderless">
                                    <tr>
                                        <td width="20%"><strong>Dibuat Oleh</strong></td>
                                        <td>: {{ $data->creator->fullname ?? 'System' }} ({{ $data->created_at->format('d M Y, H:i') }})</td>
                                    </tr>
                                    <tr>
                                        <td><strong>Diubah Oleh</strong></td>
                                        <td>: {{ $data->modificator->fullname ?? '-' }} ({{ $data->updated_at ? $data->updated_at->format('d M Y, H:i') : '-' }})</td>
                                    </tr>
                                </table>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</section>
@endsection