<!doctype html>
<html lang="ar" dir="rtl">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>NLT API - التوثيق التقني</title>
    <style>
        :root {
            --bg-color: #ffffff;
            --text-color: #1a202c;
            --primary-color: #2563eb;
            --secondary-color: #f8fafc;
            --border-color: #e2e8f0;
            --code-bg: #f1f5f9;
            --code-text: #1e293b;
            --accent-color: #dbeafe;
        }

        [data-theme="dark"] {
            --bg-color: #0f172a;
            --text-color: #f1f5f9;
            --primary-color: #60a5fa;
            --secondary-color: #1e293b;
            --border-color: #334155;
            --code-bg: #000000;
            --code-text: #cbd5e1;
            --accent-color: #1e3a8a;
        }

        body {
            font-family: system-ui, -apple-system, sans-serif;
            background-color: var(--bg-color);
            color: var(--text-color);
            margin: 0;
            line-height: 1.6;
            transition: background-color 0.3s, color 0.3s;
        }

        header {
            position: sticky;
            top: 0;
            z-index: 100;
            background-color: var(--bg-color);
            border-bottom: 1px solid var(--border-color);
            padding: 1rem 2rem;
            display: flex;
            flex-wrap: wrap;
            align-items: center;
            justify-content: space-between;
            gap: 1rem;
        }

        .brand {
            font-size: 1.5rem;
            font-weight: bold;
            color: var(--primary-color);
        }

        nav {
            display: flex;
            gap: 1rem;
            flex-wrap: wrap;
        }

        nav a {
            text-decoration: none;
            color: var(--text-color);
            font-size: 0.9rem;
            padding: 0.5rem;
            border-radius: 4px;
            transition: background 0.2s;
        }

        nav a:hover, nav a:focus {
            background-color: var(--secondary-color);
            color: var(--primary-color);
            outline: 2px solid var(--primary-color);
        }

        .controls {
            display: flex;
            align-items: center;
            gap: 1rem;
        }

        input[type="search"] {
            padding: 0.5rem;
            border: 1px solid var(--border-color);
            border-radius: 4px;
            background: var(--secondary-color);
            color: var(--text-color);
            width: 200px;
        }

        button#theme-toggle {
            cursor: pointer;
            padding: 0.5rem;
            border: 1px solid var(--border-color);
            border-radius: 4px;
            background: var(--secondary-color);
            color: var(--text-color);
            display: flex;
            align-items: center;
            justify-content: center;
        }

        main {
            max-width: 1000px;
            margin: 2rem auto;
            padding: 0 1.5rem;
        }

        section {
            margin-bottom: 3rem;
            scroll-margin-top: 100px;
        }

        h1, h2 {
            color: var(--primary-color);
        }

        table {
            width: 100%;
            border-collapse: collapse;
            margin: 1rem 0;
            text-align: right;
        }

        th, td {
            border: 1px solid var(--border-color);
            padding: 0.75rem;
        }

        th {
            background-color: var(--secondary-color);
        }

        pre {
            direction: ltr;
            text-align: left;
            background-color: var(--code-bg);
            color: var(--code-text);
            padding: 1rem;
            border-radius: 8px;
            overflow-x: auto;
            border: 1px solid var(--border-color);
            font-family: 'Courier New', Courier, monospace;
        }

        .warning {
            background-color: var(--accent-color);
            border-right: 4px solid var(--primary-color);
            padding: 1rem;
            margin: 1rem 0;
            border-radius: 4px;
        }

        #no-results {
            display: none;
            text-align: center;
            font-size: 1.2rem;
            padding: 2rem;
            color: var(--text-color);
        }

        footer {
            text-align: center;
            padding: 2rem;
            border-top: 1px solid var(--border-color);
            font-size: 0.9rem;
            color: var(--text-color);
            opacity: 0.8;
        }

        @media (max-width: 600px) {
            header {
                flex-direction: column;
                align-items: stretch;
            }
            nav {
                justify-content: center;
            }
            input[type="search"] {
                width: 100%;
            }
        }
    </style>
</head>
<body>

    <header>
        <div class="brand">NLT API</div>
        <nav>
            <a href="#overview">نظرة عامة</a>
            <a href="#quickstart">البدء السريع</a>
            <a href="#auth">المصادقة</a>
            <a href="#endpoints">نقاط النهاية</a>
            <a href="#errors">الأخطاء</a>
        </nav>
        <div class="controls">
            <input type="search" id="search-box" placeholder="ابحث..." aria-label="ابحث في الوثائق">
            <button id="theme-toggle" aria-label="تبديل الوضع الداكن">
                <span id="theme-icon">🌙</span>
            </button>
        </div>
    </header>

    <main id="content">
        <section id="overview">
            <h2>نظرة عامة</h2>
            <p>تُقدم NLT API مجموعة من الأدوات المتقدمة لمعالجة النصوص العربية عبر واجهة برمجة تطبيقات HTTP تعتمد على تنسيق JSON، مما يتيح للمطورين دمج قدرات التحليل الصرفي والترجمة الآلية في تطبيقاتهم بسهولة وكفاءة.</p>
        </section>

        <section id="quickstart">
            <h2>البدء السريع</h2>
            <ol>
                <li>احصل على مفتاح API الخاص بك من لوحة التحكم.</li>
                <li>قم بإرسال طلب POST إلى نقطة النهاية <code>/analyze</code>.</li>
                <li>أضف مفتاح المصادقة في الترويسة (Header).</li>
            </ol>
            <pre><code>curl -X POST https://api.nlt.example/v1/analyze \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{"text": "مرحباً بك في عالم البرمجة"}'</code></pre>
        </section>

        <section id="auth">
            <h2>المصادقة</h2>
            <p>تستخدم NLT API نظام "Bearer Token" للمصادقة. يجب إرسال المفتاح مع كل طلب في ترويسة HTTP كالتالي:</p>
            <pre><code>Authorization: Bearer $NLT_API_KEY</code></pre>
            <div class="warning">
                <strong>تنبيه أمني:</strong> لا تقم أبداً بتضمين مفتاح API الخاص بك مباشرة في كود الواجهة الأمامية (Client-side code) لتجنب سرقته. استخدم خادماً وسيطاً أو متغيرات بيئية.
            </div>
        </section>

        <section id="endpoints">
            <h2>نقاط النهاية</h2>
            <table>
                <thead>
                    <tr>
                        <th>الطريقة</th>
                        <th>المسار</th>
                        <th>الوصف</th>
                    </tr>
                </thead>
                <tbody>
                    <tr>
                        <td><code>POST</code></td>
                        <td><code>/analyze</code></td>
                        <td>إجراء تحليل صرفي للنص العربي.</td>
                    </tr>
                    <tr>
                        <td><code>POST</code></td>
                        <td><code>/translate</code></td>
                        <td>ترجمة النصوص من الإنجليزية إلى العربية.</td>
                    </tr>
                    <tr>
                        <td><code>GET</code></td>
                        <td><code>/models</code></td>
                        <td>عرض قائمة بجميع النماذج المتاحة.</td>
                    </tr>
                </tbody>
            </table>
        </section>

        <section id="errors">
            <h2>الأخطاء</h2>
            <p>في حال حدوث خطأ، ستعيد API رمز حالة HTTP مع رسالة توضيحية بتنسيق JSON:</p>
            <table>
                <thead>
                    <tr>
                        <th>الرمز</th>
                        <th>المعنى</th>
                        <th>السبب</th>
                    </tr>
                </thead>
                <tbody>
                    <tr>
                        <td><code>400</code></td>
                        <td>Bad Request</td>
                        <td>تنسيق JSON غير صالح.</td>
                    </tr>
                    <tr>
                        <td><code>401</code></td>
                        <td>Unauthorized</td>
                        <td>مفتاح API مفقود أو غير صحيح.</td>
                    </tr>
                    <tr>
                        <td><code>429</code></td>
                        <td>Too Many Requests</td>
                        <td>تجاوز حد الطلبات (60 طلب/دقيقة).</td>
                    </tr>
                    <tr>
                        <td><code>500</code></td>
                        <td>Internal Server Error</td>
                        <td>خطأ داخلي في الخادم.</td>
                    </tr>
                </tbody>
            </table>
            <pre><code>{
  "error": "rate_limit_exceeded",
  "message": "You have exceeded the limit of 60 requests per minute."
}</code></pre>
        </section>

        <div id="no-results">لا توجد نتائج تطابق بحثك.</div>
    </main>

    <footer>
        © 2026 NLT API
    </footer>

    <script>
        // Dark Mode Toggle
        const themeToggle = document.getElementById('theme-toggle');
        const themeIcon = document.getElementById('theme-icon');
        const body = document.body;

        themeToggle.addEventListener('click', () => {
            const currentTheme = body.getAttribute('data-theme');
            if (currentTheme === 'dark') {
                body.removeAttribute('data-theme');
                themeIcon.textContent = '🌙';
            } else {
                body.setAttribute('data-theme', 'dark');
                themeIcon.textContent = '☀️';
            }
        });

        // Search Functionality
        const searchBox = document.getElementById('search-box');
        const sections = document.querySelectorAll('section');
        const noResults = document.getElementById('no-results');

        searchBox.addEventListener('input', (e) => {
            const term = e.target.value.toLowerCase();
            let hasMatch = false;

            sections.forEach(section => {
                const text = section.innerText.toLowerCase();
                if (text.includes(term)) {
                    section.style.display = 'block';
                    hasMatch = true;
                } else {
                    section.style.display = 'none';
                }
            });

            noResults.style.display = hasMatch ? 'none' : 'block';
        });
    </script>
</body>
</html>