/* === Reset & Base === */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; background: #0f1117; color: #e0e0e0; }

/* === Layout === */
body { display: flex; overflow: hidden; }

#sidebar {
  width: 240px; min-width: 240px; background: #161822;
  display: flex; flex-direction: column; border-right: 1px solid #2a2d3a;
  overflow-y: auto;
}
#content { flex: 1; overflow-y: auto; padding: 24px; }
#detail-panel {
  width: 420px; min-width: 420px; background: #1a1d2e;
  border-left: 1px solid #2a2d3a; overflow-y: auto;
  transition: transform 0.2s ease;
}
#detail-panel.hidden { display: none; }

/* === Sidebar === */
.sidebar-header { padding: 20px 16px 8px; border-bottom: 1px solid #2a2d3a; }
.sidebar-header h2 { font-size: 22px; color: #4A90D9; letter-spacing: 2px; }
.sidebar-subtitle { font-size: 10px; color: #666; text-transform: uppercase; letter-spacing: 1px; }

.workspace-input { padding: 12px 16px; border-bottom: 1px solid #2a2d3a; }
.workspace-input label { font-size: 11px; color: #888; text-transform: uppercase; letter-spacing: 0.5px; display: block; margin-bottom: 6px; }
.workspace-input input {
  width: 100%; padding: 6px 8px; background: #0f1117; border: 1px solid #2a2d3a;
  border-radius: 4px; color: #e0e0e0; font-size: 12px; font-family: monospace;
}
.workspace-input input:focus { border-color: #4A90D9; outline: none; }
.workspace-input button {
  width: 100%; margin-top: 6px; padding: 6px; background: #4A90D9; color: white;
  border: none; border-radius: 4px; cursor: pointer; font-size: 12px;
}
.workspace-input button:hover { background: #3a7bc8; }

.nav-links { list-style: none; padding: 8px 0; flex: 1; }
.nav-links li a {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 16px; color: #aaa; text-decoration: none; font-size: 14px;
  transition: background 0.15s, color 0.15s;
}
.nav-links li a:hover { background: #1e2130; color: #e0e0e0; }
.nav-links li a.active { background: #1e2130; color: #4A90D9; border-left: 3px solid #4A90D9; }
.nav-icon { font-size: 16px; width: 20px; text-align: center; }

.sidebar-footer { padding: 12px 16px; border-top: 1px solid #2a2d3a; }
#ws-display { font-size: 11px; color: #666; font-family: monospace; word-break: break-all; }

/* === View Container === */
.empty-state { text-align: center; padding: 80px 20px; color: #666; }
.empty-state h2 { font-size: 24px; margin-bottom: 8px; color: #888; }

.view-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; }
.view-header h1 { font-size: 22px; font-weight: 600; }
.view-header .actions { display: flex; gap: 8px; }

/* === Tables === */
.data-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.data-table th {
  text-align: left; padding: 10px 12px; border-bottom: 2px solid #2a2d3a;
  color: #888; font-size: 11px; text-transform: uppercase; letter-spacing: 0.5px;
  cursor: pointer; user-select: none; white-space: nowrap;
}
.data-table th:hover { color: #bbb; }
.data-table th .sort-arrow { margin-left: 4px; font-size: 10px; }
.data-table td {
  padding: 10px 12px; border-bottom: 1px solid #1e2130;
  max-width: 300px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.data-table tr { cursor: pointer; transition: background 0.1s; }
.data-table tbody tr:hover { background: #1a1d2e; }

/* === Badges === */
.badge {
  display: inline-block; padding: 2px 8px; border-radius: 10px;
  font-size: 11px; font-weight: 500; text-transform: uppercase; letter-spacing: 0.3px;
}
.badge-entity { background: #4A90D920; color: #4A90D9; }
.badge-event { background: #50C87820; color: #50C878; }
.badge-artifact { background: #F5A62320; color: #F5A623; }
.badge-claim { background: #9B59B620; color: #9B59B6; }
.badge-narrative { background: #95A5A620; color: #95A5A6; }
.badge-proposed { background: #F5A62320; color: #F5A623; }
.badge-accepted { background: #50C87820; color: #50C878; }
.badge-rejected { background: #E74C3C20; color: #E74C3C; }
.badge-superseded { background: #95A5A620; color: #95A5A6; }
.badge-confirmed { background: #50C87820; color: #50C878; }
.badge-provisional { background: #F5A62320; color: #F5A623; }
.badge-unknown { background: #95A5A620; color: #95A5A6; }

/* === Buttons === */
.btn {
  padding: 6px 14px; border: none; border-radius: 4px; cursor: pointer;
  font-size: 13px; transition: background 0.15s;
}
.btn-primary { background: #4A90D9; color: white; }
.btn-primary:hover { background: #3a7bc8; }
.btn-secondary { background: #2a2d3a; color: #ccc; }
.btn-secondary:hover { background: #3a3d4a; }
.btn-success { background: #50C878; color: white; }
.btn-success:hover { background: #40b868; }
.btn-danger { background: #E74C3C; color: white; }
.btn-danger:hover { background: #d73c2c; }
.btn-sm { padding: 4px 10px; font-size: 12px; }

/* === Detail Panel === */
.detail-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 16px 20px; border-bottom: 1px solid #2a2d3a; position: sticky; top: 0;
  background: #1a1d2e; z-index: 10;
}
.detail-header h3 { font-size: 16px; }
#detail-close {
  background: none; border: none; color: #888; font-size: 22px;
  cursor: pointer; padding: 0 4px;
}
#detail-close:hover { color: #e0e0e0; }
#detail-content { padding: 20px; }

.detail-section { margin-bottom: 24px; }
.detail-section h4 {
  font-size: 12px; text-transform: uppercase; letter-spacing: 0.5px;
  color: #888; margin-bottom: 10px; padding-bottom: 6px; border-bottom: 1px solid #2a2d3a;
}
.detail-field { display: flex; margin-bottom: 8px; font-size: 13px; }
.detail-field .label { color: #888; min-width: 110px; flex-shrink: 0; }
.detail-field .value { color: #e0e0e0; word-break: break-all; font-family: monospace; font-size: 12px; }

/* === Tabs === */
.tabs { display: flex; gap: 0; margin-bottom: 16px; border-bottom: 1px solid #2a2d3a; }
.tab-btn {
  padding: 8px 16px; background: none; border: none; border-bottom: 2px solid transparent;
  color: #888; cursor: pointer; font-size: 13px; transition: color 0.15s;
}
.tab-btn:hover { color: #ccc; }
.tab-btn.active { color: #4A90D9; border-bottom-color: #4A90D9; }
.tab-content { display: none; }
.tab-content.active { display: block; }

/* === Graph Container === */
#graph-container { width: 100%; height: calc(100vh - 140px); border-radius: 8px; background: #0a0c12; border: 1px solid #2a2d3a; }
.graph-controls {
  display: flex; gap: 12px; align-items: center; flex-wrap: wrap; margin-bottom: 12px;
}
.graph-controls label { display: flex; align-items: center; gap: 4px; font-size: 13px; cursor: pointer; }
.graph-controls input[type="checkbox"] { accent-color: #4A90D9; }
.graph-legend {
  display: flex; gap: 16px; flex-wrap: wrap; margin-bottom: 12px; font-size: 12px;
}
.legend-item { display: flex; align-items: center; gap: 6px; }
.legend-dot { width: 12px; height: 12px; border-radius: 50%; }

/* === Dedup Cards === */
.dedup-card {
  background: #1a1d2e; border: 1px solid #2a2d3a; border-radius: 8px;
  padding: 20px; margin-bottom: 16px;
}
.dedup-pair { display: flex; gap: 16px; align-items: stretch; }
.dedup-entity { flex: 1; background: #161822; padding: 14px; border-radius: 6px; }
.dedup-entity h4 { font-size: 15px; margin-bottom: 6px; }
.dedup-vs { display: flex; align-items: center; font-size: 18px; color: #666; font-weight: bold; padding: 0 8px; }
.dedup-confidence {
  margin-top: 12px; display: flex; align-items: center; gap: 12px; font-size: 13px;
}
.confidence-bar { flex: 1; height: 6px; background: #2a2d3a; border-radius: 3px; overflow: hidden; }
.confidence-fill { height: 100%; background: #4A90D9; border-radius: 3px; transition: width 0.3s; }
.dedup-actions { margin-top: 12px; display: flex; gap: 8px; }

/* === JSON Editor === */
.json-editor-wrapper { border: 1px solid #2a2d3a; border-radius: 6px; overflow: hidden; }
.json-editor-wrapper .CodeMirror { height: 400px; font-size: 13px; }

/* === Example Selector === */
.example-selector { margin-bottom: 12px; }
.example-selector select {
  padding: 6px 10px; background: #161822; border: 1px solid #2a2d3a;
  border-radius: 4px; color: #e0e0e0; font-size: 13px;
}

/* === Loading / Error === */
.loading { text-align: center; padding: 40px; color: #666; }
.loading::after { content: ''; display: inline-block; width: 20px; height: 20px; border: 2px solid #333; border-top-color: #4A90D9; border-radius: 50%; animation: spin 0.8s linear infinite; margin-left: 10px; vertical-align: middle; }
@keyframes spin { to { transform: rotate(360deg); } }
.error-msg { background: #E74C3C20; border: 1px solid #E74C3C40; color: #E74C3C; padding: 12px 16px; border-radius: 6px; font-size: 13px; margin-bottom: 16px; }
.success-msg { background: #50C87820; border: 1px solid #50C87840; color: #50C878; padding: 12px 16px; border-radius: 6px; font-size: 13px; margin-bottom: 16px; }

/* === Scrollbar === */
::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #2a2d3a; border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: #3a3d4a; }

/* === Filter bar === */
.filter-bar { display: flex; gap: 8px; align-items: center; margin-bottom: 16px; }
.filter-bar select, .filter-bar input {
  padding: 6px 10px; background: #161822; border: 1px solid #2a2d3a;
  border-radius: 4px; color: #e0e0e0; font-size: 13px;
}
