<!doctype html>
<html lang="ar" dir="rtl">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>NLT API — الوثائق</title>
<style>
  :root {
    --bg: #f7f8fb;
    --surface: #ffffff;
    --surface-2: #eef1f6;
    --text: #1c2333;
    --muted: #55607a;
    --border: #d9deea;
    --accent: #0b6bcb;
    --accent-contrast: #ffffff;
    --code-bg: #101828;
    --code-text: #e6edf7;
    --focus: #0b6bcb;
    --danger: #b42318;
    --shadow: 0 1px 3px rgba(16,24,40,.08);
  }
  html[data-theme="dark"] {
    --bg: #0e1420;
    --surface: #17202f;
    --surface-2: #1f2a3d;
    --text: #e8edf6;
    --muted: #a7b2c7;
    --border: #2c3a52;
    --accent: #5aa9ff;
    --accent-contrast: #0b1424;
    --code-bg: #0a0f1a;
    --code-text: #d7e3f5;
    --focus: #5aa9ff;
    --danger: #ff8a7a;
    --shadow: 0 1px 3px rgba(0,0,0,.4);
  }
  * { box-sizing: border-box; }
  html { scroll-behavior: smooth; }
  body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: "Segoe UI", Tahoma, Arial, sans-serif;
    line-height: 1.75;
    transition: background .25s ease, color .25s ease;
  }
  a { color: var(--accent); }
  :focus-visible {
    outline: 3px solid var(--focus);
    outline-offset: 2px;
    border-radius: 4px;
  }
  .skip-link {
    position: absolute;
    top: -100px;
    right: 1rem;
    background: var(--accent);
    color: var(--accent-contrast);
    padding: .5rem 1rem;
    border-radius: 6px;
    z-index: 100;
    text-decoration: none;
  }
  .skip-link:focus { top: .5rem; }
  header.site {
    position: sticky;
    top: 0;
    z-index: 50;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    box-shadow: var(--shadow);
  }
  .header-inner {
    max-width: 1100px;
    margin: 0 auto;
    padding: .75rem 1rem;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: .75rem;
  }
  .brand {
    display: flex;
    align-items: center;
    gap: .5rem;
    font-weight: 800;
    font-size: 1.25rem;
    color: var(--text);
    text-decoration: none;
    letter-spacing: .02em;
  }
  .brand svg { flex: 0 0 auto; }
  nav.main {
    display: flex;
    flex-wrap: wrap;
    gap: .25rem;
    margin-inline-start: auto;
  }
  nav.main a {
    color: var(--muted);
    text-decoration: none;
    padding: .4rem .65rem;
    border-radius: 6px;
    font-size: .95rem;
    font-weight: 600;
  }
  nav.main a:hover, nav.main a:focus-visible {
    color: var(--text);
    background: var(--surface-2);
  }
  .controls {
    display: flex;
    align-items: center;
    gap: .5rem;
    flex-wrap: wrap;
  }
  .search-wrap { position: relative; }
  .search-wrap input[type="search"] {
    width: 100%;
    min-width: 180px;
    padding: .45rem .75rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface-2);
    color: var(--text);
    font-size: .95rem;
    font-family: inherit;
  }
  .search-wrap input[type="search"]::placeholder { color: var(--muted); }
  .theme-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 42px;
    height: 42px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface-2);
    color: var(--text);
    cursor: pointer;
  }
  .theme-toggle:hover { background: var(--border); }
  main {
    max-width: 1100px;
    margin: 0 auto;
    padding: 1.5rem 1rem 3rem;
  }
  section.doc {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    box-shadow: var(--shadow);
    scroll-margin-top: 90px;
  }
  section.doc[hidden] { display: none; }
  h1, h2, h3 { line-height: 1.4; }
  h1 { font-size: 1.9rem; margin: 0 0 .5rem; }
  h2 {
    font-size: 1.4rem;
    margin: 0 0 1rem;
    padding-bottom: .5rem;
    border-bottom: 2px solid var(--border);
  }
  h2 .num {
    display: inline-block;
    min-width: 2rem;
    text-align: center;
    background: var(--accent);
    color: var(--accent-contrast);
    border-radius: 6px;
    font-size: .9rem;
    padding: .1rem .4rem;
    margin-inline-end: .5rem;
  }
  p { margin: .5rem 0 1rem; }
  .lead { font-size: 1.1rem; color: var(--muted); }
  ol.steps { padding-inline-start: 1.5rem; margin: .5rem 0 1rem; }
  ol.steps li { margin-bottom: .6rem; }
  code, pre {
    font-family: "Cascadia Code", Consolas, "Courier New", monospace;
    direction: ltr;
    text-align: left;
  }
  code {
    background: var(--surface-2);
    color: var(--text);
    padding: .15rem .4rem;
    border-radius: 5px;
    font-size: .9em;
    word-break: break-word;
  }
  pre {
    background: var(--code-bg);
    color: var(--code-text);
    padding: 1rem;
    border-radius: 10px;
    overflow-x: auto;
    font-size: .85rem;
    line-height: 1.6;
    margin: .75rem 0 1rem;
    border: 1px solid var(--border);
  }
  pre code { background: transparent; padding: 0; color: inherit; }
  table {
    width: 100%;
    border-collapse: collapse;
    font-size: .95rem;
    margin: .75rem 0 1rem;
  }
  th, td {
    text-align: start;
    padding: .6rem .7rem;
    border-bottom: 1px solid var(--border);
    vertical-align: top;
  }
  th {
    background: var(--surface-2);
    color: var(--text);
    font-weight: 700;
  }
  tr:last-child td { border-bottom: none; }
  .method {
    display: inline-block;
    font-family: Consolas, monospace;
    font-size: .78rem;
    font-weight: 700;
    padding: .1rem .45rem;
    border-radius: 5px;
    color: #fff;
    background: #0e7a3d;
  }
  .method.post { background: #0b6bcb; }
  .method.get { background: #0e7a3d; }
  .method.post.post { background: #0b6bcb; }
  .warn {
    border-inline-start: 4px solid var(--danger);
    background: var(--surface-2);
    padding: .75rem 1rem;
    border-radius: 8px;
    margin: 1rem 0;
  }
  .warn strong { color: var(--danger); }
  .no-results {
    display: none;
    text-align: center;
    padding: 2rem 1rem;
    background: var(--surface);
    border: 1px dashed var(--border);
    border-radius: 12px;
    color: var(--muted);
    font-size: 1.1rem;
  }
  .no-results.visible { display: block; }
  footer.site {
    border-top: 1px solid var(--border);
    background: var(--surface);
    text-align: center;
    padding: 1.25rem 1rem;
    color: var(--muted);
    font-size: .9rem;
  }
  @media (max-width: 640px) {
    .header-inner { flex-direction: column; align-items: stretch; }
    nav.main { margin-inline-start: 0; justify-content: center; }
    .controls { justify-content: stretch; }
    .search-wrap { flex: 1 1 auto; }
    .search-wrap input[type="search"] { width: 100%; }
    h1 { font-size: 1.5rem; }
    h2 { font-size: 1.2rem; }
    section.doc { padding: 1.1rem; }
    table { font-size: .85rem; }
    th, td { padding: .45rem .4rem; }
  }
</style>
</head>
<body>
<a class="skip-link" href="#overview">تخطَّ إلى المحتوى</a>

<header class="site">
  <div class="header-inner">
    <a class="brand" href="#overview" aria-label="NLT API — الصفحة الرئيسية">
      <svg width="28" height="28" viewBox="0 0 32 32" aria-hidden="true" focusable="false">
        <rect x="2" y="2" width="28" height="28" rx="7" fill="#0b6bcb"/>
        <text x="16" y="21" text-anchor="middle" font-family="Arial, sans-serif" font-size="12" font-weight="700" fill="#ffffff">NLT</text>
      </svg>
      <span>NLT API</span>
    </a>
    <nav class="main" aria-label="التنقل الرئيسي">
      <a href="#overview">نظرة عامة</a>
      <a href="#quickstart">البدء السريع</a>
      <a href="#auth">المصادقة</a>
      <a href="#endpoints">نقاط النهاية</a>
      <a href="#errors">الأخطاء</a>
    </nav>
    <div class="controls">
      <div class="search-wrap">
        <input type="search" id="doc-search" aria-label="ابحث في الوثائق" placeholder="ابحث في الوثائق…" autocomplete="off">
      </div>
      <button type="button" class="theme-toggle" id="theme-toggle" aria-label="تبديل الوضع الداكن" aria-pressed="false">
        <svg id="icon-moon" width="20" height="20" viewBox="0 0 24 24" aria-hidden="true" focusable="false">
          <path d="M21 12.8A9 9 0 1 1 11.2 3a7 7 0 0 0 9.8 9.8z" fill="currentColor"/>
        </svg>
        <svg id="icon-sun" width="20" height="20" viewBox="0 0 24 24" aria-hidden="true" focusable="false" style="display:none">
          <circle cx="12" cy="12" r="4.5" fill="currentColor"/>
          <g stroke="currentColor" stroke-width="2" stroke-linecap="round">
            <line x1="12" y1="1.5" x2="12" y2="4"/><line x1="12" y1="20" x2="12" y2="22.5"/>
            <line x1="1.5" y1="12" x2="4" y2="12"/><line x1="20" y1="12" x2="22.5" y2="12"/>
            <line x1="4.6" y1="4.6" x2="6.4" y2="6.4"/><line x1="17.6" y1="17.6" x2="19.4" y2="19.4"/>
            <line x1="4.6" y1="19.4" x2="6.4" y2="17.6"/><line x1="17.6" y1="6.4" x2="19.4" y2="4.6"/>
          </g>
        </svg>
      </button>
    </div>
  </div>
</header>

<main id="main">
  <section class="doc" id="overview" aria-labelledby="overview-title">
    <h2 id="overview-title"><span class="num">1</span>نظرة عامة</h2>
    <p class="lead">NLT API خدمة معالجة لغة طبيعية للعربية تعمل عبر واجهة HTTP بصيغة JSON.</p>
    <p>تتيح لك الواجهة تحليل النصوص العربية نحويًا وصرفياً، وترجمة النصوص من الإنجليزية إلى العربية، واستعراض النماذج المتاحة. كل الطلبات تُرسل إلى <code>https://api.nlt.example/v1</code> وتُرجع إجابات بصيغة JSON.</p>
  </section>

  <section class="doc" id="quickstart" aria-labelledby="quickstart-title">
    <h2 id="quickstart-title"><span class="num">2</span>البدء السريع</h2>
    <p>اتبع الخطوات التالية لإجراء أول طلب لك:</p>
    <ol class="steps">
      <li>احصل على مفتاح API الخاص بك من لوحة التحكم.</li>
      <li>عيّن المفتاح في متغير البيئة <code>NLT_API_KEY</code>.</li>
      <li>أرسل طلب <code>POST</code> إلى نقطة النهاية <code>/analyze</code> مع ترويسة المصادقة.</li>
      <li>اقرأ استجابة JSON التي تحتوي على التحليل الصرفي والنحوي للنص.</li>
    </ol>
    <pre><code>curl -X POST https://api.nlt.example/v1/analyze \
  -H "Authorization: Bearer $NLT_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"text": "اللغة العربية غنية بالتعابير"}'</code></pre>
    <p>مثال على استجابة ناجحة:</p>
    <pre><code>{
  "id": "req_8f3a2c",
  "text": "اللغة العربية غنية بالتعابير",
  "tokens": [
    {"word": "اللغة", "lemma": "لغة", "pos": "noun"},
    {"word": "العربية", "lemma": "عربي", "pos": "adjective"}
  ],
  "language": "ar"
}</code></pre>
  </section>

  <section class="doc" id="auth" aria-labelledby="auth-title">
    <h2 id="auth-title"><span class="num">3</span>المصادقة</h2>
    <p>تتطلب جميع الطلبات ترويسة <code>Authorization</code> تحمل رمز Bearer. ضع مفتاح API الخاص بك في متغير البيئة <code>NLT_API_KEY</code> وأرسله مع كل طلب:</p>
    <pre><code>Authorization: Bearer $NLT_API_KEY</code></pre>
    <div class="warn" role="note">
      <strong>تنبيه أمني:</strong> لا تضع مفتاح API في كود يعمل في المتصفح أو في تطبيقات العميل. أي مفتاح يظهر في كود العميل يمكن قراءته واستخدامه من قبل الآخرين. احتفظ بالمفتاح في بيئة الخادم فقط، ومرّره عبر متغيرات البيئة.
    </div>
    <p>إذا أرسلت طلبًا بدون ترويسة المصادقة أو بمفتاح غير صالح، ستتلقى استجابة بحالة <code>401</code>.</p>
  </section>

  <section class="doc" id="endpoints" aria-labelledby="endpoints-title">
    <h2 id="endpoints-title"><span class="num">4</span>نقاط النهاية</h2>
    <p>جميع المسارات تُضاف إلى الرابط الأساسي <code>https://api.nlt.example/v1</code>.</p>
    <table>
      <thead>
        <tr>
          <th scope="col">الطريقة</th>
          <th scope="col">المسار</th>
          <th scope="col">الوصف</th>
        </tr>
      </thead>
      <tbody>
        <tr>
          <td><span class="method post">POST</span></td>
          <td><code>/analyze</code></td>
          <td>تحليل نص عربي نحويًا وصرفيًا وإرجاع الرموز والجذور وأنواع الكلمات.</td>
        </tr>
        <tr>
          <td><span class="method post">POST</span></td>
          <td><code>/translate</code></td>
          <td>ترجمة نص من الإنجليزية إلى العربية.</td>
        </tr>
        <tr>
          <td><span class="method get">GET</span></td>
          <td><code>/models</code></td>
          <td>إرجاع قائمة النماذج المتاحة لاستخدامها في الطلبات.</td>
        </tr>
      </tbody>
    </table>
    <p>حد المعدل: 60 طلبًا في الدقيقة. تجاوز هذا الحد يُرجع استجابة <code>429</code>.</p>
  </section>

  <section class="doc" id="errors" aria-labelledby="errors-title">
    <h2 id="errors-title"><span class="num">5</span>الأخطاء</h2>
    <p>تُرجع الواجهة استجابة JSON عند حدوث خطأ، تحتوي على رمز الحالة والرسالة:</p>
    <table>
      <thead>
        <tr>
          <th scope="col">رمز الحالة</th>
          <th scope="col">السبب</th>
        </tr>
      </thead>
      <tbody>
        <tr>
          <td><code>400</code></td>
          <td>JSON غير صالح في جسم الطلب.</td>
        </tr>
        <tr>
          <td><code>401</code></td>
          <td>مفتاح مفقود أو غير صالح.</td>
        </tr>
        <tr>
          <td><code>429</code></td>
          <td>تجاوز حد المعدل (60 طلبًا في الدقيقة).</td>
        </tr>
        <tr>
          <td><code>500</code></td>
          <td>خطأ في الخادم.</td>
        </tr>
      </tbody>
    </table>
    <pre><code>{
  "error": {
    "code": 429,
    "message": "Rate limit exceeded",
    "retry_after": 30
  }
}</code></pre>
  </section>

  <div class="no-results" id="no-results" role="status">لا توجد نتائج</div>
</main>

<footer class="site">
  <p>© 2026 NLT API</p>
</footer>

<script>
(function () {
  "use strict";

  // Dark mode toggle
  var root = document.documentElement;
  var toggle = document.getElementById("theme-toggle");
  var iconMoon = document.getElementById("icon-moon");
  var iconSun = document.getElementById("icon-sun");

  function applyTheme(theme) {
    root.setAttribute("data-theme", theme);
    var dark = theme === "dark";
    toggle.setAttribute("aria-pressed", dark ? "true" : "false");
    iconMoon.style.display = dark ? "none" : "";
    iconSun.style.display = dark ? "" : "none";
    try { localStorage.setItem("nlt-theme", theme); } catch (e) {}
  }

  var saved = null;
  try { saved = localStorage.getItem("nlt-theme"); } catch (e) {}
  if (saved === "dark" || saved === "light") {
    applyTheme(saved);
  } else if (window.matchMedia && window.matchMedia("(prefers-color-scheme: dark)").matches) {
    applyTheme("dark");
  } else {
    applyTheme("light");
  }

  toggle.addEventListener("click", function () {
    var current = root.getAttribute("data-theme");
    applyTheme(current === "dark" ? "light" : "dark");
  });

  // Search filter
  var search = document.getElementById("doc-search");
  var sections = Array.prototype.slice.call(document.querySelectorAll("section.doc"));
  var noResults = document.getElementById("no-results");

  function normalize(s) {
    return (s || "").toString().toLowerCase().replace(/\s+/g, " ").trim();
  }

  function filter() {
    var q = normalize(search.value);
    var visible = 0;
    sections.forEach(function (sec) {
      var text = normalize(sec.textContent);
      var match = q === "" || text.indexOf(q) !== -1;
      sec.hidden = !match;
      if (match) visible++;
    });
    noResults.classList.toggle("visible", visible === 0);
  }

  search.addEventListener("input", filter);
  filter();
})();
</script>
</body>
</html>