/* ── Agent Chat Widget ───────────────────────────────────────── */
.agent-chat-widget {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 420px;
    max-height: 600px;
    background: var(--bs-body-bg, #fff);
    border: 1px solid var(--bs-border-color, #dee2e6);
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0,0,0,.12);
    display: flex;
    flex-direction: column;
    z-index: 1050;
    overflow: hidden;
}

.agent-chat-header {
    padding: 10px 16px;
    border-bottom: 1px solid var(--bs-border-color, #eaecef);
    display: flex;
    justify-content: space-between;
    align-items: center;
    user-select: none;
    flex-shrink: 0;
}

.agent-chat-header h6 {
    margin: 0;
    font-size: .95rem;
}

.agent-status {
    font-size: .75rem;
    color: var(--bs-secondary-color, #6c757d);
}

.agent-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 12px 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-height: 0;
}

.chat-message {
    padding: 8px 12px;
    border-radius: 8px;
    font-size: .875rem;
    line-height: 1.5;
    max-width: 90%;
    word-break: break-word;
}

.chat-message.user {
    align-self: flex-end;
    background: var(--bs-primary, #0d6efd);
    color: #fff;
}

.chat-message.assistant {
    align-self: flex-start;
    background: var(--bs-light, #f8f9fa);
    color: var(--bs-body-color, #212529);
}

/* ── Thinking Bar ────────────────────────────────────────────── */
.agent-thinking-bar {
    padding: 8px 16px;
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--bs-secondary-color, #6c757d);
    font-size: .8rem;
    flex-shrink: 0;
}

.agent-thinking-dots {
    display: flex;
    gap: 4px;
}

.agent-thinking-dots span {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--bs-primary, #0d6efd);
    animation: agent-dot-bounce 1.4s infinite ease-in-out both;
}

.agent-thinking-dots span:nth-child(1) { animation-delay: -.32s; }
.agent-thinking-dots span:nth-child(2) { animation-delay: -.16s; }
.agent-thinking-dots span:nth-child(3) { animation-delay: 0s; }

@keyframes agent-dot-bounce {
    0%, 80%, 100% { transform: scale(0); opacity: .5; }
    40% { transform: scale(1); opacity: 1; }
}

/* ── Input ───────────────────────────────────────────────────── */
.agent-chat-input {
    padding: 10px 16px;
    border-top: 1px solid var(--bs-border-color, #eaecef);
    display: flex;
    gap: 8px;
    align-items: flex-end;
    flex-shrink: 0;
}

.agent-chat-input textarea {
    flex: 1;
    border: 1px solid var(--bs-border-color, #dee2e6);
    border-radius: 8px;
    padding: 8px 12px;
    font-size: .875rem;
    resize: none;
    min-height: 38px;
    max-height: 120px;
    background: var(--bs-body-bg, #fff);
    color: var(--bs-body-color, #212529);
}

.agent-chat-input textarea:focus {
    outline: none;
    border-color: var(--bs-primary, #0d6efd);
    box-shadow: 0 0 0 2px rgba(13,110,253,.15);
}

/* ── Advice / Diff Cards ──────────────────────────────────────── */
.advice-card {
    border: 1px solid var(--bs-border-color, #dee2e6);
    border-radius: 8px;
    padding: 12px;
    background: var(--bs-light, #f8f9fa);
    margin-top: 4px;
}

.advice-header {
    font-size: .8rem;
    color: var(--bs-secondary-color, #6c757d);
    margin-bottom: 8px;
    font-weight: 600;
}

.advice-diff {
    font-family: 'Cascadia Code', 'Consolas', 'Courier New', monospace;
    font-size: .78rem;
    border-radius: 6px;
    overflow: hidden;
    margin-bottom: 10px;
    border: 1px solid var(--bs-border-color, #dee2e6);
}

.diff-hunk-header {
    background: #f0f4f8;
    color: #0366d6;
    padding: 4px 10px;
    font-size: .75rem;
    border-bottom: 1px solid #e1e4e8;
}

.diff-line {
    padding: 1px 10px;
    white-space: pre-wrap;
    word-break: break-all;
}

.diff-add { background: #e6ffec; color: #1a7f37; }
.diff-remove { background: #ffebe9; color: #cf222e; }
.diff-context { background: #fff; color: var(--bs-body-color, #212529); }

.advice-params {
    font-size: .8rem;
    margin-bottom: 8px;
}

.advice-param-row {
    display: flex;
    gap: 8px;
    padding: 3px 0;
}

.advice-param-key {
    font-weight: 600;
    color: var(--bs-secondary-color, #6c757d);
    min-width: 80px;
}

.advice-param-value {
    color: var(--bs-body-color, #212529);
    word-break: break-all;
}

.advice-actions {
    display: flex;
    gap: 8px;
}

.advice-result {
    margin-top: 8px;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: .75rem;
    text-align: center;
}

.advice-result.success { background: #d4edda; color: #155724; }
.advice-result.failure { background: #f8d7da; color: #721c24; }
