

<div id="panel-catalogue">

    
    <div class="bg-white rounded-xl border border-gray-200 px-2.5 sm:px-4 py-2 sm:py-2.5 mb-4 flex flex-wrap items-center gap-2 sm:gap-3">
        <div class="flex flex-wrap items-center gap-1.5 sm:gap-3">
            <div id="catConnectionDot" class="w-2 h-2 rounded-full bg-gray-300 shrink-0"></div>
            <span id="catConnectionLabel" class="text-xs text-gray-500 whitespace-nowrap">Not connected</span>
            <span id="catBalanceBadge" class="hidden inline-flex items-center gap-1 px-2 py-0.5 bg-green-50 border border-green-200 rounded-full text-xs font-semibold text-green-700 whitespace-nowrap">
                <svg class="w-3 h-3 shrink-0" fill="none" stroke="currentColor" stroke-width="2" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" d="M12 6v12m-3-2.818l.879.659c1.171.879 3.07.879 4.242 0 1.172-.879 1.172-2.303 0-3.182C13.536 12.219 12.768 12 12 12c-.725 0-1.45-.22-2.003-.659-1.106-.879-1.106-2.303 0-3.182s2.9-.879 4.006 0l.415.33M21 12a9 9 0 11-18 0 9 9 0 0118 0z"/></svg>
                <span id="catBalanceAmount">0.00</span>
            </span>
            <button type="button" id="catTopUpBtn" onclick="CAT.openTopUpModal()" class="hidden inline-flex items-center gap-1 px-2.5 py-1 text-[11px] font-semibold text-primary-700 bg-primary-50 hover:bg-primary-100 border border-primary-200 rounded-lg transition-colors whitespace-nowrap">
                <svg class="w-3 h-3 shrink-0" fill="none" stroke="currentColor" stroke-width="2.5" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" d="M12 4.5v15m7.5-7.5h-15"/></svg>
                Top Up
            </button>
        </div>
        <div class="flex items-center gap-2 ml-auto">
            <button type="button" id="catConnectBtn" onclick="CAT.autoConnect()" class="inline-flex items-center gap-1 sm:gap-1.5 px-2 sm:px-3 py-1 sm:py-1.5 text-xs font-semibold text-white bg-primary-600 hover:bg-primary-700 rounded-lg transition-colors whitespace-nowrap">
                <svg class="w-3.5 h-3.5 shrink-0" fill="none" stroke="currentColor" stroke-width="2" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" d="M13.19 8.688a4.5 4.5 0 011.242 7.244l-4.5 4.5a4.5 4.5 0 01-6.364-6.364l1.757-1.757m9.86-2.54a4.5 4.5 0 00-1.242-7.244l-4.5-4.5a4.5 4.5 0 00-6.364 6.364L4.343 8.28" /></svg>
                Connect
            </button>
            <button type="button" id="catDisconnectBtn" onclick="CAT.disconnect()" class="hidden inline-flex items-center gap-1 sm:gap-1.5 px-2 sm:px-3 py-1 sm:py-1.5 text-xs font-semibold text-red-600 bg-red-50 hover:bg-red-100 border border-red-200 rounded-lg transition-colors whitespace-nowrap">
                <svg class="w-3.5 h-3.5 shrink-0" fill="none" stroke="currentColor" stroke-width="2" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" d="M6 18L18 6M6 6l12 12"/></svg>
                Disconnect
            </button>
            <button type="button" onclick="CAT.openConfigDrawer()" class="inline-flex items-center gap-1.5 px-2 sm:px-3 py-1.5 text-xs font-medium text-gray-600 hover:text-primary-600 hover:bg-gray-50 rounded-lg transition-colors whitespace-nowrap">
                <svg class="w-4 h-4 shrink-0" fill="none" stroke="currentColor" stroke-width="1.5" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" d="M9.594 3.94c.09-.542.56-.94 1.11-.94h2.593c.55 0 1.02.398 1.11.94l.213 1.281c.063.374.313.686.645.87.074.04.147.083.22.127.325.196.72.257 1.075.124l1.217-.456a1.125 1.125 0 011.37.49l1.296 2.247a1.125 1.125 0 01-.26 1.431l-1.003.827c-.293.241-.438.613-.431.992a6.759 6.759 0 010 .255c-.007.378.138.75.43.991l1.004.827c.424.35.534.955.26 1.43l-1.298 2.247a1.125 1.125 0 01-1.369.491l-1.217-.456c-.355-.133-.75-.072-1.076.124a6.57 6.57 0 01-.22.128c-.331.183-.581.495-.644.869l-.213 1.281c-.09.543-.56.941-1.11.941h-2.594c-.55 0-1.019-.398-1.11-.94l-.213-1.281c-.062-.374-.312-.686-.644-.87a6.52 6.52 0 01-.22-.127c-.325-.196-.72-.257-1.076-.124l-1.217.456a1.125 1.125 0 01-1.369-.49l-1.297-2.247a1.125 1.125 0 01.26-1.431l1.004-.827c.292-.24.437-.613.43-.991a6.932 6.932 0 010-.255c.007-.378-.138-.75-.43-.992l-1.004-.827a1.125 1.125 0 01-.26-1.43l1.297-2.247a1.125 1.125 0 011.37-.491l1.216.456c.356.133.751.072 1.076-.124.072-.044.146-.087.22-.128.332-.183.582-.495.644-.869l.214-1.28z"/><path stroke-linecap="round" stroke-linejoin="round" d="M15 12a3 3 0 11-6 0 3 3 0 016 0z"/></svg>
                <span class="hidden sm:inline">Settings</span>
            </button>
        </div>
    </div>

    
    <div class="flex gap-0 bg-white rounded-xl border border-gray-200 overflow-hidden" style="min-height: calc(100vh - 280px)">

        
        <div id="catSidebarOverlay" class="hidden fixed inset-0 z-30 lg:hidden" style="background:rgba(0,0,0,.4)" onclick="CAT.toggleMobileSidebar()"></div>

        
        <aside id="catSidebar" class="hidden lg:flex flex-col w-56 shrink-0 border-r border-gray-200" style="background:#f9fafb">
            
            <div class="lg:hidden flex items-center justify-between px-3 py-2 border-b border-gray-200">
                <span class="text-xs font-bold text-gray-500 uppercase tracking-wide">Filters</span>
                <button type="button" onclick="CAT.toggleMobileSidebar()" class="w-8 h-8 flex items-center justify-center rounded-lg text-gray-400 hover:text-gray-600 hover:bg-gray-100 transition-colors">
                    <svg class="w-5 h-5" fill="none" stroke="currentColor" stroke-width="2" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" d="M6 18L18 6M6 6l12 12"/></svg>
                </button>
            </div>
            
            <div class="p-2 border-b border-gray-200">
                <div class="flex rounded-lg bg-gray-100 p-0.5">
                    <button type="button" onclick="CAT.selectMedia('videos')" data-media="videos"
                        class="cat-media-tab flex-1 py-1.5 text-[11px] font-bold tracking-wide rounded-md transition-all bg-white shadow text-primary-700">VIDEOS</button>
                    <button type="button" onclick="CAT.selectMedia('galleries')" data-media="galleries"
                        class="cat-media-tab flex-1 py-1.5 text-[11px] font-bold tracking-wide rounded-md transition-all text-gray-500 hover:text-gray-700">GALLERIES</button>
                </div>
            </div>
            
            <div class="p-2 border-b border-gray-200" id="catSecType">
                <div class="flex rounded-lg bg-gray-100 p-0.5" id="catTypeTabs">
                    <?php $__isFirst = true; foreach (Video::typeLabels() as $__code => $__label): ?>
                    <button type="button" onclick="CAT.selectVideoType('<?= $__code ?>')" data-type="<?= $__code ?>"
                        class="cat-type-tab flex-1 py-1.5 text-[10px] font-bold tracking-wider rounded-md transition-all <?= $__isFirst ? 'bg-white shadow text-blue-700' : 'text-gray-500 hover:text-gray-700' ?>"><?= strtoupper(htmlspecialchars($__label)) ?></button>
                    <?php $__isFirst = false; endforeach; ?>
                </div>
            </div>
            <div class="flex-1 overflow-y-auto" style="max-height: calc(100vh - 320px)">
                
                <div class="p-3">
                    <h4 class="text-[10px] font-bold text-gray-400 uppercase tracking-wider mb-2">Sources <span id="catCount_sources" class="ml-1 text-gray-300 font-semibold"></span></h4>
                    <div id="catSidebarSources">
                        <button type="button" onclick="CAT.selectSource('')" class="cat-source-item active w-full flex items-center gap-2 px-2.5 py-1.5 rounded-lg text-xs transition-colors">
                            <span class="w-4 h-4 rounded bg-gray-200 flex items-center justify-center text-[9px] font-bold text-gray-500">*</span>
                            <span class="flex-1 text-left font-medium">All Sources</span>
                        </button>
                    </div>
                </div>

                
                <div class="border-t border-gray-200 p-3">
                    <button type="button" onclick="CAT.toggleSidebarSection('categories')" class="w-full flex items-center justify-between mb-2">
                        <h4 class="text-[10px] font-bold text-gray-400 uppercase tracking-wider">Categories <span id="catCount_categories" class="ml-1 text-gray-300 font-semibold"></span></h4>
                        <svg id="catCatChevron" class="w-3.5 h-3.5 text-gray-400 transition-transform" style="transform:rotate(-90deg)" fill="none" stroke="currentColor" stroke-width="2" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" d="M19.5 8.25l-7.5 7.5-7.5-7.5"/></svg>
                    </button>
                    <div id="catSidebarCategories" class="space-y-0.5 hidden"></div>
                </div>

                
                <div class="border-t border-gray-200 p-3 hidden" id="catSecPerformers">
                    <button type="button" onclick="CAT.toggleSidebarSection('performers')" class="w-full flex items-center justify-between mb-2">
                        <h4 class="text-[10px] font-bold text-gray-400 uppercase tracking-wider">Pornstars <span id="catCount_performers" class="ml-1 text-gray-300 font-semibold"></span></h4>
                        <svg id="catPerformersChevron" class="w-3.5 h-3.5 text-gray-400 transition-transform" style="transform:rotate(-90deg)" fill="none" stroke="currentColor" stroke-width="2" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" d="M19.5 8.25l-7.5 7.5-7.5-7.5"/></svg>
                    </button>
                    <div id="catSecPerformersBody" class="hidden">
                        <input type="text" id="catPerformerSearch" oninput="CAT.facetSearch('performer',this.value)" placeholder="Search pornstars…" class="w-full mb-1.5 pl-2.5 pr-2 py-1 text-[11px] border border-gray-200 rounded-lg focus:ring-1 focus:ring-primary-400 focus:border-primary-400">
                        <div id="catSidebarPerformers" class="space-y-0.5 max-h-56 overflow-y-auto"></div>
                    </div>
                </div>

                
                <div class="border-t border-gray-200 p-3 hidden" id="catSecChannels">
                    <button type="button" onclick="CAT.toggleSidebarSection('channels')" class="w-full flex items-center justify-between mb-2">
                        <h4 class="text-[10px] font-bold text-gray-400 uppercase tracking-wider">Channels <span id="catCount_channels" class="ml-1 text-gray-300 font-semibold"></span></h4>
                        <svg id="catChannelsChevron" class="w-3.5 h-3.5 text-gray-400 transition-transform" style="transform:rotate(-90deg)" fill="none" stroke="currentColor" stroke-width="2" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" d="M19.5 8.25l-7.5 7.5-7.5-7.5"/></svg>
                    </button>
                    <div id="catSecChannelsBody" class="hidden">
                        <input type="text" id="catChannelSearch" oninput="CAT.facetSearch('channel',this.value)" placeholder="Search channels…" class="w-full mb-1.5 pl-2.5 pr-2 py-1 text-[11px] border border-gray-200 rounded-lg focus:ring-1 focus:ring-primary-400 focus:border-primary-400">
                        <div id="catSidebarChannels" class="space-y-0.5 max-h-56 overflow-y-auto"></div>
                    </div>
                </div>

                
                <div class="border-t border-gray-200 p-3 hidden" id="catSecTags">
                    <button type="button" onclick="CAT.toggleSidebarSection('tags')" class="w-full flex items-center justify-between mb-2">
                        <h4 class="text-[10px] font-bold text-gray-400 uppercase tracking-wider">Tags <span id="catCount_tags" class="ml-1 text-gray-300 font-semibold"></span></h4>
                        <svg id="catTagsChevron" class="w-3.5 h-3.5 text-gray-400 transition-transform" style="transform:rotate(-90deg)" fill="none" stroke="currentColor" stroke-width="2" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" d="M19.5 8.25l-7.5 7.5-7.5-7.5"/></svg>
                    </button>
                    <div id="catSecTagsBody" class="hidden">
                        <input type="text" id="catTagSearch" oninput="CAT.facetSearch('tag',this.value)" placeholder="Search tags…" class="w-full mb-1.5 pl-2.5 pr-2 py-1 text-[11px] border border-gray-200 rounded-lg focus:ring-1 focus:ring-primary-400 focus:border-primary-400">
                        <div id="catSidebarTags" class="space-y-0.5 max-h-56 overflow-y-auto"></div>
                    </div>
                </div>

                
                <div class="border-t border-gray-200 p-3 hidden" id="catSecImages">
                    <button type="button" onclick="CAT.toggleSidebarSection('images')" class="w-full flex items-center justify-between mb-2">
                        <h4 class="text-[10px] font-bold text-gray-400 uppercase tracking-wider">Images <span id="catCount_images" class="ml-1 text-gray-300 font-semibold"></span></h4>
                        <svg id="catImagesChevron" class="w-3.5 h-3.5 text-gray-400 transition-transform" style="transform:rotate(-90deg)" fill="none" stroke="currentColor" stroke-width="2" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" d="M19.5 8.25l-7.5 7.5-7.5-7.5"/></svg>
                    </button>
                    <div id="catSidebarImages" class="flex flex-wrap gap-1.5 hidden"></div>
                </div>

                
                <div class="border-t border-gray-200 p-3" id="catSecQuality">
                    <button type="button" onclick="CAT.toggleSidebarSection('quality')" class="w-full flex items-center justify-between mb-2">
                        <h4 class="text-[10px] font-bold text-gray-400 uppercase tracking-wider">Quality <span id="catCount_quality" class="ml-1 text-gray-300 font-semibold"></span></h4>
                        <svg id="catQualChevron" class="w-3.5 h-3.5 text-gray-400 transition-transform" style="transform:rotate(-90deg)" fill="none" stroke="currentColor" stroke-width="2" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" d="M19.5 8.25l-7.5 7.5-7.5-7.5"/></svg>
                    </button>
                    <div id="catSidebarQuality" class="flex flex-wrap gap-1.5 hidden"></div>
                </div>

                
                <div class="border-t border-gray-200 p-3" id="catSecViews">
                    <button type="button" onclick="CAT.toggleSidebarSection('views')" class="w-full flex items-center justify-between mb-2">
                        <h4 class="text-[10px] font-bold text-gray-400 uppercase tracking-wider">Views <span id="catCount_views" class="ml-1 text-gray-300 font-semibold"></span></h4>
                        <svg id="catViewsChevron" class="w-3.5 h-3.5 text-gray-400 transition-transform" style="transform:rotate(-90deg)" fill="none" stroke="currentColor" stroke-width="2" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" d="M19.5 8.25l-7.5 7.5-7.5-7.5"/></svg>
                    </button>
                    <div id="catSidebarViews" class="flex flex-wrap gap-1.5 hidden"></div>
                </div>

                
                <div class="border-t border-gray-200 p-3" id="catSecDuration">
                    <button type="button" onclick="CAT.toggleSidebarSection('duration')" class="w-full flex items-center justify-between mb-2">
                        <h4 class="text-[10px] font-bold text-gray-400 uppercase tracking-wider">Duration <span id="catCount_duration" class="ml-1 text-gray-300 font-semibold"></span></h4>
                        <svg id="catDurationChevron" class="w-3.5 h-3.5 text-gray-400 transition-transform" style="transform:rotate(-90deg)" fill="none" stroke="currentColor" stroke-width="2" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" d="M19.5 8.25l-7.5 7.5-7.5-7.5"/></svg>
                    </button>
                    <div id="catSidebarDuration" class="flex flex-wrap gap-1.5 hidden"></div>
                </div>
            </div>
        </aside>

        
        <button type="button" id="catMobileSidebarBtn" onclick="CAT.toggleMobileSidebar()" class="lg:hidden fixed bottom-4 left-4 z-30 w-10 h-10 bg-primary-600 text-white rounded-full shadow-lg flex items-center justify-center">
            <svg class="w-5 h-5" fill="none" stroke="currentColor" stroke-width="2" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" d="M10.5 6h9.75M10.5 6a1.5 1.5 0 11-3 0m3 0a1.5 1.5 0 10-3 0M3.75 6H7.5m3 12h9.75m-9.75 0a1.5 1.5 0 01-3 0m3 0a1.5 1.5 0 00-3 0m-3.75 0H7.5m9-6h3.75m-3.75 0a1.5 1.5 0 01-3 0m3 0a1.5 1.5 0 00-3 0m-9.75 0h9.75"/></svg>
        </button>

        
        <div class="flex-1 flex flex-col min-w-0">
            
            <div class="p-3 border-b border-gray-200">
                <div id="catInfoBanner" class="flex items-center gap-2 px-3 py-1.5 bg-blue-50 border border-blue-100 rounded-lg text-xs text-blue-700 mb-2">
                    <svg class="w-3.5 h-3.5 shrink-0" fill="none" stroke="currentColor" stroke-width="2" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" d="M11.25 11.25l.041-.02a.75.75 0 011.063.852l-.708 2.836a.75.75 0 001.063.853l.041-.021M21 12a9 9 0 11-18 0 9 9 0 0118 0zm-9-3.75h.008v.008H12V8.25z"/></svg>
                    <span>Thumbnails and clips shown are low-resolution previews. The <strong>full-length HD video</strong> and high-quality assets are downloaded after purchase.</span>
                </div>
                <div class="flex items-center gap-2">
                    <div class="flex-1 relative">
                        <svg class="absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-gray-400" fill="none" stroke="currentColor" stroke-width="2" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" d="M21 21l-5.197-5.197m0 0A7.5 7.5 0 105.196 5.196a7.5 7.5 0 0010.607 10.607z"/></svg>
                        <input type="text" id="catSearch" class="w-full pl-9 pr-3 py-2 text-sm border border-gray-300 rounded-lg focus:ring-2 focus:ring-primary-500 focus:border-primary-500" placeholder="Search videos..." onkeydown="if(event.key==='Enter'){CAT.browse(1)}">
                    </div>
                    <button type="button" onclick="CAT.browse(1)" class="px-4 py-2 bg-gray-100 text-gray-700 text-sm font-medium rounded-lg hover:bg-gray-200 transition-colors shrink-0">Search</button>
                </div>
                
                <div id="catActiveFilters" class="flex items-center gap-1.5 flex-wrap mt-2"></div>
            </div>

            
            <div class="flex-1 p-3 overflow-y-auto">
                
                <div class="relative inline-block float-right -mt-9 mr-1 z-10" id="catCalcWrapper">
                    <button type="button" onclick="document.getElementById('catCalcPopover').classList.toggle('hidden')" class="p-1.5 text-amber-500 hover:text-amber-700 hover:bg-amber-50 rounded-lg transition-colors" title="Cost calculator">
                        <svg class="w-4 h-4" fill="none" stroke="currentColor" stroke-width="2" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" d="M15.75 15.75V18m-7.5-6.75h.008v.008H8.25v-.008zm0 2.25h.008v.008H8.25V13.5zm0 2.25h.008v.008H8.25v-.008zm0 2.25h.008v.008H8.25V18zm2.498-6.75h.007v.008h-.007v-.008zm0 2.25h.007v.008h-.007V13.5zm0 2.25h.007v.008h-.007v-.008zm0 2.25h.007v.008h-.007V18zm2.504-6.75h.008v.008h-.008v-.008zm0 2.25h.008v.008h-.008V13.5zm0 2.25h.008v.008h-.008v-.008zm0 2.25h.008v.008h-.008V18zm2.498-6.75h.008v.008h-.008v-.008zm0 2.25h.008v.008h-.008V13.5zM8.25 6h7.5v2.25h-7.5V6zM12 2.25c-1.892 0-3.758.11-5.593.322C5.307 2.7 4.5 3.65 4.5 4.757V19.5a2.25 2.25 0 002.25 2.25h10.5a2.25 2.25 0 002.25-2.25V4.757c0-1.108-.806-2.057-1.907-2.185A48.507 48.507 0 0012 2.25z"/></svg>
                    </button>
                    <div id="catCalcPopover" class="hidden absolute right-0 top-full mt-1 w-64 bg-white border border-gray-200 rounded-xl shadow-xl p-4 z-50">
                        <div class="flex items-center justify-between mb-3">
                            <h4 class="text-xs font-bold text-gray-900">Cost Calculator</h4>
                            <button type="button" onclick="document.getElementById('catCalcPopover').classList.add('hidden')" class="text-gray-400 hover:text-gray-600"><svg class="w-3.5 h-3.5" fill="none" stroke="currentColor" stroke-width="2" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" d="M6 18L18 6M6 6l12 12"/></svg></button>
                        </div>
                        <label class="text-[10px] font-semibold text-gray-500 uppercase">Number of videos</label>
                        <input type="number" id="catCalcInput" min="1" max="100000" value="100" class="w-full mt-1 px-3 py-2 text-sm border border-gray-200 rounded-lg focus:ring-2 focus:ring-amber-400 focus:border-amber-400 text-center font-medium" oninput="var _c=this.value*IMP_VIDEO_COST;document.getElementById('catCalcCredits').textContent=(+_c.toFixed(2));document.getElementById('catCalcUsd').textContent=(_c*<?= json_encode($_creditRate) ?>).toFixed(2);">
                        <div class="mt-3 flex items-center justify-between">
                            <div>
                                <div class="text-lg font-bold text-amber-600"><span id="catCalcCredits"><?= rtrim(rtrim(number_format(100 * (float) $_priceVideo, 2), '0'), '.') ?></span> <span class="text-xs font-normal text-gray-500">credits</span></div>
                                <div class="text-sm text-gray-500">~$<span id="catCalcUsd"><?= number_format(100 * (float) $_priceVideo * $_creditRate, 2) ?></span> USD</div>
                            </div>
                            <div class="text-right text-[10px] text-gray-400 leading-relaxed"><?= rtrim(rtrim(number_format((float) $_priceVideo, 2), '0'), '.') ?> credit / video<br>1 credit &asymp; $<?= rtrim(rtrim(number_format($_creditRate, 4), '0'), '.') ?></div>
                        </div>
                    </div>
                </div>
                <div id="catQuickBar" class="hidden flex items-center justify-between gap-2 px-3 py-2 bg-gray-50 border border-gray-200 rounded-lg mb-2">
                    <div class="flex items-center gap-2 text-xs text-gray-600 min-w-0">
                        <svg class="w-3.5 h-3.5 shrink-0 text-gray-400" fill="none" stroke="currentColor" stroke-width="2" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" d="M3 16.5v2.25A2.25 2.25 0 005.25 21h13.5A2.25 2.25 0 0021 18.75V16.5M16.5 12L12 16.5m0 0L7.5 12m4.5 4.5V3"/></svg>
                        <span id="catQuickLabel" class="truncate"></span>
                    </div>
                    <div id="catQuickActions" class="flex items-center gap-2 shrink-0">
                        <button type="button" onclick="CAT.selectAllPage()" class="px-2.5 py-1 text-[11px] font-medium text-gray-600 bg-white border border-gray-200 rounded-md hover:bg-gray-100 transition-colors">Select page</button>
                        <button type="button" id="catDownloadAllBtn" onclick="CAT.downloadAllMatching()" class="hidden px-2.5 py-1 text-[11px] font-semibold text-white bg-primary-600 rounded-md hover:bg-primary-700 transition-colors inline-flex items-center gap-1">
                            <svg class="w-3 h-3" fill="none" stroke="currentColor" stroke-width="2.5" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" d="M3 16.5v2.25A2.25 2.25 0 005.25 21h13.5A2.25 2.25 0 0021 18.75V16.5M16.5 12L12 16.5m0 0L7.5 12m4.5 4.5V3"/></svg>
                            <span id="catDownloadAllLabel">Download all</span>
                        </button>
                    </div>
                </div>
                <div id="catGrid" class="grid grid-cols-2 md:grid-cols-3 lg:grid-cols-4 xl:grid-cols-5 gap-3">
                    <div class="col-span-full text-center py-12 text-gray-400 text-sm">
                        <svg class="w-8 h-8 mx-auto mb-2 text-gray-300 animate-spin" fill="none" viewBox="0 0 24 24"><circle class="opacity-25" cx="12" cy="12" r="10" stroke="currentColor" stroke-width="4"/><path class="opacity-75" fill="currentColor" d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"/></svg>
                        Loading catalogue...
                    </div>
                </div>
            </div>

            
            <div id="catPagination" class="flex justify-center gap-1 p-3 border-t border-gray-100"></div>
        </div>
    </div>

    
    <div id="catGalleryModal" class="hidden fixed inset-0 z-[60] bg-black/60 flex items-start justify-center overflow-y-auto p-4">
        <div class="bg-white rounded-2xl shadow-2xl w-full max-w-5xl my-6">
            <div id="catGalleryModalBody" class="p-5"></div>
        </div>
    </div>

    
    <div id="catLoading" class="hidden fixed inset-0 bg-black/20 z-50 flex items-center justify-center">
        <div class="bg-white rounded-xl shadow-lg px-6 py-4 flex items-center gap-3">
            <svg class="animate-spin h-5 w-5 text-primary-600" fill="none" viewBox="0 0 24 24"><circle class="opacity-25" cx="12" cy="12" r="10" stroke="currentColor" stroke-width="4"/><path class="opacity-75" fill="currentColor" d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"/></svg>
            <span class="text-sm text-gray-700" id="catLoadingText">Loading...</span>
        </div>
    </div>

    
    <div id="catBulkBar" class="hidden fixed bottom-0 left-0 right-0 lg:left-60 bg-white border-t border-gray-200 shadow-lg z-40 px-3 py-2.5 sm:px-4 sm:py-3">
        <div class="max-w-7xl mx-auto flex flex-col gap-2 sm:flex-row sm:items-center sm:justify-between sm:gap-4">
            <div class="flex items-center justify-between gap-3">
                <div class="flex items-center gap-2.5 min-w-0">
                    <span class="text-sm font-medium text-gray-900 whitespace-nowrap"><span id="catSelectedCount">0</span> selected</span>
                    <span class="text-sm text-gray-500 whitespace-nowrap">Est. <strong id="catEstCost">0.00</strong></span>
                </div>
                <button type="button" onclick="CAT.clearSelection()" class="text-xs text-gray-400 hover:text-gray-600 shrink-0">&times; Clear</button>
            </div>
            <button type="button" id="catPurchaseBtn" onclick="CAT.openImportModal()" class="w-full sm:w-auto px-5 py-2.5 bg-green-600 text-white text-sm font-semibold rounded-lg hover:bg-green-700 transition-colors inline-flex items-center justify-center gap-2 shrink-0">
                <svg class="w-4 h-4 shrink-0" fill="none" stroke="currentColor" stroke-width="2" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" d="M13.19 8.688a4.5 4.5 0 011.242 7.244l-4.5 4.5a4.5 4.5 0 01-6.364-6.364l1.757-1.757m9.86-2.54a4.5 4.5 0 00-1.242-7.244l-4.5-4.5a4.5 4.5 0 00-6.364 6.364L4.343 8.28"/></svg>
                <span>Connect to download</span>
            </button>
        </div>
    </div>

    
    <div id="catGalleryImportModal" class="hidden fixed inset-0 z-[70] flex items-center justify-center p-4 bg-black/50" onclick="CAT.closeGalleryImportModal()">
        <div class="bg-white rounded-2xl shadow-2xl w-full max-w-xl max-h-[92vh] flex flex-col overflow-hidden" onclick="event.stopPropagation()">
            <div class="px-6 pt-5 pb-4">
                <div class="flex items-start justify-between mb-5">
                    <div>
                        <h3 class="text-lg font-bold text-gray-900" id="catGalStepTitle">Import Settings</h3>
                        <p class="text-[13px] text-gray-500 mt-0.5"><span id="catGalCount" class="font-semibold text-gray-700">0</span> galler<span id="catGalCountPlural">ies</span> &mdash; <span id="catGalCostHdr" class="font-semibold text-amber-600">0</span></p>
                    </div>
                    <button type="button" onclick="CAT.closeGalleryImportModal()" class="p-2 -mr-2 -mt-1 text-gray-400 hover:text-gray-600 rounded-full hover:bg-gray-100"><i class="fa-solid fa-xmark text-base"></i></button>
                </div>
                <div class="flex items-center">
                    <button type="button" onclick="CAT.galGoToStep(1)" class="cat-step-dot flex flex-col items-center gap-1" data-galstep="1">
                        <span class="w-8 h-8 rounded-full flex items-center justify-center text-xs font-bold bg-primary-600 text-white ring-2 ring-primary-200 transition-all" data-galdot="1">1</span>
                        <span class="text-[11px] font-semibold text-primary-700" data-gallabel="1">Settings</span>
                    </button>
                    <div class="flex-1 h-0.5 mx-1 rounded-full bg-gray-200"></div>
                    <button type="button" onclick="CAT.galGoToStep(2)" class="cat-step-dot flex flex-col items-center gap-1" data-galstep="2">
                        <span class="w-8 h-8 rounded-full flex items-center justify-center text-xs font-bold bg-gray-200 text-gray-400 transition-all" data-galdot="2">2</span>
                        <span class="text-[11px] font-medium text-gray-400" data-gallabel="2">AI</span>
                    </button>
                    <div class="flex-1 h-0.5 mx-1 rounded-full bg-gray-200"></div>
                    <button type="button" onclick="CAT.galGoToStep(3)" class="cat-step-dot flex flex-col items-center gap-1" data-galstep="3">
                        <span class="w-8 h-8 rounded-full flex items-center justify-center text-xs font-bold bg-gray-200 text-gray-400 transition-all" data-galdot="3">3</span>
                        <span class="text-[11px] font-medium text-gray-400" data-gallabel="3">Confirm</span>
                    </button>
                </div>
            </div>
            <div class="max-h-[60vh] overflow-y-auto border-t border-gray-100">
                <div id="catGalStep1" class="px-6 py-5 space-y-4">
                    <div class="text-[11px] leading-relaxed text-gray-500 bg-gray-50 border border-gray-200 rounded-lg p-2.5"><i class="fa-solid fa-circle-info text-gray-400 mr-1"></i> One <strong>Album</strong> is created per gallery &mdash; its images are downloaded and the taxonomy you choose below maps to your album taxonomy.</div>
                    <div>
                        <h4 class="text-[11px] font-semibold text-gray-400 uppercase tracking-wider mb-2">Include with import</h4>
                        <div class="rounded-xl border border-gray-200 divide-y divide-gray-100 overflow-hidden">
                            <label class="cat-gal-opt flex items-center gap-3 px-4 py-2.5 bg-gray-50/50 cursor-default" data-locked>
                                <input type="checkbox" checked disabled class="w-3.5 h-3.5 rounded border-gray-300 text-gray-400"><i class="fa-solid fa-images text-gray-300 text-xs w-4 text-center"></i><span class="text-sm text-gray-500">Images + cover</span><span class="ml-auto text-[10px] text-gray-300 font-medium">Always included</span>
                            </label>
                        <label class="cat-gal-opt flex items-center gap-3 px-4 py-2.5 hover:bg-gray-50 cursor-pointer transition-colors" data-galkey="description">
                            <input type="checkbox" checked class="w-3.5 h-3.5 rounded border-gray-300 text-primary-600 focus:ring-primary-500"><i class="fa-solid fa-align-left text-gray-400 text-xs w-4 text-center"></i><span class="text-sm text-gray-900">Description</span>
                        </label>
                        <label class="cat-gal-opt flex items-center gap-3 px-4 py-2.5 hover:bg-gray-50 cursor-pointer transition-colors" data-galkey="categories">
                            <input type="checkbox" checked class="w-3.5 h-3.5 rounded border-gray-300 text-primary-600 focus:ring-primary-500"><i class="fa-solid fa-folder text-gray-400 text-xs w-4 text-center"></i><span class="text-sm text-gray-900">Categories</span>
                        </label>
                        <label class="cat-gal-opt flex items-center gap-3 px-4 py-2.5 hover:bg-gray-50 cursor-pointer transition-colors" data-galkey="tags">
                            <input type="checkbox" checked class="w-3.5 h-3.5 rounded border-gray-300 text-primary-600 focus:ring-primary-500"><i class="fa-solid fa-hashtag text-gray-400 text-xs w-4 text-center"></i><span class="text-sm text-gray-900">Tags</span>
                        </label>
                        <label class="cat-gal-opt flex items-center gap-3 px-4 py-2.5 hover:bg-gray-50 cursor-pointer transition-colors" data-galkey="performers">
                            <input type="checkbox" checked class="w-3.5 h-3.5 rounded border-gray-300 text-primary-600 focus:ring-primary-500"><i class="fa-solid fa-star text-gray-400 text-xs w-4 text-center"></i><span class="text-sm text-gray-900">Pornstars</span>
                        </label>
                        <label class="cat-gal-opt flex items-center gap-3 px-4 py-2.5 hover:bg-gray-50 cursor-pointer transition-colors" data-galkey="channels">
                            <input type="checkbox" checked class="w-3.5 h-3.5 rounded border-gray-300 text-primary-600 focus:ring-primary-500"><i class="fa-solid fa-tv text-gray-400 text-xs w-4 text-center"></i><span class="text-sm text-gray-900">Channels</span>
                        </label>
                        <label class="cat-gal-opt flex items-center gap-3 px-4 py-2.5 hover:bg-gray-50 cursor-pointer transition-colors" data-galkey="views">
                            <input type="checkbox" class="w-3.5 h-3.5 rounded border-gray-300 text-primary-600 focus:ring-primary-500"><i class="fa-solid fa-eye text-gray-400 text-xs w-4 text-center"></i><span class="text-sm text-gray-900">Views count</span>
                        </label>
                        </div>
                    </div>
                </div>
                <div id="catGalStep2" class="hidden px-6 py-5 space-y-3">
                    <div class="flex items-center gap-2.5 px-3.5 py-2.5 rounded-xl bg-gray-50 border border-gray-100"><i class="fa-solid fa-wand-magic-sparkles text-gray-300"></i><p class="text-xs text-gray-500">Optional &mdash; AI enhances each gallery in the <strong>background</strong> after import (same #kimi engine as videos).</p></div>
                    <div class="rounded-xl border border-gray-200 overflow-hidden">
                        <label class="flex items-center gap-3 px-4 py-3.5 cursor-pointer hover:bg-gray-50/80">
                            <input type="checkbox" id="galAiRewriteTitle" onchange="CAT.galleryAiToggle('"""+cid+"""','"""+wrapid+"""')" class="w-4 h-4 rounded border-gray-300 text-indigo-600 focus:ring-indigo-500">
                            <div class="w-8 h-8 rounded-lg bg-indigo-50 flex items-center justify-center shrink-0"><i class="fa-solid fa-pen-fancy text-indigo-500 text-sm"></i></div>
                            <div class="flex-1 min-w-0"><div class="text-sm font-semibold text-gray-900">Rewrite Title</div><div class="text-[11px] text-gray-400">Unique, SEO-friendly title</div></div>
                            <span class="shrink-0 text-[11px] font-bold text-indigo-600 bg-indigo-50 px-2.5 py-1 rounded-lg">+<?= rtrim(rtrim(number_format((float) ($_priceAi['rewrite_title'] ?? 0.30), 2), '0'), '.') ?> Cr</span>
                        </label>
                        <div id="galAiTitlePromptWrap" class="hidden border-t border-gray-100 px-4 py-3 bg-gray-50/50">
                            <label class="block text-[10px] font-semibold text-gray-400 uppercase tracking-wider mb-1.5">Prompt</label>
                            <textarea id="galAiTitlePromptText" rows="2" maxlength="500" class="w-full text-xs px-3 py-2 border border-gray-200 rounded-lg focus:ring-2 focus:ring-indigo-500/20 focus:border-indigo-400 resize-none font-mono leading-relaxed"><?= htmlspecialchars($_savedTitlePrompt ?: 'Rewrite this image gallery title to be unique and SEO-friendly while keeping the same meaning. Keep it natural and under 80 characters. Do NOT add quotes around the title.') ?></textarea>
                        </div>
                    </div>
<?php if (count($_enabledLangs) > 0): ?>
                    <div class="rounded-xl border border-gray-200 overflow-hidden">
                        <label class="flex items-center gap-3 px-4 py-3.5 cursor-pointer hover:bg-gray-50/80">
                            <input type="checkbox" id="galAiTranslate" onchange="CAT.galleryAiToggle('"""+cid+"""','"""+wrapid+"""')" class="w-4 h-4 rounded border-gray-300 text-sky-600 focus:ring-sky-500">
                            <div class="w-8 h-8 rounded-lg bg-sky-50 flex items-center justify-center shrink-0"><i class="fa-solid fa-language text-sky-500 text-sm"></i></div>
                            <div class="flex-1 min-w-0"><div class="text-sm font-semibold text-gray-900">Translate Title</div><div class="text-[11px] text-gray-400"><?= count($_enabledLangs) ?> language(s): <?= implode(', ', array_map(fn($l) => strtoupper($l['code']), $_enabledLangs)) ?></div></div>
                            <span class="shrink-0 text-[11px] font-bold text-sky-600 bg-sky-50 px-2.5 py-1 rounded-lg" title="Billed per target language">+<?= $_fmtCr((float) ($_priceAiPerLang['translate'] ?? 0.05)) ?> Cr/lang <span class="font-normal opacity-70">&times; <?= count($_enabledLangs) ?> = <?= $_fmtCr((float) ($_priceAiPerLang['translate'] ?? 0.05) * count($_enabledLangs)) ?> Cr</span></span>
                        </label>
                        <div id="galAiTranslatePromptWrap" class="hidden border-t border-gray-100 px-4 py-3 bg-gray-50/50">
                            <label class="block text-[10px] font-semibold text-gray-400 uppercase tracking-wider mb-1.5">Prompt</label>
                            <textarea id="galAiTranslatePromptText" rows="2" maxlength="500" class="w-full text-xs px-3 py-2 border border-gray-200 rounded-lg focus:ring-2 focus:ring-sky-500/20 focus:border-sky-400 resize-none font-mono leading-relaxed"><?= htmlspecialchars($_savedTranslatePrompt ?: 'Translate this image gallery title accurately. Keep it natural and concise.') ?></textarea>
                        </div>
                    </div>
<?php endif; ?>
                    <div class="rounded-xl border border-gray-200 overflow-hidden">
                        <label class="flex items-center gap-3 px-4 py-3.5 cursor-pointer hover:bg-gray-50/80">
                            <input type="checkbox" id="galAiRewriteDesc" onchange="CAT.galleryAiToggle('"""+cid+"""','"""+wrapid+"""')" class="w-4 h-4 rounded border-gray-300 text-emerald-600 focus:ring-emerald-500">
                            <div class="w-8 h-8 rounded-lg bg-emerald-50 flex items-center justify-center shrink-0"><i class="fa-solid fa-paragraph text-emerald-500 text-sm"></i></div>
                            <div class="flex-1 min-w-0"><div class="text-sm font-semibold text-gray-900">Rewrite Description</div><div class="text-[11px] text-gray-400">Unique SEO description</div></div>
                            <span class="shrink-0 text-[11px] font-bold text-emerald-600 bg-emerald-50 px-2.5 py-1 rounded-lg">+<?= rtrim(rtrim(number_format((float) ($_priceAi['rewrite_description'] ?? 0.30), 2), '0'), '.') ?> Cr</span>
                        </label>
                        <div id="galAiDescPromptWrap" class="hidden border-t border-gray-100 px-4 py-3 bg-gray-50/50">
                            <label class="block text-[10px] font-semibold text-gray-400 uppercase tracking-wider mb-1.5">Prompt</label>
                            <textarea id="galAiDescPromptText" rows="2" maxlength="500" class="w-full text-xs px-3 py-2 border border-gray-200 rounded-lg focus:ring-2 focus:ring-emerald-500/20 focus:border-emerald-400 resize-none font-mono leading-relaxed"><?= htmlspecialchars($_savedDescPrompt ?: 'Rewrite this image gallery description to be unique and SEO-friendly. Keep it concise (2-3 sentences max). Do NOT use markdown or HTML.') ?></textarea>
                        </div>
                    </div>
<?php if (count($_enabledLangs) > 0): ?>
                    <div class="rounded-xl border border-gray-200 overflow-hidden">
                        <label class="flex items-center gap-3 px-4 py-3.5 cursor-pointer hover:bg-gray-50/80">
                            <input type="checkbox" id="galAiTransDesc" onchange="CAT.galleryAiToggle('"""+cid+"""','"""+wrapid+"""')" class="w-4 h-4 rounded border-gray-300 text-teal-600 focus:ring-teal-500">
                            <div class="w-8 h-8 rounded-lg bg-teal-50 flex items-center justify-center shrink-0"><i class="fa-solid fa-language text-teal-500 text-sm"></i></div>
                            <div class="flex-1 min-w-0"><div class="text-sm font-semibold text-gray-900">Translate Description</div><div class="text-[11px] text-gray-400"><?= count($_enabledLangs) ?> language(s)</div></div>
                            <span class="shrink-0 text-[11px] font-bold text-teal-600 bg-teal-50 px-2.5 py-1 rounded-lg" title="Billed per target language">+<?= $_fmtCr((float) ($_priceAiPerLang['translate_description'] ?? 0.06)) ?> Cr/lang <span class="font-normal opacity-70">&times; <?= count($_enabledLangs) ?> = <?= $_fmtCr((float) ($_priceAiPerLang['translate_description'] ?? 0.06) * count($_enabledLangs)) ?> Cr</span></span>
                        </label>
                        <div id="galAiTransDescPromptWrap" class="hidden border-t border-gray-100 px-4 py-3 bg-gray-50/50">
                            <label class="block text-[10px] font-semibold text-gray-400 uppercase tracking-wider mb-1.5">Prompt</label>
                            <textarea id="galAiTransDescPromptText" rows="2" maxlength="500" class="w-full text-xs px-3 py-2 border border-gray-200 rounded-lg focus:ring-2 focus:ring-teal-500/20 focus:border-teal-400 resize-none font-mono leading-relaxed"><?= htmlspecialchars($_savedTranslateDescPrompt ?: 'Translate this image gallery description accurately into each target language.') ?></textarea>
                        </div>
                    </div>
<?php endif; ?>
                </div>
                <div id="catGalStep3" class="hidden px-6 py-5"><div id="catGalSummary"></div></div>
            </div>
            <div class="px-6 py-3.5 bg-gray-50/80 border-t border-gray-100 flex items-center justify-between">
                <div class="flex items-center gap-3">
                    <button type="button" id="catGalBackBtn" onclick="CAT.galPrevStep()" class="hidden text-sm text-gray-500 hover:text-gray-700 font-medium inline-flex items-center gap-1.5"><i class="fa-solid fa-arrow-left text-xs"></i> Back</button>
                    <button type="button" onclick="CAT.closeGalleryImportModal()" class="text-sm text-gray-400 hover:text-gray-600">Cancel</button>
                </div>
                <div class="flex items-center gap-2.5">
                    <button type="button" id="catGalNextBtn" onclick="CAT.galNextStep()" class="px-5 py-2 bg-primary-600 text-white text-sm font-semibold rounded-xl hover:bg-primary-700 inline-flex items-center gap-2">Continue <i class="fa-solid fa-arrow-right text-xs"></i></button>
                    <button type="button" id="catGalImportBtn" onclick="CAT.confirmGalleryImport()" class="hidden px-6 py-2.5 bg-green-600 text-white text-sm font-bold rounded-xl hover:bg-green-700 inline-flex items-center gap-2"><i class="fa-solid fa-cart-shopping"></i> Purchase &amp; Download</button>
                </div>
            </div>
        </div>
    </div>


    
    <style>
        .import-step-fade { animation: importFadeIn .25s ease-out; }
        @keyframes importFadeIn { from { opacity:0; transform:translateY(6px) } to { opacity:1; transform:translateY(0) } }
        .import-stepper-line { transition: background-color .3s ease; }
        .ai-card-body { transition: max-height .3s ease, opacity .2s ease; max-height: 0; opacity: 0; overflow: hidden; }
        .ai-card-body.open { max-height: 500px; opacity: 1; }
        .ai-test-result-enter { animation: importFadeIn .2s ease-out; }
    </style>
    <div id="catImportOverlay" class="hidden fixed inset-0 bg-black/50 backdrop-blur-sm z-[60] transition-opacity"></div>
    <div id="catImportModal" class="hidden fixed inset-0 z-[60] flex items-center justify-center p-4">
        <div class="bg-white rounded-2xl shadow-2xl w-full max-w-xl overflow-hidden import-step-fade" onclick="event.stopPropagation()">

            
            <div class="px-6 pt-5 pb-4">
                <div class="flex items-start justify-between mb-5">
                    <div>
                        <h3 class="text-lg font-bold text-gray-900" id="catImportStepTitle">Import Settings</h3>
                        <p class="text-[13px] text-gray-500 mt-0.5">
                            <span id="catImportCount" class="font-semibold text-gray-700">0</span> video(s) &mdash;
                            <span id="catImportCost" class="font-semibold text-green-600">0</span>
                        </p>
                    </div>
                    <button type="button" onclick="CAT.closeImportModal()" class="p-2 -mr-2 -mt-1 text-gray-400 hover:text-gray-600 rounded-full hover:bg-gray-100 transition-colors">
                        <i class="fa-solid fa-xmark text-base"></i>
                    </button>
                </div>

                
                <div class="flex items-center" id="catImportSteps">
                    
                    <button type="button" onclick="CAT.goToImportStep(1)" class="cat-step-dot flex flex-col items-center gap-1 group" data-step="1">
                        <span class="w-8 h-8 rounded-full flex items-center justify-center text-xs font-bold bg-primary-600 text-white shadow-sm shadow-primary-200 transition-all duration-300 ring-2 ring-primary-200">1</span>
                        <span class="text-[11px] font-semibold text-primary-700 transition-colors">Files</span>
                    </button>
                    <div class="flex-1 h-0.5 mx-1 rounded-full bg-gray-200 import-stepper-line" data-line="1"></div>
                    
                    <button type="button" onclick="CAT.goToImportStep(2)" class="cat-step-dot flex flex-col items-center gap-1 group" data-step="2">
                        <span class="w-8 h-8 rounded-full flex items-center justify-center text-xs font-bold bg-gray-200 text-gray-400 transition-all duration-300">2</span>
                        <span class="text-[11px] font-medium text-gray-400 transition-colors">AI</span>
                    </button>
                    <div class="flex-1 h-0.5 mx-1 rounded-full bg-gray-200 import-stepper-line" data-line="2"></div>
                    
                    <button type="button" onclick="CAT.goToImportStep(3)" class="cat-step-dot flex flex-col items-center gap-1 group" data-step="3">
                        <span class="w-8 h-8 rounded-full flex items-center justify-center text-xs font-bold bg-gray-200 text-gray-400 transition-all duration-300">3</span>
                        <span class="text-[11px] font-medium text-gray-400 transition-colors">Confirm</span>
                    </button>
                </div>
            </div>

            
            <div class="max-h-[60vh] overflow-y-auto border-t border-gray-100">

                
                <div id="catImportStep1" class="px-6 py-5 space-y-5 import-step-fade">

                    <?php if (TranscodeManager::isEnabled()):
                        $tcFormats = TranscodeManager::getFormats();
                        $tcTimeline = Setting::get('transcode_timeline', '0') === '1';
                        $tcHasConvServer = (bool)Database::fetchOne("SELECT id FROM transcode_servers WHERE is_active = 1 LIMIT 1");
                        uasort($tcFormats, fn($a, $b) => ((int)($b['h'] ?? 0)) <=> ((int)($a['h'] ?? 0)));  
                    ?>
                    <?php if (!empty($tcFormats)): ?>
                    <div id="tcQualityBlock">
                        <h4 class="text-[11px] font-semibold text-gray-400 uppercase tracking-wider mb-1">Output quality</h4>
                        <p id="tcSubtitle" class="text-[11px] text-gray-500 mb-2.5 leading-snug"></p>

                        <div id="tcOutcomes" class="space-y-1.5">
                            <label class="tc-out flex items-start gap-3 px-4 py-3 rounded-xl border-2 border-gray-200 cursor-pointer transition-all has-[:checked]:border-blue-500 has-[:checked]:bg-blue-50/40">
                                <input type="radio" name="tcOut" value="keep" checked class="mt-0.5 w-4 h-4 text-blue-600 focus:ring-blue-500">
                                <span class="flex-1 min-w-0">
                                    <span class="block text-sm font-bold text-gray-900">Keep originals only</span>
                                    <span class="block text-[11px] text-gray-500 leading-snug mt-0.5">Import the files as-is. No conversion. Fastest, least disk.</span>
                                </span>
                            </label>
                            <label class="tc-out flex items-start gap-3 px-4 py-3 rounded-xl border-2 border-gray-200 cursor-pointer transition-all has-[:checked]:border-blue-500 has-[:checked]:bg-blue-50/40">
                                <input type="radio" name="tcOut" value="stream" class="mt-0.5 w-4 h-4 text-blue-600 focus:ring-blue-500">
                                <span class="flex-1 min-w-0">
                                    <span class="block text-sm font-bold text-gray-900">Stream smoothly</span>
                                    <span class="block text-[11px] text-gray-500 leading-snug mt-0.5">Keep every original at full quality, and add lower qualities so the player adapts to slow connections. Deletes nothing.</span>
                                </span>
                            </label>
                            <label class="tc-out flex items-start gap-3 px-4 py-3 rounded-xl border-2 border-gray-200 cursor-pointer transition-all has-[:checked]:border-amber-500 has-[:checked]:bg-amber-50/40">
                                <input type="radio" name="tcOut" value="shrink" class="mt-0.5 w-4 h-4 text-amber-600 focus:ring-amber-500">
                                <span class="flex-1 min-w-0">
                                    <span class="block text-sm font-bold text-gray-900">Shrink to save space</span>
                                    <span class="block text-[11px] text-gray-500 leading-snug mt-0.5">Downscale big videos and <b class="text-gray-700">delete the bigger originals</b> to free disk. Smaller videos are left untouched.</span>
                                    <span id="tcCapWrap" style="display:none" class="items-center gap-2 mt-2 flex-wrap">
                                        <span class="text-[11px] font-medium text-gray-700">Make every video no bigger than</span>
                                        <select id="tcCapSel" onclick="event.stopPropagation()" class="text-xs border-2 border-gray-200 rounded-lg px-2 py-1.5 font-bold text-gray-800 focus:border-amber-500 outline-none cursor-pointer"></select>
                                    </span>
                                </span>
                            </label>
                        </div>

                        <div id="tcReassure" class="mt-2.5 px-3 py-2.5 rounded-lg text-[11px] leading-relaxed"></div>

                        <label id="tcConfirmWrap" style="display:none" class="items-center gap-2.5 mt-2 px-3 py-2 rounded-lg bg-red-50 border border-red-200 cursor-pointer">
                            <input type="checkbox" id="tcConfirm" class="w-4 h-4 rounded border-red-300 text-red-600 focus:ring-red-500 shrink-0">
                            <span id="tcConfirmLbl" class="text-[11px] font-semibold text-red-700"></span>
                        </label>

                        <script>window.TC_FORMATS = <?= json_encode(array_values(array_map(fn($t, $f) => ['task' => $t, 'h' => (int)$f['h'], 'w' => (int)$f['w']], array_keys($tcFormats), $tcFormats))) ?>; window.TC_TIMELINE = <?= $tcTimeline ? 'true' : 'false' ?>; window.TC_HAS_CONV_SERVER = <?= $tcHasConvServer ? 'true' : 'false' ?>;</script>
                    </div>
                    <?php endif; ?>
                    <?php elseif (!TranscodeManager::canProcess()): ?>
                    <div class="flex items-start gap-2.5 px-3.5 py-2.5 bg-amber-50 border border-amber-200 rounded-xl text-xs">
                        <i class="fa-solid fa-lightbulb text-amber-400 mt-0.5"></i>
                        <div>
                            <span class="text-amber-800 font-medium">Transcoding is not available.</span>
                            <span class="text-amber-700">Only the source quality will be served. <a href="/admin/settings?tab=transcode" class="underline font-medium">Configure transcoding</a> to auto-generate multiple resolutions.</span>
                        </div>
                    </div>
                    <?php endif; ?>

                    
                    <div>
                        <h4 class="text-[11px] font-semibold text-gray-400 uppercase tracking-wider mb-2">Include with import</h4>
                        <div class="rounded-xl border border-gray-200 divide-y divide-gray-100 overflow-hidden">
                            
                            <label class="cat-import-opt flex items-center gap-3 px-4 py-2.5 bg-gray-50/50 cursor-default" data-key="thumbnail" data-locked>
                                <input type="checkbox" checked disabled class="w-3.5 h-3.5 rounded border-gray-300 text-gray-400">
                                <i class="fa-solid fa-image text-gray-300 text-xs w-4 text-center"></i>
                                <span class="text-sm text-gray-500">Thumbnail</span>
                                <span class="ml-auto text-[10px] text-gray-300 font-medium">Always included</span>
                            </label>
                            <label class="cat-import-opt flex items-center gap-3 px-4 py-2.5 bg-gray-50/50 cursor-default" data-key="thumbnail_small" data-locked>
                                <input type="checkbox" checked disabled class="w-3.5 h-3.5 rounded border-gray-300 text-gray-400">
                                <i class="fa-solid fa-image text-gray-300 text-[10px] w-4 text-center"></i>
                                <span class="text-sm text-gray-500">Small Thumbnail</span>
                                <span class="ml-auto text-[10px] text-gray-300 font-medium">Always included</span>
                            </label>
                            
                            <label class="cat-import-opt flex items-center gap-3 px-4 py-2.5 hover:bg-green-50/40 cursor-pointer transition-colors" data-key="preview">
                                <input type="checkbox" checked class="w-3.5 h-3.5 rounded border-gray-300 text-green-600 focus:ring-green-500">
                                <i class="fa-solid fa-clapperboard text-green-500 text-xs w-4 text-center"></i>
                                <span class="text-sm text-gray-900 font-medium">Preview MP4</span>
                                <span class="ml-auto text-[10px] text-green-600 font-semibold bg-green-50 px-1.5 py-0.5 rounded">Recommended</span>
                            </label>
                            <label class="cat-import-opt flex items-center gap-3 px-4 py-2.5 hover:bg-gray-50 cursor-pointer transition-colors" data-key="description">
                                <input type="checkbox" checked class="w-3.5 h-3.5 rounded border-gray-300 text-primary-600 focus:ring-primary-500">
                                <i class="fa-solid fa-align-left text-gray-400 text-xs w-4 text-center"></i>
                                <span class="text-sm text-gray-900">Description</span>
                            </label>
                            <label class="cat-import-opt flex items-center gap-3 px-4 py-2.5 hover:bg-gray-50 cursor-pointer transition-colors" data-key="categories">
                                <input type="checkbox" checked class="w-3.5 h-3.5 rounded border-gray-300 text-primary-600 focus:ring-primary-500">
                                <i class="fa-solid fa-folder text-gray-400 text-xs w-4 text-center"></i>
                                <span class="text-sm text-gray-900">Categories</span>
                            </label>
                            <label class="cat-import-opt flex items-center gap-3 px-4 py-2.5 hover:bg-gray-50 cursor-pointer transition-colors" data-key="tags">
                                <input type="checkbox" checked class="w-3.5 h-3.5 rounded border-gray-300 text-primary-600 focus:ring-primary-500">
                                <i class="fa-solid fa-hashtag text-gray-400 text-xs w-4 text-center"></i>
                                <span class="text-sm text-gray-900">Tags</span>
                            </label>
                            <label class="cat-import-opt flex items-center gap-3 px-4 py-2.5 hover:bg-gray-50 cursor-pointer transition-colors" data-key="performers">
                                <input type="checkbox" checked class="w-3.5 h-3.5 rounded border-gray-300 text-primary-600 focus:ring-primary-500">
                                <i class="fa-solid fa-star text-gray-400 text-xs w-4 text-center"></i>
                                <span class="text-sm text-gray-900" id="catImpPerfLabel">Pornstars</span>
                            </label>
                            <label class="cat-import-opt flex items-center gap-3 px-4 py-2.5 hover:bg-gray-50 cursor-pointer transition-colors" data-key="channels">
                                <input type="checkbox" checked class="w-3.5 h-3.5 rounded border-gray-300 text-primary-600 focus:ring-primary-500">
                                <i class="fa-solid fa-clapperboard text-gray-400 text-xs w-4 text-center"></i>
                                <span class="text-sm text-gray-900">Channels</span>
                            </label>
                            <label class="cat-import-opt flex items-center gap-3 px-4 py-2.5 hover:bg-gray-50 cursor-pointer transition-colors" data-key="views">
                                <input type="checkbox" checked class="w-3.5 h-3.5 rounded border-gray-300 text-primary-600 focus:ring-primary-500">
                                <i class="fa-solid fa-eye text-gray-400 text-xs w-4 text-center"></i>
                                <span class="text-sm text-gray-900">Views count</span>
                            </label>
                        </div>
                    </div>
                </div>

                
                <div id="catImportStep2" class="hidden px-6 py-5 space-y-3 import-step-fade">
                    <div class="flex items-center gap-2.5 px-3.5 py-2.5 rounded-xl bg-gray-50 border border-gray-100">
                        <i class="fa-solid fa-wand-magic-sparkles text-gray-300"></i>
                        <p class="text-xs text-gray-500">Optional &mdash; AI will process each video during import. Skip if not needed.</p>
                    </div>

                    
                    <div class="rounded-xl border border-gray-200 overflow-hidden transition-all duration-200" id="catAiTitleBlock">
                        <label class="flex items-center gap-3 px-4 py-3.5 cursor-pointer hover:bg-gray-50/80 transition-colors">
                            <input type="checkbox" id="catAiRewriteTitle" onchange="CAT.toggleAiOption('title')" class="w-4 h-4 rounded border-gray-300 text-indigo-600 focus:ring-indigo-500">
                            <div class="w-8 h-8 rounded-lg bg-indigo-50 flex items-center justify-center shrink-0">
                                <i class="fa-solid fa-pen-fancy text-indigo-500 text-sm"></i>
                            </div>
                            <div class="flex-1 min-w-0">
                                <div class="text-sm font-semibold text-gray-900">Rewrite Title</div>
                                <div class="text-[11px] text-gray-400">Unique, SEO-friendly title</div>
                            </div>
                            <span class="shrink-0 text-[11px] font-bold text-indigo-600 bg-indigo-50 px-2.5 py-1 rounded-lg">+<?= rtrim(rtrim(number_format((float) ($_priceAi['rewrite_title'] ?? 0.30), 2), '0'), '.') ?> Cr <span class="font-normal text-indigo-400" id="catAiTitleUsd"></span></span>
                        </label>
                        <div id="catAiTitlePrompt" class="ai-card-body border-t border-gray-100">
                            <div class="px-4 py-3 bg-gray-50/50">
                                <label class="block text-[10px] font-semibold text-gray-400 uppercase tracking-wider mb-1.5">Prompt</label>
                                <textarea id="catAiTitlePromptText" rows="2" maxlength="500" class="w-full text-xs px-3 py-2 border border-gray-200 rounded-lg focus:ring-2 focus:ring-indigo-500/20 focus:border-indigo-400 resize-none font-mono leading-relaxed transition-shadow" placeholder="Custom prompt..."><?= htmlspecialchars($_savedTitlePrompt ?: 'Rewrite this porn video title to be unique and SEO-friendly while keeping the same meaning. Keep it natural and under 80 characters. Do NOT add quotes around the title.') ?></textarea>
                                <div class="flex items-center justify-between mt-2">
                                    <p class="text-[10px] text-gray-400"><i class="fa-solid fa-lightbulb text-amber-400 mr-0.5"></i> Customize for your site's writing style</p>
                                    <div class="flex items-center gap-2">
                                        <span class="text-[10px] text-gray-300" id="catAiTitleTestCount">0 / 3</span>
                                        <button type="button" id="catAiTitleTestBtn" onclick="CAT.testAiPrompt('title')"
                                            class="text-[11px] font-semibold text-indigo-600 hover:text-indigo-800 bg-indigo-50 hover:bg-indigo-100 px-2.5 py-1 rounded-lg inline-flex items-center gap-1 disabled:opacity-40 disabled:cursor-not-allowed transition-colors"
                                            disabled>
                                            <i class="fa-solid fa-flask text-[10px]"></i> Test
                                        </button>
                                    </div>
                                </div>
                                <div id="catAiTitleTestResult" class="hidden mt-2.5 rounded-lg border border-gray-200 overflow-hidden text-xs"></div>
                            </div>
                        </div>
                    </div>

                    
                    <?php if (count($_enabledLangs) > 0): ?>
                    <div class="rounded-xl border border-gray-200 overflow-hidden transition-all duration-200" id="catAiTranslateBlock">
                        <label class="flex items-center gap-3 px-4 py-3.5 cursor-pointer hover:bg-gray-50/80 transition-colors">
                            <input type="checkbox" id="catAiTranslate" onchange="CAT.toggleAiOption('translate')" class="w-4 h-4 rounded border-gray-300 text-sky-600 focus:ring-sky-500">
                            <div class="w-8 h-8 rounded-lg bg-sky-50 flex items-center justify-center shrink-0">
                                <i class="fa-solid fa-language text-sky-500 text-sm"></i>
                            </div>
                            <div class="flex-1 min-w-0">
                                <div class="text-sm font-semibold text-gray-900">Translate Title</div>
                                <div id="catAiTranslateSubtitle" class="text-[11px] text-gray-400"><?= count($_enabledLangs) ?> language(s): <?= implode(', ', array_map(fn($l) => strtoupper($l['code']), $_enabledLangs)) ?></div>
                            </div>
                            <span class="shrink-0 text-[11px] font-bold text-sky-600 bg-sky-50 px-2.5 py-1 rounded-lg" title="Billed per target language">+<?= $_fmtCr((float) ($_priceAiPerLang['translate'] ?? 0.05)) ?> Cr/lang <span class="font-normal opacity-70">&times; <?= count($_enabledLangs) ?> = <?= $_fmtCr((float) ($_priceAiPerLang['translate'] ?? 0.05) * count($_enabledLangs)) ?> Cr</span> <span class="font-normal text-sky-400" id="catAiTranslateUsd"></span></span>
                        </label>
                        <div id="catAiTranslatePrompt" class="ai-card-body border-t border-gray-100">
                            <div class="px-4 py-3 bg-gray-50/50">
                                <div id="catAiTranslateRewriteNotice" class="hidden mb-2.5 flex items-center gap-2 px-3 py-2 bg-sky-50 border border-sky-200 rounded-lg text-[11px] text-sky-700">
                                    <i class="fa-solid fa-link text-sky-400"></i>
                                    <span><strong>Rewrite Title</strong> is on &mdash; translations use the <strong>rewritten</strong> title.</span>
                                </div>
                                <label class="block text-[10px] font-semibold text-gray-400 uppercase tracking-wider mb-1.5">Prompt</label>
                                <textarea id="catAiTranslatePromptText" rows="3" maxlength="500" class="w-full text-xs px-3 py-2 border border-gray-200 rounded-lg focus:ring-2 focus:ring-sky-500/20 focus:border-sky-400 resize-none font-mono leading-relaxed transition-shadow" placeholder="Translation prompt..."><?= htmlspecialchars($_savedTranslatePrompt ?: 'Translate this ' . ($_defaultLang['name'] ?? 'English') . ' porn title (max 60 chars each).

RULES:
1. Translate ALL words to target language (NO mixing languages)
2. Keep same meaning (do not add or remove words)
3. Natural phrasing (native speaker quality)
4. Understand adult content terminology') ?></textarea>
                                <code id="catAiTranslateFormat" class="hidden"><?php foreach ($_enabledLangs as $lang): ?>&lt;<?= strtoupper($lang['code']) ?>&gt;<?= htmlspecialchars($lang['name']) ?>&lt;/<?= strtoupper($lang['code']) ?>&gt;
<?php endforeach; ?></code>
                                <div class="flex items-center justify-end gap-2 mt-2">
                                    <span class="text-[10px] text-gray-300" id="catAiTranslateTestCount">0 / 3</span>
                                    <button type="button" id="catAiTranslateTestBtn" onclick="CAT.testAiPrompt('translate')"
                                        class="text-[11px] font-semibold text-sky-600 hover:text-sky-800 bg-sky-50 hover:bg-sky-100 px-2.5 py-1 rounded-lg inline-flex items-center gap-1 disabled:opacity-40 disabled:cursor-not-allowed transition-colors"
                                        disabled>
                                        <i class="fa-solid fa-flask text-[10px]"></i> Test
                                    </button>
                                </div>
                                <div id="catAiTranslateTestResult" class="hidden mt-2.5 rounded-lg border border-gray-200 overflow-hidden text-xs"></div>
                            </div>
                        </div>
                    </div>
                    <?php endif; ?>

                    
                    <div class="rounded-xl border border-gray-200 overflow-hidden transition-all duration-200" id="catAiDescBlock">
                        <label class="flex items-center gap-3 px-4 py-3.5 cursor-pointer hover:bg-gray-50/80 transition-colors">
                            <input type="checkbox" id="catAiRewriteDesc" onchange="CAT.toggleAiOption('desc')" class="w-4 h-4 rounded border-gray-300 text-emerald-600 focus:ring-emerald-500">
                            <div class="w-8 h-8 rounded-lg bg-emerald-50 flex items-center justify-center shrink-0">
                                <i class="fa-solid fa-paragraph text-emerald-500 text-sm"></i>
                            </div>
                            <div class="flex-1 min-w-0">
                                <div class="text-sm font-semibold text-gray-900">Rewrite Description</div>
                                <div class="text-[11px] text-gray-400">Unique SEO description</div>
                            </div>
                            <span class="shrink-0 text-[11px] font-bold text-emerald-600 bg-emerald-50 px-2.5 py-1 rounded-lg">+<?= rtrim(rtrim(number_format((float) ($_priceAi['rewrite_description'] ?? 0.30), 2), '0'), '.') ?> Cr <span class="font-normal text-emerald-400" id="catAiDescUsd"></span></span>
                        </label>
                        <div id="catAiDescPrompt" class="ai-card-body border-t border-gray-100">
                            <div class="px-4 py-3 bg-gray-50/50">
                                <label class="block text-[10px] font-semibold text-gray-400 uppercase tracking-wider mb-1.5">Prompt</label>
                                <textarea id="catAiDescPromptText" rows="2" maxlength="500" class="w-full text-xs px-3 py-2 border border-gray-200 rounded-lg focus:ring-2 focus:ring-emerald-500/20 focus:border-emerald-400 resize-none font-mono leading-relaxed transition-shadow" placeholder="Custom prompt..."><?= htmlspecialchars($_savedDescPrompt ?: 'Rewrite this porn video description to be unique and SEO-friendly. Keep it concise (2-3 sentences max). Do NOT use markdown or HTML.') ?></textarea>
                                <div class="flex items-center justify-between mt-2">
                                    <p class="text-[10px] text-gray-400"><i class="fa-solid fa-lightbulb text-amber-400 mr-0.5"></i> Customize for your site's writing style</p>
                                    <div class="flex items-center gap-2">
                                        <span class="text-[10px] text-gray-300" id="catAiDescTestCount">0 / 3</span>
                                        <button type="button" id="catAiDescTestBtn" onclick="CAT.testAiPrompt('desc')"
                                            class="text-[11px] font-semibold text-emerald-600 hover:text-emerald-800 bg-emerald-50 hover:bg-emerald-100 px-2.5 py-1 rounded-lg inline-flex items-center gap-1 disabled:opacity-40 disabled:cursor-not-allowed transition-colors"
                                            disabled>
                                            <i class="fa-solid fa-flask text-[10px]"></i> Test
                                        </button>
                                    </div>
                                </div>
                                <div id="catAiDescTestResult" class="hidden mt-2.5 rounded-lg border border-gray-200 overflow-hidden text-xs"></div>
                            </div>
                        </div>
                    </div>

                    
                    <?php if (count($_enabledLangs) > 0): ?>
                    <div class="rounded-xl border border-gray-200 overflow-hidden transition-all duration-200" id="catAiTransDescBlock">
                        <label class="flex items-center gap-3 px-4 py-3.5 cursor-pointer hover:bg-gray-50/80 transition-colors">
                            <input type="checkbox" id="catAiTransDesc" onchange="CAT.toggleAiOption('transdesc')" class="w-4 h-4 rounded border-gray-300 text-teal-600 focus:ring-teal-500">
                            <div class="w-8 h-8 rounded-lg bg-teal-50 flex items-center justify-center shrink-0">
                                <i class="fa-solid fa-language text-teal-500 text-sm"></i>
                            </div>
                            <div class="flex-1 min-w-0">
                                <div class="text-sm font-semibold text-gray-900">Translate Description</div>
                                <div id="catAiTransDescSubtitle" class="text-[11px] text-gray-400"><?= count($_enabledLangs) ?> language(s): <?= implode(', ', array_map(fn($l) => strtoupper($l['code']), $_enabledLangs)) ?></div>
                            </div>
                            <span class="shrink-0 text-[11px] font-bold text-teal-600 bg-teal-50 px-2.5 py-1 rounded-lg" title="Billed per target language">+<?= $_fmtCr((float) ($_priceAiPerLang['translate_description'] ?? 0.06)) ?> Cr/lang <span class="font-normal opacity-70">&times; <?= count($_enabledLangs) ?> = <?= $_fmtCr((float) ($_priceAiPerLang['translate_description'] ?? 0.06) * count($_enabledLangs)) ?> Cr</span> <span class="font-normal text-teal-400" id="catAiTransDescUsd"></span></span>
                        </label>
                        <div id="catAiTransDescPrompt" class="ai-card-body border-t border-gray-100">
                            <div class="px-4 py-3 bg-gray-50/50">
                                <div id="catAiTransDescRewriteNotice" class="hidden mb-2.5 flex items-center gap-2 px-3 py-2 bg-teal-50 border border-teal-200 rounded-lg text-[11px] text-teal-700">
                                    <i class="fa-solid fa-link text-teal-400"></i>
                                    <span><strong>Rewrite Description</strong> is on &mdash; translations use the <strong>rewritten</strong> description.</span>
                                </div>
                                <label class="block text-[10px] font-semibold text-gray-400 uppercase tracking-wider mb-1.5">Prompt</label>
                                <textarea id="catAiTransDescPromptText" rows="3" maxlength="500" class="w-full text-xs px-3 py-2 border border-gray-200 rounded-lg focus:ring-2 focus:ring-teal-500/20 focus:border-teal-400 resize-none font-mono leading-relaxed transition-shadow" placeholder="Description translation prompt..."><?= htmlspecialchars($_savedTranslateDescPrompt ?: 'Translate this ' . ($_defaultLang['name'] ?? 'English') . ' porn video description into each target language.

RULES:
1. Translate ALL words to the target language (NO mixing languages)
2. Keep the same meaning, tone and adult terminology (native speaker quality)
3. Do NOT use markdown or HTML
4. Output ONLY the translation inside the XML tags') ?></textarea>
                                <code id="catAiTransDescFormat" class="hidden"><?php foreach ($_enabledLangs as $lang): ?>&lt;<?= strtoupper($lang['code']) ?>&gt;<?= htmlspecialchars($lang['name']) ?>&lt;/<?= strtoupper($lang['code']) ?>&gt;
<?php endforeach; ?></code>
                                <div class="flex items-center justify-end gap-2 mt-2">
                                    <span class="text-[10px] text-gray-300" id="catAiTransDescTestCount">0 / 3</span>
                                    <button type="button" id="catAiTransDescTestBtn" onclick="CAT.testAiPrompt('transdesc')"
                                        class="text-[11px] font-semibold text-teal-600 hover:text-teal-800 bg-teal-50 hover:bg-teal-100 px-2.5 py-1 rounded-lg inline-flex items-center gap-1 disabled:opacity-40 disabled:cursor-not-allowed transition-colors"
                                        disabled>
                                        <i class="fa-solid fa-flask text-[10px]"></i> Test
                                    </button>
                                </div>
                                <div id="catAiTransDescTestResult" class="hidden mt-2.5 rounded-lg border border-gray-200 overflow-hidden text-xs"></div>
                            </div>
                        </div>
                    </div>
                    <?php endif; ?>
                </div>

                
                <div id="catImportStep3" class="hidden px-6 py-5 import-step-fade">
                    <div id="catImportSummary"></div>
                </div>

            </div>

            
            <div class="px-6 py-3.5 bg-gray-50/80 border-t border-gray-100 flex items-center justify-between">
                <div class="flex items-center gap-3">
                    <button type="button" id="catImportBackBtn" onclick="CAT.prevImportStep()" class="hidden text-sm text-gray-500 hover:text-gray-700 font-medium inline-flex items-center gap-1.5 transition-colors">
                        <i class="fa-solid fa-arrow-left text-xs"></i> Back
                    </button>
                    <button type="button" id="catImportCancelBtn" onclick="CAT.closeImportModal()" class="text-sm text-gray-400 hover:text-gray-600 transition-colors">Cancel</button>
                </div>
                <div class="flex items-center gap-2.5">
                    <button type="button" id="catImportNextBtn" onclick="CAT.nextImportStep()" class="px-5 py-2 bg-primary-600 text-white text-sm font-semibold rounded-xl hover:bg-primary-700 transition-all inline-flex items-center gap-2 shadow-sm shadow-primary-200">
                        Continue <i class="fa-solid fa-arrow-right text-xs"></i>
                    </button>
                    <button type="button" id="catImportConfirmBtn" onclick="CAT.confirmImport()" class="hidden px-6 py-2.5 bg-green-600 text-white text-sm font-bold rounded-xl hover:bg-green-700 transition-all inline-flex items-center gap-2 shadow-sm shadow-green-200 disabled:opacity-50 disabled:cursor-not-allowed disabled:shadow-none">
                        <i class="fa-solid fa-cart-shopping"></i> Purchase & Download
                    </button>
                </div>
            </div>
        </div>
    </div>

</div>


