:root {
    --bg-primary: #0f172a;
    --bg-secondary: #1e293b;
    --bg-code: #0f172a;
    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --accent: #38bdf8;
    --accent-dim: #0ea5e9;
    --border: #334155;
    --success: #22c55e;
    --warning: #f59e0b;
    --font-sans: 'Vazirmatn', 'Tahoma', sans-serif;
}

* {
    box-sizing: border-box;
}

body {
    font-family: var(--font-sans);
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.7;
    margin: 0;
    padding: 2rem;
    max-width: 900px;
    margin: 0 auto;
}

@font-face {
    font-family: 'Vazirmatn';
    src: url('https://cdn.jsdelivr.net/gh/rastikerdar/vazirmatn@v33.003/Vazirmatn-font-face.css');
}

h1 {
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
    color: var(--text-primary);
}

h2 {
    font-size: 1.35rem;
    font-weight: 600;
    margin-top: 2.5rem;
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border);
    color: var(--accent);
}

h2:first-of-type {
    margin-top: 0;
}

h3 {
    font-size: 1.15rem;
    font-weight: 600;
    margin-top: 1.5rem;
    color: var(--text-primary);
}

p {
    margin: 0.75rem 0;
    color: var(--text-secondary);
}

/* Code: always LTR */
code, pre, .endpoint-path, .code-block {
    direction: ltr;
    text-align: left;
    unicode-bidi: embed;
}

code {
    background: var(--bg-code);
    padding: 0.2em 0.4em;
    border-radius: 4px;
    font-family: 'JetBrains Mono', 'Fira Code', monospace;
    font-size: 0.9em;
    border: 1px solid var(--border);
}

pre {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 1rem 1.25rem;
    overflow-x: auto;
    margin: 1rem 0;
    direction: ltr;
    text-align: left;
}

pre code {
    background: none;
    padding: 0;
    border: none;
    font-size: 0.85rem;
}

table {
    width: 100%;
    border-collapse: collapse;
    margin: 1rem 0;
    font-size: 0.95rem;
}

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

th {
    background: var(--bg-secondary);
    color: var(--accent);
    font-weight: 600;
}

td {
    color: var(--text-secondary);
}

/* Code in table cells: LTR */
td code, th code {
    direction: ltr;
    text-align: left;
    display: inline-block;
}

tr:nth-child(even) td {
    background: rgba(30, 41, 59, 0.5);
}

/* Wrapper to force left alignment in RTL pages */
.ltr-align {
    direction: ltr;
    text-align: left;
    width: 100%;
    unicode-bidi: embed;
}

.ltr-align h3 {
    margin-top: 1.5rem;
}

.ltr-align h3:first-child {
    margin-top: 0;
}

.endpoint {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    margin: 0.5rem 0 0;
    direction: ltr;
    text-align: left;
}

.method {
    font-weight: 700;
    padding: 0.2em 0.5em;
    border-radius: 4px;
    font-size: 0.85rem;
    direction: ltr;
}

.method-post {
    background: #166534;
    color: #86efac;
}

.base-url {
    color: var(--accent);
    font-weight: 500;
}

.flow-list {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 1rem 1.5rem;
    margin: 1rem 0;
}

.flow-list ol {
    margin: 0;
    padding-right: 1.25rem;
    color: var(--text-secondary);
}

.flow-list li {
    margin: 0.5rem 0;
}

.note {
    background: rgba(14, 165, 233, 0.1);
    border-right: 4px solid var(--accent);
    padding: 1rem 1.25rem;
    border-radius: 4px;
    margin: 1rem 0;
}

.note-title {
    font-weight: 600;
    color: var(--accent);
    margin-bottom: 0.5rem;
}

.limits {
    background: rgba(245, 158, 11, 0.1);
    border-right: 4px solid var(--warning);
    padding: 1rem 1.25rem;
    border-radius: 4px;
    margin: 1rem 0;
}

.limits ul {
    margin: 0.5rem 0 0 1rem;
    padding: 0;
    color: var(--text-secondary);
}

.limits li {
    margin: 0.25rem 0;
}

.doc-meta {
    color: var(--text-secondary);
    font-size: 1.2rem;
    margin-bottom: 2rem;
}

.doc-meta.base-url-line {
    text-align: left;
    direction: ltr;
    width: 100%;
}

a {
    color: var(--accent);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

/* Back to landing */
.back-to-landing {
    display: inline-block;
    margin-bottom: 1rem;
    padding: 0.5rem 1rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--accent);
    font-weight: 500;
    transition: background 0.2s, border-color 0.2s;
}

.back-to-landing:hover {
    background: var(--border);
    text-decoration: none;
}

/* Navigation */
.doc-nav {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 1rem 1.5rem;
    margin-bottom: 2rem;
}

.doc-nav ul {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem 1.5rem;
}

.doc-nav a {
    display: block;
    padding: 0.25rem 0;
}

.doc-nav a.active {
    font-weight: 600;
    color: var(--accent);
}

.doc-nav a:not(.active) {
    color: var(--text-secondary);
}

.doc-nav a:not(.active):hover {
    color: var(--accent);
}

.prev-next {
    display: flex;
    justify-content: space-between;
    margin-top: 2.5rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border);
}

.prev-next a {
    color: var(--accent);
}

/* Responsive */
@media (max-width: 768px) {
    body {
        padding: 1rem;
    }

    h1 {
        font-size: 1.5rem;
    }

    h2 {
        font-size: 1.2rem;
        margin-top: 1.75rem;
    }

    h3 {
        font-size: 1.05rem;
    }

    .doc-meta {
        font-size: 1rem;
    }

    .doc-nav {
        padding: 1rem;
    }

    .doc-nav ul {
        flex-direction: column;
        gap: 0.25rem;
    }

    .doc-nav a {
        padding: 0.5rem 0;
        border-bottom: 1px solid var(--border);
    }

    .doc-nav li:last-child a {
        border-bottom: none;
    }

    .back-to-landing {
        display: block;
        text-align: center;
        margin-bottom: 1rem;
    }

    pre {
        padding: 0.75rem 1rem;
        font-size: 0.8rem;
    }

    pre code {
        font-size: 0.75rem;
    }

    table {
        display: block;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    th, td {
        padding: 0.5rem 0.75rem;
        font-size: 0.9rem;
    }

    .flow-list {
        padding: 1rem;
    }

    .prev-next {
        flex-direction: column;
        gap: 1rem;
        text-align: center;
    }

    .prev-next a {
        display: block;
    }
}

@media (max-width: 480px) {
    body {
        padding: 0.75rem;
    }

    h1 {
        font-size: 1.35rem;
    }

    .endpoint {
        flex-wrap: wrap;
    }

    .method {
        flex-shrink: 0;
    }
}
