<!DOCTYPE html>
<html lang="cs">
<head>
    <meta charset="UTF-8">
    <title>Katalog Profilů</title>
    <!-- PhotoSwipe CSS -->
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/photoswipe/5.4.4/photoswipe.min.css">
    <style>
        #katalog-rozvrzeni, #katalog-rozvrzeni * { box-sizing: border-box; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; }
        #katalog-rozvrzeni { display: grid; grid-template-columns: 320px 1fr; gap: 25px; align-items: start; max-width: 1600px; margin: 0 auto; padding: 20px; background: #0a0a0b; min-height: 100vh; }
        #filtr-kontejner { background: linear-gradient(180deg, #141417 0%, #101012 100%); color: #ffffff; padding: 24px; border-radius: 22px; position: sticky; top: 20px; max-height: calc(100vh - 40px); overflow-y: auto; border: 1px solid #1f1f25; box-shadow: 0 10px 40px rgba(0,0,0,0.45), inset 0 1px 0 rgba(255,255,255,0.03); }
        #filtr-kontejner::-webkit-scrollbar { width: 8px; }
        #filtr-kontejner::-webkit-scrollbar-track { background: transparent; }
        #filtr-kontejner::-webkit-scrollbar-thumb { background: #2f2f38; border-radius: 20px; }
        .filtr-sekce { margin-bottom: 24px; }
        .filtr-sekce h4 { color: #ff4d67; margin-top: 0; margin-bottom: 14px; border-bottom: 1px solid #24242a; padding-bottom: 10px; font-size: 12px; letter-spacing: 1.4px; font-weight: 800; text-transform: uppercase; }
        .filtr-moznosti-scroll { max-height: 220px; overflow-y: auto; padding-right: 8px; }
        .filtr-moznosti-scroll::-webkit-scrollbar { width: 7px; }
        .filtr-moznosti-scroll::-webkit-scrollbar-thumb { background: #33333d; border-radius: 20px; }
        .filtr-sekce label { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; cursor: pointer; font-size: 14px; color: #b6b6c2; width: 100%; transition: all 0.22s ease; padding: 4px 0; }
        .filtr-sekce label:hover { color: #ffffff; transform: translateX(3px); }
        .filtr-sekce input[type="checkbox"] { accent-color: #ff4d67; width: 20px !important; height: 20px !important; min-width: 20px !important; max-width: 20px !important; cursor: pointer; flex-shrink: 0; }
        .filtr-grid-velikosti { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
        .filtr-grid-velikosti label { justify-content: center; background: #1a1a1f; border: 1px solid #24242b; border-radius: 10px; padding: 10px !important; margin: 0 !important; }
        .filtr-grid-velikosti label:hover { background: #212129; }
        .filtr-id-input-class, .filtr-tel-input-class { width: 100%; padding: 13px 15px; border: 1px solid #24242b; border-radius: 12px; background: #19191d; color: #ffffff; font-size: 14px; transition: all 0.25s ease; }
        .filtr-id-input-class:focus, .filtr-tel-input-class:focus { outline: none; border-color: #ff4d67; box-shadow: 0 0 0 4px rgba(255, 77, 103, 0.14); }
        #vysledky-profilu { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 24px; }
        .loading-text { color: #888892; grid-column: 1 / -1; text-align: center; padding: 80px; font-size: 16px; }
        .profil-karta { border: 1px solid #1f1f26; padding: 22px; border-radius: 24px; background: linear-gradient(180deg, #141416 0%, #111114 100%); display: flex; flex-direction: column; box-shadow: 0 8px 30px rgba(0,0,0,0.35), inset 0 1px 0 rgba(255,255,255,0.03); transition: all 0.35s ease; overflow: hidden; position: relative; }
        .profil-karta:hover { transform: translateY(-6px); border-color: rgba(255, 77, 103, 0.35); box-shadow: 0 16px 40px rgba(0,0,0,0.55), 0 0 25px rgba(255,77,103,0.08); }
        .profil-hlavicka { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; padding-bottom: 12px; border-bottom: 1px solid #222228; gap: 10px; }
        .profil-jmeno { margin: 0; font-size: 24px; color: #ffd53d; font-weight: 800; line-height: 1.2; }
        .profil-id { font-size: 12px; color: #00f5d4; font-weight: 700; background: rgba(0,245,212,0.08); padding: 6px 10px; border-radius: 8px; border: 1px solid rgba(0,245,212,0.16); white-space: nowrap; }
        .profil-parametry-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; background: #18181c; padding: 14px; border-radius: 14px; margin-bottom: 14px; border: 1px solid rgba(255,255,255,0.03); }
        .param-item { font-size: 13px; display: flex; justify-content: space-between; gap: 10px; }
        .param-item strong { color: #ff4d67; font-size: 11px; letter-spacing: 0.6px; text-transform: uppercase; }
        .param-item span { color: #ffffff; font-weight: 700; }
        .profil-kontakt-sekce { margin-bottom: 14px; }
        .profil-tel-blok { display: flex; flex-direction: column; align-items: center; gap: 8px; background: rgba(0,255,136,0.06); padding: 14px; border-radius: 12px; border: 1px solid rgba(0,255,136,0.14); }
        .profil-tel-cislo { font-size: 22px; color: #00ff88; font-weight: 800; letter-spacing: 1px; margin-bottom: 4px; text-decoration: none; display: flex; align-items: center; }
        .profil-tel-cislo .ikona { color: #ff4d67; margin-right: 6px; display: inline-block; vertical-align: middle; }
        @keyframes pulzovani-textu { 0%, 100% { transform: scale(1); color: #00ff88; } 50% { transform: scale(1.08); color: #ff4d67; } }
        .koupit-pristup-link { font-size: 12px; font-weight: 900; text-decoration: none; text-transform: uppercase; text-align: center; display: inline-block; animation: pulzovani-textu 1.5s infinite ease-in-out; }
        .pswp-gallery { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 16px; cursor: pointer; }
        .pswp-gallery img { width: 100%; height: 100px; object-fit: cover; border-radius: 12px; border: 1px solid #232329; transition: all 0.25s ease; }
        .pswp-gallery img:hover { transform: scale(1.04); border-color: rgba(255,255,255,0.18); }
        .profil-sluzby-sekce { display: flex; flex-direction: column; gap: 8px; margin-bottom: 18px; }
        .badge-skupina { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; margin-bottom: 8px; }
        .badge { font-size: 11px; font-weight: 700; padding: 6px 10px; border-radius: 999px; letter-spacing: 0.4px; }
        .badge-dostupnost { background: rgba(255,77,103,0.1); color: #ff4d67; border: 1px solid rgba(255,77,103,0.2); }
        .badge-praktika { background: #1e1e25; color: #ffffff; border: 1px solid #30303a; }
        @keyframes pulzovani { 0% { transform: scale(1); box-shadow: 0 8px 24px rgba(255,213,61,0.25); } 50% { transform: scale(1.03); box-shadow: 0 10px 30px rgba(255,213,61,0.5); } 100% { transform: scale(1); box-shadow: 0 8px 24px rgba(255,213,61,0.25); } }
        .btn-galerie { display: flex; align-items: center; justify-content: center; text-align: center; background: linear-gradient(135deg, #ffd53d 0%, #ffc107 100%); color: #000000 !important; padding: 14px 20px; border-radius: 14px; text-decoration: none; font-weight: 800; font-size: 14px; letter-spacing: 0.5px; transition: all 0.25s ease; margin-top: auto; white-space: normal; animation: pulzovani 2s infinite ease-in-out; }
        .btn-galerie:hover { animation: none; transform: translateY(-2px); filter: brightness(1.1); box-shadow: 0 12px 30px rgba(255,213,61,0.45); }
        .no-results { grid-column: 1 / -1; text-align: center; padding: 80px 20px; color: #8b8b96; font-size: 15px; border-radius: 24px; background: #121214; border: 1px dashed #26262d; }
        
        .pswp__img { object-fit: contain !important; }
        
        @media (max-width: 991px) { #katalog-rozvrzeni { grid-template-columns: 1fr; padding: 10px; gap: 15px; } #filtr-kontejner { position: static; max-height: none; padding: 14px; border-radius: 18px; } }
    </style>
</head>
<body>

<div id="katalog-rozvrzeni">
    <div id="filtr-kontejner">
        <div id="filtr-obsah">
            <div class="filtr-sekce">
                <h4>Město</h4>
                <div class="filtr-moznosti-scroll">
                    <label>
                        <input type="checkbox" id="check-praha" class="filtr-check" data-kategorie="mesto" value="Praha"> 
                        <span>Praha</span>
                    </label>
                    <div id="sub-praha" style="display: none; padding-left: 25px; margin-bottom: 10px;">
                        <label style="font-size: 13px;"><input type="checkbox" class="filtr-check" data-kategorie="mesto" value="Praha 1"> <span>Praha 1</span></label>
                        <label style="font-size: 13px;"><input type="checkbox" class="filtr-check" data-kategorie="mesto" value="Praha 2"> <span>Praha 2</span></label>
                        <label style="font-size: 13px;"><input type="checkbox" class="filtr-check" data-kategorie="mesto" value="Praha 3"> <span>Praha 3</span></label>
                        <label style="font-size: 13px;"><input type="checkbox" class="filtr-check" data-kategorie="mesto" value="Praha 4"> <span>Praha 4</span></label>
                        <label style="font-size: 13px;"><input type="checkbox" class="filtr-check" data-kategorie="mesto" value="Praha 5"> <span>Praha 5</span></label>
                        <label style="font-size: 13px;"><input type="checkbox" class="filtr-check" data-kategorie="mesto" value="Praha 6"> <span>Praha 6</span></label>
                        <label style="font-size: 13px;"><input type="checkbox" class="filtr-check" data-kategorie="mesto" value="Praha 7"> <span>Praha 7</span></label>
                        <label style="font-size: 13px;"><input type="checkbox" class="filtr-check" data-kategorie="mesto" value="Praha 8"> <span>Praha 8</span></label>
                        <label style="font-size: 13px;"><input type="checkbox" class="filtr-check" data-kategorie="mesto" value="Praha 9"> <span>Praha 9</span></label>
                        <label style="font-size: 13px;"><input type="checkbox" class="filtr-check" data-kategorie="mesto" value="Praha 10"> <span>Praha 10</span></label>
                    </div>
                    <label><input type="checkbox" class="filtr-check" data-kategorie="mesto" value="Středočeský kraj"> <span>Středočeský kraj</span></label>
                    <label><input type="checkbox" class="filtr-check" data-kategorie="mesto" value="Brno"> <span>Brno</span></label>
                    <label><input type="checkbox" class="filtr-check" data-kategorie="mesto" value="Ostrava"> <span>Ostrava</span></label>
                    <label><input type="checkbox" class="filtr-check" data-kategorie="mesto" value="Plzeň"> <span>Plzeň</span></label>
                    <label><input type="checkbox" class="filtr-check" data-kategorie="mesto" value="Liberec"> <span>Liberec</span></label>
                    <label><input type="checkbox" class="filtr-check" data-kategorie="mesto" value="Olomouc"> <span>Olomouc</span></label>
                    <label><input type="checkbox" class="filtr-check" data-kategorie="mesto" value="České Budějovice"> <span>České Budějovice</span></label>
                    <label><input type="checkbox" class="filtr-check" data-kategorie="mesto" value="Hradec Králové"> <span>Hradec Králové</span></label>
                    <label><input type="checkbox" class="filtr-check" data-kategorie="mesto" value="Pardubice"> <span>Pardubice</span></label>
                    <label><input type="checkbox" class="filtr-check" data-kategorie="mesto" value="Ústí nad Labem"> <span>Ústí nad Labem</span></label>
                </div>
            </div>
            <div class="filtr-sekce">
                <h4>Vyhledat podle ID / Tel.</h4>
                <input type="text" class="filtr-id-input-class" placeholder="ID inzerátu (např. 080...)">
                <input type="text" class="filtr-tel-input-class" placeholder="Telefon (např. 777...)" style="margin-top: 8px;">
            </div>
            <div class="filtr-sekce">
                <h4>Věk</h4>
                <label><input type="checkbox" class="filtr-check" data-kategorie="vek" value="18-25"> <span>18–25 let</span></label>
                <label><input type="checkbox" class="filtr-check" data-kategorie="vek" value="25-30"> <span>25–30 let</span></label>
                <label><input type="checkbox" class="filtr-check" data-kategorie="vek" value="31-40"> <span>31–40 let</span></label>
                <label><input type="checkbox" class="filtr-check" data-kategorie="vek" value="41-99"> <span>41+ let</span></label>
            </div>
            <div class="filtr-sekce">
                <h4>Výška</h4>
                <label><input type="checkbox" class="filtr-check" data-kategorie="vyska" value="130-150"> <span>130–150 cm</span></label>
                <label><input type="checkbox" class="filtr-check" data-kategorie="vyska" value="151-160"> <span>151–160 cm</span></label>
                <label><input type="checkbox" class="filtr-check" data-kategorie="vyska" value="161-170"> <span>161–170 cm</span></label>
                <label><input type="checkbox" class="filtr-check" data-kategorie="vyska" value="171-180"> <span>171–180 cm</span></label>
                <label><input type="checkbox" class="filtr-check" data-kategorie="vyska" value="181-220"> <span>181+ cm</span></label>
            </div>
            <div class="filtr-sekce">
                <h4>Váha</h4>
                <label><input type="checkbox" class="filtr-check" data-kategorie="vaha" value="40-50"> <span>40–50 kg</span></label>
                <label><input type="checkbox" class="filtr-check" data-kategorie="vaha" value="51-60"> <span>51–60 kg</span></label>
                <label><input type="checkbox" class="filtr-check" data-kategorie="vaha" value="61-70"> <span>61–70 kg</span></label>
                <label><input type="checkbox" class="filtr-check" data-kategorie="vaha" value="71-150"> <span>71+ kg</span></label>
            </div>
            <div class="filtr-sekce">
                <h4>Prsa</h4>
                <div class="filtr-grid-velikosti">
                    <label><input type="checkbox" class="filtr-check" data-kategorie="prsa" value="1"> <span>1</span></label>
                    <label><input type="checkbox" class="filtr-check" data-kategorie="prsa" value="2"> <span>2</span></label>
                    <label><input type="checkbox" class="filtr-check" data-kategorie="prsa" value="3"> <span>3</span></label>
                    <label><input type="checkbox" class="filtr-check" data-kategorie="prsa" value="4"> <span>4</span></label>
                    <label><input type="checkbox" class="filtr-check" data-kategorie="prsa" value="5"> <span>5</span></label>
                    <label><input type="checkbox" class="filtr-check" data-kategorie="prsa" value="6"> <span>6</span></label>
                </div>
            </div>
            <div class="filtr-sekce">
                <h4>Barva vlasů</h4>
                <label><input type="checkbox" class="filtr-check" data-kategorie="vlasy" value="Blond"> <span>Blond</span></label>
                <label><input type="checkbox" class="filtr-check" data-kategorie="vlasy" value="Bruneta"> <span>Bruneta</span></label>
                <label><input type="checkbox" class="filtr-check" data-kategorie="vlasy" value="Černé"> <span>Černé</span></label>
                <label><input type="checkbox" class="filtr-check" data-kategorie="vlasy" value="Tmavý blond"> <span>Tmavý blond</span></label>
            </div>
            <div class="filtr-sekce">
                <h4>Dostupnost</h4>
                <label><input type="checkbox" class="filtr-check" data-kategorie="dostupnost" value="privat"> <span>Privát</span></label>
                <label><input type="checkbox" class="filtr-check" data-kategorie="dostupnost" value="eskort"> <span>Eskort</span></label>
                <label><input type="checkbox" class="filtr-check" data-kategorie="dostupnost" value="online"> <span>Pouze online</span></label>
            </div>
            <div class="filtr-sekce">
                <h4>Praktiky</h4>
                <label><input type="checkbox" class="filtr-check" data-kategorie="praktiky" value="anal"> <span>Anál</span></label>
                <label><input type="checkbox" class="filtr-check" data-kategorie="praktiky" value="hluboky_oral"> <span>Hluboký orál</span></label>
                <label><input type="checkbox" class="filtr-check" data-kategorie="praktiky" value="oral_bez"> <span>Orál bez</span></label>
                <label><input type="checkbox" class="filtr-check" data-kategorie="praktiky" value="masaze"> <span>Pouze masáže</span></label>
            </div>
        </div>
    </div>

    <div id="vysledky-profilu">
        <p class="loading-text">Načítám profily, prosím o strpení...</p>
    </div>
</div>

<script type="module">
    import PhotoSwipeLightbox from 'https://cdnjs.cloudflare.com/ajax/libs/photoswipe/5.4.4/photoswipe-lightbox.esm.min.js';

    document.addEventListener("DOMContentLoaded", function() {
        const zdrojStrankaUrl = 'http://privaty.online/zdroj-profilu.php';
        const vysledkyDiv = document.getElementById('vysledky-profilu');
        let vsechnyProfily = [];
        let aktualniStranka = 1;
        const profilyNaStranku = 30;

        const checkPraha = document.getElementById('check-praha');
        const subPraha = document.getElementById('sub-praha');
        checkPraha.addEventListener('change', function() {
            subPraha.style.display = this.checked ? 'block' : 'none';
            if (!this.checked) {
                subPraha.querySelectorAll('input').forEach(cb => cb.checked = false);
            }
            provedFiltraci();
        });

        function naVelkePocatecniPismeno(text) {
            if (!text) return '';
            let t = text.trim().replace(/_/g, ' ');
            const slovnik = { 'anal': 'Anál', 'hluboky oral': 'Hluboký orál', 'hluboky_oral': 'Hluboký orál', 'oral bez': 'Orál bez', 'oral_bez': 'Orál bez', 'pouze masaze': 'Pouze masáže', 'pouze_masaze': 'Pouze masáže', 'masaze': 'Pouze masáže', 'privat': 'Privát', 'eskort': 'Eskort', 'online': 'Pouze online', 'pouze online': 'Pouze online' };
            const klic = t.toLowerCase();
            return slovnik[klic] || (t.charAt(0).toUpperCase() + t.slice(1));
        }

        function vytvorPremiumKartu(puvodniKarta) {
            const div = document.createElement('div');
            div.className = 'profil-karta';
            const jmeno = puvodniKarta.querySelector('h3') ? puvodniKarta.querySelector('h3').innerText.replace(/\s*\([^)]*\)/g, '') : 'Profil';
            const id = puvodniKarta.getAttribute('data-id') || '---';
            const tel = puvodniKarta.getAttribute('data-telefon') || '';
            const mesto = puvodniKarta.getAttribute('data-mesto') || '';
            const vek = puvodniKarta.getAttribute('data-vek') || '';
            const vyska = puvodniKarta.getAttribute('data-vyska') || '';
            const vaha = puvodniKarta.getAttribute('data-vaha') || '';
            const prsa = puvodniKarta.getAttribute('data-prsa') || '';
            const vlasy = puvodniKarta.getAttribute('data-vlasy') || '';
            const dostupnostRaw = puvodniKarta.getAttribute('data-dostupnost') || '';
            const praktikyRaw = puvodniKarta.getAttribute('data-praktiky') || '';

            const obrazky = Array.from(puvodniKarta.querySelectorAll('img'));
            
            let fotkyHtml = `<div class="pswp-gallery" id="gallery-${id}">` + obrazky.map(img => {
                return `<a href="${img.src}" data-pswp-width="1200" data-pswp-height="1600" target="_blank"><img src="${img.src}" alt="Foto" /></a>`;
            }).join('') + `</div>`;
            
            let dostupnostBadges = dostupnostRaw.split(',').map(d => naVelkePocatecniPismeno(d)).filter(d => d).map(d => `<span class="badge badge-dostupnost">${d}</span>`).join('');
            let praktikyBadges = praktikyRaw.split(',').map(p => naVelkePocatecniPismeno(p)).filter(p => p).map(p => `<span class="badge badge-praktika">${p}</span>`).join('');
            
            const hrefOdkaz = puvodniKarta.querySelector('.btn-galerie')?.getAttribute('href') || '#';

            div.innerHTML = `
                <div class="profil-hlavicka"><h3 class="profil-jmeno">${jmeno}</h3><span class="profil-id">ID: ${id}</span></div>
                <div class="profil-parametry-grid">
                    <div class="param-item"><strong>Věk:</strong> <span>${vek} let</span></div><div class="param-item"><strong>Město:</strong> <span>${mesto}</span></div>
                    <div class="param-item"><strong>Výška:</strong> <span>${vyska} cm</span></div><div class="param-item"><strong>Váha:</strong> <span>${vaha} kg</span></div>
                    <div class="param-item"><strong>Prsa:</strong> <span>${prsa}</span></div><div class="param-item"><strong>Vlasy:</strong> <span>${vlasy}</span></div>
                </div>
                ${tel ? `<div class="profil-kontakt-sekce"><div class="profil-tel-blok"><a href="https://platba.online/pokladna/?add-to-cart=2754" class="profil-tel-cislo" target="_blank"><span class="ikona"><svg width="20" height="20" viewBox="0 0 24 24" fill="currentColor"><path d="M20.01 15.38c-1.23 0-2.42-.2-3.53-.56-.35-.12-.74-.03-1.01.24l-1.57 1.97c-2.83-1.35-5.48-3.9-6.89-6.83l1.95-1.66c.27-.28.35-.67.24-1.02C8.87 6.4 8.67 5.21 8.67 3.98c0-.4-.33-.73-.73-.73H4.03c-.4 0-.73.33-.73.73 0 9.2 7.48 16.68 16.68 16.68.4 0 .73-.33.73-.73v-3.92c0-.4-.33-.73-.73-.73z"/></svg></span>${tel.slice(0, -3) + 'xxx'}</a><a href="https://platba.online/pokladna/?add-to-cart=2754" class="koupit-pristup-link" target="_blank">KOUPIT PŘÍSTUPOVÉ HESLO = 1 Kč / 1 Den</a></div></div>` : ''}
                ${fotkyHtml}
                ${(dostupnostBadges || praktikyBadges) ? `<div class="profil-sluzby-sekce"><div class="badge-skupina">${dostupnostBadges}</div><div class="badge-skupina">${praktikyBadges}</div></div>` : ''}
                <a href="${hrefOdkaz}" class="btn-galerie">ZOBRAZIT INZERÁT + KONTAKT</a>
            `;
            Array.from(puvodniKarta.attributes).forEach(attr => div.setAttribute(attr.name, attr.value));
            return div;
        }

        function inicializujGalerie() {
            new PhotoSwipeLightbox({
                gallery: '.pswp-gallery',
                children: 'a',
                initialZoomLevel: 'fit',
                secondaryZoomLevel: 1.5,
                pswpModule: () => import('https://cdnjs.cloudflare.com/ajax/libs/photoswipe/5.4.4/photoswipe.esm.min.js')
            }).init();
        }

        function ocistiTelefon(t) { return !t ? '' : t.replace(/[\s+\-()]/g, '').replace(/\u00a0/g, '').replace(/^(00|420|421)/, ''); }

        function kontrolaRozsahu(hodnota, rozsahy) {
            if (rozsahy.length === 0) return true;
            let c = parseInt(hodnota);
            return !isNaN(c) && rozsahy.some(r => { let [min, max] = r.split('-').map(Number); return c >= min && c <= max; });
        }

        function vykresliStranku(vyhovujici) {
            if (aktualniStranka === 1) vysledkyDiv.innerHTML = '';
            const kZobrazeni = vyhovujici.slice(0, aktualniStranka * profilyNaStranku);
            vysledkyDiv.innerHTML = '';
            kZobrazeni.forEach(p => vysledkyDiv.appendChild(p.cloneNode(true)));
            
            if (kZobrazeni.length < vyhovujici.length) {
                const btn = document.createElement('button');
                btn.className = 'btn-galerie';
                btn.style.gridColumn = '1 / -1';
                btn.innerText = 'NAČÍST DALŠÍ PROFILY';
                btn.onclick = () => { aktualniStranka++; vykresliStranku(vyhovujici); };
                vysledkyDiv.appendChild(btn);
            }
            if (vyhovujici.length === 0) vysledkyDiv.innerHTML = `<p class="no-results">Žádné profily neodpovídají filtrům.</p>`;
            inicializujGalerie();
        }

        function provedFiltraci() {
            aktualniStranka = 1;
            let aktivniFiltry = { mesto: [], vek: [], vyska: [], vaha: [], prsa: [], vlasy: [], dostupnost: [], praktiky: [] };
            document.querySelectorAll('.filtr-check:checked').forEach(cb => aktivniFiltry[cb.getAttribute('data-kategorie')].push(cb.value));
            const hledaneId = document.querySelector('.filtr-id-input-class').value.trim().toLowerCase();
            const hledanyTel = ocistiTelefon(document.querySelector('.filtr-tel-input-class').value.trim());

            const maKonkretniPrahu = aktivniFiltry.mesto.some(m => m.startsWith('Praha '));
            if (aktivniFiltry.mesto.includes('Praha') && maKonkretniPrahu) {
                aktivniFiltry.mesto = aktivniFiltry.mesto.filter(m => m !== 'Praha');
            }

            const vyhovujici = vsechnyProfily.filter(p => {
                const pMesto = p.getAttribute('data-mesto') || '';
                const pDost = p.getAttribute('data-dostupnost')?.split(',').map(s => s.trim().toLowerCase()) || [];
                const pPrak = p.getAttribute('data-praktiky')?.split(',').map(s => s.trim().toLowerCase()) || [];
                
                let shodaMesto = aktivniFiltry.mesto.length === 0 || aktivniFiltry.mesto.includes(pMesto);
                
                if (!shodaMesto && aktivniFiltry.mesto.includes('Praha')) {
                    if (pMesto.startsWith('Praha')) shodaMesto = true;
                }

                return shodaMesto &&
                       kontrolaRozsahu(p.getAttribute('data-vek'), aktivniFiltry.vek) &&
                       kontrolaRozsahu(p.getAttribute('data-vyska'), aktivniFiltry.vyska) &&
                       kontrolaRozsahu(p.getAttribute('data-vaha'), aktivniFiltry.vaha) &&
                       (aktivniFiltry.prsa.length === 0 || aktivniFiltry.prsa.includes(p.getAttribute('data-prsa'))) &&
                       (aktivniFiltry.vlasy.length === 0 || aktivniFiltry.vlasy.includes(p.getAttribute('data-vlasy'))) &&
                       (aktivniFiltry.dostupnost.length === 0 || aktivniFiltry.dostupnost.some(d => pDost.includes(d))) &&
                       (aktivniFiltry.praktiky.length === 0 || aktivniFiltry.praktiky.some(p => pPrak.includes(p))) &&
                       (hledaneId === '' || p.getAttribute('data-id').toLowerCase().includes(hledaneId)) &&
                       (hledanyTel === '' || ocistiTelefon(p.getAttribute('data-telefon')).includes(hledanyTel));
            });
            vykresliStranku(vyhovujici);
        }

        fetch(zdrojStrankaUrl).then(r => r.text()).then(html => {
            const doc = new DOMParser().parseFromString(html, 'text/html');
            vsechnyProfily = Array.from(doc.querySelectorAll('.profil-karta')).map(p => vytvorPremiumKartu(p));
            provedFiltraci();
        });

        document.querySelectorAll('.filtr-check').forEach(cb => cb.addEventListener('change', provedFiltraci));
        document.querySelectorAll('.filtr-id-input-class, .filtr-tel-input-class').forEach(i => i.addEventListener('input', provedFiltraci));
    });
</script>
</body>
</html>