/* ═══════════════════════════════════════════════════════════════
   LIVE PANEL - Activity & Diff Viewer
   ═══════════════════════════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=IBM+Plex+Mono:wght@400;500;600&display=swap');

/* Overlay */
.diff-overlay {
    position: fixed;
    inset: 0;
    z-index: 9999;
    background: rgba(0, 0, 0, 0.9);
    backdrop-filter: blur(8px);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.25s ease, visibility 0.25s ease;
}
.diff-overlay.active {
    opacity: 1;
    visibility: visible;
}

/* Viewer Container */
.diff-viewer {
    position: absolute;
    inset: 16px;
    display: flex;
    flex-direction: column;
    background: #0d1117;
    border: 1px solid #30363d;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.8);
    transform: scale(0.95) translateY(20px);
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.diff-overlay.active .diff-viewer {
    transform: scale(1) translateY(0);
}

/* Header */
.diff-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 20px;
    background: linear-gradient(180deg, #161b22 0%, #0d1117 100%);
    border-bottom: 1px solid #30363d;
}
.diff-header-left {
    display: flex;
    align-items: center;
    gap: 12px;
}
.diff-logo {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    background: linear-gradient(135deg, #1a1f26 0%, #0d1117 100%);
    border: 1px solid #30363d;
    border-radius: 8px;
}
.diff-logo svg {
    color: #58a6ff;
}
.diff-title {
    display: none;
}

/* Tabs */
.live-tabs {
    display: flex;
    gap: 4px;
    background: rgba(0, 0, 0, 0.3);
    padding: 4px;
    border-radius: 8px;
}
.live-tab {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    background: transparent;
    border: none;
    border-radius: 6px;
    font-family: 'IBM Plex Mono', monospace;
    font-size: 0.8rem;
    font-weight: 500;
    color: #8b949e;
    cursor: pointer;
    transition: all 0.15s ease;
}
.live-tab:hover {
    color: #e6edf3;
    background: rgba(255, 255, 255, 0.05);
}
.live-tab.active {
    color: #e6edf3;
    background: rgba(88, 166, 255, 0.15);
}
.live-tab svg {
    opacity: 0.7;
}
.live-tab.active svg {
    opacity: 1;
    color: #58a6ff;
}

/* Tab Panels */
.live-panel {
    display: none;
    flex: 1;
    overflow: hidden;
}
.live-panel.active {
    display: flex;
}
#panel-activity {
    flex-direction: column;
}
#panel-diff {
    flex-direction: row;
}

/* Activity Panel */
.activity-content {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    font-family: 'IBM Plex Mono', monospace;
    font-size: 13px;
    line-height: 1.6;
}
.activity-empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    text-align: center;
    color: #6e7681;
}
.activity-empty-icon {
    margin-bottom: 16px;
    opacity: 0.3;
}
.activity-empty-state h3 {
    margin: 0 0 8px;
    color: #8b949e;
    font-weight: 500;
}
.activity-empty-state p {
    margin: 0;
    font-size: 12px;
}

/* Activity Log Items */
.activity-item {
    display: flex;
    gap: 12px;
    padding: 12px;
    margin-bottom: 8px;
    background: rgba(22, 27, 34, 0.5);
    border: 1px solid #21262d;
    border-radius: 8px;
}
.activity-item.tool-use {
    border-left: 3px solid #f0883e;
}
.activity-item.tool-result {
    border-left: 3px solid #3fb950;
}
.activity-item.thinking {
    border-left: 3px solid #a371f7;
}
.activity-item.text {
    border-left: 3px solid #58a6ff;
}
.activity-icon {
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    flex-shrink: 0;
}
.activity-item.tool-use .activity-icon { background: rgba(240, 136, 62, 0.15); color: #f0883e; }
.activity-item.tool-result .activity-icon { background: rgba(63, 185, 80, 0.15); color: #3fb950; }
.activity-item.thinking .activity-icon { background: rgba(163, 113, 247, 0.15); color: #a371f7; }
.activity-item.text .activity-icon { background: rgba(88, 166, 255, 0.15); color: #58a6ff; }
.activity-body {
    flex: 1;
    min-width: 0;
}
.activity-title {
    font-weight: 600;
    color: #e6edf3;
    margin-bottom: 4px;
}
.activity-detail {
    color: #8b949e;
    font-size: 12px;
    white-space: pre-wrap;
    word-break: break-word;
}
.activity-detail code {
    background: rgba(110, 118, 129, 0.2);
    padding: 1px 4px;
    border-radius: 3px;
    font-size: 11px;
}

/* Streaming Thinking Block */
.thinking-stream-block {
    margin: 8px 0 12px 0;
    background: linear-gradient(135deg, rgba(163, 113, 247, 0.08) 0%, rgba(88, 166, 255, 0.05) 100%);
    border: 1px solid rgba(163, 113, 247, 0.2);
    border-radius: 8px;
    overflow: hidden;
    animation: thinkingBlockAppear 0.3s ease-out;
}
@keyframes thinkingBlockAppear {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}
.thinking-stream-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    background: rgba(163, 113, 247, 0.1);
    border-bottom: 1px solid rgba(163, 113, 247, 0.15);
    font-size: 12px;
    font-weight: 600;
    color: #a371f7;
}
.thinking-stream-header svg {
    flex-shrink: 0;
}
.thinking-stream-spinner {
    margin-left: auto;
    width: 14px;
    height: 14px;
    border: 2px solid rgba(163, 113, 247, 0.3);
    border-top-color: #a371f7;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}
@keyframes spin {
    to { transform: rotate(360deg); }
}
.thinking-stream-content {
    padding: 12px 16px;
    font-size: 12px;
    line-height: 1.5;
    color: #c9d1d9;
    white-space: pre-wrap;
    word-break: break-word;
}
.thinking-stream-content:empty::before {
    content: 'Starting...';
    color: #6e7681;
    font-style: italic;
}

/* Streaming Text Block */
.text-stream-block {
    margin: 8px 0 12px 0;
    background: linear-gradient(135deg, rgba(88, 166, 255, 0.08) 0%, rgba(63, 185, 80, 0.05) 100%);
    border: 1px solid rgba(88, 166, 255, 0.2);
    border-radius: 8px;
    overflow: hidden;
    animation: thinkingBlockAppear 0.3s ease-out;
}
.text-stream-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    background: rgba(88, 166, 255, 0.1);
    border-bottom: 1px solid rgba(88, 166, 255, 0.15);
    font-size: 12px;
    font-weight: 600;
    color: #58a6ff;
}
.text-stream-header svg {
    flex-shrink: 0;
}
.text-stream-spinner {
    margin-left: auto;
    width: 14px;
    height: 14px;
    border: 2px solid rgba(88, 166, 255, 0.3);
    border-top-color: #58a6ff;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}
.text-stream-content {
    padding: 12px 16px;
    font-size: 12px;
    line-height: 1.5;
    color: #c9d1d9;
    white-space: pre-wrap;
    word-break: break-word;
}
.text-stream-content:empty::before {
    content: 'Starting...';
    color: #6e7681;
    font-style: italic;
}

/* Completed state for streaming blocks */
.thinking-stream-block.completed,
.text-stream-block.completed {
    opacity: 0.7;
}
.thinking-stream-block.completed .thinking-stream-header,
.text-stream-block.completed .text-stream-header {
    background: rgba(63, 185, 80, 0.1);
    color: #3fb950;
}

/* Status Indicator */
.diff-status {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    background: rgba(88, 166, 255, 0.1);
    border: 1px solid rgba(88, 166, 255, 0.2);
    border-radius: 20px;
    font-family: 'IBM Plex Mono', monospace;
    font-size: 0.7rem;
    color: #58a6ff;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}
.diff-status-indicator {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #f0883e;
    animation: statusPulse 2s ease-in-out infinite;
}
.diff-status.connected .diff-status-indicator {
    background: #3fb950;
    animation: none;
}
.diff-status.error .diff-status-indicator {
    background: #f85149;
    animation: none;
}
@keyframes statusPulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.5; transform: scale(0.8); }
}

/* Header Right */
.diff-header-right {
    display: flex;
    align-items: center;
    gap: 16px;
}
.diff-stats {
    display: flex;
    align-items: center;
    gap: 16px;
}
.diff-stat {
    display: flex;
    align-items: center;
    gap: 5px;
    font-family: 'IBM Plex Mono', monospace;
    font-size: 0.8rem;
    color: #8b949e;
}
.diff-stat.files svg { color: #8b949e; }
.diff-stat.insertions { color: #3fb950; }
.diff-stat.insertions .diff-stat-icon { font-weight: 700; font-size: 1rem; }
.diff-stat.deletions { color: #f85149; }
.diff-stat.deletions .diff-stat-icon { font-weight: 700; font-size: 1rem; }
.diff-action-btn, .diff-close-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    background: transparent;
    border: 1px solid #30363d;
    border-radius: 6px;
    color: #8b949e;
    cursor: pointer;
    transition: all 0.15s ease;
}
.diff-action-btn:hover, .diff-close-btn:hover {
    background: #21262d;
    border-color: #8b949e;
    color: #e6edf3;
}
.diff-close-btn:hover {
    border-color: #f85149;
    color: #f85149;
}

/* Body */
.diff-body {
    flex: 1;
    display: flex;
    overflow: hidden;
}

/* Sidebar */
.diff-sidebar {
    width: 280px;
    min-width: 280px;
    background: #0d1117;
    border-right: 1px solid #30363d;
    display: flex;
    flex-direction: column;
}
.diff-sidebar-header {
    padding: 12px 16px;
    font-family: 'IBM Plex Mono', monospace;
    font-size: 0.7rem;
    font-weight: 600;
    color: #8b949e;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    border-bottom: 1px solid #21262d;
}
.diff-file-list {
    flex: 1;
    overflow-y: auto;
    padding: 8px 0;
    margin: 0;
    list-style: none;
}
.diff-file-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 16px;
    font-family: 'IBM Plex Mono', monospace;
    font-size: 0.75rem;
    color: #e6edf3;
    cursor: pointer;
    transition: background 0.1s ease;
    border-left: 2px solid transparent;
}
.diff-file-item:hover {
    background: #161b22;
}
.diff-file-item.active {
    background: #161b22;
    border-left-color: #58a6ff;
}
.diff-file-icon {
    flex-shrink: 0;
    width: 16px;
    height: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
}
.diff-file-icon.added { color: #3fb950; }
.diff-file-icon.modified { color: #f0883e; }
.diff-file-icon.deleted { color: #f85149; }
.diff-file-name {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.diff-file-path {
    color: #6e7681;
}
.diff-file-stats {
    display: flex;
    gap: 4px;
    font-size: 0.65rem;
}
.diff-file-stats .add { color: #3fb950; }
.diff-file-stats .del { color: #f85149; }
.diff-sidebar-empty {
    padding: 32px 16px;
    text-align: center;
    color: #6e7681;
    font-size: 0.8rem;
}

/* Main Content */
.diff-main {
    flex: 1;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    background: #010409;
}
.diff-content {
    flex: 1;
    overflow: auto;
    font-family: 'IBM Plex Mono', 'JetBrains Mono', monospace;
    font-size: 13px;
    line-height: 1.5;
}
.diff-empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    padding: 48px;
    text-align: center;
}
.diff-empty-icon {
    margin-bottom: 24px;
    color: #30363d;
}
.diff-empty-state h3 {
    margin: 0 0 8px;
    font-family: 'IBM Plex Mono', monospace;
    font-size: 1.1rem;
    font-weight: 600;
    color: #e6edf3;
}
.diff-empty-state p {
    margin: 0;
    max-width: 400px;
    font-size: 0.85rem;
    color: #6e7681;
    line-height: 1.6;
}

/* Footer */
.diff-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 16px;
    background: #161b22;
    border-top: 1px solid #30363d;
    font-family: 'IBM Plex Mono', monospace;
    font-size: 0.7rem;
    color: #6e7681;
}
.diff-footer-left {
    display: flex;
    align-items: center;
    gap: 16px;
}
.diff-footer kbd {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 20px;
    padding: 2px 6px;
    margin-right: 4px;
    background: #21262d;
    border: 1px solid #30363d;
    border-radius: 4px;
    font-size: 0.65rem;
    color: #8b949e;
}
.diff-branch {
    display: flex;
    align-items: center;
    gap: 6px;
    color: #8b949e;
}
.diff-branch::before {
    content: '';
    display: inline-block;
    width: 12px;
    height: 12px;
    background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%238b949e' stroke-width='2'%3E%3Cline x1='6' y1='3' x2='6' y2='15'/%3E%3Ccircle cx='18' cy='6' r='3'/%3E%3Ccircle cx='6' cy='18' r='3'/%3E%3Cpath d='M18 9a9 9 0 0 1-9 9'/%3E%3C/svg%3E") center/contain no-repeat;
}

/* Diff button in status bar */
#diff-btn.has-changes {
    background: rgba(240, 136, 62, 0.15) !important;
    border-color: #f0883e !important;
    color: #f0883e !important;
    opacity: 1 !important;
    animation: diffPulse 2s ease-in-out infinite;
}
@keyframes diffPulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(240, 136, 62, 0.4); }
    50% { box-shadow: 0 0 0 4px rgba(240, 136, 62, 0); }
}

/* GitHub-style Diff Rendering */
.gh-diff-file {
    border: 1px solid #30363d;
    border-radius: 6px;
    margin-bottom: 16px;
    overflow: hidden;
    background: #0d1117;
}
.gh-diff-header {
    background: #161b22;
    padding: 10px 16px;
    font-family: 'IBM Plex Mono', monospace;
    font-size: 13px;
    font-weight: 600;
    color: #e6edf3;
    border-bottom: 1px solid #30363d;
}
.gh-diff-body {
    overflow-x: auto;
}
.gh-diff-table {
    width: 100%;
    border-collapse: collapse;
    font-family: 'IBM Plex Mono', monospace;
    font-size: 13px;
    line-height: 20px;
}
.gh-linenum {
    width: 1%;
    min-width: 44px;
    padding: 0 10px;
    text-align: right;
    color: #6e7681;
    background: #161b22;
    user-select: none;
    vertical-align: top;
    border-right: 1px solid #21262d;
}
.gh-linenum.gh-old { border-right: none; }
.gh-code {
    padding: 0;
    background: #0d1117;
}
.gh-code pre {
    margin: 0;
    padding: 0 16px;
    white-space: pre;
    color: #e6edf3;
}
.gh-line.gh-add .gh-linenum { background: #122117; }
.gh-line.gh-add .gh-code { background: rgba(63, 185, 80, 0.15); }
.gh-line.gh-add .gh-code pre { color: #7ee787; }
.gh-line.gh-del .gh-linenum { background: #2d1b1e; }
.gh-line.gh-del .gh-code { background: rgba(248, 81, 73, 0.15); }
.gh-line.gh-del .gh-code pre { color: #ffa198; }
.gh-hunk-header td {
    background: rgba(56, 139, 253, 0.1);
    color: #58a6ff;
    padding: 8px 16px;
    font-size: 12px;
}

/* Mobile responsive */
@media (max-width: 768px) {
    .diff-viewer { inset: 0; border-radius: 0; }
    .diff-sidebar { display: none; }
    .diff-stats { display: none; }
}
