<!doctype html>
<html lang="en">
<head>
  <meta charset="utf-8" />
  <meta name="viewport" content="width=device-width,initial-scale=1" />
  <title>SKIDATA Parking.Logic – Software User Guide</title>
  <style>
    :root{
      --bg:#0b1020; --panel:#0f172a; --card:#111c36; --muted:#94a3b8; --text:#e2e8f0;
      --accent:#fbbf24; --line:#1f2a44; --btn:#142042; --btn2:#182852;
    }
    *{box-sizing:border-box}
    body{margin:0; font-family:system-ui,-apple-system,Segoe UI,Roboto,Ubuntu,sans-serif; background:var(--bg); color:var(--text);}    
    header{position:sticky; top:0; z-index:10; display:flex; align-items:center; gap:.75rem; padding:.75rem 1rem; background:rgba(11,16,32,.9); backdrop-filter: blur(10px); border-bottom:1px solid var(--line);}    
    header h1{font-size:1rem; margin:0; font-weight:650; letter-spacing:.2px;}    
    header .sub{color:var(--muted); font-size:.85rem;}    
    header .pill{margin-left:auto; display:flex; gap:.5rem; align-items:center;}    
    .btn{border:1px solid var(--line); background:var(--btn); color:var(--text); padding:.45rem .65rem; border-radius:.65rem; font-size:.85rem; cursor:pointer;}    
    .btn:hover{background:var(--btn2);}    
    .layout{display:grid; grid-template-columns: 340px 1fr; min-height:calc(100vh - 56px);}    
    aside{border-right:1px solid var(--line); background:linear-gradient(180deg, rgba(15,23,42,.9), rgba(11,16,32,.9));}    
    .aside-inner{padding:1rem; height:100%; overflow:auto;}    
    .search{display:flex; gap:.5rem; margin-bottom:.75rem;}    
    .search input{flex:1; background:#070b16; border:1px solid var(--line); color:var(--text); padding:.6rem .7rem; border-radius:.75rem; outline:none;}    
    .search input:focus{border-color:#2d3b60; box-shadow:0 0 0 3px rgba(251,191,36,.15);}    
    .small{color:var(--muted); font-size:.8rem; line-height:1.35;}    
    .results{margin:.75rem 0; padding:0; list-style:none;}    
    .results li{margin:.45rem 0;}    
    .results a{display:block; text-decoration:none; color:var(--text); border:1px solid var(--line); background:#070b16; padding:.55rem .65rem; border-radius:.75rem;}    
    .results a:hover{border-color:#2d3b60;}    
    .results .hit{color:var(--accent); font-weight:650;}    
    .pages{margin-top:1rem;}    
    .pages h2{margin:.25rem 0 .5rem; font-size:.9rem; color:var(--accent);}    
    .page-list{display:grid; grid-template-columns: repeat(4, 1fr); gap:.4rem;}    
    .page-list button{border:1px solid var(--line); background:#070b16; color:var(--text); padding:.5rem .35rem; border-radius:.6rem; font-size:.85rem; cursor:pointer;}    
    .page-list button:hover{background:#0b1226;}    
    .page-list button.active{outline:2px solid rgba(251,191,36,.4); border-color:#3a2f12;}    

    main{overflow:auto;}    
    .main-inner{padding:1rem; max-width: 1200px; margin:0 auto;}    
    .card{background:var(--card); border:1px solid var(--line); border-radius:1rem; overflow:hidden; box-shadow: 0 10px 30px rgba(0,0,0,.25);}    
    .card-head{display:flex; align-items:center; justify-content:space-between; gap:.75rem; padding:.75rem 1rem; border-bottom:1px solid var(--line);}    
    .card-head .title{font-weight:650;}    
    .card-head .meta{color:var(--muted); font-size:.85rem;}    
    .viewer{padding:0;}    
    .page-img{width:100%; height:auto; display:block; background:#0b1020;}    
    .page-text{padding:1rem; border-top:1px dashed rgba(148,163,184,.25); color:#cbd5e1; font-size:.92rem; line-height:1.55; white-space:pre-wrap; display:none;}    
    .page-text.show{display:block;}    
    .navrow{display:flex; gap:.5rem; align-items:center;}    

    @media (max-width: 1000px){      
      .layout{grid-template-columns: 1fr;}      
      aside{border-right:none; border-bottom:1px solid var(--line);}      
      .page-list{grid-template-columns: repeat(6, 1fr);}    
    }    
    @media (max-width: 520px){      
      .page-list{grid-template-columns: repeat(5, 1fr);}    
    }
  </style>
</head>
<body>
  <header>
    <h1>SKIDATA Parking.Logic Software User Guide</h1>
    <div class="sub">Interactive manual (page images + searchable text)</div>
    <div class="pill">
      <button class="btn" id="toggleText" type="button">Show text</button>
      <button class="btn" id="downloadPdf" type="button">Open PDF</button>
    </div>
  </header>

  <div class="layout">
    <aside>
      <div class="aside-inner">
        <div class="search">
          <input id="q" type="search" placeholder="Search (e.g. 'archive', 'rate schemes', 'manual open')…" />
        </div>
        <div class="small">Search scans extracted text across all pages. Click a hit to jump. Tip: press <strong>/</strong> to focus search.</div>
        <ul class="results" id="results"></ul>

        <div class="pages">
          <h2>Pages</h2>
          <div class="page-list" id="pageList"></div>
        </div>
      </div>
    </aside>

    <main>
      <div class="main-inner">
        <div class="card" id="card">
          <div class="card-head">
            <div>
              <div class="title" id="pageTitle">Page</div>
              <div class="meta" id="pageMeta">Rendered software user guide page</div>
            </div>
            <div class="navrow">
              <button class="btn" id="prev" type="button">◀ Prev</button>
              <button class="btn" id="next" type="button">Next ▶</button>
            </div>
          </div>
          <div class="viewer">
            <img id="pageImg" class="page-img" alt="Manual page" />
            <div id="pageText" class="page-text"></div>
          </div>
        </div>
      </div>
    </main>
  </div>

<script>
(async function(){
  const data = await fetch('assets/search.json').then(r=>r.json());
  const pages = data.pages;
  const pageList = document.getElementById('pageList');
  const results = document.getElementById('results');
  const q = document.getElementById('q');
  const img = document.getElementById('pageImg');
  const txt = document.getElementById('pageText');
  const pageTitle = document.getElementById('pageTitle');
  const toggleText = document.getElementById('toggleText');
  const prev = document.getElementById('prev');
  const next = document.getElementById('next');
  const downloadPdf = document.getElementById('downloadPdf');

  let showText = false;
  let current = 1;

  function setActiveButton(){
    [...pageList.querySelectorAll('button')].forEach(b=>{
      b.classList.toggle('active', Number(b.dataset.page) === current);
    });
  }

  function renderPage(p){
    current = Math.min(Math.max(1, p), pages.length);
    const rec = pages[current-1];
    pageTitle.textContent = 'Page ' + current + ' of ' + pages.length;
    if(rec.img){ img.src = rec.img; img.style.display='block'; } else { img.style.display='none'; }
    txt.textContent = rec.text || '';
    txt.classList.toggle('show', showText);
    toggleText.textContent = showText ? 'Hide text' : 'Show text';
    setActiveButton();
    window.scrollTo({top:0, behavior:'smooth'});
  }

  for(let i=1;i<=pages.length;i++){
    const b=document.createElement('button');
    b.type='button';
    b.textContent=i;
    b.dataset.page=i;
    b.onclick=()=>renderPage(i);
    pageList.appendChild(b);
  }

  function escapeHtml(s){return (s||'').replaceAll('&','&amp;').replaceAll('<','&lt;').replaceAll('>','&gt;');}
  function highlight(snippet, term){const l=snippet.toLowerCase(), t=term.toLowerCase(); const i=l.indexOf(t); if(i<0) return snippet; return snippet.slice(0,i)+"<span class='hit'>"+snippet.slice(i,i+term.length)+"</span>"+snippet.slice(i+term.length);}  

  function doSearch(term){results.innerHTML=''; const t=term.trim(); if(!t) return;
    const hits=[];
    for(const rec of pages){ const text=rec.text||''; const pos=text.toLowerCase().indexOf(t.toLowerCase()); if(pos>=0){ hits.push({page:rec.page, snip:text.slice(Math.max(0,pos-60), Math.min(text.length,pos+120))}); }}
    if(!hits.length){ results.innerHTML = `<li><a>No results for <span class='hit'>${escapeHtml(t)}</span></a></li>`; return; }
    for(const h of hits.slice(0,60)){
      const li=document.createElement('li'); const a=document.createElement('a'); a.href='javascript:void(0)'; a.innerHTML='<strong>Page '+h.page+':</strong> '+highlight(escapeHtml(h.snip), t)+'…'; a.onclick=()=>renderPage(h.page); li.appendChild(a); results.appendChild(li);
    }
  }

  q.addEventListener('input', ()=>doSearch(q.value));
  toggleText.onclick=()=>{ showText=!showText; renderPage(current); };
  prev.onclick=()=>renderPage(current-1);
  next.onclick=()=>renderPage(current+1);

  downloadPdf.onclick=()=>window.open('SKIDATA_software_user_guide.pdf','_blank');

  window.addEventListener('keydown',(e)=>{
    if(e.key==='ArrowLeft') renderPage(current-1);
    if(e.key==='ArrowRight') renderPage(current+1);
    if(e.key==='/'){ e.preventDefault(); q.focus(); }
  });

  renderPage(1);
})();
</script>
</body>
</html>