﻿/* Variables */
:root {
  --hsc-blue-thread: #9C27B0;
  --hsc-purple-thread: #5C6BC0;
  --hsc-indigo-thread: #1c84c6;
  --hsc-teal-thread: #009688;
  --hsc-green-thread: #30b035;
  --hsc-gray-border: #E5E7EB;
  --hsc-gray-text: #374151;
  --hsc-gray-muted: #6B7280;
  --hsc-bg-header: #F9FAFB;
}

/* Containers */
.result-container {
  display: flex;
  background: #fff;
  border: 1px solid var(--hsc-gray-border);
  margin-bottom: 20px;
  box-shadow: 0 1px 2px rgba(0,0,0,0.05);
  border-radius: 4px;
  overflow: hidden;
}
.instance-content {
  flex: 1;
  min-width: 0;
  overflow-x: auto;
}

/* Sidebar (base) */
.instance-sidebar {
  background: #fff;
  border-right: 1px solid var(--hsc-gray-border);
  flex-shrink: 0;
}

/* Sidebar – InstanceResult scope */
[id^="instance-card-"] .instance-sidebar {
  width: 120px;
  padding: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
}
[id^="instance-card-"] .instance-name {
  font-size: 15px;
  font-weight: 700;
  color: #111827;
  line-height: 1.4;
}

/* Sidebar – CodeResult scope */
#code-result-card .instance-sidebar {
  display: flex;
  padding: 0;
}
#code-result-card .sidebar-vertical-bar {
  width: 36px;
  background-color: #06c;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  writing-mode: vertical-lr;
  padding: 20px 0;
  letter-spacing: 4px;
  font-size: 14px;
  font-weight: bold;
}
#code-result-card .sidebar-content {
  padding: 15px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-width: 200px;
  background-color: #f8f9fa;
}
#code-result-card .sidebar-item-code {
  font-weight: bold;
  color: #333;
  font-size: 14px;
  display: block;
}
#code-result-card .sidebar-item-name {
  color: #666;
  font-size: 12px;
  line-height: 1.4;
  margin-top: 2px;
  display: block;
}

/* Controls */
.thread-controls {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--hsc-gray-border);
  background: var(--hsc-bg-header);
  flex-wrap: wrap;
}
.control-btn {
  font-size: 12px;
  padding: 4px 8px;
  border: 1px solid #D1D5DB;
  background: #fff;
  color: #374151;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.2s;
}
.control-btn:hover { background: #F9FAFB; }
.btn-level-1 { color: var(--hsc-blue-thread); border-color: var(--hsc-blue-thread); }
.btn-level-1:hover { background-color: rgba(156, 39, 176, 0.1); }
.btn-level-2 { color: var(--hsc-purple-thread); border-color: var(--hsc-purple-thread); }
.btn-level-2:hover { background-color: rgba(92, 107, 192, 0.1); }
.btn-level-3 { color: var(--hsc-indigo-thread); border-color: var(--hsc-indigo-thread); }
.btn-level-3:hover { background-color: rgba(28, 132, 198, 0.1); }
.btn-level-4 { color: var(--hsc-teal-thread); border-color: var(--hsc-teal-thread); }
.btn-level-4:hover { background-color: rgba(0, 150, 136, 0.1); }

/* Table */
.thread-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
}
.thread-table th {
  background: var(--hsc-bg-header);
  color: var(--hsc-gray-muted);
  font-size: 13px;
  font-weight: 600;
  padding: 10px 12px;
  text-align: left;
  border-bottom: 1px solid var(--hsc-gray-border);
  white-space: nowrap;
}
.thread-table th.center { text-align: center; }
/* CodeResult header tweaks */
#code-result-card .thread-table th {
  font-size: 12px;
  padding: 10px 8px;
}

/* Column widths */
.col-tree { width: 65%; }
/* InstanceResult columns */
.col-data { width: 10%; }
.col-action { width: 15%; }
/* CodeResult columns */
.col-unit { width: 6%; }
.col-tax { width: 5%; }
.col-reg { width: 7%; }
.col-insp { width: 7%; }

/* Rows */
.thread-row td {
  padding: 0;
  border-bottom: 1px solid var(--hsc-gray-border);
  vertical-align: middle;
  font-size: 14px;
  color: var(--hsc-gray-text);
  background: #fff;
}

/* Tree cell */
.thread-cell {
  display: flex;
  align-items: center;
  padding: 8px 12px;
  min-height: 42px;
  border-left-width: 4px;
  border-left-style: solid;
  transition: background-color 0.1s;
}
.thread-row:hover .thread-cell { background-color: #F9FAFB; }
.level-1 { border-left-color: var(--hsc-blue-thread); background: #F8FAFC; }
.level-2 { border-left-color: var(--hsc-purple-thread); }
.level-3 { border-left-color: var(--hsc-indigo-thread); }
.level-4 { border-left-color: var(--hsc-teal-thread); }
.level-leaf { border-left-color: var(--hsc-green-thread); }
.level-leaf.thread-cell { align-items: flex-start; padding-top: 10px; padding-bottom: 10px; }
.indent-0 { padding-left: 12px; }
.indent-1 { padding-left: 24px; }
.indent-2 { padding-left: 36px; }
.indent-3 { padding-left: 48px; }
.indent-4 { padding-left: 60px; }

/* Toggle */
.thread-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  margin-right: 8px;
  border: 1px solid #D1D5DB;
  background: #fff;
  border-radius: 2px;
  color: #6B7280;
  font-size: 10px;
  cursor: pointer;
  line-height: 1;
  user-select: none;
  flex-shrink: 0;
  margin-top: 3px;
}
.thread-toggle:hover { border-color: #9CA3AF; color: #111827; }
.hidden-toggle { visibility: hidden; }

/* Content */
.code-pill {
  color: #111827;
/*  font-weight: 600;*/
  margin-right: 8px;
  font-size: 14px;
  white-space: nowrap;
  flex-shrink: 0;
}

.code-pill del{
    color: gray;
/*    font-weight: 0;*/
    font-size: 14px;
    white-space: nowrap;
    flex-shrink: 0;
}

.level-leaf .code-pill { color: #2563EB; }
.desc-text {
  color: #374151;
  line-height: 1.4;
  word-break: break-all;
}
.node-link {
  text-decoration: none;
  color: inherit;
  display: flex;
  align-items: center;
  flex: 1;
}
#code-result-card .node-link { align-items: flex-start; }
.node-link:hover .code-pill { text-decoration: underline; }
.expired { opacity: 0.6; text-decoration: line-through; }

/* Data cells */
.data-cell-content {
  padding: 8px;
  text-align: center;
  display: flex;
  justify-content: center;
  gap: 4px;
}
#code-result-card .data-cell-content { padding: 8px 4px; gap: 2px; flex-wrap: wrap; }
.data-badge {
  font-size: 12px;
  padding: 1px 5px;
  border: 1px solid #E5E7EB;
  border-radius: 4px;
  background: #F9FAFB;
  color: #6B7280;
}
.tax-text { font-weight: 600; color: #111827; }
.badge-tax { font-size: 12px; font-weight: 700; color: #1c84c6; }
.badge-char {
  display: inline-block;
  width: 18px;
  height: 18px;
  line-height: 18px;
  text-align: center;
  background: #f0f2f5;
  border: 1px solid #d9d9d9;
  border-radius: 3px;
  font-size: 11px;
  color: #555;
  font-family: Consolas, monospace;
  cursor: help;
}
.badge-char:hover { border-color: #1c84c6; color: #1c84c6; background: #fff; }
.btn-detail {
  color: #2563EB;
  font-weight: 500;
  font-size: 14px;
  text-decoration: none;
  padding: 4px 10px;
  border-radius: 4px;
}
.btn-detail:hover { background: #EFF6FF; }
#code-result-card .btn-detail { white-space: nowrap; }
.btn-copy {
  font-size: 12px;
  color: #1c84c6;
  cursor: pointer;
  margin-left: 8px;
  text-decoration: none;
  white-space: nowrap;
  flex-shrink: 0;
}
.btn-copy:hover { text-decoration: underline; }

/* Utilities */
.d-none { display: none; }

/* Mobile */
@media (max-width: 768px) {
  .result-container { flex-direction: column; }
  .instance-sidebar { width: 100%; border-right: none; border-bottom: 1px solid var(--hsc-gray-border); padding: 10px; }
  /* InstanceResult table */
  .col-data, .col-action { display: none; }
  /* CodeResult table */
  .col-unit, .col-tax, .col-reg, .col-insp, .col-action { display: none; }
  .thread-cell { padding-right: 12px; }
  .indent-1, .indent-2, .indent-3, .indent-4 { padding-left: 12px; }
  /* CodeResult sidebar vertical writing on mobile */
  #code-result-card .sidebar-vertical-bar {
    writing-mode: horizontal-tb;
    width: 100%;
    padding: 8px;
    letter-spacing: 2px;
    height: auto;
  }
  #code-result-card .sidebar-content {
    flex-direction: row;
    flex-wrap: wrap;
    max-width: 100%;
  }
}

/* Instance quick nav (Index) */
.instance-quick-nav {
  position: fixed;
  top: 160px;
  left: 20px;
  width: 220px;
  z-index: 999;
  max-height: calc(100vh - 200px);
  display: flex;
  flex-direction: column;
  background: transparent;
  overflow: hidden;
}
.nav-header {
  padding: 0 0 12px 16px;
  color: #999;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  flex-shrink: 0;
}
.nav-body { overflow-y: auto; padding: 0; flex-grow: 1; }
.nav-item-row {
  display: block;
  padding: 6px 0 6px 16px;
  text-decoration: none !important;
  color: #666;
  font-size: 13px;
  line-height: 1.5;
  border-left: 2px solid #e5e5e5;
  transition: all 0.2s;
}
.nav-item-row:hover {
  color: var(--brand-orange, #ed6c00);
  border-left-color: var(--brand-orange, #ed6c00);
  background: transparent;
}
.nav-text {
  display: block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.custom-scrollbar::-webkit-scrollbar { width: 3px; }
.custom-scrollbar::-webkit-scrollbar-track { background: transparent; }
.custom-scrollbar::-webkit-scrollbar-thumb { background: #ddd; border-radius: 3px; }
@media (min-width: 1700px) {
  .instance-quick-nav {
    left: calc(50% - 820px);
    text-align: right;
  }
}
@media (max-width: 1399px) {
  .instance-quick-nav { left: 10px; width: 180px; }
}

