/* static/css/reasoning-tree.css */
/* ARCHITECTURE: Styles for clinical reasoning tree visualization */
/* WHY: Visual clarity for diagnostic decision trees */
/* TRADEOFF: Additional CSS vs polished clinical UI */

/* =============================================================================
   REASONING TREE SVG
   ============================================================================= */

.reasoning-tree-svg {
    background: var(--color-surface, #1a1a1a);
    border-radius: 8px;
    overflow: hidden;
}

/* Links */
.reasoning-tree-svg .tree-link {
    transition: stroke 0.2s, opacity 0.2s;
}

.reasoning-tree-svg .link-confirmed {
    stroke: var(--color-success, #22c55e) !important;
    stroke-width: 3px;
}

.reasoning-tree-svg .link-pruned {
    stroke: var(--color-text-muted, #666) !important;
    stroke-dasharray: 4 2;
}

/* Nodes */
.reasoning-tree-svg .tree-node {
    transition: opacity 0.2s;
}

.reasoning-tree-svg .tree-node:hover .node-bg {
    stroke-width: 2px;
    filter: brightness(1.1);
}

.reasoning-tree-svg .tree-node.selected .node-bg {
    stroke: var(--color-primary, #3b82f6) !important;
    stroke-width: 3px;
}

.reasoning-tree-svg .node-title {
    font-family: var(--font-mono, 'JetBrains Mono', monospace);
    font-size: 12px;
    font-weight: 500;
}

/* Empty state */
.reasoning-tree-svg .empty-state {
    font-size: 14px;
    font-style: italic;
}

/* =============================================================================
   TOOLTIP
   ============================================================================= */

.reasoning-tree-tooltip {
    background: var(--color-surface-elevated, #2a2a2a);
    border: 1px solid var(--color-border, #555);
    border-radius: 8px;
    padding: 12px 16px;
    max-width: 300px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
    z-index: 1000;
    font-size: 13px;
}

.reasoning-tree-tooltip .tooltip-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
}

.reasoning-tree-tooltip .tooltip-header strong {
    color: var(--color-text, #eee);
}

.reasoning-tree-tooltip .status-indicator {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

.reasoning-tree-tooltip .status-indicator.confirmed {
    background: var(--color-success, #22c55e);
    box-shadow: 0 0 8px var(--color-success, #22c55e);
}

.reasoning-tree-tooltip .status-indicator.active {
    background: var(--color-primary, #3b82f6);
}

.reasoning-tree-tooltip .status-indicator.pruned {
    background: var(--color-text-muted, #666);
}

.reasoning-tree-tooltip .tooltip-reasoning {
    color: var(--color-text-secondary, #aaa);
    font-size: 12px;
    margin-bottom: 8px;
    padding: 8px;
    background: var(--color-surface, #1a1a1a);
    border-radius: 4px;
}

.reasoning-tree-tooltip .tooltip-evidence {
    display: flex;
    gap: 12px;
    font-size: 12px;
    margin-bottom: 8px;
}

.reasoning-tree-tooltip .evidence-for {
    color: var(--color-success, #22c55e);
}

.reasoning-tree-tooltip .evidence-against {
    color: var(--color-error, #ef4444);
}

.reasoning-tree-tooltip .tooltip-hint {
    font-size: 11px;
    color: var(--color-text-muted, #666);
    font-style: italic;
}

/* =============================================================================
   EVIDENCE PANEL
   ============================================================================= */

.evidence-panel {
    background: var(--color-surface, #1a1a1a);
    border: 1px solid var(--color-border, #333);
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
}

.evidence-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    border-bottom: 1px solid var(--color-border, #333);
    background: var(--color-surface-elevated, #222);
}

.evidence-panel-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--color-text, #eee);
    margin: 0;
}

.evidence-panel-close {
    background: transparent;
    border: none;
    color: var(--color-text-muted, #888);
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    transition: background 0.15s, color 0.15s;
}

.evidence-panel-close:hover {
    background: var(--color-surface, #333);
    color: var(--color-text, #eee);
}

.evidence-panel-content {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
}

/* Empty state */
.evidence-empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
    text-align: center;
    color: var(--color-text-muted, #666);
}

.evidence-empty-state i {
    font-size: 48px;
    margin-bottom: 16px;
    opacity: 0.5;
}

.evidence-empty-state p {
    font-size: 13px;
    margin: 0;
}

/* Node header in panel */
.evidence-node-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--color-border, #333);
}

.evidence-node-status {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}

.evidence-node-status.confirmed {
    background: var(--color-success, #22c55e);
    box-shadow: 0 0 8px var(--color-success, #22c55e);
}

.evidence-node-status.active {
    background: var(--color-primary, #3b82f6);
}

.evidence-node-status.pruned {
    background: var(--color-text-muted, #666);
}

.evidence-node-name {
    font-weight: 600;
    color: var(--color-text, #eee);
    font-size: 14px;
}

/* Reasoning text */
.evidence-reasoning {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    padding: 12px;
    background: var(--color-surface-elevated, #222);
    border-radius: 6px;
    margin-bottom: 16px;
    font-size: 13px;
    color: var(--color-text-secondary, #bbb);
}

.evidence-reasoning i {
    color: var(--color-primary, #3b82f6);
    flex-shrink: 0;
    margin-top: 2px;
}

/* Evidence sections */
.evidence-section {
    margin-bottom: 20px;
}

.evidence-section:last-child {
    margin-bottom: 0;
}

.evidence-section-header {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 10px;
}

.evidence-section-supporting .evidence-section-header {
    color: var(--color-success, #22c55e);
}

.evidence-section-supporting .evidence-section-header i {
    color: var(--color-success, #22c55e);
}

.evidence-section-refuting .evidence-section-header {
    color: var(--color-error, #ef4444);
}

.evidence-section-refuting .evidence-section-header i {
    color: var(--color-error, #ef4444);
}

/* Evidence list */
.evidence-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.evidence-item {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    padding: 10px 12px;
    background: var(--color-surface-elevated, #222);
    border-radius: 6px;
    margin-bottom: 8px;
    cursor: pointer;
    transition: background 0.15s, transform 0.1s;
    border-left: 3px solid transparent;
}

.evidence-item:hover {
    background: var(--color-surface-hover, #2a2a2a);
    transform: translateX(2px);
}

.evidence-item:active {
    transform: translateX(0);
}

.evidence-item-supporting {
    border-left-color: var(--color-success, #22c55e);
}

.evidence-item-refuting {
    border-left-color: var(--color-error, #ef4444);
}

.evidence-item i:first-child {
    color: var(--color-text-muted, #888);
    flex-shrink: 0;
    margin-top: 2px;
}

.evidence-text {
    flex: 1;
    font-size: 13px;
    color: var(--color-text, #eee);
    line-height: 1.4;
}

.evidence-source-badge {
    font-size: 10px;
    padding: 2px 6px;
    background: var(--color-surface, #1a1a1a);
    border-radius: 4px;
    color: var(--color-text-muted, #888);
    text-transform: uppercase;
    letter-spacing: 0.3px;
    flex-shrink: 0;
}

.evidence-link-icon {
    color: var(--color-text-muted, #666);
    opacity: 0;
    transition: opacity 0.15s;
    flex-shrink: 0;
}

.evidence-item:hover .evidence-link-icon {
    opacity: 1;
}

/* Confidence bar */
.evidence-confidence {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid var(--color-border, #333);
}

.confidence-label {
    font-size: 12px;
    color: var(--color-text-muted, #888);
}

.confidence-bar {
    flex: 1;
    height: 6px;
    background: var(--color-surface, #1a1a1a);
    border-radius: 3px;
    overflow: hidden;
}

.confidence-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--color-primary, #3b82f6), var(--color-success, #22c55e));
    border-radius: 3px;
    transition: width 0.3s ease-out;
}

.confidence-value {
    font-size: 12px;
    font-weight: 600;
    color: var(--color-text, #eee);
    min-width: 36px;
    text-align: right;
}

/* Temporal info */
.evidence-temporal {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    color: var(--color-text-muted, #888);
    margin-top: 12px;
}

.evidence-temporal i {
    color: var(--color-text-muted, #666);
}

/* =============================================================================
   PROSE HIGHLIGHT
   ============================================================================= */

.evidence-highlight {
    background: rgba(59, 130, 246, 0.25) !important;
    border-radius: 2px;
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.4);
    transition: background 0.3s, box-shadow 0.3s;
}

@keyframes evidence-pulse {
    0% {
        box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.4);
    }
    50% {
        box-shadow: 0 0 0 6px rgba(59, 130, 246, 0.2);
    }
    100% {
        box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.4);
    }
}

/* =============================================================================
   LAYOUT CONTAINER
   ============================================================================= */

.reasoning-tree-container {
    display: flex;
    gap: 16px;
    height: 100%;
}

.reasoning-tree-view {
    flex: 1;
    min-width: 0;
}

.reasoning-tree-sidebar {
    width: 320px;
    flex-shrink: 0;
}

.reasoning-tree-sidebar.hidden {
    display: none;
}

/* Stats bar */
.reasoning-tree-stats {
    display: flex;
    gap: 16px;
    padding: 12px 16px;
    background: var(--color-surface-elevated, #222);
    border-radius: 8px;
    margin-bottom: 12px;
}

.reasoning-tree-stat {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.reasoning-tree-stat-value {
    font-size: 18px;
    font-weight: 700;
    color: var(--color-text, #eee);
}

.reasoning-tree-stat-label {
    font-size: 11px;
    color: var(--color-text-muted, #888);
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.reasoning-tree-stat.confirmed .reasoning-tree-stat-value {
    color: var(--color-success, #22c55e);
}

.reasoning-tree-stat.pruned .reasoning-tree-stat-value {
    color: var(--color-text-muted, #666);
}

.reasoning-tree-stat.active .reasoning-tree-stat-value {
    color: var(--color-primary, #3b82f6);
}

/* Controls */
.reasoning-tree-controls {
    display: flex;
    gap: 8px;
    margin-bottom: 12px;
}

.reasoning-tree-control-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    background: var(--color-surface-elevated, #222);
    border: 1px solid var(--color-border, #333);
    border-radius: 6px;
    color: var(--color-text-muted, #888);
    cursor: pointer;
    transition: all 0.15s;
}

.reasoning-tree-control-btn:hover {
    background: var(--color-surface-hover, #2a2a2a);
    color: var(--color-text, #eee);
    border-color: var(--color-border-hover, #444);
}

.reasoning-tree-control-btn.active {
    background: var(--color-primary, #3b82f6);
    color: white;
    border-color: var(--color-primary, #3b82f6);
}

/* =============================================================================
   RESPONSIVE
   ============================================================================= */

@media (max-width: 768px) {
    .reasoning-tree-container {
        flex-direction: column;
    }

    .reasoning-tree-sidebar {
        width: 100%;
        max-height: 300px;
    }

    .reasoning-tree-stats {
        flex-wrap: wrap;
    }
}

/* =============================================================================
   REASONING TREE PANEL (Census Integration)
   ============================================================================= */

.reasoning-tree-panel {
    position: fixed;
    right: 0;
    top: var(--header-height, 60px);
    bottom: 0;
    width: 400px;
    background: var(--color-surface, #1a1a1a);
    border-left: 1px solid var(--color-border, #333);
    z-index: 100;
    display: flex;
    flex-direction: column;
    transform: translateX(100%);
    transition: transform 0.3s ease;
}

.reasoning-tree-panel.open {
    transform: translateX(0);
}

.reasoning-tree-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 12px 16px;
    border-bottom: 1px solid var(--color-border, #333);
    background: var(--color-surface-elevated, #222);
}

.reasoning-tree-header h4 {
    color: var(--color-text, #eee);
    font-size: 14px;
    font-weight: 600;
    margin: 0;
}

.reasoning-tree-header i {
    color: var(--color-primary, #3b82f6);
}

.reasoning-tree-badge {
    background: var(--color-primary, #3b82f6);
    color: white;
    font-size: 11px;
    padding: 2px 8px;
    border-radius: 12px;
    font-weight: 500;
}

.reasoning-tree-toggle-btn {
    background: transparent;
    border: none;
    color: var(--color-text-muted, #888);
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 4px;
    margin-left: auto;
    transition: background 0.15s, color 0.15s;
}

.reasoning-tree-toggle-btn:hover {
    background: var(--color-surface, #333);
    color: var(--color-text, #eee);
}

.reasoning-tree-body {
    flex: 1;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.reasoning-tree-body .reasoning-tree-container {
    flex: 1;
    min-height: 300px;
    overflow: auto;
}

.reasoning-tree-body .reasoning-tree-evidence {
    flex-shrink: 0;
    max-height: 40%;
    overflow-y: auto;
    border-top: 1px solid var(--color-border, #333);
}

.reasoning-tree-empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    padding: 40px 20px;
    text-align: center;
    color: var(--color-text-muted, #666);
}

.reasoning-tree-empty-state i {
    font-size: 48px;
    margin-bottom: 16px;
    opacity: 0.5;
}

.reasoning-tree-empty-state p {
    font-size: 13px;
    margin: 0;
}

/* =============================================================================
   PROVENANCE TAGS IN EDITOR (TipTap Extension)
   ============================================================================= */

prov,
.prov-tag {
    display: inline;
    background: rgba(59, 130, 246, 0.15);
    border-radius: 2px;
    padding: 0 2px;
    cursor: pointer;
    transition: background 0.15s, box-shadow 0.15s;
}

prov:hover,
.prov-tag:hover {
    background: rgba(59, 130, 246, 0.25);
    box-shadow: 0 0 0 1px rgba(59, 130, 246, 0.4);
}

prov.highlighted,
.prov-tag.highlighted {
    background: rgba(59, 130, 246, 0.35);
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.5);
    animation: evidence-pulse 1s ease-in-out;
}

/* Source-specific styling */
prov[src="labs"],
.prov-tag[data-src="labs"] {
    background: rgba(34, 197, 94, 0.15);
}

prov[src="labs"]:hover,
.prov-tag[data-src="labs"]:hover {
    background: rgba(34, 197, 94, 0.25);
    box-shadow: 0 0 0 1px rgba(34, 197, 94, 0.4);
}

prov[src="vitals"],
.prov-tag[data-src="vitals"] {
    background: rgba(249, 115, 22, 0.15);
}

prov[src="vitals"]:hover,
.prov-tag[data-src="vitals"]:hover {
    background: rgba(249, 115, 22, 0.25);
    box-shadow: 0 0 0 1px rgba(249, 115, 22, 0.4);
}

prov[src="imaging"],
.prov-tag[data-src="imaging"] {
    background: rgba(168, 85, 247, 0.15);
}

prov[src="imaging"]:hover,
.prov-tag[data-src="imaging"]:hover {
    background: rgba(168, 85, 247, 0.25);
    box-shadow: 0 0 0 1px rgba(168, 85, 247, 0.4);
}

prov[src="micro"],
.prov-tag[data-src="micro"] {
    background: rgba(236, 72, 153, 0.15);
}

prov[src="micro"]:hover,
.prov-tag[data-src="micro"]:hover {
    background: rgba(236, 72, 153, 0.25);
    box-shadow: 0 0 0 1px rgba(236, 72, 153, 0.4);
}

prov[src="exam"],
.prov-tag[data-src="exam"] {
    background: rgba(14, 165, 233, 0.15);
}

prov[src="exam"]:hover,
.prov-tag[data-src="exam"]:hover {
    background: rgba(14, 165, 233, 0.25);
    box-shadow: 0 0 0 1px rgba(14, 165, 233, 0.4);
}

/* Evidence chunk ID tooltip on hover */
prov::after,
.prov-tag::after {
    content: attr(chunk-id);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    background: var(--color-surface-elevated, #2a2a2a);
    color: var(--color-text-muted, #888);
    font-size: 10px;
    padding: 2px 6px;
    border-radius: 4px;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.15s;
    z-index: 10;
}

prov:hover::after,
.prov-tag:hover::after {
    opacity: 1;
}

/* ===== ITERATION 11: Toolbar Toggle Button ===== */

#reasoningTreeToolbarToggle.active {
    background: var(--color-primary-light, #e0f2fe);
    color: var(--color-primary, #0284c7);
}

#reasoningTreeToolbarToggle.active i {
    color: var(--color-primary, #0284c7);
}
