
<style>
    /* ═══════════ ORTAK ═══════════ */
    .cpx-wrap, .csx-wrap, .cdx-wrap { display:flex; flex-direction:column; gap:.85rem; }

    .cpx-chip, .cdx-exp { display:inline-flex; align-items:center; gap:4px; border-radius:999px;
        padding:1px 8px; font-size:.65rem; font-weight:800; background:#f1f5f9; color:#64748b; }
    .cpx-chip.soft { background:#eef2ff; color:#4338ca; }
    .cpx-chip.warn { background:#fef3c7; color:#92400e; }
    .cpx-chip.danger { background:#fee2e2; color:#b91c1c; }

    /* ═══════════ YOLCULAR ═══════════ */
    .cpx-bar { display:flex; align-items:center; justify-content:space-between; gap:1rem; flex-wrap:wrap;
        background:linear-gradient(135deg,#f8fafc,#f1f5f9); border:1px solid #e8ecf3; border-radius:14px; padding:.6rem .85rem; }
    .cpx-bar-stats { display:flex; align-items:center; gap:.55rem; flex-wrap:wrap; }
    .cpx-stat { display:inline-flex; align-items:center; gap:6px; font-size:.76rem; font-weight:600; color:#64748b; }
    .cpx-stat i { color:#94a3b8; }
    .cpx-stat b { color:#1e293b; font-weight:800; }
    .cpx-stat.warn i, .cpx-stat.warn b { color:#d97706; }
    .cpx-stat.danger i, .cpx-stat.danger b { color:#dc2626; }
    .cpx-sep { width:1px; height:14px; background:#e2e8f0; }
    .cpx-bar-actions { display:flex; align-items:center; gap:.45rem; }

    .cpx-search { display:flex; align-items:center; gap:6px; background:#fff; border:1.5px solid #e8ecf3;
        border-radius:10px; padding:.28rem .6rem; }
    .cpx-search i { color:#cbd5e1; font-size:.72rem; }
    .cpx-search input { border:none; outline:none; font-size:.76rem; font-weight:600; width:130px; background:transparent; }

    .cpx-add-btn { display:inline-flex; align-items:center; gap:6px; border:none; border-radius:10px;
        background:linear-gradient(135deg,#6366f1,#4f46e5); color:#fff; font-size:.76rem; font-weight:800;
        padding:.45rem .9rem; cursor:pointer; box-shadow:0 5px 14px rgba(79,70,229,.3); transition:.15s; }
    .cpx-add-btn:hover { transform:translateY(-1px); box-shadow:0 8px 20px rgba(79,70,229,.4); }

    .cpx-new { background:#fff; border:1.5px solid #c7d2fe; border-radius:16px; padding:.9rem 1rem;
        box-shadow:0 8px 24px rgba(79,70,229,.1); }
    .cpx-new[hidden] { display:none; }
    .cpx-new-head { font-size:.82rem; font-weight:800; color:#3730a3; margin-bottom:.7rem; }
    .cpx-new-head i { margin-right:6px; }
    .cpx-new-grid { display:grid; grid-template-columns:repeat(auto-fill,minmax(170px,1fr)); gap:.55rem; }
    .cpx-new-foot { display:flex; justify-content:flex-end; gap:.5rem; margin-top:.75rem; }

    /* ── Yolcu tablosu ── */
    /* Satır içi baş harf rozeti tablo satırına sığacak kadar küçülür */
    .qvt .cpx-av { display:inline-grid; width:22px; height:22px; border-radius:7px; font-size:.6rem;
        vertical-align:middle; margin-right:6px; box-shadow:none; }
    .qvt tr.cpx-tr.is-open > td { background:var(--bg-hover,#f8fafc); }
    .qvt tr.cpx-det > td { padding:0; background:var(--bg-inset,#f8fafc); }
    .qvt tr.cpx-det .cpx-card { margin:.6rem .75rem; border-radius:14px; }
    .qvt tr.cpx-det:hover > td { background:var(--bg-inset,#f8fafc); }

    /* ── Yolcu kartı: Özet sekmesindeki künye paneliyle (.pfx) aynı dil ── */
    .cpx-card { transition:border-color .18s, box-shadow .18s; }
    .cpx-card:hover { border-color:#dbe3ee; box-shadow:0 6px 20px rgba(15,23,42,.06); }
    /* Operasyondan gelindiğinde hedef yolcu kartı kısa süre vurgulanır */
    @keyframes cpxFlash { 0%,60% { box-shadow:0 0 0 3px rgba(37,99,235,.32), 0 10px 30px rgba(37,99,235,.14); } 100% { box-shadow:0 6px 20px rgba(15,23,42,.06); } }
    .cpx-card.cpx-flash { animation: cpxFlash 1.8s ease-out; }

    .cpx-head { gap:.4rem; flex-wrap:wrap; }
    .cpx-head > .pfx-chip, .cpx-head > .pfx-b { flex:none; }
    .cpx-av { width:32px; height:32px; flex:none; border-radius:10px; display:grid; place-items:center;
        background:linear-gradient(135deg,#3b82f6,#2563eb); color:#fff; font-size:.72rem; font-weight:800;
        box-shadow:0 4px 12px -4px rgba(37,99,235,.55); }

    .cpx-idn { flex:1; min-width:0; display:flex; flex-direction:column; gap:2px; }
    .cpx-idn b { font-size:.86rem; font-weight:800; color:#0f172a; letter-spacing:-.01em;
        overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
    .cpx-idn small { display:flex; align-items:center; gap:4px; flex-wrap:wrap; }
    .cpx-idn small:empty { display:none; }

    .cpx-fold i { transition:transform .2s; }
    .cpx-card.folded .cpx-fold i { transform:rotate(180deg); }
    .cpx-card.folded .cpx-body { display:none; }
    .cpx-card.folded .pfx-top { border-bottom:0; border-radius:15px; }
    .cpx-del:hover { color:#dc2626 !important; background:#fef2f2 !important; }

    /* Süresi dolan / dolmak üzere olan belge satırları */
    .pfx-row.st-soon .pfx-v { color:#b45309; }
    .pfx-row.st-expired .pfx-v { color:#b91c1c; }
    .pfx-flag { margin-left:5px; border-radius:999px; padding:0 5px; font-size:.53rem; font-weight:800;
        letter-spacing:.03em; text-transform:uppercase; }
    .pfx-flag.warn { background:#fef3c7; color:#92400e; }
    .pfx-flag.danger { background:#fee2e2; color:#b91c1c; }

    .cpx-fld input, .cpx-fld select, .cpx-new input, .cpx-new select {
        width:100%; background:#fff; border:1.5px solid #e8ecf3; border-radius:9px; padding:.36rem .55rem;
        font-size:.79rem; font-weight:600; color:#1e293b; transition:border-color .15s, box-shadow .15s, background .3s; }
    .cpx-fld input::placeholder { color:#cbd5e1; font-weight:500; }
    .cpx-fld input:hover, .cpx-fld select:hover { border-color:#dbe3ee; }
    .cpx-fld input:focus, .cpx-fld select:focus, .cpx-new input:focus, .cpx-new select:focus {
        outline:none; border-color:#6366f1; box-shadow:0 0 0 3px rgba(99,102,241,.12); }
    .cpx-fld.st-soon input { border-color:#fde68a; background:#fffbeb; }
    .cpx-fld.st-expired input { border-color:#fecaca; background:#fef2f2; }
    .cpx-flag { border-radius:999px; padding:0 6px; font-size:.58rem; font-weight:800; }
    .cpx-flag.warn { background:#fef3c7; color:#92400e; }
    .cpx-flag.danger { background:#fee2e2; color:#b91c1c; }

    /* Anlık kayıt geri bildirimi */
    .cpx-saving { border-color:#fbbf24 !important; background:#fffbeb !important; }
    .cpx-ok { border-color:#86efac !important; background:#f0fdf4 !important; }
    .cpx-err { border-color:#fca5a5 !important; background:#fef2f2 !important; }

    .cpx-cancel, .cdx-clear { border:1.5px solid #e2e8f0; background:#fff; color:#64748b; font-weight:700;
        font-size:.76rem; border-radius:9px; padding:.36rem .9rem; cursor:pointer; }
    .cpx-save { border:none; background:linear-gradient(135deg,#6366f1,#4f46e5); color:#fff; font-weight:800;
        font-size:.78rem; border-radius:9px; padding:.36rem 1.1rem; cursor:pointer; box-shadow:0 4px 12px rgba(79,70,229,.3); }

    .cpx-foot { display:flex; align-items:center; flex-wrap:wrap; gap:4px; font-size:.68rem; color:#94a3b8; font-weight:600; }
    .cpx-foot i { color:#f59e0b; margin-right:4px; }
    .cpx-foot i.fa-copy, .cpx-foot i.fa-clipboard-list { color:#818cf8; margin:0 2px; }
    .cpx-foot-sep { width:1px; height:11px; background:#e2e8f0; margin:0 .35rem; }

    .cpx-empty, .csx-empty, .cdx-empty { display:flex; flex-direction:column; align-items:center; gap:5px;
        padding:2.6rem 1rem; text-align:center; background:#fff; border:1.5px dashed #e2e8f0; border-radius:16px; }
    .cpx-empty i, .csx-empty i, .cdx-empty i { font-size:2rem; color:#cbd5e1; margin-bottom:.4rem; }
    .cpx-empty b, .csx-empty b, .cdx-empty b { font-size:.88rem; color:#334155; }
    .cpx-empty span, .csx-empty span, .cdx-empty span { font-size:.75rem; color:#94a3b8; max-width:380px; }
    .cpx-empty .cpx-add-btn { margin-top:.7rem; }

    /* ═══════════ SATIŞLAR ═══════════ */
    .csx-summary { position:relative; display:grid; grid-template-columns:repeat(3,1fr); gap:1rem;
        background:linear-gradient(135deg,#0f172a,#1e293b 65%,#312e81 160%); border-radius:18px;
        padding:1rem 1.15rem 1.35rem; overflow:hidden; }
    .csx-sum-item { display:flex; flex-direction:column; gap:2px; min-width:0; }
    .csx-sum-l { font-size:.62rem; font-weight:800; text-transform:uppercase; letter-spacing:.06em; color:#94a3b8; }
    .csx-sum-v { font-size:1.15rem; font-weight:800; color:#fff; letter-spacing:-.02em; }
    .csx-sum-v.pos { color:#4ade80; }
    .csx-sum-v.neg { color:#fb7185; }
    .csx-sum-s { font-size:.66rem; color:#94a3b8; font-weight:600; }
    .csx-sum-bar { position:absolute; left:0; right:0; bottom:0; height:5px; background:rgba(255,255,255,.1); }
    .csx-sum-fill { height:100%; background:linear-gradient(90deg,#22c55e,#4ade80); transition:width .5s cubic-bezier(.16,1,.3,1); }

    .csx-filters { display:flex; gap:.35rem; flex-wrap:wrap; }
    .csx-f { border:1.5px solid #e8ecf3; background:#fff; color:#64748b; font-size:.73rem; font-weight:700;
        border-radius:999px; padding:.28rem .8rem; cursor:pointer; transition:.15s; }
    .csx-f b { color:#94a3b8; margin-left:4px; font-weight:800; }
    .csx-f:hover { border-color:#c7d2fe; color:#4f46e5; }
    .csx-f.active { background:#1e293b; border-color:#1e293b; color:#fff; }
    .csx-f.active b { color:#94a3b8; }

    .csx-list { display:flex; flex-direction:column; gap:.5rem; }
    .csx-row { position:relative; display:flex; align-items:center; gap:.8rem; background:#fff;
        border:1px solid #e8ecf3; border-radius:14px; padding:.65rem .85rem .65rem 1.05rem;
        cursor:pointer; transition:.18s; overflow:hidden; }
    .csx-row:hover { border-color:#c7d2fe; transform:translateX(2px); box-shadow:0 6px 20px rgba(79,70,229,.1); }
    .csx-rail { position:absolute; left:0; top:0; bottom:0; width:4px; }

    .csx-date { flex:none; width:44px; text-align:center; line-height:1.1; }
    .csx-date b { display:block; font-size:1.05rem; font-weight:800; color:#1e293b; }
    .csx-date span { display:block; font-size:.62rem; font-weight:800; text-transform:uppercase; color:#94a3b8; }
    .csx-date small { display:block; font-size:.58rem; color:#cbd5e1; }

    .csx-main { flex:1; min-width:0; }
    .csx-title { font-size:.85rem; font-weight:800; color:#1e293b; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
    .csx-meta { display:flex; align-items:center; gap:8px; flex-wrap:wrap; margin-top:2px; font-size:.68rem; color:#94a3b8; font-weight:600; }
    .csx-meta i { margin-right:3px; color:#cbd5e1; }
    .csx-code { background:#f1f5f9; color:#64748b; border-radius:999px; padding:0 7px; font-weight:800; font-size:.63rem; }
    .csx-soon { color:#d97706; }
    .csx-soon i { color:#f59e0b; }
    .csx-soon.now { color:#dc2626; }
    .csx-soon.now i { color:#ef4444; }

    .csx-pay { flex:none; width:170px; display:flex; flex-direction:column; gap:5px; }
    .csx-pay-top { display:flex; align-items:center; justify-content:space-between; gap:6px; }
    .csx-badge { border-radius:999px; padding:1px 8px; font-size:.62rem; font-weight:800; white-space:nowrap; }
    .csx-due { font-size:.65rem; font-weight:800; color:#dc2626; white-space:nowrap; }
    .csx-paid { font-size:.65rem; font-weight:800; color:#16a34a; white-space:nowrap; }
    .csx-prog { height:4px; background:#f1f5f9; border-radius:999px; overflow:hidden; }
    .csx-prog-fill { height:100%; background:linear-gradient(90deg,#22c55e,#4ade80); border-radius:999px; transition:width .5s; }

    .csx-amount { flex:none; text-align:right; }
    .csx-amount b { display:block; font-size:.92rem; font-weight:800; color:#1e293b; }
    .csx-amount span { font-size:.62rem; font-weight:800; color:#94a3b8; }
    .csx-go { color:#cbd5e1; font-size:.72rem; transition:.15s; }
    .csx-row:hover .csx-go { color:#4f46e5; transform:translateX(2px); }

    @media (max-width:720px) {
        .csx-summary { grid-template-columns:1fr; gap:.6rem; }
        .csx-pay { width:120px; }
        .csx-date { display:none; }
    }

    /* ═══════════ DÖKÜMANLAR ═══════════ */
    .cdx-drop { background:#fff; border:1.5px solid #e8ecf3; border-radius:18px; padding:.9rem; }
    .cdx-drop-inner { border:2px dashed #dbe3ee; border-radius:14px; padding:1.35rem 1rem; text-align:center;
        transition:.18s; background:#fbfcfe; }
    .cdx-drop-inner.is-over { border-color:#6366f1; background:#f5f3ff; transform:scale(1.01); }
    .cdx-drop-ico { width:46px; height:46px; margin:0 auto .55rem; border-radius:14px; display:grid; place-items:center;
        background:linear-gradient(135deg,#6366f1,#4f46e5); color:#fff; font-size:1.1rem; box-shadow:0 8px 20px rgba(79,70,229,.3); }
    .cdx-drop-txt b { display:block; font-size:.85rem; font-weight:800; color:#334155; }
    .cdx-drop-txt span { font-size:.74rem; color:#94a3b8; font-weight:600; }
    .cdx-browse { border:none; background:none; padding:0; color:#4f46e5; font-weight:800; font-size:.74rem;
        cursor:pointer; text-decoration:underline; }

    .cdx-drop-row { display:flex; align-items:flex-end; gap:.55rem; margin-top:.75rem; flex-wrap:wrap; }
    .cdx-fld { flex:1; min-width:170px; display:flex; flex-direction:column; gap:3px; }
    .cdx-fld label { font-size:.63rem; font-weight:800; text-transform:uppercase; letter-spacing:.04em; color:#94a3b8; }
    .cdx-fld label span { color:#ef4444; }
    .cdx-fld select { width:100%; background:#fff; border:1.5px solid #e8ecf3; border-radius:9px;
        padding:.4rem .55rem; font-size:.79rem; font-weight:600; color:#1e293b; }
    .cdx-fld select:focus { outline:none; border-color:#6366f1; box-shadow:0 0 0 3px rgba(99,102,241,.12); }
    .cdx-picked { display:flex; align-items:center; gap:6px; background:#eef2ff; color:#3730a3; border-radius:9px;
        padding:.35rem .6rem; font-size:.74rem; font-weight:700; max-width:230px; }
    .cdx-picked[hidden] { display:none; }
    .cdx-picked span { white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
    .cdx-clear { padding:0 5px; border:none; background:transparent; color:#6366f1; }
    .cdx-up-btn { border:none; background:linear-gradient(135deg,#6366f1,#4f46e5); color:#fff; font-weight:800;
        font-size:.78rem; border-radius:10px; padding:.42rem 1.1rem; cursor:pointer; box-shadow:0 5px 14px rgba(79,70,229,.3); }

    .cdx-listhead { display:flex; align-items:center; gap:7px; font-size:.72rem; color:#94a3b8; font-weight:600; }
    .cdx-listhead b { color:#1e293b; font-weight:800; }
    .cdx-dot { width:3px; height:3px; border-radius:50%; background:#cbd5e1; display:inline-block; }

    .cdx-group + .cdx-group { margin-top:.75rem; }
    .cdx-group-h { display:flex; align-items:center; gap:7px; margin-bottom:.4rem; }
    .cdx-group-name { font-size:.68rem; font-weight:800; text-transform:uppercase; letter-spacing:.05em; color:#64748b; }
    .cdx-group-n { background:#f1f5f9; color:#94a3b8; border-radius:999px; padding:0 6px; font-size:.62rem; font-weight:800; }
    .cdx-group-line { flex:1; height:1px; background:#eef2f7; }

    .cdx-items { display:flex; flex-direction:column; gap:.4rem; }
    .cdx-item { display:flex; align-items:center; gap:.7rem; background:#fff; border:1px solid #e8ecf3;
        border-radius:13px; padding:.55rem .7rem; transition:.15s; }
    .cdx-item:hover { border-color:#dbe3ee; box-shadow:0 4px 14px rgba(15,23,42,.05); }
    .cdx-item.st-expired { border-color:#fecaca; background:#fffbfb; }
    .cdx-item.st-soon { border-color:#fde68a; background:#fffdf7; }
    .cdx-ico { width:34px; height:34px; flex:none; border-radius:11px; display:grid; place-items:center; font-size:.85rem; }
    .cdx-info { flex:1; min-width:0; }
    .cdx-name { font-size:.8rem; font-weight:700; color:#1e293b; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
    .cdx-meta { display:flex; align-items:center; gap:6px; flex-wrap:wrap; margin-top:1px; font-size:.66rem; color:#94a3b8; font-weight:600; }
    .cdx-exp.expired { background:#fee2e2; color:#b91c1c; }
    .cdx-exp.soon { background:#fef3c7; color:#92400e; }
    .cdx-note { font-size:.68rem; color:#94a3b8; margin-top:2px; font-style:italic; }
    .cdx-acts { display:flex; gap:3px; }
    .cdx-act { width:29px; height:29px; border-radius:9px; border:1px solid #e8ecf3; background:#fff; color:#94a3b8;
        display:grid; place-items:center; cursor:pointer; font-size:.72rem; transition:.15s; text-decoration:none; }
    .cdx-act:hover { border-color:#c7d2fe; color:#4f46e5; background:#f5f3ff; }
    .cdx-act.danger:hover { border-color:#fecaca; color:#dc2626; background:#fef2f2; }

    /* Operasyondan üretilen belgeler — yüklenenlerden görsel olarak ayrışır */
    .cdx-op { background:linear-gradient(135deg,#fffbfc,#fff5f7); border:1px solid #fde2e7;
        border-radius:16px; padding:.7rem .8rem; }
    .cdx-op .cdx-group-name i { color:#e11d48; margin-right:5px; }
    .cdx-op .cdx-item { border-color:#fbe3e8; }
    .cdx-op .cdx-item:hover { border-color:#fbcfe1; }
    .cdx-tag, .cdx-status { border-radius:999px; padding:0 7px; font-size:.6rem; font-weight:800; white-space:nowrap; }
    .cdx-salelink { border:none; background:#f1f5f9; color:#4f46e5; border-radius:999px; padding:0 7px;
        font-size:.62rem; font-weight:800; cursor:pointer; }
    .cdx-salelink:hover { background:#eef2ff; }
    /* Operasyon kartına atlama çipi — op-belge bölümünün gül tonunda */
    .cdx-oplink { background:#ffe4ea; color:#be123c; }
    .cdx-oplink:hover { background:#fecdd6; color:#9f1239; }
    .cdx-oplink i { color:inherit; font-size:.56rem; margin-right:3px; }
    .cdx-meta i { margin-right:3px; color:#cbd5e1; }
    .cdx-opnote { margin-top:.55rem; font-size:.66rem; color:#9f1239; font-weight:600; opacity:.85; }
    .cdx-opnote i { color:#e11d48; margin-right:4px; }
</style>

<script>
(function () {
    const CSRF = document.querySelector('meta[name="csrf-token"]')?.content || '';
    const toast = (icon, title) => {
        if (typeof Swal === 'undefined') return;
        Swal.fire({ toast: true, position: 'top-end', timer: 2000, showConfirmButton: false, icon, title });
    };

    // ── Yolcular: anlık kayıt ──
    window.cpxSave = function (el) {
        const prev = el.dataset.prev ?? '';
        el.classList.remove('cpx-ok', 'cpx-err');
        el.classList.add('cpx-saving');

        fetch(el.dataset.url, {
            method: 'PATCH',
            headers: { 'Content-Type': 'application/json', 'Accept': 'application/json', 'X-CSRF-TOKEN': CSRF },
            body: JSON.stringify({ field: el.dataset.field, value: el.value }),
        })
        .then(r => r.json())
        .then(d => {
            el.classList.remove('cpx-saving');
            if (d.success) {
                el.classList.add('cpx-ok');
                el.dataset.prev = el.value;
                setTimeout(() => el.classList.remove('cpx-ok'), 1100);
                // Ad/soyad değiştiyse baş harfleri tazele
                if (el.dataset.field === 'first_name' || el.dataset.field === 'last_name') {
                    const card = el.closest('.cpx-card');
                    const names = [...card.querySelectorAll('.cpx-name')].map(i => i.value.trim());
                    card.querySelector('.cpx-av').textContent =
                        names.map(n => n.charAt(0).toUpperCase()).join('').slice(0, 2) || '?';
                    card.dataset.cpxName = names.join(' ').toLowerCase();
                }
            } else {
                el.classList.add('cpx-err');
                el.value = prev;
                toast('error', d.message || 'Kaydedilemedi');
            }
        })
        .catch(() => { el.classList.remove('cpx-saving'); el.classList.add('cpx-err'); toast('error', 'Sunucuya ulaşılamadı'); });
    };

    window.cpxToggleNew = function () {
        const f = document.getElementById('cpxNewForm');
        if (!f) return;
        const show = f.hasAttribute('hidden');
        f.toggleAttribute('hidden', !show);
        if (show) f.querySelector('input[name="first_name"]')?.focus();
    };

    // Yeni yolcu: drawer içindeyiz, sayfa yenilenmemeli → AJAX + kartı tazele
    const newForm = document.getElementById('cpxNewForm');
    if (newForm && !newForm.__bound) {
        newForm.__bound = true;
        newForm.addEventListener('submit', e => {
            e.preventDefault();
            const btn = newForm.querySelector('.cpx-save');
            const prev = btn.innerHTML;
            btn.disabled = true;
            btn.innerHTML = '<span class="spinner-border spinner-border-sm me-1"></span>Ekleniyor…';

            fetch(newForm.action, {
                method: 'POST',
                headers: { 'Accept': 'application/json', 'X-CSRF-TOKEN': CSRF },
                body: new FormData(newForm),
            })
            .then(r => r.json())
            .then(d => {
                btn.disabled = false; btn.innerHTML = prev;
                if (!d.success) {
                    const msg = d.errors ? Object.values(d.errors).flat().join('\n') : (d.message || 'Yolcu eklenemedi');
                    toast('error', msg);
                    return;
                }
                toast('success', d.message || 'Yolcu eklendi');
                if (typeof activeQuickViewUrl !== 'undefined' && activeQuickViewUrl && typeof openQuickView === 'function') {
                    openQuickView(activeQuickViewUrl, 'passengers');
                }
            })
            .catch(() => { btn.disabled = false; btn.innerHTML = prev; toast('error', 'Sunucuya ulaşılamadı'); });
        });
    }

    /** Yolcu satırını (ve altındaki detay satırını) aç/kapat. */
    window.cpxToggleRow = function (btn) {
        const tr = btn.closest('tr');
        const det = tr?.nextElementSibling;
        if (!det || !det.classList.contains('cpx-det')) return;
        const open = det.hasAttribute('hidden');
        det.toggleAttribute('hidden', !open);
        tr.classList.toggle('is-open', open);
        btn.querySelector('i').className = open ? 'fas fa-chevron-up' : 'fas fa-chevron-down';
    };

    window.cpxFilter = function (q) {
        const s = (q || '').trim().toLowerCase();
        document.querySelectorAll('#cpxList tr.cpx-tr').forEach(tr => {
            const hit = !s || (tr.dataset.cpxName || '').includes(s);
            tr.style.display = hit ? '' : 'none';
            const det = tr.nextElementSibling;
            // Eşleşmeyen satırın açık detayı da gizlensin
            if (det && det.classList.contains('cpx-det')) det.style.display = hit ? '' : 'none';
        });
    };

    window.cpxDelete = function (url, btn, name) {
        const run = () => fetch(url, {
            method: 'POST',
            headers: { 'X-CSRF-TOKEN': CSRF, 'Accept': 'application/json' },
            body: new URLSearchParams({ _method: 'DELETE' }),
        }).then(() => {
            // Tablo düzeni: özet satırıyla birlikte altındaki detay satırı da kalkar
            const tr = btn.closest('tr.cpx-tr');
            const det = tr?.nextElementSibling;
            if (det && det.classList.contains('cpx-det')) det.remove();
            (tr || btn.closest('.cpx-card'))?.remove();
            toast('success', 'Yolcu silindi');
        }).catch(() => toast('error', 'Silinemedi'));

        if (typeof Swal !== 'undefined') {
            Swal.fire({ title: (name || 'Yolcu') + ' silinsin mi?', icon: 'warning', showCancelButton: true,
                confirmButtonColor: '#ef4444', confirmButtonText: 'Evet, sil', cancelButtonText: 'Vazgeç' })
                .then(r => r.isConfirmed && run());
        } else if (confirm('Yolcu silinsin mi?')) run();
    };

    // ── Satışlar: filtre ──
    window.csxFilter = function (btn, key) {
        btn.parentElement.querySelectorAll('.csx-f').forEach(b => b.classList.toggle('active', b === btn));
        document.querySelectorAll('.csx-row').forEach(r => {
            r.style.display = (r.dataset.csx || '').split(' ').includes(key) ? '' : 'none';
        });
    };

    // ── Dökümanlar: sürükle-bırak ──
    window.cdxPick = function (input) {
        const box = document.getElementById('cdxPicked');
        const name = document.getElementById('cdxPickedName');
        const file = input.files?.[0];
        if (!file) { box?.setAttribute('hidden', ''); return; }
        if (name) name.textContent = file.name;
        box?.removeAttribute('hidden');
    };
    window.cdxClear = function () {
        const i = document.getElementById('cdxFile');
        if (i) i.value = '';
        document.getElementById('cdxPicked')?.setAttribute('hidden', '');
    };

    const drop = document.getElementById('cdxDrop');
    if (drop && !drop.__bound) {
        drop.__bound = true;
        ['dragenter', 'dragover'].forEach(ev => drop.addEventListener(ev, e => {
            e.preventDefault(); drop.classList.add('is-over');
        }));
        ['dragleave', 'drop'].forEach(ev => drop.addEventListener(ev, e => {
            e.preventDefault(); drop.classList.remove('is-over');
        }));
        drop.addEventListener('drop', e => {
            const file = e.dataTransfer?.files?.[0];
            if (!file) return;
            const input = document.getElementById('cdxFile');
            const dt = new DataTransfer();
            dt.items.add(file);
            input.files = dt.files;
            cdxPick(input);
        });
    }
})();
</script>
<?php /**PATH C:\xampp\htdocs\acente\resources\views/agency/customers/partials/qv-tabs-styles.blade.php ENDPATH**/ ?>