/* Activity Tab Styles for Linear Tree View */

/* Container and Layout */
.activity-container {
    padding: 20px;
    height: calc(100vh - 280px);
    display: flex;
    flex-direction: column;
}

.activity-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px;
    background: white;
    border-radius: 8px;
    margin-bottom: 15px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.activity-controls {
    display: flex;
    gap: 10px;
    align-items: center;
}

.activity-controls .btn-sm {
    padding: 6px 12px;
    font-size: 12px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.3s;
}

.activity-controls .btn-sm:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(102, 126, 234, 0.4);
}

.activity-controls select {
    padding: 6px 10px;
    border: 1px solid #e2e8f0;
    border-radius: 4px;
    font-size: 12px;
    background: white;
}

.activity-controls input {
    padding: 6px 12px;
    border: 1px solid #e2e8f0;
    border-radius: 4px;
    font-size: 12px;
    width: 200px;
}

.activity-stats {
    display: flex;
    gap: 20px;
}

.stat-item {
    display: flex;
    align-items: center;
    gap: 5px;
}

.stat-label {
    font-size: 12px;
    color: #718096;
    font-weight: 600;
}

.stat-value {
    font-size: 14px;
    font-weight: bold;
    color: #2d3748;
}

/* Tree Container */
.activity-tree-container {
    flex: 1;
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
    position: relative;
    overflow-y: auto;
    overflow-x: hidden;
    min-height: 400px;
    max-height: calc(100vh - 320px);
    padding: 0;
    scroll-behavior: smooth;
}

/* SVG Tree Styles */
#activity-tree-svg {
    font-family: 'SF Mono', Monaco, 'Cascadia Code', 'Roboto Mono', monospace;
    width: 100%;
    height: 100%;
    min-height: 400px;
}

/* D3 Tree Group */
.tree-group {
    cursor: move; /* Cursor for pan */
}

/* D3 Node Styles */
.node {
    cursor: pointer;
    transition: all 0.3s ease;
}

.node.selected .node-circle {
    stroke: #4299e1 !important;
    stroke-width: 3px !important;
    filter: drop-shadow(0 0 6px rgba(66, 153, 225, 0.6));
}

.node-circle {
    transition: all 0.3s ease;
}

.node:hover .node-circle {
    stroke-width: 3px;
    filter: drop-shadow(0 0 4px rgba(0, 0, 0, 0.3));
}

.node-icon {
    font-size: 12px;
    pointer-events: none;
    font-weight: bold;
}

.node-label {
    font-size: 14px;
    font-weight: 500;
    fill: #2d3748;
    transition: all 0.3s ease;
}

.node:hover .node-label {
    fill: #4299e1;
}

/* Node Type Colors */
.node-project .node-circle {
    fill: #4299e1;
    stroke: #2c5282;
}

.node-session .node-circle {
    fill: #38a169;
    stroke: #276749;
}

.node-todo .node-circle {
    fill: #ed8936;
    stroke: #c05621;
}

.node-agent .node-circle {
    fill: #9f7aea;
    stroke: #6b46c1;
}

.node-tool .node-circle {
    fill: #e53e3e;
    stroke: #c53030;
}

/* Status Badges */
.status-badge {
    transition: all 0.3s ease;
}

.status-text {
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    pointer-events: none;
}

/* Links */
.link {
    transition: all 0.3s ease;
}

.node:hover .link {
    stroke: #4299e1;
    stroke-width: 3px;
}

/* D3 Tooltip */
.d3-tooltip {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    line-height: 1.4;
    max-width: 250px;
    word-wrap: break-word;
}

/* Legacy Tree Styles - Keep for fallback */
.linear-tree {
    font-family: 'SF Mono', Monaco, 'Cascadia Code', 'Roboto Mono', monospace;
    line-height: 1.6;
    padding: 15px;
    min-height: 100%;
}

/* Tree Node Base Styles */
.tree-node {
    margin: 2px 0;
    border-radius: 4px;
    transition: background-color 0.2s ease;
}

.tree-node:hover {
    background-color: #f7fafc;
}

.tree-node-content {
    display: flex;
    align-items: center;
    padding: 6px 8px;
    gap: 8px;
    cursor: pointer;
    border-radius: 4px;
    transition: all 0.2s ease;
}

.tree-node-content:hover {
    background-color: #edf2f7;
}

/* Tree Indentation */
.tree-node[data-level="1"] {
    margin-left: 20px;
}

.tree-node[data-level="2"] {
    margin-left: 40px;
}

.tree-node[data-level="3"] {
    margin-left: 60px;
}

.tree-node[data-level="4"] {
    margin-left: 80px;
}

/* Tree Icons */
.tree-icon {
    font-size: 16px;
    width: 20px;
    text-align: center;
    flex-shrink: 0;
}

.tree-status-icon {
    font-size: 14px;
    width: 18px;
    text-align: center;
    flex-shrink: 0;
    margin-left: 2px;
}

.tree-expand-icon {
    font-size: 12px;
    width: 16px;
    text-align: center;
    flex-shrink: 0;
    cursor: pointer;
    color: #718096;
    transition: transform 0.2s ease;
}

.tree-expand-icon:hover {
    color: #4a5568;
    transform: scale(1.2);
}

/* Tree Labels and Text */
.tree-label {
    flex-grow: 1;
    font-size: 14px;
    color: #2d3748;
    font-weight: 500;
}

.tree-label.clickable {
    cursor: pointer;
    transition: all 0.2s ease;
    border-radius: 3px;
    padding: 2px 4px;
}

.tree-label.clickable:hover {
    background-color: #e2e8f0;
    color: #2c5282;
}

.tree-meta {
    font-size: 12px;
    color: #718096;
    font-style: italic;
    margin-left: auto;
}

.tree-params {
    font-size: 11px;
    color: #4a5568;
    background: #edf2f7;
    padding: 2px 6px;
    border-radius: 3px;
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.tree-status {
    font-size: 11px;
    padding: 2px 6px;
    border-radius: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-left: 8px;
}

/* Tree Children */
.tree-children {
    margin-left: 0;
    border-left: 1px solid #e2e8f0;
    margin-left: 20px;
    padding-left: 0;
}

/* Node Type Styles */

/* Project Root */
.tree-node.project-root {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    margin-bottom: 10px;
    border-radius: 6px;
}

.tree-node.project-root .tree-node-content {
    padding: 10px 12px;
}

.tree-node.project-root .tree-label {
    color: white;
    font-weight: 600;
    font-size: 16px;
}

.tree-node.project-root .tree-meta {
    color: rgba(255, 255, 255, 0.8);
}

/* Session Nodes */
.tree-node.session {
    background: #f8f9fa;
    border: 1px solid #e9ecef;
    margin-bottom: 8px;
    border-radius: 6px;
}

.tree-node.session .tree-node-content {
    padding: 8px 12px;
    font-weight: 600;
}

.tree-node.session .tree-icon {
    font-size: 18px;
}

.tree-node.session .tree-label {
    font-size: 15px;
    color: #495057;
}

/* Todo Nodes */
.tree-node.todo {
    border-left: 3px solid #cbd5e0;
    margin: 4px 0;
}

.tree-node.todo.status-pending {
    border-left-color: #cbd5e0;
    background: #f8f9fa;
}

.tree-node.todo.status-in_progress {
    border-left-color: #3182ce;
    background: #ebf8ff;
}

.tree-node.todo.status-completed {
    border-left-color: #38a169;
    background: #f0fff4;
}

/* Agent Nodes */
.tree-node.agent {
    background: #fef5e7;
    border-left: 2px solid #ed8936;
    margin: 2px 0;
    cursor: pointer;
    transition: all 0.2s ease;
}

.tree-node.agent:hover {
    background: #fed7aa;
    transform: translateX(2px);
    box-shadow: 0 2px 4px rgba(237, 137, 54, 0.2);
}

.tree-node.agent.selected {
    background: #fed7aa;
    border-left-color: #c05621;
    border-left-width: 4px;
    box-shadow: 0 4px 8px rgba(192, 86, 33, 0.3);
}

.tree-node.agent.status-active {
    background: #fef5e7;
    border-left-color: #ed8936;
}

.tree-node.agent.status-completed {
    background: #f0fff4;
    border-left-color: #38a169;
}

/* Tool Nodes - Maximum Specificity to Override Any Conflicting Styles */
body .activity-tree-container .linear-tree .tree-node.tool,
.tree-node.tool {
    background: #faf5ff !important;
    border-left: 2px solid #9f7aea !important;
    margin: 1px 0 !important;
    cursor: pointer !important;
    transition: all 0.2s ease !important;
}

body .activity-tree-container .linear-tree .tree-node.tool:hover,
.tree-node.tool:hover {
    background: #f3e8ff !important;
    transform: translateX(2px) !important;
    box-shadow: 0 2px 4px rgba(159, 122, 234, 0.2) !important;
}

body .activity-tree-container .linear-tree .tree-node.tool.selected,
.tree-node.tool.selected {
    background: #e9d8fd !important;
    border-left-color: #7c3aed !important;
    border-left-width: 4px !important;
    box-shadow: 0 4px 8px rgba(124, 58, 237, 0.3) !important;
}

/* Tool Status Styles - Maximum Specificity to Override Any Other Rules */
body .activity-tree-container .linear-tree .tree-node.tool.status-pending,
.tree-node.tool.status-pending {
    background: #faf5ff !important;
    border-left-color: #9f7aea !important;
    border-left-width: 2px !important;
}

body .activity-tree-container .linear-tree .tree-node.tool.status-in_progress,
.tree-node.tool.status-in_progress {
    background: #e6fffa !important;
    border-left-color: #38b2ac !important;
    border-left-width: 3px !important;
    animation: pulse-tool 2s infinite;
}

body .activity-tree-container .linear-tree .tree-node.tool.status-completed,
.tree-node.tool.status-completed {
    background: #f0fff4 !important;
    border-left-color: #38a169 !important;
    border-left-width: 2px !important;
}

body .activity-tree-container .linear-tree .tree-node.tool.status-failed,
.tree-node.tool.status-failed {
    background: #fed7d7 !important;
    border-left-color: #e53e3e !important;
    border-left-width: 2px !important;
}

/* Tool Status Icons */
.tree-node.tool .tree-status-icon {
    color: #718096;
}

.tree-node.tool.status-in_progress .tree-status-icon {
    color: #38b2ac;
    animation: spin 2s linear infinite;
}

.tree-node.tool.status-completed .tree-status-icon {
    color: #38a169;
}

.tree-node.tool.status-failed .tree-status-icon {
    color: #e53e3e;
}

/* Spinning animation for in-progress tools */
@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Pulse animation for in-progress tools */
@keyframes pulse-tool {
    0% {
        background: #e6fffa !important;
    }
    50% {
        background: #b2f5ea !important;
    }
    100% {
        background: #e6fffa !important;
    }
}

/* Privileged Tool (TodoWrite) - High Specificity */
body .activity-tree-container .linear-tree .tree-node.tool.privileged-tool,
.tree-node.tool.privileged-tool {
    background: #fff8e1 !important;
    border-left: 3px solid #ff9800 !important;
    border-radius: 6px !important;
    margin: 4px 0 !important;
}

body .activity-tree-container .linear-tree .tree-node.tool.privileged-tool .tree-label,
.tree-node.tool.privileged-tool .tree-label {
    font-weight: 600 !important;
    color: #e65100 !important;
}

body .activity-tree-container .linear-tree .tree-node.tool.privileged-tool .tree-params,
.tree-node.tool.privileged-tool .tree-params {
    background: #ffe0b2 !important;
    color: #e65100 !important;
    font-weight: 500 !important;
}

/* Catch-all rule to prevent any other styles from overriding tool styling */
.tree-node.tool:not(.privileged-tool) {
    background: #faf5ff !important;
    border-left: 2px solid #9f7aea !important;
}

.tree-node.tool:not(.privileged-tool).status-pending {
    background: #faf5ff !important;
    border-left-color: #9f7aea !important;
}

.tree-node.tool:not(.privileged-tool).status-in_progress {
    background: #e6fffa !important;
    border-left-color: #38b2ac !important;
    border-left-width: 3px !important;
    animation: pulse-tool 2s infinite;
}

.tree-node.tool:not(.privileged-tool).status-completed {
    background: #f0fff4 !important;
    border-left-color: #38a169 !important;
}

.tree-node.tool:not(.privileged-tool).status-failed {
    background: #fed7d7 !important;
    border-left-color: #e53e3e !important;
}

/* Todo Items within TodoWrite tool */
.tree-node.todo-item {
    background: #f8f9fa;
    border-left: 2px solid #cbd5e0;
    margin: 1px 0;
    border-radius: 3px;
}

.tree-node.todo-item.status-pending {
    border-left-color: #cbd5e0;
    background: #f8f9fa;
}

.tree-node.todo-item.status-in_progress {
    border-left-color: #3182ce;
    background: #ebf8ff;
    animation: pulse-todo 2s infinite;
}

.tree-node.todo-item.status-completed {
    border-left-color: #38a169;
    background: #f0fff4;
}

@keyframes pulse-todo {
    0% { 
        background: #ebf8ff;
    }
    50% { 
        background: #bee3f8;
    }
    100% { 
        background: #ebf8ff;
    }
}

/* Status Badges */
.tree-status.status-pending {
    background: #e2e8f0;
    color: #4a5568;
}

.tree-status.status-in_progress {
    background: #bee3f8;
    color: #2c5282;
    animation: pulse-status 2s infinite;
}

.tree-status.status-active {
    background: #fbb6ce;
    color: #97266d;
    animation: pulse-status 2s infinite;
}

.tree-status.status-completed {
    background: #c6f6d5;
    color: #276749;
}

.tree-status.status-failed {
    background: #fed7d7;
    color: #c53030;
}

/* Status Animation */
@keyframes pulse-status {
    0% { 
        opacity: 1; 
    }
    50% { 
        opacity: 0.7; 
    }
    100% { 
        opacity: 1; 
    }
}

/* Pinned TODOs Styles */
.tree-node.pinned-todos {
    background: linear-gradient(135deg, #fff8dc 0%, #f0e68c 100%) !important;
    border-left: 4px solid #daa520 !important;
    border-radius: 6px !important;
    margin: 4px 0 !important;
    font-weight: 600 !important;
}

.tree-node.pinned-todos:hover {
    background: linear-gradient(135deg, #f0e68c 0%, #daa520 100%) !important;
    box-shadow: 0 4px 8px rgba(218, 165, 32, 0.3) !important;
}

.tree-node.pinned-todos .tree-label {
    color: #b8860b !important;
    font-weight: bold !important;
}

.tree-node.pinned-todos .tree-icon {
    color: #daa520 !important;
    font-size: 18px !important;
}

.tree-node.pinned-todos .tree-params {
    background: #f5deb3 !important;
    color: #8b4513 !important;
    font-weight: 600 !important;
    border: 1px solid #daa520 !important;
}

.tree-node.pinned-todos .tree-status {
    background: #daa520 !important;
    color: white !important;
    font-weight: bold !important;
    text-transform: uppercase !important;
}

/* Tree Legend */
.tree-legend {
    position: absolute;
    top: 15px;
    right: 15px;
    background: rgba(255, 255, 255, 0.95);
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    padding: 10px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 5px;
    font-size: 12px;
    color: #4a5568;
}

.legend-item:last-child {
    margin-bottom: 0;
}

.legend-icon {
    width: 14px;
    height: 14px;
    display: inline-block;
    text-align: center;
}

.legend-icon.pm {
    color: #4A90E2;
}

.legend-icon.todowrite {
    color: #9B59B6;
}

.legend-icon.agent {
    color: #27AE60;
}

.legend-icon.tool {
    color: #E67E22;
}

.legend-icon.file {
    color: #95A5A6;
}

/* Search Highlighting - Specific to activity tree only */
.activity-tree-container .tree-node.search-match:not(.tool) {
    background: #fff3cd !important;
    border-left-color: #ffc107 !important;
}

.activity-tree-container .tree-node.search-match:not(.tool) .tree-label {
    background: #ffecb5;
    padding: 2px 4px;
    border-radius: 3px;
}

/* Empty State */
.linear-tree:empty::after {
    content: "No activity data available. Start using the PM to see the activity tree.";
    display: block;
    text-align: center;
    color: #718096;
    font-style: italic;
    padding: 40px 20px;
}

/* Scrollbar Styles */
.activity-tree-container::-webkit-scrollbar {
    width: 8px;
}

.activity-tree-container::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

.activity-tree-container::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 4px;
}

.activity-tree-container::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}

/* User instruction styles */
.tree-node.user-instruction {
    background: linear-gradient(135deg, #e3f2fd 0%, #bbdefb 100%);
    border-left: 4px solid #2196f3;
    cursor: pointer;
    transition: all 0.2s ease;
}

.tree-node.user-instruction.selected {
    background: linear-gradient(135deg, #bbdefb 0%, #90caf9 100%);
    border-left-color: #1976d2;
    box-shadow: 0 4px 8px rgba(25, 118, 210, 0.3);
}

.tree-node.user-instruction:hover {
    background: linear-gradient(135deg, #bbdefb 0%, #90caf9 100%);
    box-shadow: 0 4px 8px rgba(33, 150, 243, 0.2);
}

.tree-node.user-instruction .tree-label {
    font-style: italic;
    color: #1976d2;
}

/* TODO checklist styles */
.tree-node.todo-checklist {
    background: linear-gradient(135deg, #f3e5f5 0%, #e1bee7 100%);
    border-left: 4px solid #9c27b0;
    font-weight: 600;
}

.tree-node.todo-checklist:hover {
    background: linear-gradient(135deg, #e1bee7 0%, #ce93d8 100%);
    box-shadow: 0 4px 8px rgba(156, 39, 176, 0.2);
}

.tree-node.todo-checklist .tree-label {
    color: #7b1fa2;
    font-weight: bold;
}

/* Enhanced TODO item styles */
.tree-node.todo-item {
    margin: 2px 0;
    border-radius: 4px;
    transition: all 0.2s ease;
}

.tree-node.todo-item.status-pending {
    background: linear-gradient(135deg, #f7fafc 0%, #e2e8f0 20%);
    border-left: 3px solid #a0aec0;
}

.tree-node.todo-item.status-in_progress {
    background: linear-gradient(135deg, #e8f5e8 0%, #a5d6a7 20%);
    border-left: 3px solid #4caf50;
    animation: pulse 2s infinite;
}

.tree-node.todo-item.status-completed {
    background: linear-gradient(135deg, #e8f5e8 0%, #c8e6c9 20%);
    border-left: 3px solid #2e7d32;
    opacity: 0.8;
}

.tree-node.todo-item.status-completed .tree-label {
    text-decoration: line-through;
    color: #666;
}

/* Instruction and todo item detail styles */
.instruction-details,
.generic-details,
.tool-details,
.agent-details {
    font-family: 'SF Mono', Monaco, 'Cascadia Code', 'Roboto Mono', monospace;
    font-size: 12px;
}

.detail-row {
    display: flex;
    margin-bottom: 12px;
    padding: 8px 0;
    border-bottom: 1px solid #f0f0f0;
    align-items: flex-start;
}

.detail-label {
    font-weight: bold;
    color: #4a5568;
    width: 120px;
    flex-shrink: 0;
    line-height: 1.4;
}

.detail-value {
    color: #2d3748;
    word-break: break-word;
    flex: 1;
    line-height: 1.4;
}

.detail-section {
    margin-top: 20px;
    padding-top: 16px;
    border-top: 2px solid #e2e8f0;
}

.detail-section-title {
    font-weight: bold;
    color: #2d3748;
    margin-bottom: 12px;
    display: block;
    font-size: 14px;
}

.params-list {
    background: #f7fafc;
    border-radius: 6px;
    padding: 12px;
    border: 1px solid #e2e8f0;
}

.param-item {
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid #e2e8f0;
}

.param-item:last-child {
    margin-bottom: 0;
    padding-bottom: 0;
    border-bottom: none;
}

.param-key {
    font-weight: bold;
    color: #553c9a;
    margin-bottom: 4px;
    display: block;
    font-size: 12px;
}

.param-value {
    color: #2d3748;
}

.param-text-short {
    background: #ffffff;
    padding: 4px 8px;
    border-radius: 3px;
    border: 1px solid #cbd5e0;
    display: inline-block;
    font-family: inherit;
}

.param-text,
.param-text-long {
    background: #ffffff;
    border: 1px solid #cbd5e0;
    border-radius: 4px;
    padding: 8px;
    margin: 4px 0;
    white-space: pre-wrap;
    word-wrap: break-word;
    font-size: 11px;
    line-height: 1.4;
    max-height: 200px;
    overflow-y: auto;
}

.param-json {
    background: #f8f9fa;
    border: 1px solid #d6d8db;
    border-radius: 4px;
    padding: 8px;
    margin: 4px 0;
    white-space: pre;
    font-size: 11px;
    line-height: 1.3;
    max-height: 300px;
    overflow: auto;
    color: #24292e;
}

.param-primitive {
    background: #edf2f7;
    padding: 2px 6px;
    border-radius: 3px;
    font-weight: 500;
    color: #2d3748;
}

.param-error {
    background: #fed7d7;
    padding: 4px 8px;
    border-radius: 3px;
    color: #c53030;
    font-style: italic;
}

.status-badge {
    display: inline-block;
    padding: 3px 8px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
    text-transform: capitalize;
    letter-spacing: 0.5px;
}

.status-badge.status-pending {
    background: #e2e8f0;
    color: #4a5568;
}

.status-badge.status-in_progress {
    background: #bee3f8;
    color: #2c5282;
}

.status-badge.status-completed {
    background: #c6f6d5;
    color: #276749;
}

.status-badge.status-failed {
    background: #fed7d7;
    color: #c53030;
}

.status-badge.status-active {
    background: #fbb6ce;
    color: #97266d;
}

.tool-result {
    background: #f8f9fa;
    border: 1px solid #d6d8db;
    border-radius: 4px;
    padding: 12px;
    margin: 8px 0;
    white-space: pre-wrap;
    font-size: 11px;
    line-height: 1.4;
    max-height: 400px;
    overflow: auto;
    color: #24292e;
}

/* Pulse animation for in-progress items */
@keyframes pulse {
    0% {
        box-shadow: 0 0 0 0 rgba(76, 175, 80, 0.4);
    }
    70% {
        box-shadow: 0 0 0 4px rgba(76, 175, 80, 0);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(76, 175, 80, 0);
    }
}

/* Responsive adjustments */
@media (max-width: 1024px) {
    .activity-header {
        flex-direction: column;
        gap: 15px;
    }
    
    .activity-controls {
        width: 100%;
        flex-wrap: wrap;
        justify-content: center;
    }
    
    .tree-legend {
        position: static;
        margin-top: 15px;
        max-width: 300px;
    }
    
    .tree-params {
        max-width: 150px;
    }
    
    .activity-controls input {
        width: 150px;
    }
}

@media (max-width: 768px) {
    .activity-container {
        padding: 10px;
    }
    
    .activity-tree-container {
        padding: 0;
    }
    
    .linear-tree {
        padding: 10px;
    }
    
    .tree-node[data-level="1"] {
        margin-left: 15px;
    }
    
    .tree-node[data-level="2"] {
        margin-left: 30px;
    }
    
    .tree-node[data-level="3"] {
        margin-left: 45px;
    }
    
    .tree-node[data-level="4"] {
        margin-left: 60px;
    }
    
    .tree-params {
        max-width: 100px;
    }
    
    .stat-item {
        flex-direction: column;
        gap: 2px;
        text-align: center;
    }
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
    .activity-tree-container {
        background: #1a202c;
        color: #e2e8f0;
    }
    
    /* D3 Dark Mode Styles */
    #activity-tree-svg {
        background: #1a202c;
    }
    
    .node-label {
        fill: #e2e8f0;
    }
    
    .node:hover .node-label {
        fill: #63b3ed;
    }
    
    .link {
        stroke: #4a5568;
    }
    
    .node:hover .link {
        stroke: #63b3ed;
    }
    
    .d3-tooltip {
        background: rgba(45, 55, 72, 0.95) !important;
        color: #e2e8f0 !important;
        border: 1px solid #4a5568;
    }
    
    .activity-header {
        background: #2d3748;
    }
    
    .activity-controls select,
    .activity-controls input {
        background: #2d3748;
        color: #e2e8f0;
        border-color: #4a5568;
    }
    
    .stat-label {
        color: #a0aec0;
    }
    
    .stat-value {
        color: #e2e8f0;
    }
    
    .tree-legend {
        background: rgba(45, 55, 72, 0.95);
        border-color: #4a5568;
    }
    
    .legend-item {
        color: #e2e8f0;
    }
    
    .tree-node:hover {
        background-color: #2d3748;
    }
    
    .tree-node-content:hover {
        background-color: #4a5568;
    }
    
    .tree-label {
        color: #e2e8f0;
    }
    
    .tree-meta {
        color: #a0aec0;
    }
    
    .tree-node.project-root {
        background: linear-gradient(135deg, #4299e1 0%, #553c9a 100%);
    }
    
    .tree-node.session {
        background: #2d3748;
        border-color: #4a5568;
    }
    
    .tree-node.session .tree-label {
        color: #e2e8f0;
    }
    
    .tree-children {
        border-left-color: #4a5568;
    }
    
    .tree-label.clickable:hover {
        background-color: rgba(74, 85, 104, 0.5);
        color: #e2e8f0;
    }
    
    .module-item-details {
        color: #e2e8f0;
    }
    
    .module-item-header {
        border-bottom-color: #4a5568;
    }
    
    .module-item-header h6 {
        color: #e2e8f0;
    }
    
    .detail-label {
        color: #a0aec0;
    }
    
    .detail-value {
        color: #e2e8f0;
    }
    
    .detail-section {
        border-top-color: #4a5568;
    }
    
    .detail-section-title {
        color: #a0aec0;
    }
    
    .tools-list, .params-list {
        background: #2d3748;
        border-color: #4a5568;
    }
    
    .tool-summary {
        background: #4a5568;
        border-color: #718096;
        color: #e2e8f0;
    }
    
    .tool-params-expanded {
        background: #2d3748;
        border-color: #4a5568;
        color: #e2e8f0;
    }
    
    .param-line .param-key,
    .param-key {
        color: #9f7aea;
    }
    
    .param-line .param-value,
    .param-value {
        color: #e2e8f0;
    }
    
    .param-item {
        border-bottom-color: #4a5568;
    }
    
    .param-text-short {
        background: #2d3748;
        border-color: #4a5568;
        color: #e2e8f0;
    }
    
    .param-text,
    .param-text-long {
        background: #2d3748;
        border-color: #4a5568;
        color: #e2e8f0;
    }
    
    .param-json {
        background: #1a202c;
        border-color: #4a5568;
        color: #e2e8f0;
    }
    
    .param-primitive {
        background: #4a5568;
        color: #e2e8f0;
    }
    
    .param-error {
        background: #742a2a;
        color: #feb2b2;
    }
    
    .tool-result {
        background: #1a202c;
        border-color: #4a5568;
        color: #e2e8f0;
    }
}

/* Enhanced TodoWrite Display Styles */

/* Todo Summary Items */
.todo-summary {
    display: flex;
    gap: 15px;
    margin: 15px 0;
    flex-wrap: wrap;
}

.summary-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: #f8fafc;
    border-radius: 6px;
    border-left: 3px solid #e2e8f0;
    min-width: 120px;
    flex: 1;
}

.summary-item.completed {
    background: #f0fff4;
    border-left-color: #38a169;
}

.summary-item.in_progress {
    background: #e6fffa;
    border-left-color: #38b2ac;
}

.summary-item.pending {
    background: #f7fafc;
    border-left-color: #a0aec0;
}

.summary-icon {
    font-size: 16px;
    flex-shrink: 0;
}

.summary-count {
    font-size: 18px;
    font-weight: bold;
    color: #2d3748;
    flex-shrink: 0;
}

.summary-label {
    font-size: 12px;
    color: #718096;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Todo Checklist Items */
.todo-checklist {
    background: #f8fafc;
    border-radius: 6px;
    border: 1px solid #e2e8f0;
    padding: 8px;
}

.todo-checklist-item {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 8px;
    margin: 4px 0;
    border-radius: 4px;
    transition: background 0.2s ease;
    border-left: 3px solid transparent;
}

.todo-checklist-item:hover {
    background: #edf2f7;
}

.todo-checklist-item.completed {
    background: #f0fff4;
    border-left-color: #38a169;
}

.todo-checklist-item.in_progress {
    background: #e6fffa;
    border-left-color: #38b2ac;
    animation: pulse-todo 2s infinite;
}

.todo-checklist-item.pending {
    background: #f7fafc;
    border-left-color: #cbd5e0;
}

.todo-checkbox {
    flex-shrink: 0;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    background: white;
    border: 2px solid #e2e8f0;
    margin-top: 2px;
}

.checkbox-icon {
    font-size: 14px;
    font-weight: bold;
}

.checkbox-icon.status-completed {
    color: #38a169;
}

.checkbox-icon.status-in_progress {
    color: #38b2ac;
}

.checkbox-icon.status-pending {
    color: #a0aec0;
}

.todo-text {
    flex: 1;
    min-width: 0;
}

.todo-content {
    display: block;
    font-size: 14px;
    color: #2d3748;
    line-height: 1.4;
    margin-bottom: 4px;
    word-wrap: break-word;
}

.todo-checklist-item.completed .todo-content {
    text-decoration: line-through;
    color: #718096;
}

.todo-status-badge {
    display: inline-block;
    padding: 2px 6px;
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-radius: 10px;
    margin-top: 2px;
}

.todo-status-badge.status-completed {
    background: #c6f6d5;
    color: #276749;
}

.todo-status-badge.status-in_progress {
    background: #b2f5ea;
    color: #285e61;
}

.todo-status-badge.status-pending {
    background: #e2e8f0;
    color: #4a5568;
}

/* No todos message */
.no-todos {
    text-align: center;
    color: #718096;
    font-style: italic;
    padding: 20px;
    background: #f7fafc;
    border-radius: 6px;
    border: 1px dashed #cbd5e0;
}

/* Animation for in-progress items */
@keyframes pulse-todo {
    0% {
        background: #e6fffa;
    }
    50% {
        background: #b2f5ea;
    }
    100% {
        background: #e6fffa;
    }
}

/* Unified viewer status and headers */
.unified-viewer-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    background: #f8fafc;
    border-bottom: 1px solid #e2e8f0;
    border-radius: 6px 6px 0 0;
}

.unified-viewer-header h6 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    color: #2d3748;
}

.unified-viewer-status {
    font-size: 12px;
    font-weight: 600;
    padding: 4px 8px;
    border-radius: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.unified-viewer-content {
    padding: 16px;
}

/* Responsive adjustments for TodoWrite display */
@media (max-width: 768px) {
    .todo-summary {
        flex-direction: column;
        gap: 8px;
    }
    
    .summary-item {
        min-width: auto;
    }
    
    .todo-checklist-item {
        padding: 6px;
    }
    
    .todo-checkbox {
        width: 20px;
        height: 20px;
    }
    
    .checkbox-icon {
        font-size: 12px;
    }
}

/* Print Styles */
@media print {
    .activity-header {
        display: none;
    }
    
    .tree-legend {
        position: static;
        margin-bottom: 20px;
    }
    
    .activity-tree-container {
        box-shadow: none;
        border: 1px solid #000;
    }
    
    .tree-node {
        break-inside: avoid;
    }
    
    .tree-status {
        border: 1px solid #000;
        background: transparent !important;
        color: #000 !important;
    }
}

/* Focus and Accessibility */
.tree-node-content:focus {
    outline: 2px solid #4299e1;
    outline-offset: 2px;
}

.tree-expand-icon:focus {
    outline: 2px solid #4299e1;
    outline-offset: 2px;
}

/* Active/current item highlighting */
.tree-node.current-active {
    background: linear-gradient(90deg, rgba(245, 158, 11, 0.1) 0%, transparent 100%);
    border-left: 3px solid #f59e0b;
    animation: pulse-active 2s ease-in-out infinite;
}

.tree-node.has-active .tree-node-content {
    font-weight: 600;
}

.tree-node.todowrite.has-active .tree-icon {
    animation: rotate-icon 3s linear infinite;
}

@keyframes pulse-active {
    0%, 100% {
        background: linear-gradient(90deg, rgba(245, 158, 11, 0.1) 0%, transparent 100%);
    }
    50% {
        background: linear-gradient(90deg, rgba(245, 158, 11, 0.2) 0%, transparent 100%);
    }
}

@keyframes rotate-icon {
    from {
        transform: rotate(0deg);
    }
    to {
        transform: rotate(360deg);
    }
}

/* Collapsed state indicators */
.tree-node.agent:not(.expanded) .tree-label {
    font-style: italic;
    color: #4b5563;
}

.tree-node.agent .tree-label .current-status {
    color: #f59e0b;
    font-weight: 600;
    margin-left: 10px;
}

/* TodoWrite specific styles */
.tree-node.todowrite {
    background: rgba(99, 102, 241, 0.05);
    border-radius: 4px;
    margin: 2px 0;
}

.tree-node.todowrite .tree-node-content {
    padding: 4px 8px;
}

/* Multiple call/update indicators */
.tree-node .tree-label .call-count,
.tree-node .tree-label .update-count {
    color: #6366f1;
    font-weight: 600;
    font-size: 0.85em;
    opacity: 0.8;
}

.tree-node.tool .tree-label {
    position: relative;
}

.tree-node.tool .call-indicator {
    display: inline-block;
    background: #f59e0b;
    color: white;
    border-radius: 10px;
    padding: 0 6px;
    font-size: 0.75em;
    margin-left: 5px;
    font-weight: 600;
}

/* ==================== IMPROVED DATA VIEWER STYLES ==================== */

/* Primary data section for important information */
.primary-data {
    padding: 10px 0;
    border-bottom: 1px solid #e5e7eb;
    margin-bottom: 15px;
}

.primary-data .detail-row.highlight {
    background: rgba(59, 130, 246, 0.05);
    padding: 8px 12px;
    border-radius: 6px;
    margin: 5px 0;
    font-weight: 500;
}

.primary-data .code {
    font-family: 'Monaco', 'Courier New', monospace;
    background: #1e293b;
    color: #94a3b8;
    padding: 2px 6px;
    border-radius: 3px;
}

/* TodoWrite specific styles */
.todo-status-bar {
    display: flex;
    gap: 20px;
    padding: 12px;
    background: linear-gradient(90deg, #f8fafc 0%, #f1f5f9 100%);
    border-radius: 8px;
    margin-bottom: 15px;
}

.todo-status-bar .status-item {
    display: flex;
    align-items: center;
    gap: 6px;
}

.todo-status-bar .status-icon {
    font-size: 1.2em;
}

.todo-status-bar .status-count {
    font-size: 1.4em;
    font-weight: 700;
    color: #1e293b;
}

.todo-status-bar .status-label {
    color: #64748b;
    font-size: 0.9em;
}

/* Horizontal status line for TodoWrite */
.todo-status-line {
    display: flex;
    gap: 20px;
    padding: 8px 12px;
    background: #f8fafc;
    border-radius: 6px;
    margin-bottom: 12px;
    font-size: 0.95em;
    border: 1px solid #e2e8f0;
}

.todo-status-line .status-inline {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-weight: 500;
    color: #475569;
}

/* Todo list primary display */
.todo-list-primary {
    padding: 10px 0;
}

.todo-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    margin: 5px 0;
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    transition: all 0.2s ease;
}

.todo-item:hover {
    border-color: #cbd5e1;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.todo-item.completed {
    opacity: 0.7;
    background: #f8fafc;
}

.todo-item.completed .todo-text {
    text-decoration: line-through;
    color: #94a3b8;
}

.todo-item.in_progress {
    background: linear-gradient(90deg, rgba(251, 146, 60, 0.1) 0%, white 100%);
    border-color: #fb923c;
}

.todo-item .todo-icon {
    font-size: 1.2em;
    flex-shrink: 0;
}

.todo-item .todo-text {
    flex-grow: 1;
    font-size: 0.95em;
    color: #334155;
}

.todo-item .todo-badge.active {
    background: #fb923c;
    color: white;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 0.75em;
    font-weight: 600;
    text-transform: uppercase;
    animation: pulse 2s ease-in-out infinite;
}

/* Tool display improvements */
.tool-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    background: #f1f5f9;
    border: 1px solid #e2e8f0;
    border-radius: 15px;
    font-size: 0.9em;
    margin: 2px;
}

.tool-chip.active {
    background: linear-gradient(90deg, #fef3c7 0%, #fed7aa 100%);
    border-color: #fb923c;
    font-weight: 500;
}

.tools-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    margin-top: 8px;
}

.active-tools-section {
    margin: 10px 0;
    padding: 10px;
    background: rgba(251, 146, 60, 0.05);
    border-radius: 6px;
}

.active-tools-section .section-label {
    font-weight: 600;
    color: #ea580c;
    display: block;
    margin-bottom: 8px;
}

/* Instruction display */
.instruction-content {
    background: #f8fafc;
    padding: 15px;
    border-radius: 8px;
    border-left: 4px solid #3b82f6;
    font-size: 0.95em;
    line-height: 1.6;
    color: #1e293b;
    margin-bottom: 10px;
}

.instruction-meta {
    display: flex;
    gap: 15px;
    padding: 8px 0;
    color: #64748b;
    font-size: 0.85em;
}

.instruction-meta .meta-item {
    display: flex;
    align-items: center;
    gap: 5px;
}

/* Collapsible JSON viewer */
.collapsible-json-section {
    margin-top: 15px;
    border-top: 1px solid #e5e7eb;
    padding-top: 10px;
}

.collapsible-json-toggle {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    padding: 6px 12px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.9em;
    color: #475569;
    transition: all 0.2s ease;
    width: auto;
    display: inline-block;
}

.collapsible-json-toggle:hover {
    background: #f1f5f9;
    border-color: #cbd5e1;
}

.collapsible-json-toggle.expanded {
    background: #e0e7ff;
    border-color: #818cf8;
    color: #4338ca;
}

.collapsible-json-content {
    margin-top: 10px;
    max-height: 400px;
    overflow-y: auto;
}

.json-viewer {
    background: #1e293b;
    color: #94a3b8;
    padding: 12px;
    border-radius: 6px;
    font-family: 'Monaco', 'Courier New', monospace;
    font-size: 0.85em;
    line-height: 1.4;
    overflow-x: auto;
}

/* Code snippets in viewers */
.code-snippet {
    background: #1e293b;
    color: #94a3b8;
    padding: 8px 12px;
    border-radius: 4px;
    font-family: 'Monaco', 'Courier New', monospace;
    font-size: 0.9em;
    margin: 5px 0;
    overflow-x: auto;
    max-width: 100%;
}

/* Animation for active items */
@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.7;
    }
}