/* ==========================================================================
   Noctra API Documentation - Dark Theme Stylesheet
   ========================================================================== */

/* ---------- CSS Variables ---------- */
:root {
    --bg-primary: #0d1117;
    --bg-secondary: #161b22;
    --bg-tertiary: #1c2128;
    --border-color: #30363d;
    --text-primary: #e6edf3;
    --text-secondary: #8b949e;
    --text-muted: #6e7681;
    --accent: #5865f2;
    --accent-hover: #4752c4;
    --method-get: #3fb950;
    --method-post: #58a6ff;
    --method-put: #d29922;
    --method-delete: #f85149;
    --status-success: #3fb950;
    --status-client-error: #f85149;
    --status-server-error: #da3633;
    --font-sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, sans-serif;
    --font-mono: 'SF Mono', 'Fira Code', 'Fira Mono', Menlo, Consolas, monospace;
    --header-height: 64px;
    --sidebar-width: 280px;
    --radius-sm: 4px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --transition: 0.2s ease;
}

/* ---------- Reset & Base ---------- */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    scroll-behavior: smooth;
    scroll-padding-top: calc(var(--header-height) + 24px);
}

body {
    font-family: var(--font-sans);
    font-size: 15px;
    line-height: 1.6;
    color: var(--text-primary);
    background: var(--bg-primary);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

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

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

code {
    font-family: var(--font-mono);
    font-size: 0.875em;
}

ul {
    list-style: none;
}

/* ---------- Header ---------- */
.docs-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 100;
    height: var(--header-height);
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    padding: 0 24px;
}

.header-content {
    display: flex;
    align-items: center;
    width: 100%;
    gap: 16px;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
}

.header-center {
    flex: 1;
    min-width: 0;
}

.header-right {
    flex-shrink: 0;
}

.header-title {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-primary);
    white-space: nowrap;
}

.version-badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 10px;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--accent);
    background: rgba(88, 101, 242, 0.12);
    border: 1px solid rgba(88, 101, 242, 0.3);
    border-radius: 20px;
    white-space: nowrap;
}

.header-description {
    font-size: 0.85rem;
    color: var(--text-secondary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.search-input {
    width: 240px;
    padding: 8px 14px;
    font-size: 0.875rem;
    color: var(--text-primary);
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    outline: none;
    transition: border-color var(--transition), box-shadow var(--transition);
}

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

.search-input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(88, 101, 242, 0.15);
}

/* ---------- Sidebar Toggle (Mobile) ---------- */
.sidebar-toggle {
    display: none;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 4px;
    width: 36px;
    height: 36px;
    background: transparent;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    cursor: pointer;
    padding: 8px;
}

.sidebar-toggle span {
    display: block;
    width: 18px;
    height: 2px;
    background: var(--text-primary);
    border-radius: 1px;
    transition: transform var(--transition), opacity var(--transition);
}

/* ---------- Layout Container ---------- */
.docs-container {
    display: flex;
    margin-top: var(--header-height);
    min-height: calc(100vh - var(--header-height));
}

/* ---------- Sidebar ---------- */
.docs-sidebar {
    position: fixed;
    top: var(--header-height);
    left: 0;
    bottom: 0;
    width: var(--sidebar-width);
    background: var(--bg-secondary);
    border-right: 1px solid var(--border-color);
    overflow-y: auto;
    overflow-x: hidden;
    padding: 16px 0;
    z-index: 50;
    scrollbar-width: thin;
    scrollbar-color: var(--border-color) transparent;
}

.docs-sidebar::-webkit-scrollbar {
    width: 6px;
}

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

.docs-sidebar::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 3px;
}

.sidebar-nav {
    padding: 0 8px;
}

.category-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.category-item {
    margin-bottom: 4px;
}

.category-link {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-weight: 600;
    font-size: 0.875rem;
    transition: background var(--transition);
}

.category-link:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.category-icon {
    font-size: 1rem;
    flex-shrink: 0;
    width: 20px;
    text-align: center;
    color: var(--accent);
}

.category-name {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.endpoint-count {
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--text-muted);
    background: var(--bg-primary);
    padding: 2px 7px;
    border-radius: 10px;
    flex-shrink: 0;
}

.endpoint-list {
    margin: 2px 0 8px 20px;
    padding-left: 12px;
    border-left: 1px solid var(--border-color);
}

.endpoint-item {
    margin: 2px 0;
}

.endpoint-link {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 10px;
    border-radius: var(--radius-sm);
    font-size: 0.8rem;
    color: var(--text-secondary);
    transition: background var(--transition), color var(--transition);
}

.endpoint-link:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.method-indicator {
    font-size: 0.65rem;
    font-weight: 700;
    font-family: var(--font-mono);
    padding: 1px 5px;
    border-radius: 3px;
    text-transform: uppercase;
    flex-shrink: 0;
}

.method-indicator.method-get {
    color: var(--method-get);
    background: rgba(63, 185, 80, 0.1);
}

.method-indicator.method-post {
    color: var(--method-post);
    background: rgba(88, 166, 255, 0.1);
}

.method-indicator.method-put {
    color: var(--method-put);
    background: rgba(210, 153, 34, 0.1);
}

.method-indicator.method-delete {
    color: var(--method-delete);
    background: rgba(248, 81, 73, 0.1);
}

.endpoint-path-short {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-family: var(--font-mono);
    font-size: 0.75rem;
}

/* ---------- Main Content ---------- */
.docs-main {
    flex: 1;
    margin-left: var(--sidebar-width);
    padding: 32px 40px;
    max-width: 960px;
}

/* ---------- Category Section ---------- */
.category-section {
    margin-bottom: 48px;
}

.category-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 8px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border-color);
}

.category-header .category-icon {
    font-size: 1.25rem;
    color: var(--accent);
}

.category-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
}

.category-header .endpoint-count {
    font-size: 0.8rem;
    color: var(--text-secondary);
    background: none;
    padding: 0;
}

.category-description {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-bottom: 24px;
}

/* ---------- Endpoint Card ---------- */
.endpoint-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 24px;
    margin-bottom: 24px;
    transition: border-color var(--transition), box-shadow var(--transition);
}

.endpoint-card:hover {
    border-color: rgba(88, 101, 242, 0.3);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.endpoint-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
}

.method-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 4px 12px;
    font-size: 0.75rem;
    font-weight: 700;
    font-family: var(--font-mono);
    text-transform: uppercase;
    border-radius: var(--radius-sm);
    letter-spacing: 0.5px;
    flex-shrink: 0;
}

.method-badge.method-get {
    color: var(--method-get);
    background: rgba(63, 185, 80, 0.12);
    border: 1px solid rgba(63, 185, 80, 0.3);
}

.method-badge.method-post {
    color: var(--method-post);
    background: rgba(88, 166, 255, 0.12);
    border: 1px solid rgba(88, 166, 255, 0.3);
}

.method-badge.method-put {
    color: var(--method-put);
    background: rgba(210, 153, 34, 0.12);
    border: 1px solid rgba(210, 153, 34, 0.3);
}

.method-badge.method-delete {
    color: var(--method-delete);
    background: rgba(248, 81, 73, 0.12);
    border: 1px solid rgba(248, 81, 73, 0.3);
}

.endpoint-path {
    font-family: var(--font-mono);
    font-size: 0.9rem;
    color: var(--text-primary);
    background: var(--bg-primary);
    padding: 6px 12px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
    word-break: break-all;
}

.endpoint-summary {
    font-size: 1rem;
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.endpoint-description {
    font-size: 0.9rem;
    color: var(--text-secondary);
    line-height: 1.7;
    margin-bottom: 16px;
}

/* ---------- Endpoint Sections ---------- */
.endpoint-section {
    margin-top: 20px;
    padding-top: 16px;
    border-top: 1px solid var(--border-color);
}

.section-title {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 12px;
}

/* ---------- Lists ---------- */
.prerequisites-list,
.use-cases-list,
.related-endpoints-list {
    padding-left: 0;
}

.prerequisites-list li,
.use-cases-list li {
    position: relative;
    padding: 6px 0 6px 20px;
    color: var(--text-secondary);
    font-size: 0.875rem;
}

.prerequisites-list li::before,
.use-cases-list li::before {
    content: '•';
    position: absolute;
    left: 6px;
    color: var(--accent);
    font-weight: bold;
}

.related-endpoints-list li {
    padding: 6px 0;
    font-size: 0.875rem;
}

.related-link {
    color: var(--accent);
    font-weight: 500;
}

.related-link:hover {
    text-decoration: underline;
}

.related-relationship {
    color: var(--text-muted);
    font-size: 0.8rem;
}

/* ---------- Tables ---------- */
.table-wrapper {
    overflow-x: auto;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
}

.params-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}

.params-table thead {
    background: var(--bg-tertiary);
}

.params-table th {
    padding: 10px 14px;
    text-align: left;
    font-weight: 600;
    color: var(--text-secondary);
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 1px solid var(--border-color);
}

.params-table td {
    padding: 10px 14px;
    color: var(--text-primary);
    border-bottom: 1px solid var(--border-color);
    vertical-align: top;
}

.params-table tbody tr:nth-child(even) {
    background: rgba(22, 27, 34, 0.5);
}

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

.params-table tbody tr:hover {
    background: var(--bg-tertiary);
}

.params-table code {
    color: var(--accent);
    background: rgba(88, 101, 242, 0.08);
    padding: 2px 6px;
    border-radius: 3px;
    font-size: 0.8rem;
}

/* ---------- Example Blocks ---------- */
.example-block {
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    margin-bottom: 12px;
    overflow: hidden;
}

.example-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    background: var(--bg-tertiary);
    border-bottom: 1px solid var(--border-color);
}

.example-title {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-primary);
    flex: 1;
}

.content-type {
    font-size: 0.7rem;
    font-family: var(--font-mono);
    color: var(--text-muted);
    background: var(--bg-primary);
    padding: 2px 8px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
}

.example-headers {
    padding: 10px 14px;
    border-bottom: 1px solid var(--border-color);
    background: rgba(13, 17, 23, 0.5);
}

.header-line {
    padding: 2px 0;
}

.header-line code {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.example-block pre {
    margin: 0;
    padding: 16px;
    overflow-x: auto;
    background: var(--bg-primary);
}

.example-block pre code {
    font-size: 0.8rem;
    line-height: 1.6;
    color: var(--text-primary);
    white-space: pre;
}

/* ---------- Copy Button ---------- */
.copy-btn {
    padding: 4px 10px;
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--text-secondary);
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all var(--transition);
    white-space: nowrap;
}

.copy-btn:hover {
    color: var(--text-primary);
    background: var(--bg-tertiary);
    border-color: var(--accent);
}

.copy-btn.copied {
    color: var(--status-success);
    border-color: var(--status-success);
}

/* ---------- Response Blocks ---------- */
.response-block {
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    margin-bottom: 12px;
    overflow: hidden;
}

.response-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    background: var(--bg-tertiary);
    border-bottom: 1px solid var(--border-color);
}

.response-description {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.response-body {
    position: relative;
    padding: 0;
}

.response-body .copy-btn {
    position: absolute;
    top: 8px;
    right: 8px;
    z-index: 2;
}

.response-body pre {
    margin: 0;
    padding: 16px;
    overflow-x: auto;
    background: var(--bg-primary);
}

.response-body pre code {
    font-size: 0.8rem;
    line-height: 1.6;
    color: var(--text-primary);
    white-space: pre;
}

/* ---------- Status Badges ---------- */
.status-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 3px 10px;
    font-size: 0.75rem;
    font-weight: 700;
    font-family: var(--font-mono);
    border-radius: var(--radius-sm);
    flex-shrink: 0;
}

.status-badge.status-success {
    color: var(--status-success);
    background: rgba(63, 185, 80, 0.12);
    border: 1px solid rgba(63, 185, 80, 0.3);
}

.status-badge.status-client-error {
    color: var(--status-client-error);
    background: rgba(248, 81, 73, 0.12);
    border: 1px solid rgba(248, 81, 73, 0.3);
}

.status-badge.status-server-error {
    color: var(--status-server-error);
    background: rgba(218, 54, 51, 0.12);
    border: 1px solid rgba(218, 54, 51, 0.3);
}

/* ---------- Responsive Design ---------- */
@media (max-width: 768px) {
    .sidebar-toggle {
        display: flex;
    }

    .docs-sidebar {
        transform: translateX(-100%);
        transition: transform 0.3s ease;
        width: 260px;
        box-shadow: none;
    }

    body.sidebar-open .docs-sidebar {
        transform: translateX(0);
        box-shadow: 4px 0 24px rgba(0, 0, 0, 0.4);
    }

    .docs-main {
        margin-left: 0;
        padding: 24px 16px;
    }

    .header-center {
        display: none;
    }

    .search-input {
        width: 160px;
    }

    .endpoint-header {
        flex-wrap: wrap;
    }

    .endpoint-path {
        width: 100%;
        margin-top: 8px;
    }

    .params-table {
        font-size: 0.8rem;
    }

    .params-table th,
    .params-table td {
        padding: 8px 10px;
    }
}

@media (max-width: 480px) {
    .header-title {
        font-size: 1rem;
    }

    .version-badge {
        display: none;
    }

    .search-input {
        width: 120px;
        padding: 6px 10px;
        font-size: 0.8rem;
    }

    .docs-main {
        padding: 16px 12px;
    }

    .endpoint-card {
        padding: 16px;
    }

    .category-title {
        font-size: 1.25rem;
    }
}

/* ---------- Overlay for mobile sidebar ---------- */
body.sidebar-open::before {
    content: '';
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 40;
}

/* ---------- Utility: Hidden during search ---------- */
.category-section.hidden,
.endpoint-card.hidden {
    display: none;
}

/* ---------- Scrollbar for main content ---------- */
.docs-main::-webkit-scrollbar {
    width: 8px;
}

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

.docs-main::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 4px;
}

/* ---------- Selection ---------- */
::selection {
    background: rgba(88, 101, 242, 0.3);
    color: var(--text-primary);
}

/* ---------- Focus visible for accessibility ---------- */
:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

/* ---------- About/Dashboard Section ---------- */
.about-section {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 28px;
    margin-bottom: 48px;
}

.about-content {
    padding-top: 8px;
}

.about-intro {
    color: var(--text-secondary);
    font-size: 0.95rem;
    line-height: 1.7;
    margin-bottom: 20px;
}

.about-intro strong {
    color: var(--text-primary);
}

.about-subtitle {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: 24px 0 8px 0;
    padding-top: 16px;
    border-top: 1px solid var(--border-color);
}

.about-content p {
    color: var(--text-secondary);
    font-size: 0.9rem;
    line-height: 1.7;
    margin-bottom: 12px;
}

.about-content code {
    color: var(--accent);
    background: rgba(88, 101, 242, 0.08);
    padding: 2px 6px;
    border-radius: 3px;
    font-size: 0.8rem;
}

.about-list {
    padding-left: 20px;
    margin: 10px 0 16px 0;
    list-style: disc;
}

.about-list li {
    color: var(--text-secondary);
    font-size: 0.85rem;
    line-height: 1.6;
    padding: 3px 0;
}

.about-note {
    font-size: 0.8rem !important;
    color: var(--text-muted) !important;
    margin-top: 16px;
    margin-bottom: 0 !important;
}

.about-note a,
.about-content a {
    color: var(--accent);
}

/* ---------- Try It Panel ---------- */
.try-it-section {
    margin-top: 20px;
    padding-top: 16px;
    border-top: 1px solid var(--border-color);
}

.try-it-panel {
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 16px;
}

.try-it-notice {
    background: rgba(63, 185, 80, 0.08);
    border: 1px solid rgba(63, 185, 80, 0.25);
    border-radius: var(--radius-sm);
    padding: 10px 14px;
    margin-bottom: 16px;
    font-size: 0.8rem;
    color: var(--text-secondary);
    line-height: 1.5;
}

.try-it-notice strong {
    color: var(--status-success);
}

.try-it-label {
    display: block;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 8px;
}

.try-it-headers,
.try-it-params,
.try-it-body {
    margin-bottom: 16px;
}

.try-it-field {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 8px;
}

.try-it-field-label {
    font-size: 0.8rem;
    font-family: var(--font-mono);
    color: var(--text-primary);
    min-width: 140px;
    flex-shrink: 0;
}

.try-it-input {
    flex: 1;
    padding: 8px 12px;
    font-size: 0.85rem;
    font-family: var(--font-mono);
    color: var(--text-primary);
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    outline: none;
    transition: border-color var(--transition);
}

.try-it-input:focus {
    border-color: var(--accent);
}

.try-it-input::placeholder {
    color: var(--text-muted);
}

.try-it-textarea {
    width: 100%;
    padding: 12px;
    font-size: 0.85rem;
    font-family: var(--font-mono);
    color: var(--text-primary);
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    outline: none;
    resize: vertical;
    min-height: 80px;
    transition: border-color var(--transition);
}

.try-it-textarea:focus {
    border-color: var(--accent);
}

.try-it-textarea::placeholder {
    color: var(--text-muted);
}

.try-it-actions {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
}

.try-it-send-btn {
    padding: 8px 20px;
    font-size: 0.85rem;
    font-weight: 600;
    color: #fff;
    background: var(--accent);
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: background var(--transition), opacity var(--transition);
}

.try-it-send-btn:hover {
    background: var(--accent-hover);
}

.try-it-send-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.try-it-status {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.try-it-response {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    overflow: hidden;
}

.try-it-response.hidden {
    display: none;
}

.try-it-response-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    background: var(--bg-tertiary);
    border-bottom: 1px solid var(--border-color);
}

.try-it-response-status {
    font-size: 0.8rem;
    font-weight: 700;
    font-family: var(--font-mono);
}

.try-it-response pre {
    margin: 0;
    padding: 16px;
    overflow-x: auto;
    max-height: 400px;
    overflow-y: auto;
}

.try-it-response pre code {
    font-size: 0.8rem;
    line-height: 1.6;
    color: var(--text-primary);
    white-space: pre;
}

@media (max-width: 768px) {
    .try-it-field {
        flex-direction: column;
        align-items: stretch;
        gap: 4px;
    }

    .try-it-field-label {
        min-width: unset;
    }
}
