:root {
    --primary-color: rgb(41, 43, 48);
    --secondary-color: #858aa0;
    --background-color: rgba(0, 0, 0, 0.85);
    --text-color: #e0e0e0;
    --border-color: #4e4e4e;
    --item-hover: rgba(255, 255, 255, 0.1);
    --item-active: rgba(255, 255, 255, 0.082);
    
    --type-string: rgba(16, 185, 129, 0.2);
    --type-string-text: rgb(34, 255, 181);

    --type-number: rgba(245, 158, 11, 0.2);
    --type-number-text: rgb(255, 196, 86);

    --type-boolean: rgba(139, 93, 246, 0.2);
    --type-boolean-text: rgb(178, 145, 255);

    --type-table: rgba(87, 112, 255, 0.2);
    --type-table-text: rgb(144, 160, 255);

    --type-function: rgba(236, 72, 153, 0.2);
    --type-function-text: rgb(255, 103, 179);
    
    --type-nil: rgba(107, 114, 128, 0.2);
    --type-nil-text: rgb(231, 231, 231);

    --type-version: rgba(52, 255, 34, 0.2);
    --type-version-text: rgb(52, 255, 34);
}

::selection {
    color: var(--type-version-text);
    background: var(--type-version);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: monospace;
}

body {
    width: 100vw;
    height: 100vh;
    overflow: hidden;
    background-color: transparent;
}

#app {
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
}

#table-viewer {
    width: 80%;
    max-width: 1200px;
    height: 80%;
    background-color: var(--background-color);
    border-radius: 10px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* Header */
.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    color: var(--text-color);
    border-bottom: 1px solid var(--border-color);
}

.header h1 {
    font-size: 20px;
    margin-right: 20px;
    font-weight: 600;
}

.controls {
    display: flex;
    align-items: center;
    flex: 1;
    justify-content: space-between;
}

.search-container {
    position: relative;
    display: flex;
    align-items: center;
    max-width: 300px;
    width: 100%;
}

.search-container i {
    position: absolute;
    left: 10px;
    color: var(--secondary-color);
}

.search-container input {
    width: 100%;
    padding: 8px 10px 8px 35px;
    border: none;
    border-radius: 4px;
    background-color: rgba(255, 255, 255, 0.1);
    color: var(--text-color);
    font-family: monospace;
}

.search-container input:focus {
    outline: none;
    background-color: rgba(255, 255, 255, 0.15);
}

.buttons {
    display: flex;
    gap: 5px;
}

.controls button {
    cursor: pointer;
    padding: 8px 12px;
    border-radius: 4px;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.controls button:hover {
    background-color: var(--item-hover);
    transform: scale(1.05);
}

.controls button:active {
    transform: scale(0.95);
}

/* Content */
.content {
    flex: 1;
    overflow-y: auto;
    padding: 10px;
}

.json-view-container {
    position: relative;
    height: 100%;
    width: 100%;
}

.json-view {
    height: 100%;
    overflow: auto;
    width: 100%;
}

.scrollbar-markers {
    position: absolute;
    right: 0;
    top: 0;
    width: 12px;
    height: 100%;
    pointer-events: none;
    z-index: 10;
}

.search-marker {
    position: absolute;
    right: 2px;
    width: 6px;
    height: 3px;
    background-color: rgba(234, 179, 8, 0.8);
    border-radius: 1px;
    pointer-events: auto;
    cursor: pointer;
    transition: width 0.1s ease, right 0.1s ease;
}

.search-marker:hover {
    width: 10px;
    right: 0;
    background-color: rgba(234, 179, 8, 0.75);
}

.json-view pre {
    font-family: monospace;
    white-space: pre-wrap;
    word-wrap: break-word;
    color: var(--text-color);
    line-height: 1.5;
    padding: 5px;
}

/* Tree View */
.tree-view {
    padding: 0 20px;
}

.tree-item {
    margin: 2px 0;
    border-radius: 4px;
}

.tree-item-header {
    display: flex;
    align-items: flex-start;
    padding: 6px 10px;
    cursor: pointer;
    border-radius: 4px;
    transition: background-color 0.2s;
    color: var(--text-color);
}

.tree-item-header:hover {
    background-color: var(--item-hover);
}

.tree-item-header.expanded {
    background-color: var(--item-active);
}

.toggle-icon {
    margin-right: 8px;
    width: 16px;
    text-align: center;
}

.key {
    font-weight: 600;
    margin-right: 8px;
}

.type-badge {
    font-size: 12px;
    padding: 2px 6px;
    border-radius: 4px;
    margin-right: 8px;
}

.type-string {
    background-color: var(--type-string);
    color: var(--type-string-text);
}

.type-number {
    background-color: var(--type-number);
    color: var(--type-number-text);
}

.type-boolean {
    background-color: var(--type-boolean);
    color: var(--type-boolean-text);
}

.type-table {
    background-color: var(--type-table);
    color: var(--type-table-text);
}

.type-function {
    background-color: var(--type-function);
    color: var(--type-function-text);
}

.type-nil {
    background-color: var(--type-nil);
    color: var(--type-nil-text);
}

.type-version{
    background-color: var(--type-version);
    color: var(--type-version-text);
}

.badge-blue {
    background-color: rgba(34, 222, 255, 0.2);
    color: rgb(34, 222, 255);
}

.badge-yellow {
    background-color: rgba(255, 196, 86, 0.2);
    color: rgb(255, 196, 86);
}

.badge-violet {
    background-color: rgba(186, 157, 255, 0.2);
    color: rgb(186, 157, 255);
}

.badge-grey {
    background-color: rgba(231, 231, 231, 0.2);
    color: rgb(231, 231, 231);
}

.badge-red {
    background-color: rgba(255, 103, 103, 0.2);
    color: rgb(255, 103, 103);
}

.json-parsed-badge {
    background-color: rgba(229, 70, 203, 0.2);
    color: rgb(255, 103, 179);
    font-size: 11px;
    padding: 1px 5px;
    border-radius: 4px;
    margin-right: 8px;
    font-style: italic;
}

.value {
    font-family: monospace;
    word-break: break-all;
}

span.value {
    background: none;
}

.summary {
    opacity: 0.7;
    font-style: italic;
}

.tree-item-children {
    padding-left: 20px;
    border-left: 1px dashed var(--border-color);
    margin-left: 10px;
}

/* Search highlighting */
.search-match > .tree-item-header {
    background-color: rgba(234, 179, 8, 0.2);
    border: 1px solid rgba(234, 179, 8, 0.4);
}

.search-highlight {
    background-color: rgba(234, 179, 8, 0.2);
    border: 1px solid rgba(234, 179, 8, 0.4);
    color: rgba(234, 179, 8, 1);
    font-weight: bold;
    border-radius: 2px;
}

/* Footer */
.footer {
    display: flex;
    justify-content: space-between;
    padding: 10px;
    background-color: var(--header-bg-color);
    color: var(--secondary-color);
    font-size: 12px;
    border-top: 1px solid var(--border-color);
}

.footer-left, .footer-right {
    display: flex;
    align-items: center;
}

.footer-left span {
    margin-right: 15px;
}

.footer-right span {
    margin-left: 15px;
    display: flex;
    align-items: center;
}

kbd {
    background-color: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 3px;
    box-shadow: 0 1px 1px rgba(0, 0, 0, 0.2);
    color: #fff;
    display: inline-block;
    font-family: monospace;
    font-size: 11px;
    line-height: 1;
    padding: 2px 4px;
    margin: 0 3px;
}

/* Context Menu */
#context-menu {
    position: fixed;
    z-index: 1000;
    background-color: var(--background-color);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
    min-width: 150px;
    overflow: hidden;
}

.context-menu-item {
    padding: 8px 12px;
    cursor: pointer;
    color: var(--text-color);
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: background-color 0.2s;
}

.context-menu-item:hover {
    background-color: var(--item-hover);
}

.context-menu-item i {
    width: 16px;
    text-align: center;
    color: var(--secondary-color);
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.1);
}

::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.3);
}