html {
    font-size: 80%;
}

@media (prefers-color-scheme: dark) {
    body {
        background: #1e1e1e;
    }

    #browser {
        background: #1e1e1e;
        color: #e0e0e0;
    }

    .widgetChild {
        background: #2d2d2d;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
    }

    #tree * {
        background-color: #2d2d2d;
        color: #e0e0e0;
    }

    #typeSelector, #entryPoint, #dtIdText, .settingsEntry input[type="text"] {
        background: #3c3c3c;
        color: #e0e0e0;
        border-color: #555;
    }

    .scrollable {
        background-color: #3c3c3c;
        border-color: #555;
    }

    #treeContext {
        background-color: #2d2d2d;
        border-color: #555;
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.6);
    }

    #treeContext a:hover {
        background: #3c3c3c;
    }

    .device:hover {
        background: #3c3c3c;
    }

    .device:active {
        background: #4a4a4a;
    }

    h4 {
        color: #e0e0e0;
        border-bottom-color: #0078d4;
    }

    #instance {
        color: #e0e0e0;
    }
}

body {
    overflow-y: auto;
    overflow-x: hidden;
    margin: 0;
    background: #f5f5f5;
}

#browser {
    display: flex;
    height: calc(100vh - 45px);
    width: 100%;
    gap: 15px;
    padding: 5px 15px 15px 15px;
    box-sizing: border-box;
    font-size: 90%; /* Smaller fonts for browser page */
}

#browser * {
    font-family: Arial, Helvetica, Verdana, Tahoma, sans-serif;
}

.widgetChild {
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    padding: 20px;
    overflow-y: auto;
}

.graphiql-logo-link {
    visibility: hidden;
    position: absolute;
}

#selectMenu {
    width: 320px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    font-size: 90%;
}

.scrollable {
    overflow-y: auto;
    max-height: 300px;
    background-color: #fafafa;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    margin-top: 8px;
    margin-bottom: 12px;
}

#typeSelector {
    width: 100%;
    padding: 6px 8px;
    border: 1px solid #d0d0d0;
    border-radius: 4px;
    font-size: 12px;
    background: white;
}

#entryPoint {
    width: 100%;
    padding: 6px 8px;
    border: 1px solid #d0d0d0;
    border-radius: 4px;
    font-size: 12px;
    background: white;
    margin-top: 6px;
}

#tree.widgetChild {
    flex: 1;
    min-width: 0;
    font-size: 90%;
}

#settings {
    font-size: 12px;
    margin-top: 8px;
}

.settingsEntry {
    margin: 4px 0;
    display: flex;
    align-items: center;
    gap: 8px;
}

.settingsEntry input[type="text"] {
    flex: 1;
    padding: 4px 8px;
    border: 1px solid #d0d0d0;
    border-radius: 4px;
    font-size: 11px;
}

.settingsEntry button {
    padding: 4px 12px;
    background: #0078d4;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 11px;
    transition: background 0.2s;
}

.settingsEntry button:hover {
    background: #106ebe;
}

#instance {
    margin-top: 8px;
    margin-bottom: 4px;
    font-size: 11px;
    font-weight: 600;
    color: #333;
}

#adminPanel {
    margin-top: 16px;
    padding-top: 16px;
    border-top: 2px solid #e0e0e0;
}

#adminPanel h4 {
    margin: 0 0 12px 0;
    color: #d32f2f;
    font-size: 12px;
}

#adminSection input[type="text"] {
    flex: 1;
    padding: 8px;
    border: 1px solid #d0d0d0;
    border-radius: 4px;
    font-size: 11px;
    background: white;
}

#adminResult {
    font-family: Arial, Helvetica, Verdana, Tahoma, sans-serif;
}

#adminResult code {
    background: #e0e0e0;
    padding: 2px 4px;
    border-radius: 2px;
    font-family: 'Courier New', monospace;
}

#dtIdText {
    flex: 1;
    padding: 6px 8px;
    border: 1px solid #d0d0d0;
    border-radius: 4px;
    font-size: 12px;
}

#treeContext {
    visibility: hidden;
    position: absolute;
    padding: 2px 0;
    background-color: white;
    border: 1px solid #d0d0d0;
    border-radius: 4px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    font-size: 10px;
    min-width: 180px;
    z-index: 1000;
}

#treeContext a {
    display: block;
    padding: 4px 12px;
    text-decoration: none;
    transition: background 0.15s;
}

#treeContext a:hover {
    background: #f5f5f5;
}

#treeContext .highlight {
    font-weight: 600;
    color: #0078d4;
}

.graphiql-container div .query-editor {
    min-height: 400px;
}

#startpoint {
    margin-top: 8px;
}

h4 {
    margin: 0 0 8px 0;
    font-size: 13px;
    font-weight: 600;
    color: #333;
    border-bottom: 2px solid #0078d4;
    padding-bottom: 4px;
}

.device {
    display: flex;
    font-size: 11px;
    flex-direction: column;
    align-items: flex-start;
    justify-content: left;
    padding: 10px 12px;
    margin: 2px 0;
    white-space: nowrap;
    text-overflow: ellipsis;
    overflow: hidden;
    cursor: pointer;
    border-radius: 4px;
    transition: background 0.15s;
}

.device:hover {
    background: #e8f4ff;
}

.device:active {
    background: #d0e8ff;
}

.hide {
    display: none !important;
}

.switch {
    position: relative;
    display: inline-block;
    width: 24px;
    height: 16px;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: darkgray;
    -webkit-transition: 0.4s;
    transition: 0.4s;
}

.slider:before {
    position: absolute;
    content: '';
    height: 14px;
    width: 10px;
    left: 0px;
    bottom: 1px;
    background-color: white;
    -webkit-transition: 0.4s;
    transition: 0.4s;
}

input:checked + .slider {
    background-color: #2196f3;
}

input:focus + .slider {
    box-shadow: 0 0 1px #2196f3;
}

input:checked + .slider:before {
    -webkit-transform: translateX(14px);
    -ms-transform: translateX(14px);
    transform: translateX(14px);
}

.slider.round {
    border-radius: 16px;
}

.slider.round:before {
    border-radius: 50%;
}

#UserInputForm {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    justify-content: flex-start;
    width: 100%;
    padding: 20px;
    box-sizing: border-box;
}

#UserInputForm input[type="text"],
#UserInputForm input[type="number"] {
    margin: 0;
    padding: 10px 12px;
    width: 100%;
    border: 1px solid #d0d0d0;
    border-radius: 4px;
    font-size: 14px;
    box-sizing: border-box;
    background: white;
}

#UserInputForm input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
}

#UserInputForm input[type="submit"] {
    margin-top: 20px;
    padding: 10px 20px;
    background: #0078d4;
    color: white;
    border: none;
    border-radius: 4px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
    width: 100%;
}

#UserInputForm input[type="submit"]:hover {
    background: #106ebe;
}

#UserInputForm label {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    margin-bottom: 4px;
    font-size: 13px;
    color: #333;
    font-weight: 500;
}

#UserInputForm label input[type="checkbox"] {
    margin-left: 0;
    margin-right: 8px;
}

#UserInputForm label:has(input[type="checkbox"]) {
    flex-direction: row;
    align-items: center;
}

#UserInputOverlay {
    display: block;
    position: fixed;
    width: auto;
    min-width: 400px;
    max-width: 600px;
    height: auto;
    max-height: 80vh;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 1000;
    border: none;
    border-radius: 8px;
    background-color: white;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    overflow: hidden;
    font-family: Arial, Helvetica, Verdana, Tahoma, sans-serif;
}

#UserInputTitle {
    margin: 0;
    padding: 20px 60px 16px 20px;
    font-size: 18px;
    font-weight: 600;
    color: #333;
    border-bottom: 1px solid #e0e0e0;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

#UserInputArgsHeader {
    font-size: 14px;
    font-weight: 600;
    color: #555;
    margin-bottom: 16px;
    padding-bottom: 8px;
    border-bottom: 1px solid #e8e8e8;
}

#UserInputOverlay button {
    position: absolute;
    top: 16px;
    right: 16px;
    width: 32px;
    height: 32px;
    margin: 0;
    padding: 0;
    border: none;
    border-radius: 4px;
    background-color: transparent;
    color: #666;
    font-size: 20px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

#UserInputOverlay button:hover {
    background-color: #f0f0f0;
    color: #333;
}

#UserInputForm label.optional {
    color: #888;
}

#UserInputForm label.optional input {
    opacity: 0.8;
}

#UserInputText {
    width: 100%;
    padding: 20px;
    max-height: 65vh;
    overflow-y: auto;
    overflow-x: hidden;
    box-sizing: border-box;
}

#UserInputResult {
    width: 100%;
    padding: 20px;
    max-height: 65vh;
    overflow-y: auto;
    box-sizing: border-box;
}

.result-success {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px;
    background: #d4edda;
    border: 1px solid #c3e6cb;
    border-radius: 6px;
    margin-bottom: 16px;
}

.result-error {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px;
    background: #f8d7da;
    border: 1px solid #f5c6cb;
    border-radius: 6px;
    margin-bottom: 16px;
}

.result-icon {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    font-weight: bold;
    flex-shrink: 0;
}

.result-success .result-icon {
    background: #28a745;
    color: white;
}

.result-error .result-icon {
    background: #dc3545;
    color: white;
}

.result-status {
    font-size: 16px;
    font-weight: 600;
    flex: 1;
}

.result-success .result-status {
    color: #155724;
}

.result-error .result-status {
    color: #721c24;
}

.result-code {
    font-size: 14px;
    font-weight: 500;
    color: #666;
}

.result-section {
    margin-bottom: 16px;
}

.result-label {
    font-size: 13px;
    font-weight: 600;
    color: #555;
    margin-bottom: 6px;
}

.result-content {
    padding: 12px;
    background: #f8f9fa;
    border: 1px solid #e0e0e0;
    border-radius: 4px;
    font-family: 'Courier New', monospace;
    font-size: 13px;
    white-space: pre-wrap;
    word-break: break-word;
    color: #333;
}

.error-separator {
    margin: 20px 0;
    border: none;
    border-top: 1px solid #ddd;
}

@media (prefers-color-scheme: dark) {
    #UserInputOverlay {
        background-color: #2d2d2d;
        box-shadow: 0 8px 32px rgba(0, 0, 0, 0.6);
    }
    
    #UserInputTitle {
        color: #e0e0e0;
        border-bottom-color: #444;
    }
    
    #UserInputArgsHeader {
        color: #b0b0b0;
        border-bottom-color: #444;
    }
    
    #UserInputOverlay button {
        color: #e0e0e0;
    }
    
    #UserInputOverlay button:hover {
        background-color: #3c3c3c;
        color: #fff;
    }
    
    #UserInputForm label {
        color: #e0e0e0;
    }
    
    #UserInputForm label.optional {
        color: #888;
    }
    
    #UserInputForm input[type="text"],
    #UserInputForm input[type="number"] {
        background: #3c3c3c;
        color: #e0e0e0;
        border-color: #555;
    }
    
    .result-success {
        background: #1e4620;
        border-color: #2d6930;
    }
    
    .result-error {
        background: #4a1c1c;
        border-color: #6b2525;
    }
    
    .result-success .result-status {
        color: #a8d5a8;
    }
    
    .result-error .result-status {
        color: #f5a5a5;
    }
    
    .result-code {
        color: #aaa;
    }
    
    .result-label {
        color: #b0b0b0;
    }
    
    .result-content {
        background: #3c3c3c;
        border-color: #555;
        color: #e0e0e0;
    }
    
    .error-separator {
        border-top-color: #555;
    }
    
    #adminPanel {
        border-top-color: #444;
    }
    
    #adminPanel h4 {
        color: #ff5252;
    }
    
    #adminSection input[type="text"] {
        background: #3c3c3c;
        color: #e0e0e0;
        border-color: #555;
    }
    
    #adminResult {
        background: #3c3c3c;
        color: #e0e0e0;
    }
    
    #adminResult code {
        background: #555;
        color: #e0e0e0;
    }
}

#plot {
    width: 100%;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

#temporaryMessage {
    position: fixed;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%);
    background: #333;
    color: white;
    padding: 12px 24px;
    border-radius: 6px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    font-size: 14px;
    z-index: 10000;
    animation: fadeIn 0.2s ease-in;
}

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

/* Enhanced Tree Styling */
span.fancytree-title {
    padding: 1px 6px !important;
    border-radius: 4px !important;
    transition: all 0.2s ease !important;
    font-size: 11px !important;
    line-height: 1.2 !important;
    vertical-align: middle !important;
    display: inline-flex !important;
    align-items: center !important;
}

span.fancytree-title:hover {
    background: #e8f4ff !important;
    border-color: #cce4ff !important;
}

span.fancytree-active span.fancytree-title,
span.fancytree-focused span.fancytree-title {
    background: linear-gradient(to right, #0078d4, #005a9e) !important;
    color: white !important;
    border-color: #0078d4 !important;
    box-shadow: 0 2px 4px rgba(0, 120, 212, 0.3);
    font-weight: 500;
}

/* Ensure all child elements in active nodes are visible */
span.fancytree-active span.fancytree-title span,
span.fancytree-focused span.fancytree-title span {
    color: white !important;
}

/* Type indicator in active/focused nodes needs special handling */
span.fancytree-active span.fancytree-title span.tree-type,
span.fancytree-focused span.fancytree-title span.tree-type {
    background: rgba(255, 255, 255, 0.25) !important;
    color: white !important;
    border: 1px solid rgba(255, 255, 255, 0.4);
}

span.fancytree-selected span.fancytree-title {
    background: #0078d4 !important;
    color: white !important;
    border-color: #0078d4 !important;
}

/* Modern Expander Icons - Inverted */
span.fancytree-expander {
    background: none !important;
    position: relative;
    cursor: pointer;
    transition: transform 0.2s ease;
}

/* Hide expander for leaf nodes */
.fancytree-exp-n span.fancytree-expander::before,
.fancytree-exp-nl span.fancytree-expander::before {
    content: '' !important;
    display: none;
}

span.fancytree-expander::before {
    content: '▶';
    position: absolute;
    left: 2px;
    top: 1px;
    font-size: 10px;
    color: #666;
    transition: transform 0.2s ease, color 0.2s ease;
}

span.fancytree-expander:hover::before {
    color: #0078d4;
    transform: scale(1.2);
}

/* Collapsed state - arrow points down */
.fancytree-exp-e span.fancytree-expander::before,
.fancytree-exp-ed span.fancytree-expander::before,
.fancytree-exp-edl span.fancytree-expander::before,
.fancytree-exp-el span.fancytree-expander::before {
    content: '▼';
    color: #666;
}

.fancytree-exp-e span.fancytree-expander:hover::before,
.fancytree-exp-ed span.fancytree-expander:hover::before {
    transform: scale(1.2);
    color: #0078d4;
}

/* Expanded state - arrow points right */
.fancytree-exp-c span.fancytree-expander::before,
.fancytree-exp-cd span.fancytree-expander::before,
.fancytree-exp-cdl span.fancytree-expander::before,
.fancytree-exp-cl span.fancytree-expander::before {
    content: '▶';
    color: #0078d4;
}

.fancytree-exp-c span.fancytree-expander:hover::before,
.fancytree-exp-cd span.fancytree-expander:hover::before {
    transform: scale(1.2);
}

/* Modern Folder Icons */
span.fancytree-icon {
    background: none !important;
    position: relative;
}

span.fancytree-icon::before {
    content: '📄';
    position: absolute;
    left: 0;
    top: 0;
    font-size: 14px;
}

.fancytree-folder span.fancytree-icon::before {
    content: '📁';
}

.fancytree-expanded.fancytree-folder span.fancytree-icon::before {
    content: '📂';
}

/* Tree container improvements */
ul.fancytree-container {
    font-size: 11px !important;
    padding: 4px !important;
}

span.fancytree-node {
    padding: 0 !important;
}

/* Key-Value pair formatting */
span.tree-key {
    font-weight: 600;
    color: #0078d4;
}

span.tree-separator {
    color: #999;
    margin: 0 4px;
}

span.tree-value {
    color: #333;
}

/* Empty/null value styling for key-value pairs */
span.tree-kv-empty {
    color: #999;
    font-style: italic;
    font-weight: 400;
}

/* Type indicator styling */
span.tree-type {
    display: inline-block;
    background: #e8f4fd;
    color: #0078d4;
    padding: 2px 6px;
    border-radius: 3px;
    font-size: 10px;
    font-weight: 500;
    margin-right: 6px;
    border: 1px solid #d0e7f9;
}

/* Dark mode tree enhancements */
@media (prefers-color-scheme: dark) {
    span.fancytree-title:hover {
        background: #3c3c3c !important;
        border-color: #555 !important;
    }
    
    span.fancytree-active span.fancytree-title,
    span.fancytree-focused span.fancytree-title {
        background: linear-gradient(to right, #0078d4, #006bb3) !important;
        color: white !important;
    }
    
    /* Ensure all child elements in active nodes are visible in dark mode */
    span.fancytree-active span.fancytree-title span,
    span.fancytree-focused span.fancytree-title span {
        color: white !important;
    }
    
    span.fancytree-expander::before {
        color: #999;
    }
    
    span.fancytree-expander:hover::before {
        color: #4da6ff;
    }
    
    .fancytree-exp-c span.fancytree-expander::before,
    .fancytree-exp-cd span.fancytree-expander::before,
    .fancytree-exp-cdl span.fancytree-expander::before,
    .fancytree-exp-cl span.fancytree-expander::before {
        color: #4da6ff;
    }
    
    span.fancytree-title {
        color: #e0e0e0 !important;
    }
    
    span.tree-key {
        color: #4da6ff;
    }
    
    span.tree-value {
        color: #e0e0e0;
    }
    
    /* Empty/null value styling for dark mode */
    span.tree-kv-empty {
        color: #888;
    }
    
    span.tree-separator {
        color: #888;
    }
    
    span.tree-type {
        background: #1a3a52;
        color: #4da6ff;
        border-color: #2d5a7a;
    }
    
    /* Type indicator in active/focused nodes for dark mode */
    span.fancytree-active span.fancytree-title span.tree-type,
    span.fancytree-focused span.fancytree-title span.tree-type {
        background: rgba(77, 166, 255, 0.2) !important;
        color: #e0e0e0 !important;
        border: 1px solid rgba(77, 166, 255, 0.4);
    }
}
