﻿/* =============== data-api.css =============== */

:root {
    --api-get-bg: #e7f0f7;
    --api-get-border: #0969da;
    --api-get-text: #0557b4;
    --api-post-bg: #e8f3e8;
    --api-post-border: #238636;
    --api-post-text: #1a6c2e;
    --api-param-bg: #f6f8fa;
    --api-code-bg: var(--code-bg); /* Reuse from refwire.css */
    --api-response-bg: #f6f8fa;
}

[data-theme="dark"] {
    --api-get-bg: #1c283c;
    --api-get-border: #58a6ff;
    --api-get-text: #79b8ff;
    --api-post-bg: #1a2f23;
    --api-post-border: #3fb950;
    --api-post-text: #56d364;
    --api-param-bg: #161b22;
    --api-code-bg: var(--code-bg);
    --api-response-bg: #0d1117;
}


.api-explorer-page {
    padding: 2rem 0 4rem;
}

/* --- Configuration Section --- */
.api-config-section {
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-lg);
    padding: 1.5rem;
    margin-bottom: 2.5rem;
    display: flex;
    flex-wrap: wrap;
    gap: 1.5rem;
    align-items: flex-end;
}

.api-config-group {
    display: flex;
    flex-direction: column;
    flex-grow: 1;
    min-width: 250px;
}

    .api-config-group label {
        font-size: 0.8rem;
        font-weight: 600;
        color: var(--text-secondary);
        margin-bottom: 0.5rem;
        text-transform: uppercase;
    }

    .api-config-group input[type="text"],
    .api-config-group input[type="url"] {
        padding: 0.6rem 0.8rem;
        border-radius: var(--border-radius);
        border: 1px solid var(--border-color);
        background-color: var(--bg-primary);
        color: var(--text-primary);
        font-size: 0.9rem;
        transition: var(--transition);
    }

    .api-config-group input:focus {
        outline: none;
        border-color: var(--accent-color);
        box-shadow: 0 0 0 3px rgba(9, 105, 218, 0.3);
    }

/* --- Operation Block --- */
.api-operation {
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    margin-bottom: 1.5rem;
    background-color: var(--bg-primary);
    overflow: hidden; /* Contain children */
}

.api-operation-summary {
    padding: 0.8rem 1.2rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 1rem;
    transition: background-color 0.2s ease;
}

.api-operation details[open] .api-operation-summary {
    /* Optional: slightly different background when open */
    background-color: var(--bg-secondary);
}


.api-method {
    font-family: monospace;
    font-weight: 700;
    font-size: 0.85rem;
    padding: 0.3rem 0.7rem;
    border-radius: var(--border-radius);
    text-transform: uppercase;
    flex-shrink: 0;
}

.api-method-get {
    background-color: var(--api-get-bg);
    border: 1px solid var(--api-get-border);
    color: var(--api-get-text);
}

.api-method-post {
    background-color: var(--api-post-bg);
    border: 1px solid var(--api-post-border);
    color: var(--api-post-text);
}

.api-path {
    font-family: monospace;
    font-weight: 600;
    color: var(--text-primary);
    word-break: break-all; /* Prevent long paths overflowing */
    flex-grow: 1;
}

.api-description {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-left: auto; /* Push description to the right */
    flex-shrink: 0;
    padding-left: 1rem;
}

.api-operation-content {
    padding: 1.5rem;
    border-top: 1px solid var(--border-color);
    background-color: var(--bg-secondary); /* Different background for content */
}

/* --- Parameters --- */
.api-parameters h4,
.api-results h4 {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border-color);
}

.api-param {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    align-items: center;
    margin-bottom: 1rem;
    padding: 0.8rem;
    background-color: var(--api-param-bg);
    border-radius: var(--border-radius);
    border: 1px solid var(--border-color);
}

    .api-param label {
        font-weight: 600;
        font-size: 0.85rem;
        min-width: 100px;
        text-align: right;
        color: var(--text-primary);
    }

        .api-param label .required {
            color: var(--danger-color);
            font-weight: bold;
            margin-left: 2px;
        }

        .api-param label .param-type {
            display: block;
            font-weight: normal;
            font-size: 0.75rem;
            color: var(--text-muted);
        }


    .api-param input[type="text"],
    .api-param input[type="number"],
    .api-param textarea {
        flex-grow: 1;
        padding: 0.5rem 0.7rem;
        border-radius: var(--border-radius);
        border: 1px solid var(--border-color);
        background-color: var(--bg-primary);
        color: var(--text-primary);
        font-size: 0.875rem;
        min-width: 200px; /* Ensure decent width */
    }

    .api-param textarea {
        font-family: monospace;
        min-height: 80px;
        resize: vertical;
    }

        .api-param input:focus,
        .api-param textarea:focus {
            outline: none;
            border-color: var(--accent-color);
            box-shadow: 0 0 0 3px rgba(9, 105, 218, 0.3);
        }

.api-param-description {
    flex-basis: 100%; /* Take full width on new line */
    font-size: 0.8rem;
    color: var(--text-secondary);
    padding-left: calc(100px + 1rem); /* Align with input field */
}

.api-execute-button {
    margin-top: 1rem;
    margin-bottom: 1.5rem;
}

    .api-execute-button .btn {
        min-width: 120px; /* Give button some width */
    }

/* --- Results --- */
.api-results {
    margin-top: 2rem;
    border-top: 1px dashed var(--border-color);
    padding-top: 1.5rem;
}

.api-result-section {
    margin-bottom: 1.5rem;
}

    .api-result-section h5 {
        font-size: 0.9rem;
        font-weight: 600;
        margin-bottom: 0.5rem;
        color: var(--text-secondary);
    }

.api-request-url,
.api-response-code,
.api-response-headers pre,
.api-response-body pre {
    background-color: var(--api-code-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    padding: 0.8rem 1rem;
    font-family: monospace;
    font-size: 0.85rem;
    color: var(--text-primary);
    word-wrap: break-word;
    white-space: pre-wrap; /* Allow wrapping */
    overflow-x: auto; /* Add scrollbar if needed */
}

.api-response-code {
    display: inline-block; /* Fit content */
    font-weight: bold;
    min-width: 50px;
    text-align: center;
}

    .api-response-code.status-2xx {
        background-color: var(--api-post-bg);
        border-color: var(--api-post-border);
        color: var(--api-post-text);
    }

    .api-response-code.status-4xx,
    .api-response-code.status-5xx {
        background-color: var(--danger-bg, #fdf1f2); /* Add danger-bg or default */
        border-color: var(--danger-color);
        color: var(--danger-color);
    }

[data-theme="dark"] .api-response-code.status-4xx,
[data-theme="dark"] .api-response-code.status-5xx {
    background-color: var(--danger-dark-bg, #351a1f); /* Add danger-dark-bg or default */
}

.api-response-body pre.error {
    color: var(--danger-color);
}

/* Loading indicator */
.api-loading {
    display: none; /* Hidden by default */
    margin-left: 1rem;
    color: var(--text-secondary);
}

    .api-loading i {
        animation: fa-spin 1.5s linear infinite;
    }


/* Responsive */
@media (max-width: 768px) {
    .api-param label {
        min-width: 80px;
        text-align: left;
        flex-basis: 100%; /* Stack label above input */
        margin-bottom: 0.25rem;
    }

    .api-param-description {
        padding-left: 0; /* Reset padding */
    }

    .api-operation-summary {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }

    .api-description {
        margin-left: 0;
        padding-left: 0;
    }
}


/* --- Additions to data-api.css --- */

/* --- Dataset Schema Section --- */
.dataset-schema-section {
    margin-bottom: 2.5rem;
    padding: 1.5rem;
    background-color: var(--bg-secondary); /* Match config section background */
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-lg);
}

    .dataset-schema-section h3 {
        font-size: 1.2rem;
        font-weight: 600;
        margin-top: 0;
        margin-bottom: 1.5rem;
        padding-bottom: 0.75rem;
        border-bottom: 1px solid var(--border-color);
    }

/* Container for responsive table */
.schema-table-container {
    overflow-x: auto; /* Enable horizontal scrolling on small screens */
}

.schema-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
    white-space: nowrap; /* Prevent wrapping initially, allow scroll */
}

    .schema-table th,
    .schema-table td {
        padding: 0.8rem 1rem;
        text-align: left;
        border-bottom: 1px solid var(--border-color);
        vertical-align: top; /* Align content to top */
    }

    .schema-table thead th {
        background-color: var(--bg-tertiary); /* Slightly different header bg */
        font-weight: 600;
        white-space: nowrap;
        position: sticky; /* Optional: Sticky header when scrolling vertically */
        top: 0; /* Required for sticky */
        z-index: 1; /* Keep header above scrolling content */
    }

    .schema-table tbody tr:last-child td {
        border-bottom: none;
    }

    .schema-table tbody tr:hover {
        background-color: var(--bg-tertiary); /* Hover effect */
    }

    /* Styling for specific columns */
    .schema-table td:nth-child(1) { /* Field Name */
        font-weight: 500;
    }

    .schema-table td code {
        background-color: var(--api-code-bg); /* Use consistent code background */
        padding: 0.2em 0.4em;
        border-radius: var(--border-radius);
        font-size: 90%; /* Slightly smaller code font */
    }

    .schema-table td:nth-child(3), /* Description */
    .schema-table td:nth-child(4) { /* Sample Values */
        white-space: normal; /* Allow description and samples to wrap */
        min-width: 200px; /* Give these columns some minimum space */
    }

/* --- Adjustments for Responsiveness --- */
@media (max-width: 768px) {
    .schema-table th,
    .schema-table td {
        padding: 0.6rem 0.8rem; /* Slightly reduce padding */
    }

    .dataset-schema-section {
        padding: 1rem;
    }
}



/* Table Styling */
.schema-table-container {
    overflow-x: auto; /* Enable horizontal scrolling on small screens */
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
    white-space: nowrap; /* Prevent wrapping initially, allow scroll */
}

    table th,
    table td {
        padding: 0.8rem 1rem;
        text-align: left;
        border-bottom: 1px solid var(--border-color);
        vertical-align: top; /* Align content to top */
    }

    table thead th {
        background-color: var(--bg-tertiary); /* Slightly different header bg */
        font-weight: 600;
        white-space: nowrap;
        position: sticky; /* Optional: Sticky header when scrolling vertically */
        top: 0; /* Required for sticky */
        z-index: 1; /* Keep header above scrolling content */
    }

    table tbody tr:last-child td {
        border-bottom: none;
    }

    table tbody tr:hover {
        background-color: var(--bg-tertiary); /* Hover effect */
    }

    /* Styling for specific columns */
    table td:nth-child(1) { /* Field Name */
        font-weight: 500;
    }

    table td code {
        background-color: var(--api-code-bg); /* Use consistent code background */
        padding: 0.2em 0.4em;
        border-radius: var(--border-radius);
        font-size: 90%; /* Slightly smaller code font */
    }

    table td:nth-child(3), /* Description */
    table td:nth-child(4) { /* Sample Values */
        white-space: normal; /* Allow description and samples to wrap */
        min-width: 200px; /* Give these columns some minimum space */
    }

/* --- Adjustments for Responsiveness --- */
@media (max-width: 768px) {
    table th,
    table td {
        padding: 0.6rem 0.8rem; /* Slightly reduce padding */
    }

    .dataset-schema-section {
        padding: 1rem;
    }
}


