/* ===== RESPONSE SCHEMA TREE VIEW ===== */

.response-schema-viewer-container {
    margin: 1.5rem 0;
}

/* Schema Section Styling */
.schema-section {
    margin-bottom: 2rem;
}

.schema-section:last-child {
    margin-bottom: 0;
}

.schema-section-title {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid var(--border-color, #e2e8f0);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--text-primary, #0f172a);
}

.schema-tree-viewer-container {
    margin-top: 0.5rem;
}

/* View Toggle */
.response-schema-view-toggle {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
    padding-bottom: 0.75rem;
    border-bottom: 2px solid var(--border-color, #e2e8f0);
}

.response-schema-view-btn {
    padding: 0.5rem 1rem;
    background: var(--bg-secondary, #f8fafc);
    border: 1px solid var(--border-color, #e2e8f0);
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-secondary, #475569);
    transition: all 0.2s ease;
    font-family: inherit;
}

.response-schema-view-btn:hover {
    background: var(--bg-tertiary, #f1f5f9);
    border-color: var(--accent-primary, #3b82f6);
    color: var(--text-primary, #0f172a);
}

.response-schema-view-btn.active {
    background: var(--accent-primary, #3b82f6);
    border-color: var(--accent-primary, #3b82f6);
    color: white;
    font-weight: 600;
}

.response-schema-view-btn:focus-visible {
    outline: 2px solid var(--accent-primary, #3b82f6);
    outline-offset: 2px;
}

/* Tree View Container */
.response-schema-tree-view {
    background: var(--bg-primary, #ffffff);
    border: 1px solid var(--border-color, #e2e8f0);
    border-radius: 8px;
    padding: 0.75rem;
    max-height: 600px;
    overflow-y: auto;
    overflow-x: hidden;
}

.schema-tree-wrapper {
    width: 100%;
}

/* Progressive background darkness for nested levels based on depth ratio */
.schema-tree-node-nested {
    border-radius: 4px;
    padding: 0.125rem 0.25rem;
    margin: 0.1875rem 0;
    transition: background-color 0.2s ease;
}

/* Light mode: progressive darkening based on calculated RGB values */
.schema-tree-node-nested[data-darkness-ratio] {
    background: var(--depth-bg-light, #f8fafc);
}

/* Dark mode: progressive darkening based on calculated RGB values */
[data-md-color-scheme="slate"] .schema-tree-node-nested[data-darkness-ratio] {
    background: var(--depth-bg-dark, #1e293b);
}

.schema-tree-toolbar {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--border-color, #e2e8f0);
}

.schema-tree-toolbar-btn {
    padding: 0.375rem 0.75rem;
    background: var(--bg-secondary, #f8fafc);
    border: 1px solid var(--border-color, #e2e8f0);
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.8125rem;
    color: var(--text-secondary, #475569);
    transition: all 0.2s ease;
    font-family: inherit;
}

.schema-tree-toolbar-btn:hover {
    background: var(--bg-tertiary, #f1f5f9);
    border-color: var(--accent-primary, #3b82f6);
    color: var(--accent-primary, #3b82f6);
}

.schema-tree-toolbar-btn:focus-visible {
    outline: 2px solid var(--accent-primary, #3b82f6);
    outline-offset: 2px;
}

.schema-tree-container {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Helvetica', 'Arial', sans-serif;
    font-size: 0.875rem;
    line-height: 1.5;
}

.schema-tree-node {
    margin: 0.125rem 0;
}

.schema-tree-node-content {
    display: flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.25rem 0;
    min-height: 1.75rem;
    flex-wrap: nowrap;
}

.schema-tree-spacer {
    flex-shrink: 0;
    min-width: 0;
}

.schema-tree-toggle {
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 0.125rem;
    width: 18px;
    height: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    color: var(--text-secondary, #64748b);
    transition: color 0.15s ease;
    border-radius: 3px;
}

.schema-tree-toggle:hover {
    color: var(--accent-primary, #3b82f6);
    background: var(--bg-tertiary, #f1f5f9);
}

.schema-tree-toggle:focus-visible {
    outline: 2px solid var(--accent-primary, #3b82f6);
    outline-offset: 1px;
    border-radius: 3px;
}

.schema-tree-toggle-icon {
    font-size: 0.6875rem;
    transition: transform 0.2s ease;
    user-select: none;
    line-height: 1;
}

.schema-tree-toggle-icon.expanded {
    transform: rotate(90deg);
}

.schema-tree-toggle-spacer {
    width: 18px;
    flex-shrink: 0;
}

.schema-tree-field-name {
    font-weight: 500;
    color: var(--text-primary, #0f172a);
    font-family: inherit;
    white-space: nowrap;
    cursor: help;
    position: relative;
}

.schema-tree-array-indicator {
    font-weight: 400;
    color: var(--text-secondary, #64748b);
    font-family: inherit;
    white-space: nowrap;
    cursor: help;
    position: relative;
    font-style: italic;
    font-size: 0.8125rem;
}

.schema-tree-field-with-tooltip {
    position: relative;
}

.schema-tree-field-with-tooltip:hover::after {
    content: attr(title);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    margin-bottom: 0.5rem;
    padding: 0.625rem 0.875rem;
    background: var(--bg-primary, #1e293b);
    color: var(--text-primary, #ffffff);
    font-size: 0.8125rem;
    font-weight: 400;
    line-height: 1.5;
    white-space: normal;
    max-width: 320px;
    min-width: 180px;
    border-radius: 6px;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    z-index: 1000;
    pointer-events: none;
    word-wrap: break-word;
    text-align: left;
    animation: tooltipFadeIn 0.15s ease-out;
}

.schema-tree-field-with-tooltip:hover::before {
    content: '';
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    margin-bottom: 0.125rem;
    border: 6px solid transparent;
    border-top-color: var(--bg-primary, #1e293b);
    z-index: 1001;
    pointer-events: none;
    animation: tooltipFadeIn 0.15s ease-out;
}

@keyframes tooltipFadeIn {
    from {
        opacity: 0;
        transform: translateX(-50%) translateY(4px);
    }
    to {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
}

.schema-tree-type-badge {
    padding: 0.1875rem 0.5rem;
    background: var(--bg-secondary, #f8fafc);
    border: 1px solid var(--border-color, #e2e8f0);
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--accent-secondary, #1d4ed8);
    font-family: 'Monaco', 'Menlo', 'SF Mono', monospace;
    white-space: nowrap;
    flex-shrink: 0;
}

.schema-tree-type-badge[data-type="string"] {
    color: #059669;
}

.schema-tree-type-badge[data-type="integer"],
.schema-tree-type-badge[data-type="number"] {
    color: #dc2626;
}

.schema-tree-type-badge[data-type="boolean"] {
    color: #7c3aed;
}

.schema-tree-type-badge[data-type="array"] {
    color: #ea580c;
}

.schema-tree-type-badge[data-type="object"] {
    color: #0284c7;
}

.schema-tree-type-ref {
    color: #7c3aed;
    font-style: italic;
}

.schema-tree-badge-required {
    padding: 0.125rem 0.375rem;
    background: #fee2e2;
    color: #991b1b;
    border-radius: 3px;
    font-size: 0.6875rem;
    font-weight: 600;
    text-transform: uppercase;
    white-space: nowrap;
    flex-shrink: 0;
}

.schema-tree-badge-optional {
    padding: 0.125rem 0.375rem;
    background: #e0e7ff;
    color: #3730a3;
    border-radius: 3px;
    font-size: 0.6875rem;
    font-weight: 600;
    text-transform: uppercase;
    white-space: nowrap;
    flex-shrink: 0;
}

.schema-tree-badge-readonly {
    padding: 0.125rem 0.375rem;
    background: #f3f4f6;
    color: #4b5563;
    border-radius: 3px;
    font-size: 0.6875rem;
    font-weight: 500;
    font-family: 'Monaco', 'Menlo', 'SF Mono', monospace;
    white-space: nowrap;
    flex-shrink: 0;
}

/* Description is now shown only in tooltip, not inline */
.schema-tree-description {
    display: none;
}

.schema-tree-validation {
    margin-left: auto;
    padding: 0.1875rem 0.5rem;
    background: var(--bg-secondary, #f8fafc);
    border-left: 2px solid var(--accent-primary, #3b82f6);
    border-radius: 3px;
    font-size: 0.6875rem;
    flex-shrink: 0;
    max-width: 300px;
}

.schema-tree-validation-text {
    color: var(--text-secondary, #64748b);
    font-family: 'Monaco', 'Menlo', 'SF Mono', monospace;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.schema-tree-children {
    margin-left: 16px;
    border-left: 1px solid var(--border-color, #e2e8f0);
    padding-left: 0.5rem;
    margin-top: 0.125rem;
    margin-bottom: 0.125rem;
}

/* Reduce indentation for deeply nested items */
.schema-tree-node[data-depth="0"] .schema-tree-spacer {
    width: 0;
}

.schema-tree-node[data-depth="1"] .schema-tree-spacer {
    width: 16px;
}

.schema-tree-node[data-depth="2"] .schema-tree-spacer {
    width: 32px;
}

.schema-tree-node[data-depth="3"] .schema-tree-spacer {
    width: 48px;
}

.schema-tree-node[data-depth="4"] .schema-tree-spacer {
    width: 64px;
}

.schema-tree-node[data-depth="5"] .schema-tree-spacer {
    width: 80px;
}

/* For very deep nesting, use a more compact approach */
.schema-tree-node[data-depth="6"] .schema-tree-spacer,
.schema-tree-node[data-depth="7"] .schema-tree-spacer,
.schema-tree-node[data-depth="8"] .schema-tree-spacer {
    width: 96px;
}

.schema-tree-empty,
.schema-view-empty {
    padding: 2rem;
    text-align: center;
    color: var(--text-secondary, #475569);
    font-style: italic;
    background: var(--bg-secondary, #f8fafc);
    border: 1px dashed var(--border-color, #e2e8f0);
    border-radius: 6px;
}

/* Table View Container */
.response-schema-table-view {
    background: var(--bg-primary, #ffffff);
}

.response-schema-row-nested {
    background: var(--bg-secondary, #f8fafc);
}

.response-schema-row-nested td:first-child {
    padding-left: 1.5rem;
}

/* Dark Mode Support */
[data-md-color-scheme="slate"] .response-schema-view-toggle {
    border-bottom-color: var(--md-default-fg-color--lightest, #404040);
}

[data-md-color-scheme="slate"] .response-schema-view-btn {
    background: var(--md-code-bg-color, #1a1a1a);
    border-color: var(--md-default-fg-color--lightest, #404040);
    color: var(--md-default-fg-color--light, #cccccc);
}

[data-md-color-scheme="slate"] .response-schema-view-btn:hover {
    background: var(--md-default-bg-color, #2d2d2d);
    border-color: var(--md-primary-fg-color, #60a5fa);
    color: var(--md-default-fg-color, #ffffff);
}

[data-md-color-scheme="slate"] .response-schema-view-btn.active {
    background: var(--md-primary-fg-color, #60a5fa);
    border-color: var(--md-primary-fg-color, #60a5fa);
    color: white;
}

[data-md-color-scheme="slate"] .response-schema-tree-view {
    background: var(--md-code-bg-color, #1a1a1a);
    border-color: var(--md-default-fg-color--lightest, #404040);
}

[data-md-color-scheme="slate"] .schema-tree-toolbar {
    border-bottom-color: var(--md-default-fg-color--lightest, #404040);
}

[data-md-color-scheme="slate"] .schema-tree-toolbar-btn {
    background: var(--md-default-bg-color, #2d2d2d);
    border-color: var(--md-default-fg-color--lightest, #404040);
    color: var(--md-default-fg-color--light, #cccccc);
}

[data-md-color-scheme="slate"] .schema-tree-toolbar-btn:hover {
    background: var(--md-code-bg-color, #1a1a1a);
    border-color: var(--md-primary-fg-color, #60a5fa);
    color: var(--md-primary-fg-color, #60a5fa);
}

[data-md-color-scheme="slate"] .schema-tree-toggle {
    color: var(--md-default-fg-color--light, #cccccc);
}

[data-md-color-scheme="slate"] .schema-tree-toggle:hover {
    color: var(--md-primary-fg-color, #60a5fa);
}

[data-md-color-scheme="slate"] .schema-tree-field-name {
    color: var(--md-default-fg-color, #ffffff);
}

[data-md-color-scheme="slate"] .schema-tree-array-indicator {
    color: var(--md-default-fg-color--light, #cccccc);
}

[data-md-color-scheme="slate"] .schema-tree-field-with-tooltip:hover::after {
    background: var(--md-code-bg-color, #1a1a1a);
    color: var(--md-default-fg-color, #ffffff);
    border: 1px solid var(--md-default-fg-color--lightest, #404040);
}

[data-md-color-scheme="slate"] .schema-tree-field-with-tooltip:hover::before {
    border-top-color: var(--md-code-bg-color, #1a1a1a);
}

/* Responsive: Adjust tooltip on smaller screens */
@media (max-width: 768px) {
    .schema-tree-field-with-tooltip:hover::after {
        max-width: 250px;
        min-width: 150px;
        font-size: 0.75rem;
        padding: 0.5rem 0.625rem;
    }
}

[data-md-color-scheme="slate"] .schema-tree-type-badge {
    background: var(--md-default-bg-color, #2d2d2d);
    border-color: var(--md-default-fg-color--lightest, #404040);
    color: var(--md-primary-fg-color, #60a5fa);
}

[data-md-color-scheme="slate"] .schema-tree-description {
    color: var(--md-default-fg-color--light, #cccccc);
}

[data-md-color-scheme="slate"] .schema-tree-validation {
    background: var(--md-default-bg-color, #2d2d2d);
    border-left-color: var(--md-primary-fg-color, #60a5fa);
}

[data-md-color-scheme="slate"] .schema-tree-validation-text {
    color: var(--md-default-fg-color--light, #cccccc);
}

[data-md-color-scheme="slate"] .schema-tree-children {
    border-left-color: var(--md-default-fg-color--lightest, #404040);
}

[data-md-color-scheme="slate"] .schema-tree-empty,
[data-md-color-scheme="slate"] .schema-view-empty {
    background: var(--md-code-bg-color, #1a1a1a);
    border-color: var(--md-default-fg-color--lightest, #404040);
    color: var(--md-default-fg-color--light, #cccccc);
}

[data-md-color-scheme="slate"] .response-schema-row-nested {
    background: var(--md-code-bg-color, #1a1a1a);
}

/* Responsive Design */
@media (max-width: 768px) {
    .response-schema-view-toggle {
        flex-wrap: wrap;
    }
    
    .schema-tree-node-content {
        flex-wrap: wrap;
        gap: 0.25rem;
    }
    
    .schema-tree-validation {
        margin-left: 0;
        margin-top: 0.25rem;
        max-width: 100%;
    }
    
    .schema-tree-description {
        margin-left: 0;
        margin-top: 0.25rem;
        width: 100%;
    }
    
    .schema-tree-children {
        margin-left: 12px;
        padding-left: 0.375rem;
    }
    
    .response-schema-tree-view {
        padding: 0.5rem;
    }
}

/* Accessibility */
@media (prefers-reduced-motion: reduce) {
    .schema-tree-toggle-icon,
    .response-schema-view-btn,
    .schema-tree-toolbar-btn {
        transition: none;
    }
}

