/* ===========================================
   API Documentation Styles
   Modern, clean API documentation design
   =========================================== */

/* Wrapper for sidebar and content - matches header max-width and padding */
.docs-wrapper {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem 12px 2rem calc(280px + 24px);
    /* 12px padding to match header, left space for sidebar */
    position: relative;
}


/* Container & Layout */
.docs-container {
    min-width: 0;
    max-width: 100%;
    margin: 0;
    padding: 0;
}

.docs-header {
    margin-bottom: 2.5rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid var(--color-border, #e5e7eb);
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 2rem;
    flex-wrap: wrap;
}

.docs-header-content {
    flex: 1;
    min-width: 300px;
}

.docs-header h1 {
    font-size: 2rem;
    margin: 0 0 0.5rem;
    color: var(--color-heading, #1f2937);
}

.docs-header h1 i {
    color: var(--color-primary, #E63946);
    margin-right: 0.5rem;
}

.docs-description {
    font-size: 1.125rem;
    color: var(--color-text-light, #6b7280);
    margin: 0;
}

.docs-header-actions {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
    align-items: flex-start;
}

@media (max-width: 768px) {
    .docs-header {
        flex-direction: column;
    }
}

/* Content Sections */
.docs-content h2 {
    font-size: 1.5rem;
    margin: 2.5rem 0 1rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--color-border, #e5e7eb);
    color: var(--color-heading, #1f2937);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.docs-content h2:first-of-type {
    margin-top: 0;
    padding-top: 0;
    border-top: none;
}

.docs-content h2 i {
    color: var(--color-primary, #E63946);
    font-size: 1.25rem;
}

.docs-content h3 {
    font-size: 1.25rem;
    margin: 2rem 0 1rem;
    color: var(--color-heading, #1f2937);
}

.docs-content h4 {
    font-size: 1rem;
    margin: 1.5rem 0 0.75rem;
    color: var(--color-heading, #1f2937);
}

.docs-content p {
    margin: 0 0 1rem;
    color: var(--color-text, #4b5563);
    line-height: 1.7;
}

/* Override paragraph color inside help box */
.docs-help-box p {
    color: #ffffff !important;
}

.docs-content ul {
    margin: 0 0 1.5rem;
    padding-left: 1.5rem;
}

.docs-content ul li {
    margin-bottom: 0.5rem;
    color: var(--color-text, #4b5563);
    line-height: 1.6;
}

.docs-content code {
    background: var(--color-background, #f3f4f6);
    padding: 0.125rem 0.375rem;
    border-radius: 0.25rem;
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    font-size: 0.875em;
    color: var(--color-primary, #E63946);
}

/* Code Blocks */
.code-block {
    background: #1e293b;
    color: #e2e8f0;
    padding: 1.25rem 1.5rem;
    border-radius: 0.5rem;
    overflow-x: auto;
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    font-size: 0.875rem;
    line-height: 1.7;
    margin: 1rem 0 1.5rem;
    white-space: pre;
}

.code-block .comment {
    color: #64748b;
}

.code-block .string {
    color: #fbbf24;
}

.code-block .keyword {
    color: #38bdf8;
}

.code-block .method {
    color: #a78bfa;
}

.code-block .variable {
    color: #4ade80;
}

/* Endpoint Cards */
.endpoint-card {
    background: white;
    border-radius: 0.75rem;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
    margin: 1.5rem 0;
    overflow: hidden;
    border: 1px solid var(--color-border, #e5e7eb);
}

.endpoint-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem 1.5rem;
    background: var(--color-background, #f8f9fc);
    border-bottom: 1px solid var(--color-border, #e5e7eb);
}

.endpoint-method {
    font-weight: 700;
    padding: 0.375rem 0.75rem;
    border-radius: 0.375rem;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.025em;
}

.endpoint-method.get {
    background: #10b981;
    color: white;
}

.endpoint-method.post {
    background: #3b82f6;
    color: white;
}

.endpoint-method.put {
    background: #f59e0b;
    color: white;
}

.endpoint-method.delete {
    background: #ef4444;
    color: white;
}

.endpoint-path {
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    font-size: 0.9375rem;
    font-weight: 500;
    color: var(--color-heading, #1f2937);
}

.endpoint-body {
    padding: 1.5rem;
}

.endpoint-body>p:first-child {
    margin-top: 0;
}

/* Parameter Tables */
.param-table {
    width: 100%;
    border-collapse: collapse;
    margin: 1rem 0;
    font-size: 0.9375rem;
}

.param-table th,
.param-table td {
    padding: 0.875rem 1rem;
    text-align: left;
    border-bottom: 1px solid var(--color-border, #e5e7eb);
}

.param-table th {
    background: var(--color-background, #f8f9fc);
    font-weight: 600;
    color: var(--color-heading, #1f2937);
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.025em;
}

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

.param-table code {
    background: var(--color-background, #f3f4f6);
    padding: 0.125rem 0.375rem;
    border-radius: 0.25rem;
    font-size: 0.875rem;
    color: var(--color-primary, #E63946);
}

.param-type {
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    font-size: 0.8125rem;
    color: #3b82f6;
    background: #dbeafe;
    padding: 0.125rem 0.5rem;
    border-radius: 0.25rem;
}

.param-required {
    font-size: 0.75rem;
    padding: 0.25rem 0.5rem;
    border-radius: 0.25rem;
    background: #fee2e2;
    color: #dc2626;
    font-weight: 500;
}

.param-optional {
    font-size: 0.75rem;
    padding: 0.25rem 0.5rem;
    border-radius: 0.25rem;
    background: var(--color-background, #f3f4f6);
    color: var(--color-text-light, #6b7280);
    font-weight: 500;
}

/* Response Examples */
.response-example {
    background: #1e293b;
    color: #e2e8f0;
    padding: 1.25rem 1.5rem;
    border-radius: 0.5rem;
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    font-size: 0.875rem;
    line-height: 1.7;
    overflow-x: auto;
    white-space: pre;
    margin: 1rem 0;
}

/* Notes & Alerts */
.docs-note {
    margin: 1rem 0;
    padding: 1rem 1.25rem;
    background: #fef3c7;
    border: 1px solid #fcd34d;
    border-radius: 0.5rem;
    color: #92400e;
    font-size: 0.9375rem;
}

.docs-note strong {
    color: #b45309;
}

/* Help Box */
.docs-help-box {
    margin-top: 3rem;
    padding: 2.5rem;
    background: linear-gradient(135deg, var(--color-primary, #E63946) 0%, #c53030 100%);
    border-radius: 1rem;
    text-align: center;
    color: white;
}

.docs-help-box h3 {
    margin: 0 0 0.75rem;
    font-size: 1.5rem;
    color: white;
}

.docs-help-box .docs-help-text,
.docs-help-box p.docs-help-text {
    margin: 0 0 1.5rem;
    color: #ffffff !important;
    font-size: 1.0625rem;
    font-weight: 600;
    line-height: 1.6;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.docs-help-box .btn {
    background: white;
    color: var(--color-primary, #E63946);
    font-weight: 600;
}

.docs-help-box .btn:hover {
    background: rgba(255, 255, 255, 0.9);
}

/* Quick Links Section */
.docs-quick-links {
    display: flex;
    gap: 1rem;
    margin-top: 2rem;
    flex-wrap: wrap;
}

.docs-sandbox-link {
    margin: 2rem 0;
}

.docs-sandbox-link .btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

/* Sandbox */
.sandbox-card {
    border: 2px solid var(--color-border, #e5e7eb);
    border-radius: 16px;
    padding: 2.5rem;
    background: linear-gradient(135deg, #ffffff 0%, #f8f9fc 100%);
    margin: 2rem 0 3rem;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.08), 0 2px 8px rgba(0, 0, 0, 0.04);
    position: relative;
    overflow: hidden;
}

.sandbox-card::before {
    content: none;
}

.sandbox-field {
    margin-bottom: 1.5rem;
}

.sandbox-label {
    display: block;
    font-weight: 600;
    margin: 0 0 0.5rem;
    color: var(--color-heading, #1f2937);
    font-size: 0.9375rem;
}

.sandbox-input {
    width: 100%;
    padding: 0.875rem 1.125rem;
    border: 2px solid #d1d5db;
    border-radius: 10px;
    font-size: 0.9375rem;
    transition: all 0.2s ease;
    background: white;
    font-family: inherit;
}

.sandbox-input:hover {
    border-color: #9ca3af;
}

.sandbox-input:focus {
    outline: none;
    border-color: var(--color-primary, #E63946);
    box-shadow: 0 0 0 4px rgba(230, 57, 70, 0.12);
    transform: translateY(-1px);
}

.sandbox-textarea {
    width: 100%;
    min-height: 140px;
    border: 2px solid #d1d5db;
    border-radius: 10px;
    padding: 0.875rem 1.125rem;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
    font-size: 0.875rem;
    transition: all 0.2s ease;
    background: white;
    resize: vertical;
    line-height: 1.6;
}

.sandbox-textarea:hover {
    border-color: #9ca3af;
}

.sandbox-textarea:focus {
    outline: none;
    border-color: var(--color-primary, #E63946);
    box-shadow: 0 0 0 4px rgba(230, 57, 70, 0.12);
}

.sandbox-actions {
    display: flex;
    gap: 0.875rem;
    margin: 1.75rem 0;
    flex-wrap: wrap;
}

.sandbox-actions .btn {
    padding: 0.75rem 1.5rem;
    font-weight: 600;
    border-radius: 8px;
    transition: all 0.2s ease;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.sandbox-actions .btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
}

.sandbox-actions .btn:active {
    transform: translateY(0);
}

.sandbox-inline {
    display: flex;
    gap: 8px;
    align-items: flex-end;
    flex-wrap: wrap;
}

.sandbox-btn-inline {
    margin-top: 4px;
}

.sandbox-divider {
    border-top: 2px solid var(--color-border, #e5e7eb);
    margin: 2rem 0;
}

.sandbox-output {
    background: #1e293b;
    color: #e2e8f0;
    border-radius: 12px;
    padding: 1.5rem;
    margin-top: 2rem;
    border: 2px solid #334155;
    box-shadow: inset 0 2px 8px rgba(0, 0, 0, 0.3);
}

.sandbox-output-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    color: #94a3b8;
    font-size: 0.875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.sandbox-pre {
    white-space: pre-wrap;
    margin: 0;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
    font-size: 0.875rem;
    line-height: 1.6;
    color: #e2e8f0;
    max-height: 400px;
    overflow-y: auto;
}

.sandbox-status {
    font-size: 0.75rem;
    padding: 0.25rem 0.75rem;
    border-radius: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.sandbox-status.idle {
    background: #475569;
    color: #cbd5e1;
}

.sandbox-status.loading {
    background: #f59e0b;
    color: white;
    animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

.sandbox-status.error {
    background: #ef4444;
    color: white;
}

.sandbox-status.success {
    background: #10b981;
    color: white;
}

@keyframes pulse {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.7;
    }
}

/* Desktop Sidebar Navigation */
.docs-sidebar {
    width: 280px;
    flex-shrink: 0;
    position: fixed;
    top: 7rem;
    /* Align with header's left edge: calc((100vw - 1200px) / 2 + 12px) */
    left: max(12px, calc((100vw - 1200px) / 2 + 12px));
    max-height: calc(100vh - 8rem);
    overflow-y: auto;
    background: white;
    border: 1px solid var(--color-border, #e5e7eb);
    border-radius: 12px;
    padding: 1.5rem;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
    z-index: 10;
}


.docs-sidebar-header {
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--color-border, #e5e7eb);
}

.docs-sidebar-header h3 {
    margin: 0;
    font-size: 1.125rem;
    color: var(--color-heading, #1f2937);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.docs-sidebar-header h3 i {
    color: var(--color-primary, #E63946);
}

.docs-nav-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.docs-nav-list li {
    margin-bottom: 0.5rem;
}

.docs-nav-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    color: var(--color-text, #4b5563);
    text-decoration: none;
    border-radius: 8px;
    transition: all 0.2s ease;
    font-size: 0.9375rem;
}

.docs-nav-link:hover {
    background: var(--color-background, #f8f9fc);
    color: var(--color-primary, #E63946);
}

.docs-nav-link.active {
    background: rgba(230, 57, 70, 0.1);
    color: var(--color-primary, #E63946);
    font-weight: 600;
}

.docs-nav-link i {
    width: 20px;
    text-align: center;
    font-size: 0.875rem;
}

/* Mobile Floating Menu Button - aligned with back-to-top button */
.docs-mobile-menu-btn {
    display: none;
    position: fixed;
    bottom: 24px;
    left: 24px;
    right: auto;
    width: 48px;
    height: 48px;
    border-radius: 12px;
    background: var(--color-primary, #E63946);
    color: white;
    border: none;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
    cursor: pointer;
    z-index: 1000;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    transition: all 0.3s ease;
}

.docs-mobile-menu-btn:hover {
    background: var(--color-primary-dark, #c53030);
    transform: translateY(-2px);
}

.docs-mobile-menu-btn:active {
    background-color: #ff6b6b;
    transform: translateY(0);
}

/* Mobile responsive sizing to match back-to-top */
@media (max-width: 768px) {
    .docs-mobile-menu-btn {
        bottom: 16px;
        left: 16px;
        width: 44px;
        height: 44px;
        border-radius: 10px;
        font-size: 0.9rem;
    }
}

/* Mobile Menu Overlay */
.docs-mobile-menu-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1001;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.docs-mobile-menu-overlay.active {
    display: block !important;
    opacity: 1;
}

/* Mobile Menu */
.docs-mobile-menu {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: white;
    border-radius: 20px 20px 0 0;
    z-index: 1002;
    max-height: 80vh;
    transform: translateY(100%);
    transition: transform 0.3s ease;
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.15);
}

.docs-mobile-menu.active {
    display: block !important;
    transform: translateY(0);
}

.docs-mobile-menu-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem;
    border-bottom: 1px solid var(--color-border, #e5e7eb);
}

.docs-mobile-menu-header h3 {
    margin: 0;
    font-size: 1.25rem;
    color: var(--color-heading, #1f2937);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.docs-mobile-menu-header h3 i {
    color: var(--color-primary, #E63946);
}

.docs-mobile-menu-close {
    width: 40px;
    height: 40px;
    border: none;
    background: var(--color-background, #f8f9fc);
    border-radius: 8px;
    color: var(--color-text, #4b5563);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    transition: all 0.2s ease;
}

.docs-mobile-menu-close:hover {
    background: var(--color-border, #e5e7eb);
    color: var(--color-heading, #1f2937);
}

.docs-mobile-nav-list {
    list-style: none;
    margin: 0;
    padding: 1rem;
    max-height: calc(80vh - 100px);
    overflow-y: auto;
}

.docs-mobile-nav-list li {
    margin-bottom: 0.5rem;
}

.docs-mobile-nav-list .docs-nav-link {
    padding: 1rem;
    font-size: 1rem;
}

/* Responsive */
@media (max-width: 1024px) {
    .docs-wrapper {
        padding: 2rem 12px;
    }

    .docs-sidebar {
        width: 100%;
        position: static;
        max-height: none;
        margin-bottom: 2rem;
        left: auto;
    }
}

@media (max-width: 768px) {
    .docs-wrapper {
        padding: 1rem 8px;
    }

    .docs-container {
        padding: 0;
    }

    .docs-header h1 {
        font-size: 1.5rem;
    }

    .docs-sidebar {
        display: none;
    }

    .docs-mobile-menu-btn {
        display: block !important;
    }

    .docs-mobile-menu-overlay {
        display: none;
    }

    .docs-mobile-menu {
        display: none;
    }

    .endpoint-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }

    .param-table {
        font-size: 0.875rem;
        display: block;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        width: 100%;
        word-break: break-word;
        -ms-overflow-style: -ms-autohiding-scrollbar;
    }

    .param-table table {
        min-width: 100%;
        width: max-content;
        border-collapse: collapse;
    }

    .param-table th,
    .param-table td {
        padding: 0.625rem 0.5rem;
        white-space: normal;
        word-break: break-word;
        overflow-wrap: break-word;
        hyphens: auto;
        max-width: 150px;
    }

    .param-table th:first-child,
    .param-table td:first-child {
        min-width: 100px;
        max-width: 120px;
    }

    /* Prevent long content from being cut off on mobile */
    .docs-content {
        max-width: 100%;
        word-wrap: break-word;
        overflow-wrap: break-word;
    }

    .docs-content p,
    .docs-content li {
        word-wrap: break-word;
        overflow-wrap: break-word;
    }

    .docs-content code,
    .endpoint-path {
        word-break: break-all;
    }

    .code-block,
    .response-example {
        padding: 1rem;
        font-size: 0.8125rem;
        overflow-x: auto;
        word-break: break-all;
        white-space: pre-wrap;
        overflow-wrap: break-word;
        -webkit-overflow-scrolling: touch;
        -ms-overflow-style: -ms-autohiding-scrollbar;
    }

    .endpoint-card {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        -ms-overflow-style: -ms-autohiding-scrollbar;
    }

    .endpoint-path {
        word-break: break-all;
        overflow-wrap: break-word;
        white-space: normal;
    }

    .docs-content {
        word-wrap: break-word;
        overflow-wrap: break-word;
        max-width: 100%;
        overflow-x: hidden;
    }

    .docs-content p,
    .docs-content li {
        word-wrap: break-word;
        overflow-wrap: break-word;
        hyphens: auto;
    }

    .docs-content code {
        word-break: break-all;
        overflow-wrap: break-word;
        white-space: normal;
    }

    .docs-content h2,
    .docs-content h3,
    .docs-content h4 {
        word-break: break-word;
        overflow-wrap: break-word;
    }

    .docs-help-box {
        padding: 1.5rem;
    }
}