/* retoor <retoor@molodetz.nl> */

dp-docs-chat {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    min-height: 60vh;
}

.docs-chat-log {
    display: flex;
    flex-direction: column;
    gap: 0.875rem;
    overflow-y: auto;
    padding: 0.25rem;
    flex: 1;
    max-height: 65vh;
}

.docs-chat-msg {
    display: flex;
}

.docs-chat-msg.user {
    justify-content: flex-end;
}

.docs-chat-msg.agent,
.docs-chat-msg.error {
    justify-content: flex-start;
}

.docs-chat-bubble {
    max-width: 85%;
    padding: 0.75rem 1rem;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    font-size: 0.9375rem;
    line-height: 1.6;
    color: var(--text-primary);
    overflow-wrap: anywhere;
}

.docs-chat-msg.user .docs-chat-bubble {
    background: var(--accent-light);
    border-color: var(--accent);
    border-bottom-right-radius: var(--radius);
    white-space: pre-wrap;
}

.docs-chat-msg.agent .docs-chat-bubble {
    background: var(--bg-card);
    border-bottom-left-radius: var(--radius);
}

.docs-chat-msg.error .docs-chat-bubble {
    background: var(--bg-card);
    border-color: var(--danger);
    color: var(--danger);
}

.docs-chat-bubble > :first-child {
    margin-top: 0;
}

.docs-chat-bubble > :last-child {
    margin-bottom: 0;
}

.docs-chat-bubble p {
    margin: 0 0 0.5rem;
}

.docs-chat-bubble h1,
.docs-chat-bubble h2,
.docs-chat-bubble h3,
.docs-chat-bubble h4 {
    margin: 0.75rem 0 0.5rem;
    font-size: 1rem;
    color: var(--text-primary);
}

.docs-chat-bubble ul,
.docs-chat-bubble ol {
    margin: 0.5rem 0;
    padding-left: 1.5rem;
}

.docs-chat-bubble li {
    margin-bottom: 0.25rem;
}

.docs-chat-bubble a {
    color: var(--accent);
    text-decoration: none;
}

.docs-chat-bubble a:hover {
    text-decoration: underline;
}

.docs-chat-bubble .md-code {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0.05rem 0.3rem;
    font-family: var(--font-mono);
    font-size: 0.85em;
}

.docs-chat-bubble .md-codewrap {
    position: relative;
    margin: 0.5rem 0;
}

.docs-chat-bubble .md-pre {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0.75rem 0.875rem;
    overflow-x: auto;
    font-size: 0.85rem;
    line-height: 1.5;
}

.docs-chat-bubble .md-pre code {
    background: none;
    border: none;
    padding: 0;
    font-family: var(--font-mono);
}

.docs-chat-bubble .md-copy {
    position: absolute;
    top: 0.375rem;
    right: 0.375rem;
    opacity: 0;
    padding: 0.125rem 0.5rem;
    font-size: 0.75rem;
    color: var(--text-secondary);
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    cursor: pointer;
    transition: opacity 0.15s ease;
}

.docs-chat-bubble .md-codewrap:hover .md-copy,
.docs-chat-bubble .md-copy:focus-visible {
    opacity: 1;
}

.docs-chat-bubble .md-copy:hover {
    color: var(--text-primary);
    border-color: var(--accent);
}

.docs-chat-bubble .md-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
    margin: 0.5rem 0;
}

.docs-chat-bubble .md-table th,
.docs-chat-bubble .md-table td {
    border: 1px solid var(--border);
    padding: 0.375rem 0.5rem;
    text-align: left;
}

.docs-chat-bubble .md-table th {
    background: var(--bg-card-hover);
    color: var(--text-primary);
}

.docs-chat-bubble .md-img {
    max-width: 100%;
    border-radius: var(--radius);
}

.docs-chat-step {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.8125rem;
    color: var(--text-muted);
    padding: 0.1rem 0.25rem;
}

.docs-chat-step-icon {
    flex: 0 0 auto;
    width: 0.85rem;
    height: 0.85rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
    font-size: 0.8rem;
    line-height: 1;
}

.docs-chat-step.pending .docs-chat-step-icon {
    border: 2px solid var(--border-light);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: docs-chat-spin 0.7s linear infinite;
}

.docs-chat-step.done {
    color: var(--text-secondary);
}

.docs-chat-step.done .docs-chat-step-icon::before {
    content: "\2713";
    color: var(--success);
}

.docs-chat-step.error .docs-chat-step-icon::before {
    content: "\2717";
    color: var(--danger);
}

.docs-chat-step-label {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

@keyframes docs-chat-spin {
    to {
        transform: rotate(360deg);
    }
}

.docs-chat-note {
    font-size: 0.78rem;
    font-style: italic;
    color: var(--text-muted);
    padding: 0.1rem 0.25rem;
}

.docs-chat-note.new {
    color: var(--accent);
    font-style: normal;
}

.docs-chat-status {
    font-size: 0.8125rem;
    color: var(--text-muted);
    padding-left: 0.25rem;
    min-height: 1rem;
}

.docs-chat-status:not(:empty)::after {
    content: " …";
    animation: docs-chat-blink 1.2s steps(1) infinite;
}

@keyframes docs-chat-blink {
    50% {
        opacity: 0.3;
    }
}

.docs-chat-input {
    display: flex;
    gap: 0.5rem;
    align-items: flex-end;
    border-top: 1px solid var(--border);
    padding-top: 0.75rem;
}

.docs-chat-field {
    flex: 1;
    resize: none;
    background: var(--bg-input);
    color: var(--text-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0.625rem 0.75rem;
    font: inherit;
    font-size: 0.9375rem;
    line-height: 1.5;
    max-height: 160px;
}

.docs-chat-field:focus {
    outline: none;
    border-color: var(--accent);
}

.docs-chat-send {
    background: var(--accent);
    color: var(--on-accent);
    border: none;
    border-radius: var(--radius);
    padding: 0.625rem 1.25rem;
    font: inherit;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
}

.docs-chat-send:hover {
    filter: brightness(1.08);
}

.docs-chat-send:disabled {
    opacity: 0.6;
    cursor: default;
}

@media (max-width: 768px) {
    .docs-chat-bubble {
        max-width: 100%;
    }
}
