            <h1>Podcasty a Záznamy pořadů</h1>
            <div style="display:flex; gap: 10px; margin-bottom: 20px;">
                <button onclick="showPodTab('podcasts')">Podcasty a Záznamy</button>
                <button onclick="showPodTab('airchecks')">AirChecky (Hodiny z vysílání)</button>
            </div>
            
            <div id="pod-podcasts" class="pod-tab" style="display:block;">
                <div style="margin-bottom: 20px;">
                    <button onclick="openPodcastModal()">➕ Přidat podcast / záznam</button>
                </div>
            <div class="modal-overlay" id="podcastModal">
                <div class="modal-content" style="width: 800px; max-height: 90vh; overflow-y: auto;">
                    <h3>Přidat / Upravit podcast</h3>
                    <form id="form-podcasts" class="form-group" style="flex-wrap: wrap;">
                        <input type="hidden" id="podId"> <input type="text" id="podTitle" placeholder="Název záznamu / epizody" required style="width:100%;">
                        <label style="width:100%; margin-top: 10px;">Audio soubor (MP3, WAV): <input type="file" id="podAudio" accept="audio/*" style="width:100%; border: 1px solid var(--glass-border); padding: 8px; border-radius: 8px; background: rgba(0,0,0,0.2);"></label>
                        <div id="podAudioPreview" style="width:100%;"></div>
                        <label style="width:100%; margin-top: 10px;">Obrázek (volitelný): <input type="file" id="podImage" accept="image/*" style="width:100%; border: 1px solid var(--glass-border); padding: 8px; border-radius: 8px; background: rgba(0,0,0,0.2);"></label> <div id="podImagePreview" style="width:100%; margin-bottom:10px;"></div>
                        <textarea id="podDesc" class="tinymce" rows="8" placeholder="Popis záznamu" style="width:100%; background: rgba(0,0,0,0.2); color:#fff; border:1px solid var(--glass-border); padding:10px; border-radius:8px;"></textarea>
                        <div style="width: 100%; margin-top: 10px; display: flex; gap: 10px;">
                            <button type="submit">Uložit</button> <button type="button" onclick="closePodcastModal()" style="background: rgba(255,255,255,0.2);">Zrušit</button>
                        </div>
                    </form>
                </div>
            </div>
            <div class="glass" style="padding: 20px;"><table><thead><tr><th>Obrázek</th><th>Název</th><th>Audio</th><th>Akce</th></tr></thead><tbody id="tbody-podcasts"></tbody></table></div>
            </div>
            
            <div id="pod-airchecks" class="pod-tab glass" style="padding: 20px; display:none;">
                <h3>Automatické nahrávky vysílání (AirChecky)</h3>
                <p>Systémový skript na pozadí zde ukládá nahrávky vysílání po hodinách. Můžete je zpětně stahovat nebo odesílat posluchačům a hostům.</p>
                <table>
                    <thead><tr><th>Název souboru</th><th>Vytvořeno</th><th>Velikost</th><th>Přehrát</th><th>Akce</th></tr></thead>
                    <tbody id="tbody-airchecks"></tbody>
                </table>
            </div>
            <script>
                function showPodTab(tab) { document.querySelectorAll('.pod-tab').forEach(el => el.style.display = 'none'); document.getElementById('pod-' + tab).style.display = 'block'; if (tab === 'airchecks') loadAirchecks(); else loadPodcasts(); }
                function openPodcastModal() { document.getElementById('podcastModal').style.display = 'flex'; }
                function closePodcastModal() { document.getElementById('podcastModal').style.display = 'none'; document.getElementById('form-podcasts').reset(); document.getElementById('podId').value=''; document.getElementById('podImagePreview').innerHTML=''; document.getElementById('podAudioPreview').innerHTML=''; setTinyContent('podDesc', ''); }
                window.allPodcastsData = [];
                async function loadPodcasts() { const res = await fetch('/admin/api/podcasts'); const json = await res.json(); window.allPodcastsData = (json.data || []).sort((a,b) => new Date(b.created_at) - new Date(a.created_at)); document.getElementById('tbody-podcasts').innerHTML = window.allPodcastsData.map((p, i) => `<tr><td>${p.image ? `<img src="/${p.image}" style="height:40px; border-radius:4px; object-fit:cover;">` : '-'}</td><td>${p.title}</td><td><audio controls src="${p.audio_url.startsWith('http') ? p.audio_url : '/' + p.audio_url}" style="height:30px;"></audio></td><td><button class="action-btn" onclick="editPodcast(window.allPodcastsData[${i}])">Upravit</button><button class="action-btn btn-delete" onclick="delPodcast('${p.id}')">Smazat</button></td></tr>`).join(''); }
                function editPodcast(p) { document.getElementById('podId').value = p.id; document.getElementById('podTitle').value = p.title; document.getElementById('podAudioPreview').innerHTML = p.audio_url ? `Aktuální soubor: ${p.audio_url}` : ''; setTinyContent('podDesc', p.description); document.getElementById('podImagePreview').innerHTML = p.image ? `<img src="/${p.image}" style="max-height:100px; border-radius:8px;">` : ''; openPodcastModal(); }
                async function delPodcast(id) { customConfirm('Smazat podcast?', async () => { await fetch('/admin/api/podcasts', { method: 'DELETE', headers: {'Content-Type':'application/json'}, body: JSON.stringify({id}) }); loadPodcasts(); }); }
                document.getElementById('form-podcasts').addEventListener('submit', async (e) => { e.preventDefault(); const formData = new FormData(); formData.append('id', document.getElementById('podId').value); formData.append('title', document.getElementById('podTitle').value); formData.append('description', getTinyContent('podDesc')); const aFile = document.getElementById('podAudio'); if(aFile.files.length > 0) formData.append('audio', aFile.files[0]); const iFile = document.getElementById('podImage'); if(iFile.files.length > 0) formData.append('image', iFile.files[0]); await fetch('/admin/api/podcasts', { method: 'POST', body: formData }); closePodcastModal(); loadPodcasts(); });
                loadPodcasts();
                
                async function loadAirchecks() { 
                    const res = await fetch('/admin/api/airchecks'); 
                    const json = await res.json(); 
                    if (!json.data || json.data.length === 0) {
                        document.getElementById('tbody-airchecks').innerHTML = '<tr><td colspan="5">Zatím nebyly zaznamenány žádné AirChecky.</td></tr>';
                        return;
                    }
                    document.getElementById('tbody-airchecks').innerHTML = json.data.map(a => {
                        let dName = a.name.replace('.mp3', '');
                        let isRaw = false; let recFlag = '';
                        if (dName.startsWith('raw_')) { isRaw = true; dName = dName.replace('raw_', ''); recFlag = ' <span style="color:#ff4b2b; font-size:0.8rem; font-weight:bold;">🔴 Nahrává se</span>'; } 
                        else { dName = dName.replace('AirCheck_', ''); }
                        dName = dName.replace('_', ' ');
                        let d = new Date(a.mtime * 1000);
                        let dateStr = d.getDate() + '.' + (d.getMonth()+1) + '.' + d.getFullYear() + ' ' + d.getHours().toString().padStart(2,'0') + ':' + d.getMinutes().toString().padStart(2,'0');
                        let audioHtml = isRaw ? '<span style="color:var(--text-muted); font-size:0.9rem;">(Zapisuje se)</span>' : `<audio controls src="/airchecks/${a.name}" style="height:30px; outline:none;"></audio>`;
                        let actionHtml = isRaw 
                            ? `<button class="action-btn btn-delete" onclick="delAircheck('${a.name}')">Smazat</button>` 
                            : `<button class="action-btn btn-info" onclick="sendAircheck('${a.name}', 'airchecks/${a.name}')">✉️ E-mailem</button> <a href="/airchecks/${a.name}" download="${a.name}" class="action-btn" style="background:rgba(255,255,255,0.2); text-decoration:none; display:inline-block; padding:4px 10px;">💾 Stáhnout</a> <button class="action-btn btn-delete" onclick="delAircheck('${a.name}')">Smazat</button>`;
                        return `<tr><td style="font-weight:bold;">${dName}${recFlag}</td><td>${dateStr}</td><td>${a.size}</td><td>${audioHtml}</td><td>${actionHtml}</td></tr>`;
                    }).join(''); 
                }
                async function delAircheck(name) { customConfirm('Opravdu smazat tento záznam vysílání?', async () => { await fetch('/admin/api/airchecks', { method: 'DELETE', headers: {'Content-Type':'application/json'}, body: JSON.stringify({name}) }); loadAirchecks(); }); }
                window.sendAircheck = function(name, url) { if (typeof window.openEmailComposer !== 'function') return customAlert('E-mailový klient se načítá...'); const link = window.location.origin + '/' + url; window.openEmailComposer('', 'Záznam vysílání: ' + name, 'Dobrý den,<br><br>přes odkaz níže zasíláme vyžádaný hodinový záznam z vysílání k poslechu či stažení.<br><br><a href="' + link + '" style="font-weight:bold; color:#00d2ff;">Stáhnout / Přehrát záznam (' + name + ')</a><br><br>S pozdravem,'); };
            </script>