/* Validator page specific styles (index.html only) */

/* Z-index layers and layout constants - centralized for easy management */
:root {
    --z-resize-handle: 10;
    --z-dropdown: 1000;
    --z-overlay: 10000;

    /* Grid layout */
    --grid-gap: 20px;
    --file-tree-width: 250px;
    --editor-width: 1fr;
    --results-width: 1fr;

    /* Resize constraints (percentages stored with %, converted to 0-1 in JS) */
    --min-tree-width: 150px;
    --max-tree-width-percent: 40%;
    --min-editor-width-percent: 30%;
    --min-split-percent: 30%;
    --max-split-percent: 70%;
}

/* Two-column layout */
body {
    height: 100vh;
    overflow: hidden;
}

.container {
    height: 100vh;
    display: flex;
    flex-direction: column;
}

main {
    display: grid;
    grid-template-columns: var(--editor-width) var(--results-width);
    gap: var(--grid-gap);
    flex: 1;
    min-height: 0;
}

/* Three-column layout when file tree is visible */
main.with-file-tree {
    grid-template-columns: var(--file-tree-width) var(--editor-width) var(--results-width);
    position: relative;
}

/* Resize handles */
.resize-handle {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 8px;
    cursor: col-resize;
    z-index: var(--z-resize-handle);
    transition: background-color 0.2s;
}

.resize-handle::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 2px;
    height: 40px;
    background-color: var(--border-color);
    border-radius: 1px;
}

.resize-handle:hover::before,
.resize-handle.active::before {
    background-color: var(--primary-color);
    width: 3px;
}

.resize-handle.active {
    background-color: rgba(74, 144, 226, 0.1);
}

.editor-section,
.results-section {
    background: var(--surface-color);
    border-radius: 8px;
    box-shadow: var(--shadow);
    padding: 20px;
    display: flex;
    flex-direction: column;
    min-height: 0;
    overflow: hidden;
}

/* Tab system */
.results-tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
    border-bottom: 2px solid var(--border-color);
}

.tab-button {
    background: none;
    border: none;
    padding: 8px 16px;
    cursor: pointer;
    font-size: 14px;
    color: var(--text-secondary);
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    transition: all 0.2s;
}

.tab-button:hover {
    color: var(--text-primary);
}

.tab-button.active {
    color: var(--primary-color);
    border-bottom-color: var(--primary-color);
}

.tab-content {
    flex: 1;
    min-height: 0;
    overflow: hidden;
}

.tab-panel {
    display: none;
    height: 100%;
    overflow-y: auto;
}

.tab-panel.active {
    display: block;
}

/* Object viewer */
.object-viewer-controls {
    margin-bottom: 16px;
}

.object-search {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    background: var(--code-bg);
    color: var(--text-primary);
    font-size: 14px;
}

.object-search:focus {
    outline: none;
    border-color: var(--primary-color);
}

.show-more-btn {
    margin-top: 8px;
    padding: 6px 12px;
    background: var(--surface-hover);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    color: var(--text-primary);
    cursor: pointer;
    font-size: 13px;
    transition: background-color 0.2s;
}

.show-more-btn:hover {
    background: var(--hover-bg);
}

.object-group {
    margin-bottom: 12px;
}

.object-group-header {
    font-size: 16px;
    font-weight: 600;
    padding: 8px 12px;
    margin: 0;
    color: var(--text-primary);
    cursor: pointer;
    background: var(--surface-hover);
    border-radius: 4px;
    user-select: none;
    list-style: none;
    transition: background-color 0.2s;
}

.object-group-header::-webkit-details-marker {
    display: none;
}

.object-group-header::before {
    content: '▸ ';
    display: inline-block;
    transition: transform 0.2s;
}

.object-group[open] > .object-group-header::before {
    transform: rotate(90deg);
}

.object-group-header:hover {
    background: var(--hover-bg);
}

.object-group-items {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-top: 8px;
    padding-left: 8px;
}

.object-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px;
    border-radius: 4px;
    background: var(--code-bg);
    font-family: var(--font-mono);
    font-size: 13px;
    gap: 16px;
}

.object-item.clickable {
    cursor: pointer;
    transition: background-color 0.2s;
}

.object-item.clickable:hover {
    background: var(--hover-bg);
}

.object-id {
    font-weight: 600;
    color: var(--text-primary);
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    min-width: 0;
}

.object-location {
    color: var(--text-secondary);
    font-size: 12px;
    flex-shrink: 0;
    white-space: nowrap;
}

/* Editor with line numbers */
.editor-wrapper {
    display: flex;
    flex: 1;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    background-color: var(--code-bg);
    overflow: hidden;
    min-height: 0;
    position: relative;
}

.line-numbers {
    background-color: var(--line-numbers-bg);
    color: var(--text-muted);
    padding: 15px 10px;
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    font-size: 14px;
    line-height: 1.5;
    text-align: right;
    user-select: none;
    border-right: 1px solid var(--border-color);
    white-space: nowrap;
    flex-shrink: 0;
    overflow: hidden;
    position: relative;
}

#modInput {
    padding: 15px;
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    font-size: 14px;
    line-height: 1.5;
    border: none;
    resize: none;
    background-color: transparent;
    color: var(--text-color);
    overflow: auto;
    white-space: pre;
    box-sizing: border-box;
    flex: 1;
}

#modInput:focus {
    outline: none;
}

#modInput::placeholder {
    color: var(--text-muted);
    opacity: 0.6;
}

.editor-wrapper:focus-within {
    outline: 2px solid var(--primary-color);
    outline-offset: -1px;
}

/* Results */
.results-container {
    flex: 1;
    overflow-y: auto;
    min-height: 0;
}

.status {
    font-weight: 600;
    padding: 8px 16px;
    border-radius: 4px;
    font-size: 14px;
}

.status.success {
    background-color: rgba(82, 196, 26, 0.1);
    color: var(--success-color);
    border: 1px solid rgba(82, 196, 26, 0.3);
}

.status.error {
    background-color: rgba(245, 34, 45, 0.1);
    color: var(--error-color);
    border: 1px solid rgba(245, 34, 45, 0.3);
}

.status.warning {
    background-color: rgba(250, 173, 20, 0.1);
    color: var(--warning-color);
    border: 1px solid rgba(250, 173, 20, 0.3);
}

/* Status buttons container */
.status-buttons-container {
    display: flex;
    gap: 10px;
}

/* Status button styling */
.status-button {
    cursor: pointer;
    transition: all 0.2s;
    user-select: none;
}

.status-button:not(.active) {
    opacity: 0.5;
    filter: grayscale(50%);
}

.status-button:not(.active):hover {
    opacity: 0.7;
    filter: grayscale(30%);
}

.status-button.active {
    cursor: default;
}

/* Validation messages */
.message {
    padding: 12px;
    margin-bottom: 10px;
    border-radius: 4px;
    border-left: 4px solid;
    background-color: var(--surface-color);
    transition: all 0.2s;
}

.message.clickable {
    cursor: pointer;
}

.message.clickable:hover {
    transform: translateX(4px);
    box-shadow: var(--shadow);
}

.message.error {
    border-left-color: var(--error-color);
    background-color: rgba(245, 34, 45, 0.05);
}

.message.warning {
    border-left-color: var(--warning-color);
    background-color: rgba(250, 173, 20, 0.05);
}

.message.hint {
    border-left-color: var(--hint-color);
    background-color: rgba(184, 115, 51, 0.05);
}

.message.info {
    border-left-color: var(--info-color);
    background-color: rgba(24, 144, 255, 0.05);
}

.message-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 6px;
    font-weight: 600;
}

.message-icon {
    font-size: 16px;
}

.message-text {
    font-size: 14px;
    margin-bottom: 4px;
}

.message-context {
    font-size: 13px;
    color: var(--text-muted);
    margin-left: 24px;
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
}

.message-suggestion {
    font-size: 13px;
    color: var(--primary-color);
    margin-left: 24px;
    margin-top: 4px;
}

.message-corrections {
    font-size: 13px;
    color: var(--primary-color);
    margin-left: 24px;
    margin-top: 4px;
}

.correction-link {
    cursor: pointer;
    text-decoration: underline;
    font-weight: 600;
    transition: all 0.2s;
}

.correction-link:hover {
    color: var(--primary-dark);
    text-decoration: none;
    background-color: rgba(74, 144, 226, 0.1);
    padding: 2px 4px;
    border-radius: 3px;
}

.documentation-link {
    color: var(--primary-color);
    text-decoration: underline;
    font-weight: 600;
    transition: all 0.2s;
}

.documentation-link:hover {
    color: var(--primary-dark);
    text-decoration: none;
    background-color: rgba(74, 144, 226, 0.1);
    padding: 2px 4px;
    border-radius: 3px;
}

.message-line-info {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 4px;
    margin-left: 24px;
    font-family: monospace;
}

/* File tree styles */
.file-tree-section {
    background: var(--surface-color);
    border-radius: 8px;
    box-shadow: var(--shadow);
    padding: 20px;
    display: flex;
    flex-direction: column;
    min-height: 0;
    overflow: hidden;
}

.file-tree-content {
    flex: 1;
    overflow-y: auto;
    min-height: 0;
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    font-size: 13px;
}

.file-tree-item {
    padding: 4px 8px;
    cursor: pointer;
    border-radius: 4px;
    display: flex;
    align-items: center;
    gap: 6px;
    user-select: none;
    transition: background-color 0.15s;
}

.file-tree-item:hover {
    background-color: rgba(74, 144, 226, 0.1);
}

.file-tree-item.active {
    background-color: var(--primary-color);
    color: white;
    font-weight: 600;
}

.file-tree-item.directory {
    font-weight: 500;
}

.file-tree-item .icon {
    width: 16px;
    text-align: center;
    flex-shrink: 0;
}

.file-tree-item .name {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* File severity colors */
.file-tree-item.file-error .name {
    color: var(--error-color);
    font-weight: 600;
}

.file-tree-item.file-warning .name {
    color: var(--warning-color);
    font-weight: 600;
}

.file-tree-item.file-hint .name {
    color: var(--hint-color);
    font-weight: 600;
}

.file-tree-item.file-info .name {
    color: var(--info-color);
    font-weight: 600;
}

.file-tree-item.file-valid .name {

}

.file-tree-item.file-unvalidated .name {
    opacity: 0.7;
}

/* Override colors when active */
.file-tree-item.active .name {
    color: white !important;
}

.file-tree-item.collapsed .children {
    display: none;
}

.file-tree-children {
    margin-left: 16px;
}

/* Upload dropdown */
.upload-dropdown {
    position: relative;
    display: inline-block;
}

.upload-menu {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    background: var(--surface-color);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    box-shadow: var(--shadow);
    margin-top: 4px;
    z-index: var(--z-dropdown);
    min-width: 150px;
}

.upload-menu-item {
    display: block;
    width: 100%;
    padding: 8px 12px;
    border: none;
    background: transparent;
    text-align: left;
    cursor: pointer;
    font-size: 14px;
    color: var(--text-color);
    transition: background-color 0.15s;
}

.upload-menu-item:hover {
    background-color: rgba(74, 144, 226, 0.1);
}

.upload-menu-item:first-child {
    border-radius: 4px 4px 0 0;
}

.upload-menu-item:last-child {
    border-radius: 0 0 4px 4px;
}

/* Drag and drop overlay */
.drag-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(74, 144, 226, 0.9);
    display: flex;
    align-items: center;
    justify-center;
    z-index: var(--z-overlay);
    pointer-events: none;
}

.drag-overlay-content {
    background: var(--surface-color);
    color: var(--primary-color);
    padding: 40px;
    border-radius: 12px;
    font-size: 24px;
    font-weight: 600;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
    border: 2px solid var(--primary-color);
}

@media (max-width: 1024px) {
    main {
        grid-template-columns: 1fr;
    }

    main.with-file-tree {
        grid-template-columns: 200px 1fr;
    }

    .results-section {
        display: none;
    }
}
