/* ==========================================================================
   PayItFast Developer Documentation Stylesheet
   Companion to styles.css — uses the same CSS custom properties and design tokens.
   Requires: Bootstrap 5.3.2, Inter font, styles.css loaded first.
   ========================================================================== */


/* ==========================================================================
   1. DOCS LAYOUT
   ========================================================================== */

.docs-layout {
    display: flex;
    min-height: 100vh;
}


/* ==========================================================================
   2. SIDEBAR
   ========================================================================== */

.docs-sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: 280px;
    background: var(--white);
    border-right: 1px solid var(--gray-200);
    padding: 0 0 24px;
    overflow-y: auto;
    z-index: 900;
    transition: transform var(--transition-slow);
    -webkit-overflow-scrolling: touch;
}

/* Thin custom scrollbar for the sidebar */
.docs-sidebar::-webkit-scrollbar {
    width: 4px;
}

.docs-sidebar::-webkit-scrollbar-track {
    background: transparent;
}

.docs-sidebar::-webkit-scrollbar-thumb {
    background: var(--gray-300);
    border-radius: 2px;
}

.docs-sidebar::-webkit-scrollbar-thumb:hover {
    background: var(--gray-400);
}

/* Sidebar logo */
.docs-sidebar-logo {
    position: sticky;
    top: 0;
    z-index: 2;
    padding: 20px 24px;
    border-bottom: 1px solid var(--gray-200);
    background: var(--white);
}

.docs-sidebar-logo a {
    display: block;
    line-height: 0;
}

.docs-sidebar-logo img {
    height: 32px;
    width: auto;
}

/* On docs pages, hide the navbar logo (it's now in the sidebar) and offset the navbar */
.docs-layout ~ .footer,
.docs-layout {
    /* no change needed here, just a comment anchor */
}

.docs-sidebar ~ .docs-sidebar-backdrop ~ .docs-content ~ .footer {
    /* no change needed */
}

/* Navbar sits above content area only (not over sidebar) */
body:has(.docs-layout) .navbar {
    left: 280px;
}

body:has(.docs-layout) .navbar .navbar-brand {
    display: none;
}

/* Navigation groups */
.docs-nav-group {
    padding: 0 20px;
    margin-bottom: 8px;
    border-bottom: 1px solid var(--gray-100);
    padding-bottom: 8px;
}

.docs-nav-group:last-child {
    border-bottom: none;
}

.docs-nav-title {
    display: block;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
    padding: 12px 12px 6px;
    margin: 0;
}

.docs-nav-link {
    display: block;
    padding: 7px 12px;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-secondary);
    border-radius: var(--radius-sm);
    border-left: 3px solid transparent;
    transition: background var(--transition-fast), color var(--transition-fast),
                border-color var(--transition-fast);
    text-decoration: none;
    line-height: 1.5;
}

.docs-nav-link:hover {
    background: var(--gray-100);
    color: var(--text-primary);
    text-decoration: none;
}

.docs-nav-link.active {
    border-left-color: var(--accent);
    color: var(--accent);
    background: var(--accent-light);
    font-weight: 600;
    box-shadow: inset 0 0 0 1px rgba(16, 185, 129, 0.12);
}

/* Sidebar overlay backdrop for mobile */
.docs-sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    z-index: 899;
    opacity: 0;
    transition: opacity var(--transition-slow);
}

.docs-sidebar-backdrop.show {
    display: block;
    opacity: 1;
}


/* ==========================================================================
   3. MAIN CONTENT
   ========================================================================== */

.docs-content {
    flex: 1;
    margin-left: 280px;
    padding: 100px 48px 48px;
    max-width: calc(280px + 900px + 96px); /* sidebar + readable width + padding */
    min-height: 100vh;
}

.docs-content > *:first-child {
    margin-top: 0;
}


/* ==========================================================================
   4. CODE BLOCKS
   ========================================================================== */

.docs-code-block {
    background: #1a1a2e;
    border-radius: var(--radius);
    overflow: hidden;
    margin: 24px 0;
    font-size: 14px;
    line-height: 1.65;
}

.docs-code-block-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 20px;
    background: rgba(255, 255, 255, 0.06);
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.docs-code-block-lang {
    font-size: 12px;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.5);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-family: 'Inter', sans-serif;
}

.docs-code-block-copy {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.12);
    color: rgba(255, 255, 255, 0.6);
    padding: 4px 12px;
    border-radius: var(--radius-sm);
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: background var(--transition-fast), color var(--transition-fast);
    font-family: 'Inter', sans-serif;
}

.docs-code-block-copy:hover {
    background: rgba(255, 255, 255, 0.14);
    color: rgba(255, 255, 255, 0.9);
}

.docs-code-block-copy.copied {
    color: var(--accent);
    border-color: var(--accent);
}

.docs-code-block pre {
    margin: 0;
    padding: 20px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.docs-code-block code {
    font-family: 'SF Mono', 'Fira Code', 'Cascadia Code', 'JetBrains Mono', Consolas, monospace;
    font-size: 13px;
    color: #e4e4e7;
    background: none;
    padding: 0;
    border-radius: 0;
    line-height: 1.7;
    tab-size: 4;
}

/* Syntax highlighting tokens — generic palette */
.docs-code-block .token-keyword {
    color: #c792ea;
}

.docs-code-block .token-string {
    color: #c3e88d;
}

.docs-code-block .token-number {
    color: #f78c6c;
}

.docs-code-block .token-comment {
    color: #636e83;
    font-style: italic;
}

.docs-code-block .token-function {
    color: #82aaff;
}

.docs-code-block .token-property {
    color: #f07178;
}

.docs-code-block .token-punctuation {
    color: #89ddff;
}


/* ==========================================================================
   5. INLINE CODE
   ========================================================================== */

code:not(.docs-code-block code) {
    background: #f0f0f0;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.875em;
    font-family: 'SF Mono', 'Fira Code', 'Cascadia Code', Consolas, monospace;
    color: var(--text-primary);
    word-break: break-word;
}


/* ==========================================================================
   6. API ENDPOINT CARDS
   ========================================================================== */

.docs-endpoint {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 18px;
    background: var(--white);
    border: 1px solid var(--gray-200);
    border-left: 3px solid var(--gray-300);
    border-radius: var(--radius);
    margin-bottom: 12px;
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.docs-endpoint:hover {
    border-color: var(--gray-300);
    box-shadow: var(--shadow-sm);
}

.docs-endpoint:has(.method-get) {
    border-left-color: #3b82f6;
}

.docs-endpoint:has(.method-post) {
    border-left-color: #10b981;
}

.docs-endpoint:has(.method-put) {
    border-left-color: #f59e0b;
}

.docs-endpoint:has(.method-delete) {
    border-left-color: #ef4444;
}

.docs-endpoint:has(.method-patch) {
    border-left-color: #8b5cf6;
}

.docs-endpoint-method {
    display: inline-block;
    padding: 4px 10px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--white);
    border-radius: var(--radius-sm);
    flex-shrink: 0;
    line-height: 1.4;
    text-align: center;
    min-width: 56px;
}

.method-get {
    background: #3b82f6;
}

.method-post {
    background: #10b981;
}

.method-put {
    background: #f59e0b;
}

.method-delete {
    background: #ef4444;
}

.method-patch {
    background: #8b5cf6;
}

.docs-endpoint-path {
    font-family: 'SF Mono', 'Fira Code', Consolas, monospace;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    flex-shrink: 0;
}

.docs-endpoint-description {
    font-size: 14px;
    color: var(--text-secondary);
    margin-left: auto;
    text-align: right;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}


/* ==========================================================================
   7. PARAMETER TABLES
   ========================================================================== */

.docs-table-wrapper {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin: 24px 0;
}

.docs-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

.docs-table thead th {
    background: var(--gray-100);
    font-weight: 600;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-secondary);
    padding: 10px 16px;
    text-align: left;
    white-space: nowrap;
    border-bottom: 2px solid var(--accent);
}

.docs-table thead th:first-child {
    border-radius: var(--radius-sm) 0 0 0;
}

.docs-table thead th:last-child {
    border-radius: 0 var(--radius-sm) 0 0;
}

.docs-table tbody td {
    padding: 12px 16px;
    border-bottom: 1px solid var(--gray-200);
    color: var(--text-primary);
    vertical-align: top;
}

.docs-table tbody tr:last-child td {
    border-bottom: none;
}

.docs-table tbody tr:hover {
    background: var(--gray-50);
}

/* Parameter name in monospace */
.docs-table .param-name {
    font-family: 'SF Mono', 'Fira Code', Consolas, monospace;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
}

/* Required badge */
.badge-required {
    display: inline-block;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    background: #fef2f2;
    color: #dc2626;
    padding: 2px 6px;
    border-radius: 3px;
    margin-left: 6px;
    vertical-align: middle;
}

/* Type badge */
.badge-type {
    display: inline-block;
    font-size: 11px;
    font-weight: 600;
    font-family: 'SF Mono', 'Fira Code', Consolas, monospace;
    background: var(--gray-100);
    color: var(--text-muted);
    padding: 2px 8px;
    border-radius: 3px;
}


/* ==========================================================================
   8. SECTION HEADERS
   ========================================================================== */

.docs-section-title {
    font-size: clamp(1.5rem, 3vw, 1.875rem);
    font-weight: 700;
    color: var(--text-primary);
    padding-bottom: 12px;
    border-bottom: 1px solid var(--gray-200);
    margin-top: 48px;
    margin-bottom: 24px;
    scroll-margin-top: 100px;
}

.docs-section-title:first-child {
    margin-top: 0;
}

.docs-subsection-title {
    font-size: clamp(1.125rem, 2.5vw, 1.375rem);
    font-weight: 600;
    color: var(--text-primary);
    margin-top: 36px;
    margin-bottom: 16px;
    scroll-margin-top: 100px;
}

/* Anchor link icon on hover (optional progressive enhancement) */
.docs-section-title:hover .docs-anchor-link,
.docs-subsection-title:hover .docs-anchor-link {
    opacity: 1;
}

.docs-anchor-link {
    color: var(--text-light);
    margin-left: 8px;
    font-size: 0.8em;
    opacity: 0;
    transition: opacity var(--transition-fast);
    text-decoration: none;
}

.docs-anchor-link:hover {
    color: var(--accent);
}


/* ==========================================================================
   9. DOCS CARDS
   ========================================================================== */

.docs-card {
    background: var(--white);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-md);
    padding: 24px;
    transition: box-shadow var(--transition), border-color var(--transition);
}

.docs-card:hover {
    box-shadow: var(--shadow-md);
    border-color: var(--gray-300);
}

.docs-card-icon {
    width: 44px;
    height: 44px;
    background: var(--accent-light);
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 16px;
}

.docs-card-icon i {
    font-size: 20px;
    color: var(--accent);
}

.docs-card h3,
.docs-card h4 {
    font-size: 1.0625rem;
    font-weight: 600;
    margin-bottom: 8px;
    color: var(--text-primary);
}

.docs-card p {
    font-size: 14px;
    color: var(--text-secondary);
    margin-bottom: 0;
    line-height: 1.6;
}

.docs-card-link {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    margin-top: 14px;
    font-size: 14px;
    font-weight: 600;
    color: var(--accent);
    text-decoration: none;
    transition: gap var(--transition-fast);
}

.docs-card-link:hover {
    gap: 8px;
    color: var(--accent-dark);
}

/* Card grid helper */
.docs-card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 20px;
    margin: 24px 0;
}


/* ==========================================================================
   10. STATUS FLOW DIAGRAMS
   ========================================================================== */

.docs-status-flow {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0;
    padding: 20px 0;
    margin: 24px 0;
}

.docs-status-badge {
    display: inline-flex;
    align-items: center;
    padding: 8px 16px;
    font-size: 13px;
    font-weight: 600;
    border-radius: var(--radius-full);
    white-space: nowrap;
}

.status-initiated {
    background: var(--gray-100);
    color: var(--text-secondary);
}

.status-processing {
    background: #eff6ff;
    color: #2563eb;
}

.status-settled {
    background: var(--accent-light);
    color: #059669;
}

.status-failed {
    background: #fef2f2;
    color: #dc2626;
}

.status-pending {
    background: #fffbeb;
    color: #d97706;
}

.status-refunded {
    background: #f5f3ff;
    color: #7c3aed;
}

.docs-status-arrow {
    display: inline-flex;
    align-items: center;
    padding: 0 10px;
    color: var(--gray-400);
    font-size: 16px;
    flex-shrink: 0;
}

.docs-status-arrow::after {
    content: '\2192'; /* right arrow */
    display: block;
}


/* ==========================================================================
   11. CALLOUT / NOTE BOXES
   ========================================================================== */

.docs-callout {
    display: flex;
    flex-direction: column;
    border-left: 4px solid var(--accent);
    background: var(--accent-light);
    padding: 16px 20px;
    border-radius: 0 var(--radius) var(--radius) 0;
    margin: 24px 0;
    font-size: 14px;
    line-height: 1.65;
}

.docs-callout p {
    color: var(--text-primary);
    margin: 0;
    font-size: inherit;
}

.docs-callout p + p {
    margin-top: 8px;
}

.docs-callout-title {
    font-weight: 700;
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: 6px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.docs-callout-info {
    border-left-color: #3b82f6;
    background: #eff6ff;
}

.docs-callout-info .docs-callout-title {
    color: #2563eb;
}

.docs-callout-warning {
    border-left-color: #f59e0b;
    background: #fffbeb;
}

.docs-callout-warning .docs-callout-title {
    color: #d97706;
}

.docs-callout-danger {
    border-left-color: #ef4444;
    background: #fef2f2;
}

.docs-callout-danger .docs-callout-title {
    color: #dc2626;
}

.docs-callout .docs-callout-title {
    color: #059669;
}


/* ==========================================================================
   12. TABLE OF CONTENTS (right-side sticky)
   ========================================================================== */

.docs-toc {
    display: none; /* hidden by default; shown on large screens */
}

.docs-toc-title {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
    margin-bottom: 12px;
    padding-left: 12px;
}

.docs-toc-list {
    list-style: none;
    padding: 0;
    margin: 0;
    border-left: 1px solid var(--gray-200);
}

.docs-toc-link {
    display: block;
    padding: 5px 0 5px 12px;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-muted);
    text-decoration: none;
    border-left: 2px solid transparent;
    margin-left: -1px;
    transition: color var(--transition-fast), border-color var(--transition-fast);
    line-height: 1.5;
}

.docs-toc-link:hover {
    color: var(--text-primary);
}

.docs-toc-link.active {
    color: var(--accent);
    border-left-color: var(--accent);
    font-weight: 600;
}

/* Nested items (h3 links) */
.docs-toc-list .docs-toc-list {
    border-left: none;
    padding-left: 12px;
}

.docs-toc-list .docs-toc-list .docs-toc-link {
    font-size: 12px;
    padding: 4px 0 4px 12px;
}


/* ==========================================================================
   13. MOBILE SIDEBAR TOGGLE
   ========================================================================== */

.docs-sidebar-toggle {
    display: none; /* hidden on desktop */
    position: fixed;
    top: 72px;
    left: 16px;
    z-index: 901;
    width: 40px;
    height: 40px;
    background: var(--white);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    box-shadow: var(--shadow-md);
    cursor: pointer;
    align-items: center;
    justify-content: center;
    transition: background var(--transition-fast);
    color: var(--text-primary);
    font-size: 18px;
    padding: 0;
}

.docs-sidebar-toggle:hover {
    background: var(--gray-100);
}

.docs-sidebar-toggle:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}


/* ==========================================================================
   14. RESPONSIVE BREAKPOINTS
   ========================================================================== */

/* ----- Large screens (above 1200px): show ToC ----- */
@media (min-width: 1201px) {
    .docs-content {
        margin-right: 220px;
    }

    .docs-toc {
        display: block;
        position: fixed;
        top: 100px;
        right: 24px;
        width: 200px;
        max-height: calc(100vh - 120px);
        overflow-y: auto;
        z-index: 100;
    }

    /* Thin scrollbar for ToC */
    .docs-toc::-webkit-scrollbar {
        width: 3px;
    }

    .docs-toc::-webkit-scrollbar-thumb {
        background: var(--gray-300);
        border-radius: 2px;
    }
}


/* ----- Below 992px: mobile sidebar ----- */
@media (max-width: 991.98px) {
    .docs-sidebar {
        transform: translateX(-100%);
        z-index: 1050;
        box-shadow: none;
    }

    .docs-sidebar.show {
        transform: translateX(0);
        box-shadow: var(--shadow-xl);
    }

    .docs-sidebar-toggle {
        display: flex;
    }

    .docs-content {
        margin-left: 0;
        padding: 100px 24px 48px;
    }

    body:has(.docs-layout) .navbar {
        left: 0;
    }

    body:has(.docs-layout) .navbar .navbar-brand {
        display: flex;
    }
}


/* ----- Below 768px: compact layout ----- */
@media (max-width: 767.98px) {
    .docs-content {
        padding: 90px 16px 36px;
    }

    .docs-section-title {
        margin-top: 36px;
        font-size: 1.375rem;
    }

    .docs-subsection-title {
        margin-top: 28px;
        font-size: 1.125rem;
    }

    /* Horizontally scrollable tables */
    .docs-table-wrapper {
        margin-left: -16px;
        margin-right: -16px;
        padding-left: 16px;
        padding-right: 16px;
    }

    /* Endpoint cards stack vertically */
    .docs-endpoint {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }

    .docs-endpoint-description {
        margin-left: 0;
        text-align: left;
        white-space: normal;
    }

    /* Status flow wraps */
    .docs-status-flow {
        gap: 8px;
    }

    .docs-status-arrow {
        padding: 0 4px;
    }

    /* Cards grid becomes single column */
    .docs-card-grid {
        grid-template-columns: 1fr;
    }

    .docs-code-block pre {
        padding: 16px;
    }

    .docs-sidebar-toggle {
        top: 66px;
        left: 12px;
        width: 36px;
        height: 36px;
        font-size: 16px;
    }
}


/* ==========================================================================
   15. UTILITY & HELPERS
   ========================================================================== */

/* Text helpers specific to docs */
.docs-text-muted {
    color: var(--text-muted);
}

.docs-text-small {
    font-size: 13px;
}

.docs-text-mono {
    font-family: 'SF Mono', 'Fira Code', Consolas, monospace;
}

/* Horizontal rule in docs */
.docs-divider {
    border: none;
    border-top: 1px solid var(--gray-200);
    margin: 40px 0;
}

/* Breadcrumb for docs */
.docs-breadcrumb {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    color: var(--text-muted);
    margin-bottom: 24px;
}

.docs-breadcrumb a {
    color: var(--text-muted);
    text-decoration: none;
    transition: color var(--transition-fast);
}

.docs-breadcrumb a:hover {
    color: var(--accent);
}

.docs-breadcrumb-separator {
    color: var(--gray-300);
}

.docs-breadcrumb-current {
    color: var(--text-primary);
    font-weight: 500;
}

/* Version badge */
.docs-version-badge {
    display: inline-block;
    font-size: 11px;
    font-weight: 600;
    background: var(--gray-100);
    color: var(--text-muted);
    padding: 3px 10px;
    border-radius: var(--radius-full);
    letter-spacing: 0.02em;
}

/* Response example block */
.docs-response-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
}

.docs-response-status {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    font-weight: 700;
    padding: 3px 10px;
    border-radius: var(--radius-full);
}

.docs-response-status.status-200 {
    background: var(--accent-light);
    color: #059669;
}

.docs-response-status.status-400,
.docs-response-status.status-401,
.docs-response-status.status-404 {
    background: #fef2f2;
    color: #dc2626;
}

.docs-response-status.status-500 {
    background: #fef2f2;
    color: #991b1b;
}


/* ==========================================================================
   16. SEARCH (optional docs search bar in sidebar)
   ========================================================================== */

.docs-search {
    padding: 0 20px 16px;
}

.docs-search-input {
    width: 100%;
    padding: 9px 14px 9px 36px;
    font-size: 13px;
    font-family: 'Inter', sans-serif;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    background: var(--gray-50);
    color: var(--text-primary);
    transition: border-color var(--transition-fast), background var(--transition-fast);
    outline: none;
}

.docs-search-input::placeholder {
    color: var(--text-light);
}

.docs-search-input:focus {
    border-color: var(--accent);
    background: var(--white);
    box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.1);
}

.docs-search-wrapper {
    position: relative;
}

.docs-search-icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-light);
    font-size: 14px;
    pointer-events: none;
}


/* ==========================================================================
   17. PRINT STYLES
   ========================================================================== */

@media print {
    .docs-sidebar,
    .docs-sidebar-toggle,
    .docs-sidebar-backdrop,
    .docs-toc,
    .docs-code-block-copy {
        display: none !important;
    }

    .docs-content {
        margin-left: 0;
        padding: 0;
        max-width: 100%;
    }

    .docs-code-block {
        background: #f5f5f5 !important;
        border: 1px solid #e5e5e5;
    }

    .docs-code-block code {
        color: #000 !important;
    }

    .docs-callout,
    .docs-callout-info,
    .docs-callout-warning,
    .docs-callout-danger {
        border-left-width: 3px;
        background: #fafafa !important;
    }
}
