<?php $__env->startSection('title', 'Operasyon Yönetimi'); ?>
<?php $__env->startSection('page_title', 'Operasyon Yönetimi'); ?>

<?php
    use Illuminate\Support\Carbon;
    // Kalkışları güne göre grupla
    $grouped = $departures->groupBy(fn ($d) => optional($d['start'])->format('Y-m-d') ?? '—');
?>

<?php $__env->startPush('styles'); ?>
<style>
    .ops-board { --slate:#334155; --slate-d:#1e293b; --line:#e2e8f0; --muted:#64748b; }

    /* ── Özet şerit ── */
    .ops-stats { display:grid; grid-template-columns:repeat(auto-fit,minmax(150px,1fr)); gap:14px; margin-bottom:22px; }
    .ops-stat { background:#fff; border:1px solid var(--line); border-radius:18px; padding:16px 18px; position:relative; overflow:hidden; transition:transform .2s, box-shadow .2s; }
    .ops-stat:hover { transform:translateY(-3px); box-shadow:0 12px 28px rgba(15,23,42,.08); }
    .ops-stat::after { content:''; position:absolute; right:-18px; top:-18px; width:64px; height:64px; border-radius:50%; background:var(--accent,rgba(51,65,85,.06)); }
    .ops-stat .val { font-size:1.7rem; font-weight:800; color:var(--slate-d); line-height:1; }
    .ops-stat .lbl { font-size:.72rem; font-weight:700; text-transform:uppercase; letter-spacing:.04em; color:var(--muted); margin-top:8px; }
    .ops-stat .ico { position:absolute; right:14px; top:14px; font-size:1rem; color:var(--icon,#94a3b8); z-index:1; }

    /* ── Filtre bar ── */
    .ops-toolbar { display:flex; flex-wrap:wrap; gap:10px; align-items:center; background:#fff; border:1px solid var(--line); border-radius:16px; padding:12px 14px; margin-bottom:22px; }
    .ops-search { flex:1; min-width:220px; display:flex; align-items:center; gap:8px; background:#f8fafc; border:1px solid var(--line); border-radius:11px; padding:9px 13px; color:var(--muted); }
    .ops-search input { border:none; outline:none; background:transparent; width:100%; font-size:.9rem; color:#0f172a; }
    .ops-select { border:1px solid var(--line); border-radius:11px; padding:9px 12px; font-size:.85rem; font-weight:600; color:#334155; background:#fff; cursor:pointer; }
    .ops-pending-link { margin-left:auto; display:inline-flex; align-items:center; gap:8px; padding:9px 15px; border-radius:11px; background:#f1f5f9; border:1px solid var(--line); color:#334155; font-size:.83rem; font-weight:700; transition:all .2s; }
    .ops-pending-link:hover { background:#334155; color:#fff; }

    /* ── Gün grubu ── */
    .ops-daygroup { margin-bottom:26px; }
    .ops-dayhead { display:flex; align-items:center; gap:12px; margin-bottom:14px; }
    .ops-daychip { display:inline-flex; flex-direction:column; align-items:center; justify-content:center; min-width:58px; padding:8px 10px; border-radius:14px; background:linear-gradient(135deg,#334155,#1e293b); color:#fff; box-shadow:0 6px 16px rgba(30,41,59,.25); }
    .ops-daychip .d { font-size:1.3rem; font-weight:800; line-height:1; }
    .ops-daychip .m { font-size:.62rem; font-weight:700; text-transform:uppercase; letter-spacing:.06em; opacity:.85; margin-top:3px; }
    .ops-dayhead .wday { font-size:.95rem; font-weight:800; color:#1e293b; }
    .ops-dayhead .cnt { font-size:.75rem; color:var(--muted); font-weight:600; }
    .ops-dayline { flex:1; height:1px; background:linear-gradient(90deg,var(--line),transparent); }

    /* ── Kalkış kartları ── */
    .ops-grid { display:grid; grid-template-columns:repeat(auto-fill,minmax(340px,1fr)); gap:16px; }
    .ops-card { background:#fff; border:1px solid var(--line); border-radius:20px; padding:18px; cursor:pointer; position:relative; transition:transform .2s, box-shadow .2s, border-color .2s; overflow:hidden; }
    .ops-card::before { content:''; position:absolute; left:0; top:0; bottom:0; width:5px; background:var(--tcolor,#334155); }
    .ops-card:hover { transform:translateY(-4px); box-shadow:0 16px 36px rgba(15,23,42,.12); border-color:#cbd5e1; }
    .ops-card.is-cancelled { opacity:.72; }
    .ops-card.is-cancelled::before { background:#ef4444; }

    .ops-card-top { display:flex; justify-content:space-between; align-items:flex-start; gap:12px; margin-bottom:14px; }
    .ops-type { display:inline-flex; align-items:center; gap:6px; font-size:.68rem; font-weight:800; text-transform:uppercase; letter-spacing:.04em; color:var(--tcolor,#334155); }
    .ops-type .dot { width:8px; height:8px; border-radius:50%; background:var(--tcolor,#334155); }
    .ops-tourname { font-size:1rem; font-weight:800; color:#0f172a; line-height:1.3; margin-top:6px; }
    .ops-code { font-size:.7rem; font-weight:700; color:#94a3b8; font-family:'Courier New',monospace; }

    /* doluluk halkası */
    .ops-ring { --pct:0; width:56px; height:56px; border-radius:50%; flex-shrink:0; display:flex; align-items:center; justify-content:center; background:conic-gradient(var(--rcolor,#334155) calc(var(--pct)*1%), #eef2f6 0); }
    .ops-ring .inner { width:44px; height:44px; border-radius:50%; background:#fff; display:flex; flex-direction:column; align-items:center; justify-content:center; }
    .ops-ring .inner .n { font-size:.85rem; font-weight:800; color:#0f172a; line-height:1; }
    .ops-ring .inner .t { font-size:.55rem; font-weight:700; color:#94a3b8; }

    .ops-badge { display:inline-flex; align-items:center; gap:6px; padding:6px 11px; border-radius:9px; font-size:.72rem; font-weight:800; margin-bottom:12px; }

    .ops-meta { display:flex; flex-wrap:wrap; gap:14px; margin-bottom:12px; }
    .ops-meta-item { display:flex; align-items:center; gap:7px; font-size:.8rem; color:#475569; font-weight:600; }
    .ops-meta-item i { color:#94a3b8; width:14px; text-align:center; }

    .ops-svc { display:flex; gap:7px; margin-bottom:12px; }
    .ops-svc span { width:26px; height:26px; border-radius:8px; display:flex; align-items:center; justify-content:center; font-size:.7rem; border:1px solid var(--line); background:#f8fafc; color:#cbd5e1; }
    .ops-svc span.on { background:#dcfce7; border-color:#bbf7d0; color:#16a34a; }

    .ops-card-foot { display:flex; align-items:center; gap:8px; padding-top:13px; border-top:1px dashed var(--line); }
    .ops-rev { font-size:.9rem; font-weight:800; color:#0f172a; }
    .ops-rev small { font-size:.65rem; font-weight:700; color:#94a3b8; display:block; }
    .ops-acts { margin-left:auto; display:flex; gap:6px; }
    .ops-btn { width:34px; height:34px; border-radius:10px; border:1px solid var(--line); background:#fff; color:#64748b; display:inline-flex; align-items:center; justify-content:center; transition:all .18s; cursor:pointer; }
    .ops-btn:hover { border-color:#94a3b8; color:#1e293b; background:#f8fafc; }
    .ops-btn.ok:hover { background:#dcfce7; border-color:#86efac; color:#16a34a; }
    .ops-btn.no:hover { background:#fee2e2; border-color:#fca5a5; color:#dc2626; }

    .ops-empty { text-align:center; padding:70px 20px; color:var(--muted); }
    .ops-empty i { font-size:2.6rem; color:#cbd5e1; margin-bottom:16px; }
    .ops-empty h5 { color:#334155; font-weight:800; }
</style>
<?php $__env->stopPush(); ?>

<?php $__env->startSection('content'); ?>
<div class="ops-board">

    
    <div class="ops-stats">
        <div class="ops-stat" style="--accent:rgba(51,65,85,.07);--icon:#334155">
            <i class="fas fa-plane-departure ico"></i>
            <div class="val"><?php echo e($stats['total']); ?></div>
            <div class="lbl">Aktif Kalkış</div>
        </div>
        <div class="ops-stat" style="--accent:rgba(16,185,129,.08);--icon:#10b981">
            <i class="fas fa-circle-check ico"></i>
            <div class="val"><?php echo e($stats['guaranteed']); ?></div>
            <div class="lbl">Kesin Kalkış</div>
        </div>
        <div class="ops-stat" style="--accent:rgba(245,158,11,.08);--icon:#f59e0b">
            <i class="fas fa-hourglass-half ico"></i>
            <div class="val"><?php echo e($stats['collecting']); ?></div>
            <div class="lbl">Riskli / Toplanıyor</div>
        </div>
        <div class="ops-stat" style="--accent:rgba(14,165,233,.08);--icon:#0ea5e9">
            <i class="fas fa-calendar-week ico"></i>
            <div class="val"><?php echo e($stats['this_week']); ?></div>
            <div class="lbl">Bu Hafta</div>
        </div>
        <div class="ops-stat" style="--accent:rgba(99,102,241,.08);--icon:#6366f1">
            <i class="fas fa-users ico"></i>
            <div class="val"><?php echo e($stats['total_pax']); ?></div>
            <div class="lbl">Toplam Yolcu</div>
        </div>
        <div class="ops-stat" style="--accent:rgba(34,197,94,.08);--icon:#22c55e">
            <i class="fas fa-coins ico"></i>
            <div class="val"><?php echo e(number_format($stats['total_revenue_won'], 0, ',', '.')); ?>₺</div>
            <div class="lbl">Kesin Ciro</div>
        </div>
        <div class="ops-stat" style="--accent:rgba(245,158,11,.08);--icon:#f59e0b">
            <i class="fas fa-hourglass-half ico"></i>
            <div class="val"><?php echo e(number_format($stats['total_revenue_potential'], 0, ',', '.')); ?>₺</div>
            <div class="lbl">Potansiyel Ciro</div>
        </div>
    </div>

    
    <?php echo $__env->make('agency.operations._filterbar-styles', array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?>

    <form method="GET" class="ops-filterbar" id="opsFilter">
        <input type="hidden" name="view" value="<?php echo e($view); ?>">

        
        <div class="ops-fb-row">
            <div class="ops-fb-search">
                <i class="fas fa-search"></i>
                <input type="text" name="search" id="opsSearch" value="<?php echo e(request('search')); ?>" placeholder="Tur adı veya kodu ile ara…">
                <?php if(request('search')): ?>
                    <i class="fas fa-times-circle clr" onclick="document.getElementById('opsSearch').value='';document.getElementById('opsFilter').submit()"></i>
                <?php endif; ?>
            </div>

            <select class="ops-cselect" name="sort" data-icon="fa-arrow-down-wide-short" data-search="0">
                <option value="date_asc" <?php if(request('sort','date_asc')==='date_asc'): echo 'selected'; endif; ?>>Tarih (Yakın → Uzak)</option>
                <option value="date_desc" <?php if(request('sort')==='date_desc'): echo 'selected'; endif; ?>>Tarih (Uzak → Yakın)</option>
                <option value="occupancy_desc" <?php if(request('sort')==='occupancy_desc'): echo 'selected'; endif; ?>>Doluluk (Yüksek)</option>
                <option value="pax_desc" <?php if(request('sort')==='pax_desc'): echo 'selected'; endif; ?>>Yolcu (Çok)</option>
            </select>

            <span class="ops-fb-spring"></span>

            <span class="ops-fb-count"><i class="fas fa-plane-departure text-secondary"></i> <?php echo e($departures->count()); ?> kalkış</span>

            <div class="ops-viewtoggle">
                <a href="<?php echo e(request()->fullUrlWithQuery(['view' => 'card'])); ?>" class="<?php echo e($view === 'card' ? 'active' : ''); ?>"><i class="fas fa-grip"></i> Kart</a>
                <a href="<?php echo e(request()->fullUrlWithQuery(['view' => 'table'])); ?>" class="<?php echo e($view === 'table' ? 'active' : ''); ?>"><i class="fas fa-table-list"></i> Tablo</a>
            </div>

            <a href="<?php echo e(route('agency.operations.pending')); ?>" class="ops-pending-link"><i class="fas fa-inbox"></i> 0 Rezervasyonlu</a>
        </div>

        
        <div class="ops-fb-row">
            <span class="ops-fb-lbl">Filtrele</span>

            <select class="ops-cselect" name="type" data-icon="fa-layer-group" data-placeholder="Tüm Tur Tipleri">
                <option value="">Tüm Tur Tipleri</option>
                <?php $__currentLoopData = $filterOptions['types']; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $k => $label): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                    <option value="<?php echo e($k); ?>" <?php if(request('type')===$k): echo 'selected'; endif; ?>><?php echo e($label); ?></option>
                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
            </select>

            <select class="ops-cselect" name="tour" data-icon="fa-route" data-placeholder="Tüm Turlar">
                <option value="">Tüm Turlar</option>
                <?php $__currentLoopData = $filterOptions['tours']; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $t): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                    <option value="<?php echo e($t['key']); ?>" <?php if(request('tour')===$t['key']): echo 'selected'; endif; ?>><?php echo e($t['label']); ?></option>
                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
            </select>

            <select class="ops-cselect" name="badge" data-icon="fa-flag" data-placeholder="Tüm Durumlar">
                <option value="">Tüm Durumlar</option>
                <?php $__currentLoopData = $filterOptions['badges']; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $k => $label): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                    <option value="<?php echo e($k); ?>" <?php if(request('badge')===$k): echo 'selected'; endif; ?>><?php echo e($label); ?></option>
                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
            </select>

            <select class="ops-cselect" name="occupancy" data-icon="fa-gauge-high" data-placeholder="Tüm Doluluklar">
                <option value="">Tüm Doluluklar</option>
                <?php $__currentLoopData = $filterOptions['occupancy']; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $k => $label): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                    <option value="<?php echo e($k); ?>" <?php if(request('occupancy')===$k): echo 'selected'; endif; ?>><?php echo e($label); ?></option>
                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
            </select>

            <label class="ops-fb-item <?php echo e(request('from') ? 'on' : ''); ?>" title="Başlangıç tarihi">
                <span class="ic"><i class="far fa-calendar"></i></span>
                <input type="date" name="from" value="<?php echo e(request('from')); ?>" onchange="document.getElementById('opsFilter').submit()">
            </label>
            <label class="ops-fb-item <?php echo e(request('to') ? 'on' : ''); ?>" title="Bitiş tarihi">
                <span class="ic"><i class="far fa-calendar-check"></i></span>
                <input type="date" name="to" value="<?php echo e(request('to')); ?>" onchange="document.getElementById('opsFilter').submit()">
            </label>
        </div>

        
        <div class="ops-fb-row ops-fb-quick">
            <span class="ops-fb-lbl"><i class="far fa-clock me-1"></i>Hızlı Tarih</span>
            <span class="ops-chip" onclick="opsRange('week')">Bu Hafta</span>
            <span class="ops-chip" onclick="opsRange('month')">Bu Ay</span>
            <span class="ops-chip" onclick="opsRange('next30')">Gelecek 30 Gün</span>
            <?php if(request('from') || request('to')): ?>
                <span class="ops-chip danger" onclick="opsClearDates()"><i class="fas fa-xmark me-1"></i>Tarihi Temizle</span>
            <?php endif; ?>
        </div>
    </form>

    <script>
    function opsRange(kind) {
        const f = document.getElementById('opsFilter');
        const pad = n => String(n).padStart(2, '0');
        const fmt = d => d.getFullYear() + '-' + pad(d.getMonth() + 1) + '-' + pad(d.getDate());
        const now = new Date();
        let from, to;
        if (kind === 'week') { const day = (now.getDay() + 6) % 7; from = new Date(now); from.setDate(now.getDate() - day); to = new Date(from); to.setDate(from.getDate() + 6); }
        else if (kind === 'month') { from = new Date(now.getFullYear(), now.getMonth(), 1); to = new Date(now.getFullYear(), now.getMonth() + 1, 0); }
        else { from = new Date(now); to = new Date(now); to.setDate(now.getDate() + 30); }
        f.from.value = fmt(from); f.to.value = fmt(to); f.submit();
    }
    function opsClearDates() {
        const f = document.getElementById('opsFilter');
        f.from.value = ''; f.to.value = ''; f.submit();
    }

    // ── Canlı arama (yazdıkça filtreler, Türkçe & büyük/küçük harf duyarsız) ──
    (function () {
        const input = document.getElementById('opsSearch');
        if (!input) return;

        // Türkçe karakterleri ASCII'ye indirger, büyük/küçük harfi önemsizleştirir
        function norm(s) {
            return (s || '')
                .replace(/İ/g, 'i').replace(/I/g, 'i').replace(/ı/g, 'i')
                .toLowerCase()
                .replace(/ş/g, 's').replace(/ğ/g, 'g').replace(/ü/g, 'u')
                .replace(/ö/g, 'o').replace(/ç/g, 'c')
                .normalize('NFD').replace(/[\u0300-\u036f]/g, '')
                .trim();
        }
        function elNorm(el) {
            if (el._opsNorm === undefined) el._opsNorm = norm(el.dataset.opsSearch);
            return el._opsNorm;
        }

        function liveFilter() {
            const q = norm(input.value);

            // Kartlar
            document.querySelectorAll('.ops-card[data-ops-search]').forEach(el => {
                el.style.display = (!q || elNorm(el).includes(q)) ? '' : 'none';
            });
            // Boş gün gruplarını gizle
            document.querySelectorAll('.ops-daygroup').forEach(g => {
                const cards = g.querySelectorAll('.ops-card[data-ops-search]');
                let vis = 0;
                cards.forEach(c => { if (c.style.display !== 'none') vis++; });
                g.style.display = (cards.length === 0 || vis > 0) ? '' : 'none';
            });
            // Tablo satırları
            document.querySelectorAll('tr[data-ops-search]').forEach(tr => {
                tr.style.display = (!q || elNorm(tr).includes(q)) ? '' : 'none';
            });

            // Sayaç güncelle
            const cnt = document.querySelector('.ops-fb-count');
            if (cnt) {
                let n = 0;
                document.querySelectorAll('.ops-card[data-ops-search]').forEach(c => { if (c.style.display !== 'none') n++; });
                document.querySelectorAll('tr[data-ops-search]').forEach(r => { if (r.style.display !== 'none') n++; });
                cnt.innerHTML = '<i class="fas fa-plane-departure text-secondary"></i> ' + n + ' kalkış';
            }
        }

        input.addEventListener('input', liveFilter);
        // Enter ile form submit olup sayfa yenilenmesini engelle (canlı filtre yeterli)
        input.addEventListener('keydown', function (e) {
            if (e.key === 'Enter') { e.preventDefault(); liveFilter(); }
        });
    })();
    </script>

    
    <?php if($view === 'table'): ?>
        <?php echo $__env->make('agency.operations._table', ['departures' => $departures], array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?>
    <?php else: ?>
        <?php $__empty_1 = true; $__currentLoopData = $grouped; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $day => $items): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); $__empty_1 = false; ?>
            <?php $dc = $day !== '—' ? Carbon::parse($day) : null; ?>
            <div class="ops-daygroup">
                <div class="ops-dayhead">
                    <div class="ops-daychip">
                        <span class="d"><?php echo e($dc?->format('d') ?? '—'); ?></span>
                        <span class="m"><?php echo e($dc?->translatedFormat('M Y') ?? ''); ?></span>
                    </div>
                    <div>
                        <div class="wday"><?php echo e($dc?->translatedFormat('l') ?? 'Tarihsiz'); ?></div>
                        <div class="cnt"><?php echo e($items->count()); ?> kalkış</div>
                    </div>
                    <div class="ops-dayline"></div>
                </div>

                <div class="ops-grid">
                    <?php $__currentLoopData = $items; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $d): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                        <?php echo $__env->make('agency.operations._card', ['d' => $d], array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?>
                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                </div>
            </div>
        <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); if ($__empty_1): ?>
            <div class="ops-empty">
                <i class="fas fa-plane-slash d-block"></i>
                <h5>Aktif rezervasyonlu kalkış yok</h5>
                <p>Bir tura rezervasyon alındığında kalkış otomatik olarak burada görünür.<br>
                   Henüz rezervasyon almamış kalkışlar için
                   <a href="<?php echo e(route('agency.operations.pending')); ?>">0 Rezervasyonlu Kalkışlar</a> ekranına bakın.</p>
            </div>
        <?php endif; ?>
    <?php endif; ?>
</div>


<?php if(count($activeFilters)): ?>
    <div class="ops-activebar" id="opsActiveBar">
        <span class="ab-lbl"><i class="fas fa-filter"></i> Aktif Filtreler (<?php echo e(count($activeFilters)); ?>)</span>
        <?php $__currentLoopData = $activeFilters; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $af): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
            <span class="ops-ab-chip">
                <span><?php echo e($af['label']); ?>: <b><?php echo e($af['display']); ?></b></span>
                <a href="<?php echo e($af['remove_url']); ?>" title="Kaldır"><i class="fas fa-xmark"></i></a>
            </span>
        <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
        <a href="<?php echo e(url()->current() . '?view=' . $view); ?>" class="ops-ab-clear">
            <i class="fas fa-trash-can"></i> Tümünü Temizle
        </a>
    </div>
<?php endif; ?>

<?php $__env->startPush('scripts'); ?>
<script>
(function () {
    function opsCustomSelect(sel) {
        if (sel.dataset.cs) return;
        sel.dataset.cs = '1';
        const withSearch = sel.getAttribute('data-search') !== '0';
        const icon = sel.getAttribute('data-icon') || 'fa-filter';

        const wrap = document.createElement('div');
        wrap.className = 'ops-cs' + (sel.value ? ' on' : '');
        sel.parentNode.insertBefore(wrap, sel);
        wrap.appendChild(sel);
        sel.style.display = 'none';

        const btn = document.createElement('button');
        btn.type = 'button';
        btn.className = 'ops-cs-btn';

        const panel = document.createElement('div');
        panel.className = 'ops-cs-panel';
        panel.hidden = true;

        let search = null;
        if (withSearch) {
            const sw = document.createElement('div');
            sw.className = 'ops-cs-search';
            sw.innerHTML = '<i class="fas fa-search"></i>';
            search = document.createElement('input');
            search.type = 'text';
            search.placeholder = 'Ara…';
            sw.appendChild(search);
            panel.appendChild(sw);
        }
        const list = document.createElement('div');
        list.className = 'ops-cs-list';
        panel.appendChild(list);

        wrap.appendChild(btn);
        wrap.appendChild(panel);

        function curText() { const o = sel.options[sel.selectedIndex]; return o ? o.text : ''; }
        function renderBtn() {
            btn.innerHTML = '<span class="cs-ic"><i class="fas ' + icon + '"></i></span>'
                + '<span class="cs-lbl">' + curText() + '</span>'
                + '<i class="fas fa-chevron-down cs-caret"></i>';
            wrap.classList.toggle('on', !!sel.value);
        }
        function buildList(q) {
            q = (q || '').toLowerCase();
            list.innerHTML = '';
            let n = 0;
            Array.from(sel.options).forEach(o => {
                if (q && !o.text.toLowerCase().includes(q)) return;
                n++;
                const it = document.createElement('div');
                it.className = 'ops-cs-opt' + (o.selected ? ' sel' : '');
                it.textContent = o.text;
                it.addEventListener('click', () => {
                    sel.value = o.value;
                    renderBtn();
                    close();
                    if (sel.form) sel.form.submit();
                });
                list.appendChild(it);
            });
            if (!n) { const e = document.createElement('div'); e.className = 'ops-cs-empty'; e.textContent = 'Sonuç bulunamadı'; list.appendChild(e); }
        }
        function open() {
            document.querySelectorAll('.ops-cs.open').forEach(x => { if (x !== wrap) { x.classList.remove('open'); x.querySelector('.ops-cs-panel').hidden = true; } });
            wrap.classList.add('open'); panel.hidden = false;
            if (search) { search.value = ''; }
            buildList('');
            if (search) setTimeout(() => search.focus(), 20);
        }
        function close() { wrap.classList.remove('open'); panel.hidden = true; }

        btn.addEventListener('click', e => { e.stopPropagation(); wrap.classList.contains('open') ? close() : open(); });
        if (search) { search.addEventListener('input', () => buildList(search.value)); search.addEventListener('click', e => e.stopPropagation()); }
        document.addEventListener('click', e => { if (!wrap.contains(e.target)) close(); });

        renderBtn();
    }
    document.querySelectorAll('select.ops-cselect').forEach(opsCustomSelect);
})();
</script>
<?php $__env->stopPush(); ?>
<?php $__env->stopSection(); ?>

<?php echo $__env->make('agency.layouts.app', array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?><?php /**PATH C:\xampp\htdocs\acente\resources\views/agency/operations/index.blade.php ENDPATH**/ ?>