/* Ask AI widget.
 *
 * Scoped under .docs-agent so nothing here can reach the documentation page,
 * and sized in relative units so the panel stays usable at phone widths.
 */

.docs-agent-launcher {
    position: fixed;
    right: 1.25rem;
    bottom: 1.25rem;
    z-index: 30;
    padding: 0.65rem 1.15rem;
    border: none;
    border-radius: 2rem;
    background: var(--md-primary-fg-color, #2094f3);
    color: #fff;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.25);
}

.docs-agent-launcher:hover {
    filter: brightness(1.08);
}

.docs-agent-panel {
    position: fixed;
    right: 1.25rem;
    bottom: 5rem;
    z-index: 31;
    display: flex;
    flex-direction: column;
    width: min(26rem, calc(100vw - 2.5rem));
    max-height: min(34rem, calc(100vh - 8rem));
    border: 1px solid var(--md-default-fg-color--lightest, #e0e0e0);
    border-radius: 0.5rem;
    background: var(--md-default-bg-color, #fff);
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.2);
    overflow: hidden;
}

.docs-agent-panel[hidden] {
    display: none;
}

.docs-agent-panel > header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.6rem 0.9rem;
    border-bottom: 1px solid var(--md-default-fg-color--lightest, #e0e0e0);
}

.docs-agent-panel > header h2 {
    margin: 0;
    font-size: 0.85rem;
    font-weight: 700;
}

.docs-agent-close {
    border: none;
    background: none;
    font-size: 1.2rem;
    line-height: 1;
    cursor: pointer;
    color: var(--md-default-fg-color--light, #666);
}

.docs-agent-log {
    flex: 1;
    overflow-y: auto;
    padding: 0.75rem 0.9rem;
    font-size: 0.75rem;
    line-height: 1.6;
}

.docs-agent-message {
    margin-bottom: 0.9rem;
}

.docs-agent-message p {
    margin: 0 0 0.5rem;
}

.docs-agent-message ul,
.docs-agent-message ol {
    margin: 0 0 0.5rem;
    padding-left: 1.15rem;
}

.docs-agent-message pre {
    margin: 0 0 0.5rem;
    padding: 0.5rem 0.6rem;
    border-radius: 0.25rem;
    background: var(--md-code-bg-color, #f5f5f5);
    /* Long commands scroll inside the block rather than widening the panel. */
    overflow-x: auto;
}

.docs-agent-message code {
    font-size: 0.9em;
}

.docs-agent-user {
    padding: 0.4rem 0.6rem;
    border-radius: 0.35rem;
    background: var(--md-code-bg-color, #f5f5f5);
    font-weight: 600;
}

.docs-agent-status {
    color: var(--md-default-fg-color--light, #666);
    font-style: italic;
}

.docs-agent-sources {
    margin-top: 0.5rem;
    padding-top: 0.5rem;
    border-top: 1px solid var(--md-default-fg-color--lightest, #e0e0e0);
}

.docs-agent-sources p {
    margin: 0 0 0.25rem;
    font-weight: 600;
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: var(--md-default-fg-color--light, #666);
}

.docs-agent-sources ul {
    margin: 0;
    padding-left: 1.15rem;
    word-break: break-word;
}

.docs-agent-form {
    display: flex;
    gap: 0.4rem;
    padding: 0.6rem 0.9rem;
    border-top: 1px solid var(--md-default-fg-color--lightest, #e0e0e0);
}

.docs-agent-form input {
    flex: 1;
    min-width: 0;
    padding: 0.4rem 0.55rem;
    border: 1px solid var(--md-default-fg-color--lighter, #ccc);
    border-radius: 0.25rem;
    background: var(--md-default-bg-color, #fff);
    color: inherit;
    font-size: 0.75rem;
}

.docs-agent-form button {
    padding: 0.4rem 0.8rem;
    border: none;
    border-radius: 0.25rem;
    background: var(--md-primary-fg-color, #2094f3);
    color: #fff;
    font-size: 0.75rem;
    font-weight: 600;
    cursor: pointer;
}

.docs-agent-form button:disabled {
    opacity: 0.6;
    cursor: default;
}

.docs-agent-footer {
    margin: 0;
    padding: 0 0.9rem 0.6rem;
    font-size: 0.62rem;
    line-height: 1.4;
    color: var(--md-default-fg-color--light, #666);
}

@media screen and (max-width: 30rem) {
    .docs-agent-panel {
        right: 0.75rem;
        left: 0.75rem;
        bottom: 4.5rem;
        width: auto;
    }
}

/* The Mat3ra mark next to the "Ask AI" label, in both the launcher and the
 * panel header. Drawn in currentColor, so it inherits whatever it sits on. */
.docs-agent-mark {
    display: inline-flex;
    align-items: center;
    margin-right: 0.4rem;
    vertical-align: -0.1em;
}

.docs-agent-launcher .docs-agent-mark svg {
    width: 0.85rem;
    height: 0.85rem;
}

.docs-agent-panel > header h2 {
    display: flex;
    align-items: center;
}

/* Anything clickable reads as a link: the documentation's own link colour where
 * the theme defines one, and a conventional blue anywhere else the widget is
 * embedded. Source URLs are long, so they wrap rather than widen the panel. */
.docs-agent-message a,
.docs-agent-term {
    color: var(--md-typeset-a-color, #1a73e8);
    text-decoration: none;
    word-break: break-word;
}

.docs-agent-message a:hover,
.docs-agent-message a:focus,
.docs-agent-term:hover,
.docs-agent-term:focus {
    text-decoration: underline;
}

/* Header controls: ending a conversation and closing the panel. */
.docs-agent-controls {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.docs-agent-clear {
    border: none;
    background: none;
    padding: 0;
    font-size: 0.68rem;
    cursor: pointer;
    color: var(--md-default-fg-color--light, #666);
}

.docs-agent-clear:hover,
.docs-agent-clear:focus {
    text-decoration: underline;
}
