/* OIM Taxonomy Viewer Styles */

:root {
    --accent: #2563eb;
    --accent-light: #eff6ff;
    --accent-hover: #1d4ed8;
    --border: #e2e8f0;
    --bg-subtle: #f8fafc;
    --bg-panel: #ffffff;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --radius: 6px;
    --shadow-sm: 0 1px 3px rgba(0,0,0,.08);
}

body {
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    margin: 0;
    padding: 0;
    display: flex;
    height: 100vh;
    background: var(--bg-subtle);
    color: var(--text-primary);
}

h2 {
    font-size: 15px;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0 0 12px 0;
    padding: 0 0 10px 0;
    border-bottom: 1px solid var(--border);
    letter-spacing: 0.3px;
}

#tree-container {
    width: 50%;
    min-width: 200px;
    max-width: 80%;
    overflow-y: auto;
    border-right: 1px solid var(--border);
    padding: 12px 14px;
    position: relative;
    background: var(--bg-panel);
}

#taxonomy-open-row {
    display: flex;
    align-items: stretch;
    gap: 6px;
    margin-bottom: 6px;
}

#taxonomy-open-row #taxonomy-select {
    flex: 1;
    min-width: 0;
}

#open-file-btn {
    flex-shrink: 0;
    padding: 5px 12px;
    background: var(--accent);
    color: white;
    border: none;
    border-radius: var(--radius);
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    white-space: nowrap;
    transition: background .15s;
}

#open-file-btn:hover {
    background: var(--accent-hover);
}

#resize-handle {
    position: absolute;
    right: 0;
    top: 0;
    bottom: 0;
    width: 5px;
    cursor: col-resize;
    background: transparent;
    z-index: 10;
}

#resize-handle:hover,
#resize-handle.dragging {
    background: var(--accent);
}

#details-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
    background: var(--bg-subtle);
}

#labels-refs {
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow-y: auto;
}

#attributes-panel, #labels-panel, #references-panel, #rel-props-panel, #locations-panel {
    flex: 0 0 auto;
    overflow-y: auto;
    padding: 14px 16px;
    border-bottom: 1px solid var(--border);
    background-color: var(--bg-panel);
}

#attributes-panel:last-child, #labels-panel:last-child, #references-panel:last-child, #rel-props-panel:last-child, #locations-panel:last-child {
    border-bottom: none;
}

/* Panel headings */
#attributes-panel h3, #labels-panel h3, #references-panel h3, #rel-props-panel h3, #locations-panel h3 {
    margin: 0 0 12px 0;
    padding: 7px 12px;
    font-size: 11px;
    font-weight: 700;
    background: var(--bg-subtle);
    color: var(--text-secondary);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    letter-spacing: 0.7px;
    text-transform: uppercase;
}

#attributes-content table, #labels-content table, #references-content table, #rel-props-content table, #locations-content table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 20px;
}

#attributes-content th, #attributes-content td, #labels-content th, #labels-content td, #references-content th, #references-content td, #rel-props-content th, #rel-props-content td, #locations-content th, #locations-content td {
    border: 1px solid var(--border);
    padding: 6px 8px;
    word-wrap: break-word;
    white-space: normal;
    font-size: 12.5px;
}

/* Labels and References — sans-serif to match body font */
#labels-content th, #labels-content td,
#references-content th, #references-content td {
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    font-size: 13px;
    color: var(--text-primary);
}

/* Relationship Properties — sans-serif to match References */
#rel-props-content th, #rel-props-content td {
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    font-size: 13px;
    color: var(--text-primary);
}

/* Table header rows — match QName Locations section label style */
#labels-content thead th,
#references-content thead th,
#rel-props-content thead th {
    background: var(--bg-subtle);
    color: var(--text-secondary);
    font-weight: 700;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* h4 sub-headings in References and Relationship Properties panels */
#references-panel h4, #rel-props-panel h4 {
    margin: 8px 0 4px;
    padding: 5px 10px;
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    background: var(--bg-subtle);
    color: var(--text-secondary);
    border-radius: var(--radius);
    border: 1px solid var(--border);
}

#details {
    flex: 1;
    overflow-y: auto;
    padding: 10px;
}

#labels-refs {
    margin-bottom: 20px;
}

ul {
    list-style-type: none;
    padding-left: 20px;
}

li {
    cursor: pointer;
}

.node {
    padding: 4px 6px;
    border: 1px solid transparent;
    margin: 1px 0;
    border-radius: 4px;
    font-size: 13px;
}

.node:hover {
    background-color: var(--accent-light);
    border-color: var(--border);
}

.node.selected {
    background-color: var(--accent-light);
    border-color: var(--accent);
    color: var(--accent-hover);
    font-weight: 500;
}

.collapsed > ul {
    display: none;
}

.expanded > ul {
    display: block;
}

#loading {
    display: none;
    font-size: 16px;
    color: #555;
    margin-top: 10px;
}

.tabs {
    display: flex;
    flex-wrap: wrap;
    margin-bottom: 10px;
    border-bottom: 2px solid var(--border);
    gap: 0;
}

.tab-button {
    padding: 8px 14px;
    border: none;
    background: transparent;
    cursor: pointer;
    font-size: 12.5px;
    font-weight: 500;
    color: var(--text-secondary);
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    transition: color .15s, border-color .15s;
    white-space: nowrap;
}

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

.tab-button.active {
    color: var(--accent);
    border-bottom-color: var(--accent);
    font-weight: 600;
}

.tab-content {
    display: none;
}

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

.self-reference-error {
    background-color: #ffcccc !important;
    border: 2px solid #ff0000 !important;
    color: #cc0000;
    font-weight: bold;
}

.self-reference-error:hover {
    background-color: #ffaaaa !important;
}

/* Cycle back-reference: a node that is already an ancestor in the current tree path */
.cycle-back-reference {
    color: darkred !important;
    font-weight: bold;
    cursor: help;
}

.cycle-back-reference::after {
    content: ' ↺';
    font-size: 11px;
    opacity: 0.8;
}

.node-icon {
    display: inline-block;
    width: 16px;
    text-align: center;
    margin-right: 4px;
    font-size: 12px;
}

/* Member group header (domain class grouping in the Members tab) */
.member-group-header {
    font-weight: 600;
    color: var(--text-primary);
    border-bottom: 1px solid var(--border);
    margin-top: 4px;
}

.member-group-header:first-child {
    margin-top: 0;
}

.filter-container {
    margin: 8px 0;
    padding: 8px 10px;
    background-color: var(--bg-subtle);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.filter-container label {
    font-weight: 600;
    font-size: 12px;
    color: var(--text-secondary);
    white-space: nowrap;
}

.filter-container select {
    padding: 4px 8px;
    border: 1px solid var(--border);
    border-radius: 4px;
    font-size: 12.5px;
    background: white;
    color: var(--text-primary);
    min-width: 180px;
}

.context-menu {
    position: absolute;
    background: white;
    border: 1px solid var(--border);
    box-shadow: 0 4px 16px rgba(0,0,0,.12);
    border-radius: var(--radius);
    z-index: 1000;
    padding: 4px 0;
    min-width: 160px;
}

.context-menu-item {
    padding: 7px 14px;
    cursor: pointer;
    user-select: none;
    font-size: 13px;
    color: var(--text-primary);
}

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

.details-tabs {
    display: flex;
    border-bottom: 2px solid var(--border);
    background-color: var(--bg-panel);
    padding: 0 10px;
    flex-shrink: 0;
}

.details-tab-button {
    padding: 9px 16px;
    background: none;
    border: none;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    transition: color .15s, border-color .15s;
}

.details-tab-button:hover {
    color: var(--text-primary);
    background-color: var(--bg-subtle);
}

.details-tab-button.active {
    color: var(--accent);
    border-bottom-color: var(--accent);
    font-weight: 600;
}

.details-tab-content {
    display: none;
    height: 100%;
    overflow: hidden;
}

.details-tab-content.active {
    display: flex;
    flex-direction: column;
}

/* Import paths container - needs scrolling */
#import-paths-container {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 10px;
}

#import-paths-content {
    min-height: min-content;
}

/* Component tabs styles */
.component-tabs {
    display: flex;
    flex-wrap: wrap;
    border-bottom: 2px solid var(--border);
    background-color: var(--bg-panel);
    padding: 0 6px;
    margin-bottom: 10px;
}

.component-tab-button {
    padding: 7px 12px;
    background: none;
    border: none;
    cursor: pointer;
    font-size: 12.5px;
    font-weight: 500;
    color: var(--text-secondary);
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    transition: color .15s, border-color .15s;
    white-space: nowrap;
}

.component-tab-button:hover {
    color: var(--text-primary);
    background-color: var(--bg-subtle);
}

.component-tab-button.active {
    color: var(--accent);
    border-bottom-color: var(--accent);
    font-weight: 600;
}

.component-tab-content {
    display: none;
    overflow-y: auto;
    flex: 1;
}

.component-tab-content.active {
    display: block;
}

#cube-grid-container {
    flex: 1;
    overflow: auto;
    padding: 10px;
}

#cube-grid {
    border-collapse: collapse;
    font-size: 12px;
}

#cube-grid th, #cube-grid td {
    border: 1px solid #ccc;
    padding: 5px;
    text-align: left;
}

#cube-grid th {
    background-color: #f0f0f0;
    font-weight: bold;
    position: sticky;
    top: 0;
    z-index: 10;
}

#cube-grid .concept-cell {
    font-weight: bold;
    background-color: #f9f9f9;
}

#cube-grid .dimension-header {
    background-color: #e3f2fd;
    text-align: center;
}

/* Cube grid table styling (for fact grids) */
.cube-grid {
    border-collapse: collapse;
    font-size: 12px;
    width: 100%;
    margin-top: 10px;
}

.cube-grid th, .cube-grid td {
    border: 1px solid #ddd;
    padding: 8px;
    text-align: left;
}

.cube-grid th {
    background-color: #f5f5f5;
    font-weight: bold;
}

.cube-grid .concept-cell {
    font-weight: bold;
    background-color: #f9f9f9;
}

/* ===== FactSources Styles ===== */
.factSources-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.factSource-item {
    margin-bottom: 8px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg-panel);
    box-shadow: var(--shadow-sm);
}

.factSource-header {
    cursor: pointer;
    padding: 8px 12px;
    background: var(--bg-subtle);
    border-bottom: 1px solid var(--border);
    font-weight: 600;
    font-size: 13px;
    display: flex;
    align-items: center;
    transition: background-color 0.15s;
    border-radius: var(--radius) var(--radius) 0 0;
}

.factSource-header:hover {
    background: var(--accent-light);
}

.expand-icon {
    display: inline-block;
    width: 20px;
    font-size: 12px;
    transition: transform 0.2s;
}

.facts-container {
    padding: 10px;
    padding-left: 30px;
}

.factSource-item .facts-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.factSource-item .fact-item {
    padding: 5px 10px;
    margin: 2px 0;
    border-radius: 3px;
    transition: background-color 0.2s;
}

.factSource-item .fact-item:hover {
    background-color: #f0f0f0;
}

.factSource-item .fact-item.selected {
    background-color: #e3f2fd;
    font-weight: bold;
}

/* Highlighted cell for fact */
.cube-grid td.highlight {
    background-color: #fff9c4 !important;
    border: 2px solid #fbc02d !important;
    font-weight: bold !important;
    color: #f57f17 !important;
}

/* Root mismatch popup styles */
.root-mismatch-popup {
    position: fixed;
    background: white;
    border: 2px solid #2196F3;
    border-radius: 8px;
    padding: 15px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
    z-index: 10000;
    max-width: 400px;
    max-height: 500px;
    overflow-y: auto;
}

.root-mismatch-popup h4 {
    margin: 0 0 10px 0;
    color: #2196F3;
    font-size: 14px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.root-mismatch-popup .close-btn {
    cursor: pointer;
    font-size: 20px;
    color: #666;
    background: none;
    border: none;
    padding: 0;
    width: 24px;
    height: 24px;
    line-height: 20px;
}

.root-mismatch-popup .close-btn:hover {
    color: #000;
}

.root-mismatch-popup .section {
    margin-bottom: 15px;
}

.root-mismatch-popup .section-title {
    font-weight: bold;
    margin-bottom: 5px;
    color: #333;
    font-size: 13px;
}

.root-mismatch-popup .item-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.root-mismatch-popup .item-list li {
    padding: 5px 10px;
    margin: 2px 0;
    background: #f5f5f5;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-family: monospace;
    font-size: 12px;
    cursor: text;
    user-select: text;
}

.root-mismatch-popup .item-list li:hover {
    background: #e8f4f8;
}

.root-mismatch-popup .copy-all-btn {
    margin-top: 10px;
    padding: 6px 12px;
    background: #2196F3;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
}

.root-mismatch-popup .copy-all-btn:hover {
    background: #1976D2;
}

.root-mismatch-popup .copied-message {
    color: #4CAF50;
    font-size: 11px;
    margin-left: 10px;
    display: none;
}

/* Facts list styles */
.facts-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.fact-item {
    padding: 8px 12px;
    cursor: pointer;
    border-bottom: 1px solid #e0e0e0;
    transition: background-color 0.2s;
}

.fact-item:hover {
    background-color: #f5f5f5;
}

.fact-item.selected {
    background-color: var(--accent-light);
    border-left: 3px solid var(--accent);
    color: var(--accent-hover);
}

.fact-name {
    font-weight: 500;
    color: #333;
}

.fact-details {
    padding: 10px;
}

.fact-details h3 {
    margin-top: 0;
    color: var(--accent);
}

.fact-details h4 {
    margin: 15px 0 8px 0;
    color: #555;
    font-size: 14px;
}

.fact-dimensions-table,
.fact-values-table {
    width: 100%;
    border-collapse: collapse;
    margin: 10px 0;
    font-size: 13px;
}

.fact-dimensions-table th,
.fact-dimensions-table td,
.fact-values-table th,
.fact-values-table td {
    border: 1px solid #ddd;
    padding: 8px;
    text-align: left;
}

.fact-dimensions-table th,
.fact-values-table th {
    background-color: #f5f5f5;
    font-weight: 600;
}

.fact-dimensions-table tr:hover,
.fact-values-table tr:hover {
    background-color: #f9f9f9;
}

.no-data {
    padding: 20px;
    text-align: center;
    color: #999;
    font-style: italic;
}

/* Layout Tab Styles */
.z-axis-tabs {
    display: flex;
    gap: 5px;
    margin-bottom: 15px;
    border-bottom: 2px solid #e0e0e0;
    padding-bottom: 10px;
}

.z-axis-tab-button {
    padding: 6px 14px;
    margin-right: 4px;
    cursor: pointer;
    border: 1px solid var(--border);
    border-radius: 4px 4px 0 0;
    background-color: var(--bg-subtle);
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 500;
    transition: all 0.15s ease;
}

.z-axis-tab-button:hover {
    background-color: var(--accent-light);
    color: var(--accent);
}

.z-axis-tab-button.active {
    background-color: var(--accent);
    color: white;
    border-color: var(--accent);
}

.z-axis-grid {
    margin-top: 10px;
}

li.active {
    background-color: var(--accent-light);
    border-left: 3px solid var(--accent);
    font-weight: 600;
    color: var(--accent-hover);
}

li:hover {
    background-color: var(--bg-subtle);
}

/* Template View and Data Table View tab scrolling */
#templateView-tab,
#dataTableView-tab {
    overflow-x: auto;
    overflow-y: auto;
    height: 100%;
    width: 100%;
}

#templateView-tab > div,
#dataTableView-tab > div {
    min-width: min-content;
}

/* Ensure tables in these tabs don't get constrained */
#templateView-tab table,
#dataTableView-tab table {
    min-width: 100%;
    width: auto;
}

/* Style the scrollbars for better visibility */
#templateView-tab::-webkit-scrollbar,
#dataTableView-tab::-webkit-scrollbar {
    height: 12px;
    width: 12px;
}

#templateView-tab::-webkit-scrollbar-track,
#dataTableView-tab::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 10px;
}

#templateView-tab::-webkit-scrollbar-thumb,
#dataTableView-tab::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 10px;
}

#templateView-tab::-webkit-scrollbar-thumb:hover,
#dataTableView-tab::-webkit-scrollbar-thumb:hover {
    background: #555;
}

/* ===== Search Panel Styles ===== */
.search-panel {
    display: none;
    flex-direction: column;
    height: 100%;
    width: 100%;
    background-color: #fff;
    overflow: hidden;
    position: relative;
}

.search-panel.active {
    display: flex;
}

.search-header {
    flex: 0 0 auto;
    padding: 12px 14px;
    border-bottom: 2px solid var(--border);
    background-color: var(--bg-panel);
}

.search-input-container {
    flex: 0 0 auto;
    padding: 15px;
    border-bottom: 1px solid #ddd;
    background-color: #fff;
}

.search-input {
    width: 100%;
    padding: 10px;
    font-size: 14px;
    border: 1px solid #ccc;
    border-radius: 4px;
    box-sizing: border-box;
    transition: border-color 0.2s;
}

.search-input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.search-results {
    flex: 1 1 auto;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 10px;
    min-height: 0; /* Important for flex scrolling */
    max-height: 100%;
}

.search-result-item {
    padding: 10px;
    border-bottom: 1px solid #eee;
    cursor: pointer;
    display: flex;
    align-items: center;
    transition: background-color 0.2s;
}

.search-result-item:hover {
    background-color: #f5f5f5;
}

.search-result-item:last-child {
    border-bottom: none;
}

.type-badge {
    display: inline-block;
    padding: 3px 8px;
    font-size: 11px;
    font-weight: bold;
    border-radius: 3px;
    margin-right: 10px;
    text-transform: uppercase;
    min-width: 80px;
    text-align: center;
}

/* Scrollbar styles for search results */
.search-results::-webkit-scrollbar {
    width: 10px;
}

.search-results::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 10px;
}

.search-results::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 10px;
}

.search-results::-webkit-scrollbar-thumb:hover {
    background: #555;
}


/* Markdown View Styles */
.markdown-content h1 {
    font-size: 2em;
    margin-top: 0.67em;
    margin-bottom: 0.67em;
    border-bottom: 2px solid #eee;
    padding-bottom: 0.3em;
}

.markdown-content h2 {
    font-size: 1.5em;
    margin-top: 0.75em;
    margin-bottom: 0.75em;
    border-bottom: 1px solid #eee;
    padding-bottom: 0.3em;
}

.markdown-content h3 {
    font-size: 1.25em;
    margin-top: 1em;
    margin-bottom: 1em;
}

.markdown-content h4 {
    font-size: 1em;
    margin-top: 1.33em;
    margin-bottom: 1.33em;
}

.markdown-content code {
    background-color: #f5f5f5;
    padding: 2px 4px;
    border-radius: 3px;
    font-family: 'Courier New', monospace;
    font-size: 0.9em;
}

.markdown-content pre {
    background-color: #f5f5f5;
    padding: 15px;
    border-radius: 5px;
    overflow-x: auto;
    border: 1px solid #ddd;
}

.markdown-content pre code {
    background-color: transparent;
    padding: 0;
}

.markdown-content blockquote {
    border-left: 4px solid #ddd;
    margin: 0;
    padding-left: 15px;
    color: #666;
}

.markdown-content table {
    border-collapse: collapse;
    width: 100%;
    margin: 1em 0;
}

.markdown-content table th,
.markdown-content table td {
    border: 1px solid #ddd;
    padding: 8px;
    text-align: left;
}

.markdown-content table th {
    background-color: #f5f5f5;
    font-weight: bold;
}

.markdown-content ul,
.markdown-content ol {
    padding-left: 2em;
}

.markdown-content a {
    color: #0066cc;
    text-decoration: none;
}

.markdown-content a:hover {
    text-decoration: underline;
}

.markdown-content img {
    max-width: 100%;
    height: auto;
}

#markdown-preview-tab {
    overflow: hidden;
}

#markdown-preview-container {
    height: 100%;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

#markdown-preview-content {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    box-sizing: border-box;
}

/* Value Source Resolution Styles */
.value-source-info {
    font-size: 0.85em;
    color: #666;
    font-style: italic;
}

.error-text {
    color: #d00;
    font-weight: bold;
}

.original-value {
    cursor: help;
    color: #0066cc;
}
