
<?php $__env->startSection('title', 'Detail Verifikasi Audit'); ?>

<?php $__env->startSection('content'); ?>
<div
    x-data="{
        showStatusModal: false,
        selectedStatus: <?php echo \Illuminate\Support\Js::from(strtolower($audit->status ?? 'open'))->toHtml() ?>,
        showSuccess: <?php echo e(session('success') ? 'true' : 'false'); ?>

    }"
    x-init="
            selectedStatus = (['open','close'].includes(String(selectedStatus).toLowerCase()))
                ? String(selectedStatus).toLowerCase()
                : 'open';

            if(showSuccess){
                setTimeout(() => showSuccess = false, 3000);
            }
        "
    class="min-h-screen bg-slate-50 p-3"
>

    <style>
        [x-cloak] {
            display: none !important;
        }

        .select-clean {
            appearance: none !important;
            -webkit-appearance: none !important;
            -moz-appearance: none !important;
            background-image: none !important;
        }

        .select-clean::-ms-expand {
            display: none !important;
        }

        .label-clean {
            display: block;
            margin-bottom: 4px;
            font-size: 11px;
            font-weight: 700;
            color: #64748b;
        }

        .input-clean {
            height: 36px;
            width: 100%;
            border-radius: 10px;
            border: 1px solid #e2e8f0;
            background: #f8fafc;
            padding: 0 12px;
            font-size: 12px;
            color: #334155;
            outline: none;
            transition: all .2s ease;
        }

        .input-clean:focus {
            border-color: #3b82f6;
            background: #ffffff;
            box-shadow: 0 0 0 3px rgba(59, 130, 246, .12);
        }

        .readonly-clean {
            min-height: 36px;
            border-radius: 10px;
            border: 1px solid #e2e8f0;
            background: #f8fafc;
            padding: 9px 12px;
            font-size: 12px;
            font-weight: 500;
            color: #334155;
        }

        .btn-modern {
            height: 36px;
            display: inline-flex;
            align-items: center;
            justify-content: center;
            gap: 7px;
            border-radius: 12px;
            padding: 0 16px;
            font-size: 12px;
            font-weight: 600;
            line-height: 1;
            border: none !important;
            outline: none;
            white-space: nowrap;
            transition: all .2s ease;
            box-shadow: 0 6px 14px rgba(15, 23, 42, .08);
        }

        .btn-modern svg,
        .btn-modern i {
            width: 14px;
            height: 14px;
            font-size: 12px;
        }

        .btn-modern:hover {
            transform: translateY(-1px);
        }

        .btn-modern:active {
            transform: translateY(0);
        }

        .btn-primary {
            color: #ffffff;
            background: #3b82f6;
        }

        .btn-primary:hover {
            background: #2563eb;
            box-shadow: 0 8px 18px rgba(37, 99, 235, .22);
        }

        .btn-red {
            color: #ffffff;
            background: #dc2626;
        }

        .btn-red:hover {
            background: #b91c1c;
            box-shadow: 0 8px 18px rgba(220, 38, 38, .20);
        }

        .btn-dark {
            color: #ffffff;
            background: #334155;
        }

        .btn-dark:hover {
            background: #0f172a;
            box-shadow: 0 8px 18px rgba(15, 23, 42, .20);
        }

        .btn-gray {
            color: #475569;
            background: #e5e7eb;
        }

        .btn-gray:hover {
            color: #334155;
            background: #d1d5db;
            box-shadow: 0 8px 16px rgba(15, 23, 42, .10);
        }

        @media print {
            .print-hidden {
                display: none !important;
            }

            .print-card {
                box-shadow: none !important;
                border: 1px solid #e5e7eb !important;
            }
        }
    </style>

    <div class="mx-auto max-w-6xl">

        
        <template x-if="showSuccess">
            <div x-show="showSuccess"
                x-transition.opacity
                class="fixed inset-0 z-50 flex items-center justify-center bg-slate-950/20 px-4">
                <div class="w-full max-w-xs rounded-xl bg-white px-4 py-4 text-center shadow-2xl">
                    <div class="mx-auto mb-3 flex h-10 w-10 items-center justify-center rounded-full bg-green-600 text-white">
                        <i class="fas fa-check text-sm"></i>
                    </div>

                    <p class="text-sm font-bold text-slate-800">
                        Audit berhasil diperbarui!
                    </p>

                    <p class="mt-1 text-xs text-slate-500">
                        Perubahan data audit telah tersimpan.
                    </p>
                </div>
            </div>
        </template>

        
        <div class="mb-4 overflow-hidden rounded-xl border border-slate-200 bg-white shadow-sm print-hidden">
            <div class="flex flex-col gap-3 px-4 py-3 lg:flex-row lg:items-center lg:justify-between">

                <div class="flex items-center gap-3">
                    <div
                        class="flex h-10 w-10 items-center justify-center rounded-xl shadow-sm"
                        style="background-color: rgba(47, 67, 91, 0.10); border: 1px solid rgba(47, 67, 91, 0.12);">
                        <i
                            data-lucide="badge-check"
                            class="h-5 w-5"
                            style="color:#2f435b;"
                            stroke-width="2.3"
                        ></i>
                    </div>

                    <div>
                        <h2 class="text-base font-semibold tracking-tight text-slate-800">
                            Detail Verifikasi Audit
                        </h2>
                        <p class="mt-0.5 text-xs text-slate-500">
                            Menentukan Status Audit
                        </p>
                    </div>
                </div>

                <div class="flex flex-wrap items-center justify-end gap-2">
                    <a
                        href="<?php echo e(route('admin.audit.export.pdf', $audit->id)); ?>"
                        class="btn-modern btn-red"
                    >
                        <i data-lucide="file-text"></i>
                        PDF
                    </a>

                    <button
                        onclick="window.print()"
                        type="button"
                        class="btn-modern btn-dark"
                    >
                        <i data-lucide="printer"></i>
                        Print
                    </button>

                    <?php if(auth('admin')->user()->role === 'superadmin'): ?>
                        <form
                            action="<?php echo e(route('admin.audit.destroy', $audit->id)); ?>"
                            method="POST"
                            onsubmit="return confirm('Yakin ingin menghapus data audit ini?')"
                            class="inline"
                        >
                            <?php echo csrf_field(); ?>
                            <?php echo method_field('DELETE'); ?>

                            <button
                                type="submit"
                                class="btn-modern btn-dark hover:!bg-red-700"
                            >
                                <i data-lucide="trash-2"></i>
                                Hapus Audit
                            </button>
                        </form>
                    <?php endif; ?>
                </div>

            </div>
        </div>

        
        <form x-ref="auditForm" action="<?php echo e(route('admin.audit.update', $audit->id)); ?>" method="POST" class="relative z-10">
            <?php echo csrf_field(); ?>
            <?php echo method_field('PUT'); ?>

            
            <?php if($errors->any()): ?>
                <div class="mb-4 overflow-hidden rounded-xl border border-red-200 bg-red-50 px-4 py-3 text-xs text-red-700 shadow-sm">
                    <div class="flex items-start gap-3">
                        <div class="flex h-8 w-8 shrink-0 items-center justify-center rounded-lg bg-red-100 text-red-600">
                            <i class="fas fa-triangle-exclamation text-xs"></i>
                        </div>

                        <div>
                            <p class="font-bold">Terjadi kesalahan:</p>
                            <ul class="mt-1 list-inside list-disc space-y-1">
                                <?php $__currentLoopData = $errors->all(); $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $e): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                    <li><?php echo e($e); ?></li>
                                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                            </ul>
                        </div>
                    </div>
                </div>
            <?php endif; ?>

            
            <input type="hidden" name="status" :value="selectedStatus">

            
            <div class="mb-4 overflow-hidden rounded-xl border border-slate-200 bg-white shadow-sm print-card">
                <div class="border-b border-slate-100 px-4 py-3">
                    <div class="flex items-center gap-3">
                        <div
                            class="flex h-10 w-10 items-center justify-center rounded-xl shadow-sm"
                            style="background-color:#eef4fa; border: 1px solid rgba(47, 67, 91, 0.10);"
                        >
                            <i
                                data-lucide="info"
                                class="h-5 w-5"
                                style="color:#2f435b;"
                                stroke-width="2.3"
                            ></i>
                        </div>

                        <div>
                            <h3 class="text-sm font-semibold text-slate-800">Informasi Audit</h3>
                            <p class="mt-0.5 text-[11px] text-slate-500">
                                Data utama audit 5S yang sudah tersimpan.
                            </p>
                        </div>
                    </div>
                </div>

                <div class="bg-white px-4 py-4">
                    <div class="grid grid-cols-1 gap-3 md:grid-cols-2">

                        <?php $__currentLoopData = [
                            'Nama Auditor'   => $audit->auditor,
                            'Nama Auditee'   => $audit->auditi,
                            'Divisi Auditor' => $audit->user->bagian->nama_bagian ?? '-',
                        ]; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $label => $value): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                            <div>
                                <label class="label-clean"><?php echo e($label); ?></label>
                                <div class="readonly-clean">
                                    <?php echo e($value); ?>

                                </div>
                            </div>
                        <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>

                        <div>
                            <label class="label-clean">Divisi yang Diaudit</label>

                            <?php if(auth('admin')->user()->role === 'superadmin'): ?>
                                <select name="bagian_id" class="select-clean input-clean">
                                    <?php $__currentLoopData = $bagianList; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $bagian): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                        <option value="<?php echo e($bagian->id); ?>" <?php echo e($audit->bagian_id == $bagian->id ? 'selected' : ''); ?>>
                                            <?php echo e($bagian->nama_bagian); ?>

                                        </option>
                                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                </select>
                            <?php else: ?>
                                <div class="readonly-clean">
                                    <?php echo e($audit->bagian->nama_bagian ?? '-'); ?>

                                </div>
                            <?php endif; ?>
                        </div>

                        <div>
                            <label class="label-clean">Tema Audit</label>

                            <input
                                type="text"
                                name="tema"
                                value="<?php echo e($audit->tema->nama); ?>"
                                class="input-clean">
                        </div>

                        <div>
                            <label class="label-clean">Kategori Audit</label>

                            <?php $kategoriOptions = ['Ringkas','Rapi','Resik','Safety','ISO 14001','Lainnya']; ?>

                            <?php if(auth('admin')->user()->role === 'superadmin'): ?>
                                <select name="kategori" class="select-clean input-clean">
                                    <?php $__currentLoopData = $kategoriOptions; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $kategori): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                        <option value="<?php echo e($kategori); ?>" <?php echo e($audit->kategori === $kategori ? 'selected' : ''); ?>>
                                            <?php echo e($kategori); ?>

                                        </option>
                                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                </select>
                            <?php else: ?>
                                <div class="readonly-clean">
                                    <?php echo e($audit->kategori); ?>

                                </div>
                            <?php endif; ?>
                        </div>

                        <div>
                            <label class="label-clean">Tanggal Audit</label>

                            <div class="readonly-clean">
                                <?php echo e(\Carbon\Carbon::parse($audit->tanggal_audit)->translatedFormat('d F Y')); ?>

                            </div>
                        </div>

                        <div>
                            <label class="label-clean">Tanggal Verifikasi</label>

                            <?php
                                $tanggalVerifikasi = $audit->tanggal_verifikasi
                                    ? \Carbon\Carbon::parse($audit->tanggal_verifikasi)->format('Y-m-d')
                                    : '';
                            ?>

                            <?php if(auth('admin')->user()->role==='superadmin'): ?>
                                <input
                                    type="date"
                                    name="tanggal_verifikasi"
                                    value="<?php echo e(old('tanggal_verifikasi', $tanggalVerifikasi)); ?>"
                                    class="input-clean">
                            <?php else: ?>
                                <div class="readonly-clean">
                                    <?php echo e($audit->tanggal_verifikasi
                                        ? \Carbon\Carbon::parse($audit->tanggal_verifikasi)->translatedFormat('d F Y')
                                        : '-'); ?>

                                </div>
                            <?php endif; ?>
                        </div>

                    </div>
                </div>
            </div>

            
            <div class="mb-4 overflow-hidden rounded-xl border border-slate-200 bg-white shadow-sm print-card">
                <div class="border-b border-slate-100 px-4 py-3">
                    <div class="flex items-center gap-3">
                        <div
                            class="flex h-10 w-10 items-center justify-center rounded-xl shadow-sm"
                            style="background-color:#ecfdf5; border: 1px solid #bbf7d0;"
                        >
                            <i
                                data-lucide="user-check"
                                class="h-5 w-5"
                                style="color:#16a34a;"
                                stroke-width="2.3"
                            ></i>
                        </div>

                        <div>
                            <h3 class="text-sm font-semibold text-slate-800">
                                PIC Perbaikan <span class="text-red-500">*</span>
                            </h3>
                            <p class="mt-0.5 text-[11px] text-slate-500">
                                Tentukan penanggung jawab perbaikan temuan audit.
                            </p>
                        </div>
                    </div>
                </div>

                <div class="px-4 py-4">
                    <input
                        type="text"
                        name="pic_perbaikan"
                        class="h-10 w-full rounded-xl border border-blue-200 bg-blue-50/40 px-3 text-sm font-medium text-slate-700 outline-none transition placeholder:text-slate-400 focus:border-blue-500 focus:bg-white focus:ring-4 focus:ring-blue-100"
                        value="<?php echo e(old('pic_perbaikan', $audit->pic_perbaikan ?? '')); ?>"
                        placeholder="Masukkan PIC Perbaikan"
                        required
                    >
                </div>
            </div>

            
            <div class="mb-4 overflow-hidden rounded-xl border border-slate-200 bg-white shadow-sm print-card">
                <div class="border-b border-slate-100 px-4 py-3">
                    <div class="flex items-center gap-3">
                        <div
                            class="flex h-10 w-10 items-center justify-center rounded-xl shadow-sm"
                            style="background-color:#f8fafc; border: 1px solid #e2e8f0;"
                        >
                            <i
                                data-lucide="map-pin"
                                class="h-5 w-5"
                                style="color:#64748b;"
                                stroke-width="2.3"
                            ></i>
                        </div>

                        <div>
                            <h3 class="text-sm font-semibold text-slate-800">Area Temuan</h3>
                            <p class="mt-0.5 text-[11px] text-slate-500">
                                Lokasi atau area temuan audit.
                            </p>
                        </div>
                    </div>
                </div>

                <div class="px-4 py-4">
                    <input
                        type="text"
                        name="lokasi"
                        value="<?php echo e($audit->lokasi); ?>"
                        class="input-clean"
                        placeholder="Masukkan area temuan">
                </div>
            </div>

            
            <div class="mb-4 grid grid-cols-1 gap-4 md:grid-cols-2">
                <div class="overflow-hidden rounded-xl border border-slate-200 bg-white shadow-sm print-card">
                    <div class="border-b border-slate-100 px-4 py-3">
                        <div class="flex items-center gap-3">
                            <div
                                class="flex h-10 w-10 items-center justify-center rounded-xl shadow-sm"
                                style="background-color:#fff7ed; border: 1px solid #fed7aa;"
                            >
                                <i
                                    data-lucide="file-warning"
                                    class="h-5 w-5"
                                    style="color:#f97316;"
                                    stroke-width="2.3"
                                ></i>
                            </div>

                            <div>
                                <h3 class="text-sm font-semibold text-slate-800">Keterangan Sebelum</h3>
                                <p class="mt-0.5 text-[11px] text-slate-500">
                                    Catatan temuan sebelum perbaikan.
                                </p>
                            </div>
                        </div>
                    </div>

                    <div class="px-4 py-4">
                        <div class="min-h-[90px] rounded-xl border border-slate-200 bg-slate-50 px-3 py-2 text-xs leading-relaxed text-slate-700">
                            <?php echo e($audit->keterangan); ?>

                        </div>
                    </div>
                </div>

                <div class="overflow-hidden rounded-xl border border-slate-200 bg-white shadow-sm print-card">
                    <div class="border-b border-slate-100 px-4 py-3">
                        <div class="flex items-center gap-3">
                            <div
                                class="flex h-10 w-10 items-center justify-center rounded-xl shadow-sm"
                                style="background-color:#ecfdf5; border: 1px solid #bbf7d0;"
                            >
                                <i
                                    data-lucide="file-check"
                                    class="h-5 w-5"
                                    style="color:#16a34a;"
                                    stroke-width="2.3"
                                ></i>
                            </div>

                            <div>
                                <h3 class="text-sm font-semibold text-slate-800">Keterangan Sesudah</h3>
                                <p class="mt-0.5 text-[11px] text-slate-500">
                                    Catatan tindak lanjut setelah perbaikan.
                                </p>
                            </div>
                        </div>
                    </div>

                    <div class="px-4 py-4">
                        <textarea
                            name="keterangan_sesudah"
                            class="min-h-[90px] w-full rounded-xl border border-slate-200 bg-slate-50 px-3 py-2 text-xs leading-relaxed text-slate-700 outline-none transition placeholder:text-slate-400 focus:border-blue-500 focus:bg-white focus:ring-2 focus:ring-blue-100"><?php echo e(old('keterangan_sesudah', $audit->keterangan_sesudah)); ?></textarea>
                    </div>
                </div>
            </div>

            
            <div class="mb-4 grid grid-cols-1 gap-4 md:grid-cols-2 print:hidden">
                <div class="overflow-hidden rounded-xl border border-slate-200 bg-white shadow-sm">
                    <div class="border-b border-slate-100 px-4 py-3">
                        <div class="flex items-center gap-3">
                            <div
                                class="flex h-10 w-10 items-center justify-center rounded-xl shadow-sm"
                                style="background-color:#fff1f2; border: 1px solid #fecdd3;"
                            >
                                <i
                                    data-lucide="image"
                                    class="h-5 w-5"
                                    style="color:#e11d48;"
                                    stroke-width="2.3"
                                ></i>
                            </div>

                            <div>
                                <h3 class="text-sm font-semibold text-slate-800">Foto Sebelum</h3>
                                <p class="mt-0.5 text-[11px] text-slate-500">
                                    Dokumentasi kondisi awal.
                                </p>
                            </div>
                        </div>
                    </div>

                    <div class="p-4">
                        <?php if($audit->foto_sebelum && file_exists(public_path('storage/'.$audit->foto_sebelum))): ?>
                            <a href="<?php echo e(asset('storage/'.$audit->foto_sebelum)); ?>" target="_blank" rel="noopener"
                                class="block overflow-hidden rounded-xl border border-slate-200 bg-slate-50">
                                <img src="<?php echo e(asset('storage/'.$audit->foto_sebelum)); ?>"
                                    class="h-56 w-full object-contain transition hover:scale-[1.01]"
                                    alt="Foto Sebelum">
                            </a>
                        <?php else: ?>
                            <div class="flex h-56 items-center justify-center rounded-xl border border-dashed border-red-200 bg-red-50 text-xs font-medium text-red-500">
                                Foto sebelum tidak ditemukan.
                            </div>
                        <?php endif; ?>
                    </div>
                </div>

                <div class="overflow-hidden rounded-xl border border-slate-200 bg-white shadow-sm">
                    <div class="border-b border-slate-100 px-4 py-3">
                        <div class="flex items-center gap-3">
                            <div
                                class="flex h-10 w-10 items-center justify-center rounded-xl shadow-sm"
                                style="background-color:#ecfdf5; border: 1px solid #bbf7d0;"
                            >
                                <i
                                    class="fas fa-image text-[18px]"
                                    style="color:#16a34a;"
                                ></i>
                            </div>

                            <div>
                                <h3 class="text-sm font-semibold text-slate-800">Foto Sesudah</h3>
                                <p class="mt-0.5 text-[11px] text-slate-500">
                                    Dokumentasi setelah perbaikan.
                                </p>
                            </div>
                        </div>
                    </div>

                    <div class="p-4">
                        <?php if($audit->foto_sesudah && file_exists(public_path('storage/'.$audit->foto_sesudah))): ?>
                            <a href="<?php echo e(asset('storage/'.$audit->foto_sesudah)); ?>" target="_blank" rel="noopener"
                                class="block overflow-hidden rounded-xl border border-slate-200 bg-slate-50">
                                <img src="<?php echo e(asset('storage/'.$audit->foto_sesudah)); ?>"
                                    class="h-56 w-full object-contain transition hover:scale-[1.01]"
                                    alt="Foto Sesudah">
                            </a>
                        <?php else: ?>
                            <div class="flex h-56 items-center justify-center rounded-xl border border-dashed border-slate-200 bg-slate-50 text-xs font-medium italic text-slate-500">
                                Belum ada foto sesudah.
                            </div>
                        <?php endif; ?>
                    </div>
                </div>
            </div>

            
            <div class="mt-4 flex flex-col gap-3 rounded-xl border border-slate-200 bg-white px-4 py-3 shadow-sm sm:flex-row sm:items-center sm:justify-between print:hidden">
                <a
                    href="<?php echo e(route('admin.audit.verifikasi')); ?>"
                    class="btn-modern btn-gray"
                >
                    <i class="fas fa-arrow-left text-[12px]"></i>
                    Kembali
                </a>

                <?php if(auth('admin')->user()->role==='superadmin'): ?>
                    <button
                        type="button"
                        @click="showStatusModal = true"
                        class="btn-modern btn-primary"
                    >
                        <i data-lucide="check"></i>
                        Verifikasi
                    </button>
                <?php endif; ?>
            </div>
        </form>

        
        <template x-if="showStatusModal">
            <div class="fixed inset-0 z-50 flex items-center justify-center bg-slate-950/50 px-4 backdrop-blur-sm">
                <div class="w-full max-w-sm overflow-hidden rounded-xl bg-white shadow-2xl">
                    <div class="border-b border-slate-100 px-4 py-3">
                        <div class="flex items-center gap-3">
                            <div class="flex h-10 w-10 items-center justify-center rounded-xl bg-blue-500 shadow-sm">
                                <i class="fas fa-clipboard-check text-[18px] text-white"></i>
                            </div>

                            <div>
                                <h3 class="text-sm font-semibold text-slate-800">Pilih Status Audit</h3>
                                <p class="mt-0.5 text-[11px] text-slate-500">
                                    Konfirmasi perubahan data audit.
                                </p>
                            </div>
                        </div>
                    </div>

                    <div class="px-4 py-4">
                        <div class="space-y-2 rounded-xl border border-slate-200 bg-slate-50 px-3 py-3">
                            <label class="flex items-center">
                                <input type="radio"
                                    class="h-4 w-4 border-slate-300 text-blue-600 focus:ring-blue-500"
                                    value="open"
                                    x-model="selectedStatus">

                                <span class="ml-2 text-xs font-semibold text-slate-700">
                                    Open
                                </span>
                            </label>

                            <label class="flex items-center">
                                <input type="radio"
                                    class="h-4 w-4 border-slate-300 text-blue-600 focus:ring-blue-500"
                                    value="close"
                                    x-model="selectedStatus">

                                <span class="ml-2 text-xs font-semibold text-slate-700">
                                    Close
                                </span>
                            </label>
                        </div>

                        <p class="mt-3 text-xs leading-relaxed text-slate-500">
                            Apakah Anda yakin ingin menyimpan perubahan dengan status ini?
                        </p>
                    </div>

                    <div class="flex justify-end gap-2 border-t border-slate-100 bg-slate-50 px-4 py-3">
                        <button
                            type="button"
                            @click="showStatusModal = false"
                            class="btn-modern btn-gray"
                        >
                            Batal
                        </button>

                        <button
                            type="button"
                            @click="$refs.auditForm.submit()"
                            class="btn-modern btn-primary"
                        >
                            Simpan
                        </button>
                    </div>
                </div>
            </div>
        </template>

    </div>
</div>
<?php $__env->stopSection(); ?>
<?php echo $__env->make('admin.layouts.app', array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?><?php /**PATH C:\xampp\htdocs\ea-systems\resources\views/admin/verifikasi-detail.blade.php ENDPATH**/ ?>