/* ===== Decision Tree Visualization — v2.0.0 ===== */
/* Warm dark theme · Neural Flow design             */
/* vis-network graph + activity panel               */

/* ─── Overlay ─── */
#decisionTreeOverlay {
    position: fixed;
    inset: 0;
    z-index: 10002;
    background: rgba(0, 0, 0, 0.55);
    backdrop-filter: blur(4px);
    display: none;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    -webkit-font-smoothing: antialiased;
}
#decisionTreeOverlay.show { display: flex; }

/* ─── Container ─── */
.dt-container {
    display: flex;
    flex-direction: column;
    width: 100%;
    height: 100%;
    background: #1c1a20;
}

/* ─── Top bar ─── */
.dt-topbar {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 16px;
    border-bottom: 1px solid rgba(232, 227, 219, 0.07);
    background: rgba(255, 250, 243, 0.02);
    min-height: 44px;
    flex-shrink: 0;
    user-select: none;
}
.dt-topbar-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    font-weight: 600;
    color: #e8e3db;
    white-space: nowrap;
}
.dt-topbar-title svg { flex-shrink: 0; color: #c9995e; }

.dt-progress-wrapper {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 120px;
}
.dt-progress-bar {
    flex: 1;
    height: 3px;
    background: rgba(232, 227, 219, 0.07);
    border-radius: 2px;
    overflow: hidden;
}
.dt-progress-fill {
    height: 100%;
    border-radius: 2px;
    background: #5db87a;
    transition: width 0.5s ease, background-color 0.5s ease;
    width: 0%;
}
.dt-progress-text {
    font-size: 11px;
    color: #948e84;
    min-width: 36px;
    text-align: right;
    white-space: nowrap;
}
.dt-status-badge {
    font-size: 10px;
    padding: 2px 8px;
    border-radius: 4px;
    font-weight: 500;
    white-space: nowrap;
    letter-spacing: 0.2px;
}
.dt-status-running   { background: rgba(201, 153, 94, 0.12); color: #c9995e; }
.dt-status-completed { background: rgba(93, 184, 122, 0.12); color: #5db87a; }
.dt-status-failed    { background: rgba(212, 112, 106, 0.12); color: #d4706a; }
.dt-status-awaiting  { background: rgba(201, 153, 94, 0.12); color: #c9995e; }

.dt-close-btn {
    background: none;
    border: none;
    cursor: pointer;
    color: #6b6560;
    padding: 4px 6px;
    border-radius: 4px;
    font-size: 20px;
    line-height: 1;
    transition: color 0.15s, background 0.15s;
}
.dt-close-btn:hover { background: rgba(232, 227, 219, 0.07); color: #e8e3db; }

/* ─── Body ─── */
.dt-body {
    display: flex;
    flex: 1;
    overflow: hidden;
    position: relative;
}

/* Graph */
.dt-graph {
    flex: 1;
    position: relative;
    background: #1c1a20;
    background-image:
        radial-gradient(circle, rgba(232, 227, 219, 0.03) 1px, transparent 1px);
    background-size: 24px 24px;
}
.dt-graph canvas:focus { outline: none; }

/* ─── Controls ─── */
.dt-controls {
    position: absolute;
    bottom: 12px;
    left: 12px;
    display: flex;
    gap: 4px;
    z-index: 10;
}
.dt-control-btn {
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 250, 243, 0.04);
    border: 1px solid rgba(232, 227, 219, 0.07);
    border-radius: 6px;
    cursor: pointer;
    color: #948e84;
    backdrop-filter: blur(8px);
    transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.dt-control-btn:hover {
    background: rgba(255, 250, 243, 0.08);
    color: #e8e3db;
    border-color: rgba(232, 227, 219, 0.13);
}

/* ─── Activity Panel (right overlay on graph) ─── */
.dt-activity-panel {
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    width: 280px;
    background: rgba(28, 26, 32, 0.88);
    backdrop-filter: blur(12px);
    border-left: 1px solid rgba(232, 227, 219, 0.05);
    display: flex;
    flex-direction: column;
    z-index: 11;
    overflow: hidden;
    transition: width 0.25s ease, opacity 0.25s ease;
}
.dt-activity-panel.collapsed {
    width: 36px;
    overflow: hidden;
}
.dt-activity-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    border-bottom: 1px solid rgba(232, 227, 219, 0.05);
    flex-shrink: 0;
    min-height: 40px;
}
.dt-activity-header-title {
    font-size: 11px;
    font-weight: 600;
    color: #948e84;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    white-space: nowrap;
    flex: 1;
}
.dt-activity-panel.collapsed .dt-activity-header-title,
.dt-activity-panel.collapsed .dt-activity-body { display: none; }
.dt-activity-toggle {
    background: none;
    border: none;
    cursor: pointer;
    color: #6b6560;
    padding: 2px;
    border-radius: 3px;
    line-height: 1;
    transition: color 0.15s;
    flex-shrink: 0;
}
.dt-activity-toggle:hover { color: #e8e3db; }

.dt-activity-body {
    flex: 1;
    overflow-y: auto;
    padding: 8px 0;
}

.dt-activity-item {
    padding: 8px 12px;
    border-bottom: 1px solid rgba(232, 227, 219, 0.03);
    animation: dt-fadeIn 0.3s ease;
}
.dt-activity-item:last-child { border-bottom: none; }
.dt-activity-time {
    font-size: 9px;
    color: #6b6560;
    font-family: 'SF Mono', 'Fira Code', monospace;
    margin-bottom: 3px;
}
.dt-activity-text {
    font-size: 11px;
    color: #948e84;
    line-height: 1.45;
    word-break: break-word;
}
.dt-activity-item.active .dt-activity-text {
    color: #e8e3db;
}
.dt-activity-item.active {
    background: rgba(201, 153, 94, 0.06);
    border-left: 2px solid #c9995e;
    padding-left: 10px;
}

/* Typing indicator */
.dt-activity-typing {
    display: inline-flex;
    gap: 3px;
    margin-left: 4px;
    vertical-align: middle;
}
.dt-activity-typing span {
    width: 3px;
    height: 3px;
    background: #c9995e;
    border-radius: 50%;
    animation: dt-typingDot 1.2s ease infinite;
}
.dt-activity-typing span:nth-child(2) { animation-delay: 0.15s; }
.dt-activity-typing span:nth-child(3) { animation-delay: 0.3s; }
@keyframes dt-typingDot {
    0%, 60%, 100% { opacity: 0.2; transform: scale(0.8); }
    30% { opacity: 1; transform: scale(1.1); }
}

@keyframes dt-fadeIn {
    from { opacity: 0; transform: translateY(-4px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ─── Sidebar (node details) ─── */
.dt-sidebar {
    width: 360px;
    border-left: 1px solid rgba(232, 227, 219, 0.07);
    background: #1e1c22;
    overflow-y: auto;
    display: none;
    flex-direction: column;
    flex-shrink: 0;
}
.dt-sidebar.open { display: flex; }

.dt-sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    border-bottom: 1px solid rgba(232, 227, 219, 0.07);
    flex-shrink: 0;
}
.dt-sidebar-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    font-weight: 600;
    color: #e8e3db;
}
.dt-type-badge {
    font-size: 10px;
    padding: 1px 6px;
    border-radius: 3px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}
.dt-sidebar-close {
    background: none;
    border: none;
    cursor: pointer;
    color: #6b6560;
    padding: 2px 4px;
    border-radius: 4px;
    font-size: 16px;
    line-height: 1;
    transition: color 0.15s;
}
.dt-sidebar-close:hover { color: #e8e3db; background: rgba(232, 227, 219, 0.07); }

.dt-sidebar-body {
    flex: 1;
    overflow-y: auto;
    padding: 12px 14px;
}

/* ─── Detail sections ─── */
.dt-section {
    margin-bottom: 16px;
}
.dt-section-title {
    font-size: 10px;
    font-weight: 600;
    color: #6b6560;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 6px;
}
.dt-row {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding: 3px 0;
    font-size: 12px;
}
.dt-row-label { color: #948e84; }
.dt-row-value { color: #e8e3db; font-weight: 500; text-align: right; max-width: 60%; word-break: break-word; }

.dt-content-block {
    font-size: 12px;
    color: #e8e3db;
    line-height: 1.5;
    background: rgba(255, 250, 243, 0.03);
    padding: 8px 10px;
    border-radius: 6px;
    border: 1px solid rgba(232, 227, 219, 0.07);
    max-height: 180px;
    overflow-y: auto;
    word-break: break-word;
    white-space: pre-wrap;
}

/* Fill bar */
.dt-fill-bar {
    height: 3px;
    background: rgba(232, 227, 219, 0.07);
    border-radius: 2px;
    margin-top: 6px;
    overflow: hidden;
}
.dt-fill-inner {
    height: 100%;
    border-radius: 2px;
    transition: width 0.3s;
}

/* ─── Connected nodes ─── */
.dt-connected-node {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 5px 8px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    color: #e8e3db;
    transition: background 0.12s;
}
.dt-connected-node:hover { background: rgba(255, 250, 243, 0.05); }
.dt-connected-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}
.dt-connected-label { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dt-connected-type { font-size: 10px; color: #6b6560; }

/* ─── LLM Calls ─── */
.dt-llm-call {
    padding: 8px 10px;
    margin-bottom: 6px;
    background: rgba(255, 250, 243, 0.03);
    border: 1px solid rgba(232, 227, 219, 0.07);
    border-radius: 6px;
    cursor: pointer;
    font-size: 12px;
    transition: border-color 0.12s, background 0.12s;
}
.dt-llm-call:hover { border-color: rgba(232, 227, 219, 0.13); background: rgba(255, 250, 243, 0.05); }
.dt-llm-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 3px;
}
.dt-llm-purpose { font-weight: 500; color: #e8e3db; }
.dt-llm-model {
    font-size: 10px;
    color: #948e84;
    background: rgba(255, 250, 243, 0.04);
    padding: 1px 6px;
    border-radius: 3px;
}
.dt-llm-meta {
    display: flex;
    gap: 10px;
    font-size: 11px;
    color: #6b6560;
}
.dt-llm-expanded {
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid rgba(232, 227, 219, 0.07);
}
.dt-llm-messages {
    font-size: 11px;
    font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
    background: rgba(0, 0, 0, 0.2);
    color: #e8e3db;
    padding: 10px 12px;
    border-radius: 4px;
    max-height: 280px;
    overflow-y: auto;
    white-space: pre-wrap;
    word-break: break-word;
    line-height: 1.5;
}
.dt-llm-msg-role {
    color: #c9995e;
    font-weight: 600;
    display: block;
    margin-top: 6px;
}
.dt-llm-msg-role:first-child { margin-top: 0; }

/* ─── Legend ─── */
.dt-legend {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 5px 16px;
    border-top: 1px solid rgba(232, 227, 219, 0.05);
    background: rgba(255, 250, 243, 0.02);
    overflow-x: auto;
    flex-shrink: 0;
}
.dt-legend-item {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 10px;
    color: #6b6560;
    white-space: nowrap;
}
.dt-legend-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    flex-shrink: 0;
}

/* ─── Empty state ─── */
.dt-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: #6b6560;
    gap: 10px;
    padding: 40px;
    text-align: center;
}
.dt-empty svg { opacity: 0.2; color: #948e84; }
.dt-empty-text { font-size: 14px; color: #948e84; }
.dt-empty-sub { font-size: 12px; color: #6b6560; }

/* ─── Loading ─── */
.dt-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: #948e84;
    gap: 8px;
    font-size: 13px;
}
@keyframes dt-spin { to { transform: rotate(360deg); } }
.dt-spinner { animation: dt-spin 0.8s linear infinite; }

/* ─── Connection status ─── */
.dt-conn-status {
    position: absolute;
    top: 8px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 10px;
    padding: 3px 10px;
    border-radius: 4px;
    z-index: 10;
    display: none;
    backdrop-filter: blur(6px);
}
.dt-conn-lost {
    display: block;
    background: rgba(212, 112, 106, 0.12);
    color: #d4706a;
}
.dt-conn-ok {
    display: block;
    background: rgba(93, 184, 122, 0.12);
    color: #5db87a;
}

/* ─── Minimap hint ─── */
.dt-minimap-hint {
    position: absolute;
    bottom: 12px;
    right: 12px;
    font-size: 10px;
    color: #6b6560;
    z-index: 8;
    pointer-events: none;
    opacity: 0.5;
}

/* ─── Scrollbars ─── */
.dt-sidebar::-webkit-scrollbar,
.dt-sidebar-body::-webkit-scrollbar,
.dt-content-block::-webkit-scrollbar,
.dt-llm-messages::-webkit-scrollbar,
.dt-legend::-webkit-scrollbar,
.dt-activity-body::-webkit-scrollbar { width: 4px; height: 4px; }

.dt-sidebar::-webkit-scrollbar-thumb,
.dt-sidebar-body::-webkit-scrollbar-thumb,
.dt-content-block::-webkit-scrollbar-thumb,
.dt-llm-messages::-webkit-scrollbar-thumb,
.dt-legend::-webkit-scrollbar-thumb,
.dt-activity-body::-webkit-scrollbar-thumb { background: rgba(232, 227, 219, 0.08); border-radius: 3px; }

.dt-sidebar::-webkit-scrollbar-thumb:hover,
.dt-sidebar-body::-webkit-scrollbar-thumb:hover,
.dt-activity-body::-webkit-scrollbar-thumb:hover { background: rgba(232, 227, 219, 0.15); }
