/* ===== Copilot Chat Layout ===== */
.copilot-layout {
    display: flex;
    height: calc(100vh - 120px);
    gap: 0;
    background: var(--bg-primary);
    border-radius: 12px;
    overflow: hidden;
    border: 1px solid var(--border-color);
}

/* Sidebar */
.jobs-sidebar {
    width: 280px;
    background: var(--bg-secondary);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
}

.sidebar-header {
    padding: 16px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.sidebar-header h3 {
    margin: 0;
    font-size: 16px;
    color: var(--text-primary);
}

.job-stats {
    display: flex;
    gap: 6px;
}

.stat-badge {
    font-size: 11px;
    padding: 2px 8px;
    border-radius: 10px;
    font-weight: 600;
}

.stat-badge.completed { background: rgba(34, 197, 94, 0.2); color: #22c55e; }
.stat-badge.failed { background: rgba(239, 68, 68, 0.2); color: #ef4444; }
.stat-badge.running { background: rgba(59, 130, 246, 0.2); color: #3b82f6; }

.jobs-list {
    flex: 1;
    overflow-y: auto;
    padding: 8px;
}

.job-item {
    display: flex;
    gap: 12px;
    padding: 12px;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.2s;
    margin-bottom: 4px;
}

.job-item:hover {
    background: var(--bg-accent);
}

.job-item.selected {
    background: var(--bg-accent);
    border-left: 3px solid var(--accent-blue);
}

.job-item-icon {
    font-size: 18px;
}

.job-item-info {
    flex: 1;
    min-width: 0;
}

.job-item-title {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.job-item-meta {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 2px;
}

/* Chat Panel */
.chat-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: var(--bg-primary);
}

.chat-empty {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    padding: 40px;
    text-align: center;
}

.chat-empty .empty-icon {
    font-size: 48px;
    margin-bottom: 16px;
}

.chat-empty h3 {
    margin: 0 0 8px 0;
    color: var(--text-primary);
}

.chat-loading {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
}

.chat-container {
    display: flex;
    flex-direction: column;
    height: 100%;
}

/* Chat Header */
.chat-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--bg-secondary);
}

.chat-header h2 {
    margin: 0;
    font-size: 18px;
    color: var(--text-primary);
}

.chat-header-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.chat-status {
    font-size: 12px;
    padding: 4px 10px;
    border-radius: 12px;
    font-weight: 500;
}

.chat-status.completed { background: rgba(34, 197, 94, 0.2); color: #22c55e; }
.chat-status.failed { background: rgba(239, 68, 68, 0.2); color: #ef4444; }
.chat-status.running { background: rgba(59, 130, 246, 0.2); color: #3b82f6; }
.chat-status.pending { background: rgba(156, 163, 175, 0.2); color: #9ca3af; }

.chat-header-meta {
    font-size: 13px;
    color: var(--text-muted);
}

/* Chat Messages */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.message {
    display: flex;
    gap: 12px;
    max-width: 85%;
}

.message.hex {
    align-self: flex-start;
}

.message.developer {
    align-self: flex-start;
}

.message-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    overflow: hidden;
    flex-shrink: 0;
}

.message-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.message-content {
    flex: 1;
    min-width: 0;
}

.message-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 6px;
}

.message-author {
    font-weight: 600;
    font-size: 14px;
    color: var(--text-primary);
}

.message.hex .message-author { color: #8b5cf6; }
.message.developer .message-author { color: #22c55e; }

.message-role {
    font-size: 11px;
    color: var(--text-muted);
    background: var(--bg-accent);
    padding: 2px 8px;
    border-radius: 10px;
}

.message-time {
    font-size: 11px;
    color: var(--text-muted);
}

.message-bubble {
    background: var(--bg-secondary);
    border-radius: 12px;
    padding: 12px 16px;
    border: 1px solid var(--border-color);
}

.message.hex .message-bubble {
    background: rgba(139, 92, 246, 0.1);
    border-color: rgba(139, 92, 246, 0.2);
}

.message.developer .message-bubble {
    background: rgba(34, 197, 94, 0.1);
    border-color: rgba(34, 197, 94, 0.2);
}

.message-text {
    font-size: 14px;
    line-height: 1.6;
    color: var(--text-primary);
}

.message-text code {
    background: var(--bg-accent);
    padding: 2px 6px;
    border-radius: 4px;
    font-family: "SF Mono", Monaco, monospace;
    font-size: 13px;
}

/* Typing indicator */
.message-typing {
    display: flex;
    gap: 4px;
    padding: 4px 0;
}

.message-typing span {
    width: 8px;
    height: 8px;
    background: var(--text-muted);
    border-radius: 50%;
    animation: typing 1.4s infinite;
}

.message-typing span:nth-child(2) { animation-delay: 0.2s; }
.message-typing span:nth-child(3) { animation-delay: 0.4s; }

@keyframes typing {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
    30% { transform: translateY(-4px); opacity: 1; }
}

/* System Messages */
.message.system {
    align-self: center;
    max-width: 100%;
    background: var(--bg-secondary);
    border-radius: 8px;
    padding: 12px 20px;
    display: flex;
    align-items: center;
    gap: 12px;
    border: 1px solid var(--border-color);
}

.message.system.success {
    background: rgba(34, 197, 94, 0.1);
    border-color: rgba(34, 197, 94, 0.3);
}

.message.system.error {
    background: rgba(239, 68, 68, 0.1);
    border-color: rgba(239, 68, 68, 0.3);
}

.system-icon {
    font-size: 24px;
}

.system-content strong {
    display: block;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.system-details {
    font-size: 13px;
    color: var(--text-muted);
}

.system-details code {
    background: var(--bg-accent);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 12px;
}

/* Chat Footer */
.chat-footer {
    border-top: 1px solid var(--border-color);
    padding: 12px 20px;
    background: var(--bg-secondary);
}

.log-details {
    background: var(--bg-primary);
    border-radius: 8px;
    border: 1px solid var(--border-color);
}

.log-details summary {
    padding: 12px 16px;
    cursor: pointer;
    font-size: 14px;
    color: var(--text-secondary);
    user-select: none;
}

.log-details summary:hover {
    color: var(--text-primary);
}

.log-details[open] summary {
    border-bottom: 1px solid var(--border-color);
}

.log-content {
    margin: 0;
    padding: 16px;
    font-family: "SF Mono", Monaco, monospace;
    font-size: 12px;
    line-height: 1.6;
    color: var(--text-secondary);
    max-height: 300px;
    overflow: auto;
    white-space: pre-wrap;
    word-wrap: break-word;
}
