/* AgentJobWorkspace structural styles.
   Ported from the production BPMN AI run page (BpmnAiInvestigationRun.razor.css) so
   the reusable component matches production pixel-for-pixel. All colors come from the
   shared design tokens (--ant-*, --gray-*, --text-*, --bg-*, --border, --radius*,
   --shadow*, --font-*). The COMPONENT ships this layout; the HOST ships a stylesheet
   that DEFINES those token values - re-theme by supplying different values, no code
   change. Plain (non-scoped) so the markdown rules also apply to MarkupString HTML.
   Host links it via _content/mindzie.Agent.Components/agentJobWorkspace.css */

.ajw-root {
    display: flex;
    gap: 16px;
    height: 100%;
    min-height: 0;
    /* Fill the host container on BOTH axes whether the host wraps the component
       in a block (width fills via auto) or a flex parent (row or column). As the
       lone child of a flex-row host the component must grow to the full width;
       without flex-grow it would shrink to its content and leave the rest of the
       row blank. */
    flex: 1 1 auto;
    width: 100%;
    min-width: 0;
    color: var(--text-primary, #0F1024);
    font-family: var(--font-sans, "Inter", sans-serif);
    background: var(--bg-layout, #F5F6FB);
    font-size: 14px;
}

.ajw-root *, .ajw-root *::before, .ajw-root *::after { box-sizing: border-box; }

.ajw-chat,
.ajw-workspace {
    display: flex;
    flex-direction: column;
    min-height: 0;
    background: var(--bg-container, #FFFFFF);
    border: 1px solid var(--border-secondary, #E7E9F4);
    border-radius: var(--radius-lg, 12px);
    box-shadow: var(--shadow-1, 0 1px 2px rgba(15,16,36,0.05));
    overflow: hidden;
}

.ajw-chat { flex: 0 0 380px; min-width: 320px; }
.ajw-workspace { flex: 1; min-width: 0; }

/* ---- pane head + status badge ---- */

.ajw-pane-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-secondary, #E7E9F4);
}

.ajw-pane-head-label {
    font-family: var(--font-mono, monospace);
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-tertiary, #6E7193);
}

.ajw-status {
    font-family: var(--font-mono, monospace);
    font-size: 11px;
    font-weight: 600;
    padding: 2px 9px;
    border-radius: 999px;
    text-transform: lowercase;
    border: 1px solid transparent;
}

.ajw-status-active { color: var(--ant-success, #1F8A5B); background: var(--ant-success-bg, #E5F2EC); border-color: var(--ant-success-border, #BFE3CF); }
.ajw-status-starting { color: var(--ant-primary-active, #5834D6); background: var(--ant-primary-bg, #F1ECFF); border-color: var(--ant-primary-border, #CBB6FF); }
.ajw-status-error { color: var(--ant-error, #C9485A); background: var(--ant-error-bg, #F8E7EA); border-color: var(--ant-error-border, #EFC3CB); }
.ajw-status-inactive { color: var(--gray-7, #9396B5); background: var(--gray-3, #EEF0FA); border-color: var(--gray-5, #E0E3F0); }

/* ---- chat stream ---- */

.ajw-stream {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    min-height: 0;
}

.ajw-empty {
    font-size: 13px;
    color: var(--text-tertiary, #6E7193);
    line-height: 1.6;
}

.ajw-empty-center { margin: auto; text-align: center; max-width: 280px; }

/* ---- example starter prompts ---- */

.ajw-examples { display: flex; flex-direction: column; gap: 8px; }

.ajw-example {
    display: flex;
    flex-direction: column;
    gap: 2px;
    width: 100%;
    text-align: left;
    padding: 9px 12px;
    border-radius: var(--radius, 9px);
    border: 1px solid var(--border-secondary, #E7E9F4);
    background: var(--gray-2, #FBFBFE);
    cursor: pointer;
}
.ajw-example:hover { border-color: var(--ant-primary-border, #CBB6FF); background: var(--ant-primary-bg, #F1ECFF); }
.ajw-example-title { font-size: 13px; font-weight: 600; color: var(--text-primary, #0F1024); }
.ajw-example-prompt { font-size: 12px; color: var(--text-tertiary, #6E7193); }

/* ---- message bubbles ---- */

.ajw-msgrow { display: flex; }
.ajw-msgrow-user { justify-content: flex-end; }
.ajw-msgrow-assistant { justify-content: flex-start; }

.ajw-bubble {
    max-width: 86%;
    font-size: 14px;
    line-height: 1.55;
    padding: 9px 13px;
    border-radius: 12px;
    white-space: pre-wrap;
    word-break: break-word;
}

.ajw-bubble-user {
    color: #ffffff;
    background: var(--ant-primary, #7C5CFF);
    border-bottom-right-radius: 4px;
}

.ajw-bubble-assistant {
    color: var(--text-primary, #0F1024);
    background: var(--gray-3, #EEF0FA);
    border-bottom-left-radius: 4px;
}

.ajw-bubble-meta {
    margin-top: 5px;
    font-size: 11px;
    color: var(--text-tertiary, #6E7193);
    font-family: var(--font-mono, monospace);
}

/* ---- completed activity rows ---- */

.ajw-activity {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 13px;
    padding: 8px 12px;
    border-radius: var(--radius, 9px);
    border: 1px dashed var(--border-secondary, #E7E9F4);
    background: var(--gray-2, #FBFBFE);
}

.ajw-activity-ico {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 22px; height: 22px;
    flex-shrink: 0;
    border-radius: 6px;
    font-family: var(--font-mono, monospace);
    font-size: 11px;
    font-weight: 700;
    background: var(--accent-display-bg, #F1ECFF);
    color: var(--accent-display, #7C5CFF);
}

.ajw-activity-text { font-weight: 600; color: var(--text-primary, #0F1024); }
.ajw-activity-detail { font-size: 12px; color: var(--text-tertiary, #6E7193); font-variant-numeric: tabular-nums; margin-left: auto; }

/* ---- live "working" / "starting" indicators ---- */

.ajw-working {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 12px 14px;
    border-radius: var(--radius, 9px);
    border: 1px solid var(--accent-display-border, #CBB6FF);
    background: var(--accent-display-bg, #F1ECFF);
}

.ajw-working-dots {
    display: inline-flex;
    gap: 5px;
    flex-shrink: 0;
    padding-top: 6px;
}

.ajw-working-dots span {
    width: 7px; height: 7px;
    border-radius: 50%;
    background: var(--accent-display, #7C5CFF);
    animation: ajw-pulse 1.2s ease-in-out infinite;
}
.ajw-working-dots span:nth-child(2) { animation-delay: 0.2s; }
.ajw-working-dots span:nth-child(3) { animation-delay: 0.4s; }

.ajw-working-body { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.ajw-working-title { font-size: 13px; font-weight: 600; color: var(--text-primary, #0F1024); }
.ajw-working-stage { display: flex; align-items: baseline; gap: 8px; font-size: 12.5px; }
.ajw-working-stage-text { color: var(--accent-display, #7C5CFF); font-weight: 500; }
.ajw-working-elapsed { font-size: 11px; color: var(--text-tertiary, #6E7193); font-variant-numeric: tabular-nums; }

@keyframes ajw-pulse {
    0%, 100% { opacity: 0.25; transform: scale(0.8); }
    50% { opacity: 1; transform: scale(1); }
}

/* The "waking up" startup indicator: blue/primary variant, distinct from the working one. */
.ajw-working-starting {
    border-color: var(--ant-primary-border, #CBB6FF);
    background: var(--ant-primary-bg, #F1ECFF);
}
.ajw-working-starting .ajw-working-dots span { background: var(--ant-primary, #7C5CFF); }
.ajw-working-starting .ajw-working-stage-text { color: var(--ant-primary-active, #5834D6); }

/* ---- inline error feedback + retry ---- */

.ajw-feedback {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 12px;
    border-radius: var(--radius, 9px);
    border: 1px solid var(--ant-error-border, #EFC3CB);
    background: var(--ant-error-bg, #F8E7EA);
    font-size: 13px;
}

.ajw-feedback-head { display: flex; align-items: flex-start; gap: 8px; }

.ajw-feedback-ico {
    display: inline-flex; align-items: center; justify-content: center;
    width: 18px; height: 18px; flex-shrink: 0;
    border-radius: 50%;
    font-weight: 700; font-size: 12px; line-height: 1;
    color: #ffffff;
    background: var(--ant-error, #C9485A);
}

.ajw-feedback-text { color: var(--ant-error, #C9485A); }
.ajw-feedback-actions { display: flex; justify-content: flex-end; }

.ajw-retry {
    font-size: 12px;
    font-weight: 600;
    color: #ffffff;
    background: var(--ant-error, #C9485A);
    border: none;
    border-radius: var(--radius, 9px);
    padding: 5px 14px;
    cursor: pointer;
}
.ajw-retry:hover { filter: brightness(0.95); }

/* ---- composer ---- */

.ajw-composer {
    border-top: 1px solid var(--border-secondary, #E7E9F4);
    padding: 12px 14px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.ajw-textarea {
    width: 100%;
    resize: none;
    font-size: 14px;
    font-family: var(--font-sans, "Inter", sans-serif);
    color: var(--text-primary, #0F1024);
    border: 1px solid var(--border, #E0E3F0);
    border-radius: var(--radius, 9px);
    padding: 9px 11px;
    outline: none;
    line-height: 1.5;
}
.ajw-textarea:focus {
    border-color: var(--ant-primary, #7C5CFF);
    box-shadow: var(--ring, 0 0 0 3px rgba(124,92,255,0.22));
}
.ajw-textarea:disabled { background: var(--gray-3, #EEF0FA); cursor: not-allowed; }

.ajw-composer-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.ajw-hint { font-size: 11px; color: var(--text-tertiary, #6E7193); }

/* ---- buttons ---- */

.ajw-btn {
    font-size: 13px;
    font-weight: 600;
    border-radius: var(--radius, 9px);
    padding: 7px 14px;
    cursor: pointer;
    border: 1px solid transparent;
    transition: background-color 0.15s ease, border-color 0.15s ease;
}
.ajw-btn:disabled { cursor: not-allowed; opacity: 0.5; }
.ajw-btn-primary { color: #ffffff; background: var(--ant-primary, #7C5CFF); }
.ajw-btn-primary:hover:not(:disabled) { background: var(--ant-primary-hover, #6A45F2); }
.ajw-btn-stop { color: #ffffff; background: var(--danger, #E03131); margin-right: 8px; }
.ajw-btn-stop:hover:not(:disabled) { background: var(--danger-hover, #C92A2A); }
.ajw-btn-ghost { color: var(--text-secondary, #4F5274); background: var(--bg-container, #FFFFFF); border-color: var(--border, #E0E3F0); }
.ajw-btn-ghost:hover:not(:disabled) { background: var(--gray-2, #FBFBFE); border-color: var(--ant-primary-border, #CBB6FF); }

/* ---- files + preview split ---- */

.ajw-ws-split { flex: 1; min-height: 0; display: flex; }

.ajw-files {
    flex: 0 0 260px;
    min-width: 220px;
    border-right: 1px solid var(--border-secondary, #E7E9F4);
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.ajw-files-scroll { flex: 1; overflow-y: auto; padding: 8px; min-height: 0; }

.ajw-file-group { margin-bottom: 14px; }

.ajw-file-group-head { display: flex; align-items: center; justify-content: space-between; padding: 6px 8px; }

.ajw-file-group-label {
    font-family: var(--font-mono, monospace);
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-quaternary, #9396B5);
    padding: 6px 8px;
}
.ajw-file-group-head .ajw-file-group-label { padding: 0; }

.ajw-addfiles-btn {
    font-size: 11px;
    font-weight: 600;
    color: var(--ant-primary, #7C5CFF);
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 2px 4px;
    border-radius: var(--radius-sm, 6px);
}
.ajw-addfiles-btn:hover { background: var(--ant-primary-bg, #F1ECFF); }

.ajw-addfiles {
    margin: 4px 8px 10px 8px;
    padding: 10px;
    border: 1px solid var(--border-secondary, #E7E9F4);
    border-radius: var(--radius, 9px);
    background: var(--gray-2, #FBFBFE);
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.ajw-addfiles-label {
    font-family: var(--font-mono, monospace);
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--text-tertiary, #6E7193);
}

.ajw-addfiles-hint {
    font-size: 11px;
    color: var(--text-tertiary, #6E7193);
    line-height: 1.4;
}

.ajw-upload-notice {
    margin: 0 8px 8px 8px;
    padding: 8px 10px;
    font-size: 11px;
    line-height: 1.5;
    color: var(--ant-error, #E5484D);
    background: var(--ant-error-bg, #FFF1F0);
    border: 1px solid var(--ant-error-border, #FFCCC7);
    border-radius: var(--radius-sm, 6px);
}

.ajw-file-empty { padding: 2px 8px 6px 8px; line-height: 1.5; }

.ajw-file {
    display: flex;
    align-items: center;
    gap: 2px;
    width: 100%;
    border-radius: var(--radius, 9px);
    border: 1px solid transparent;
    background: transparent;
}
.ajw-file:hover { background: var(--gray-2, #FBFBFE); }

/* The clickable select area fills the row; the delete button sits beside it. The row
   itself is the flex container so a button is never nested inside another button. */
.ajw-file-select {
    flex: 1;
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 10px;
    text-align: left;
    padding: 8px;
    border: none;
    background: transparent;
    border-radius: var(--radius, 9px);
    cursor: pointer;
}

.ajw-file-delete,
.ajw-file-action {
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    padding: 0;
    border: none;
    border-radius: 6px;
    background: transparent;
    color: var(--text-quaternary, #9396B5);
    cursor: pointer;
}
.ajw-file-delete { margin-right: 6px; }
.ajw-file-action { margin-right: 2px; }
.ajw-file-delete:hover {
    background: var(--ant-error-bg, #FFF1F0);
    color: var(--ant-error, #E5484D);
}
.ajw-file-action:hover {
    background: var(--ant-primary-bg, #F1ECFF);
    color: var(--ant-primary, #7C5CFF);
}

.ajw-file-active {
    background: var(--ant-primary-bg, #F1ECFF);
    border-color: var(--ant-primary-border, #CBB6FF);
    box-shadow: inset 2px 0 0 0 var(--accent-display, #7C5CFF);
}
.ajw-file-active:hover { background: var(--ant-primary-bg, #F1ECFF); }

.ajw-file-ico {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px; height: 30px;
    flex-shrink: 0;
    border-radius: 6px;
    font-family: var(--font-mono, monospace);
    font-size: 9px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.02em;
}
.ajw-file-ico-input { background: var(--gray-4, #E7E9F4); color: var(--text-secondary, #4F5274); }
.ajw-file-ico-diagram { background: var(--accent-display-bg, #F1ECFF); color: var(--accent-display, #7C5CFF); }
.ajw-file-ico-report { background: var(--accent-display-bg, #F1ECFF); color: var(--accent-display, #7C5CFF); }
.ajw-file-ico-image { background: var(--ant-primary-bg, #F1ECFF); color: var(--ant-primary-active, #5834D6); }

.ajw-file-main { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.ajw-file-name {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary, #0F1024);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.ajw-file-subrow { display: flex; align-items: baseline; gap: 8px; min-width: 0; }
.ajw-file-sub { font-size: 11px; color: var(--text-tertiary, #6E7193); flex-shrink: 0; }
.ajw-file-time { font-size: 11px; color: var(--text-quaternary, #9396B5); flex-shrink: 0; font-variant-numeric: tabular-nums; white-space: nowrap; }

/* ---- preview ---- */

.ajw-preview { flex: 1; min-width: 0; display: flex; flex-direction: column; min-height: 0; }

.ajw-preview-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 12px;
    border-bottom: 1px solid var(--border-secondary, #E7E9F4);
}
.ajw-preview-head-left { display: flex; align-items: center; min-width: 0; }
.ajw-preview-actions { display: inline-flex; gap: 8px; }

.ajw-preview-kind {
    font-family: var(--font-display, "Inter", sans-serif);
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary, #0F1024);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.ajw-tabs {
    display: inline-flex;
    gap: 2px;
    background: var(--gray-3, #EEF0FA);
    border-radius: var(--radius, 9px);
    padding: 2px;
}
.ajw-tab {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary, #4F5274);
    background: transparent;
    border: none;
    border-radius: var(--radius-sm, 6px);
    padding: 5px 14px;
    cursor: pointer;
}
.ajw-tab-active {
    color: var(--text-primary, #0F1024);
    background: var(--bg-container, #FFFFFF);
    box-shadow: var(--shadow-1, 0 1px 2px rgba(15,16,36,0.05));
}

.ajw-preview-body { flex: 1; min-height: 0; display: flex; position: relative; }
.ajw-preview-host { flex: 1; min-height: 0; display: flex; overflow: auto; }

.ajw-xml {
    flex: 1;
    margin: 0;
    overflow: auto;
    padding: 14px;
    font-size: 12px;
    line-height: 1.5;
    font-family: var(--font-mono, "JetBrains Mono", monospace);
    color: var(--text-secondary, #4F5274);
    background: var(--gray-2, #FBFBFE);
    white-space: pre;
}

.ajw-preview-meta {
    display: flex;
    align-items: baseline;
    gap: 10px;
    padding: 10px 14px;
    border-top: 1px solid var(--border-secondary, #E7E9F4);
    background: var(--gray-2, #FBFBFE);
}
.ajw-preview-meta-name { font-size: 13px; font-weight: 600; color: var(--text-primary, #0F1024); }
.ajw-preview-meta-sub { font-family: var(--font-mono, monospace); font-size: 11px; color: var(--text-tertiary, #6E7193); }

/* ---- responsive ---- */
@media (max-width: 1200px) {
    .ajw-chat { flex-basis: 320px; min-width: 280px; }
    .ajw-files { flex-basis: 220px; min-width: 200px; }
}

/* ---- rendered markdown (shared mindzie.Markdown output, injected as MarkupString) ---- */
.ajw-md > :first-child { margin-top: 0; }
.ajw-md > :last-child { margin-bottom: 0; }
.ajw-md h1, .ajw-md h2, .ajw-md h3, .ajw-md h4 { margin: 10px 0 6px; line-height: 1.3; }
.ajw-md h1 { font-size: 17px; }
.ajw-md h2 { font-size: 15px; }
.ajw-md h3 { font-size: 14px; }
.ajw-md p { margin: 6px 0; }
.ajw-md ul, .ajw-md ol { margin: 6px 0; padding-left: 20px; }
.ajw-md li { margin: 2px 0; }
.ajw-md code { background: var(--gray-3, #EEF0FA); padding: 1px 5px; border-radius: 4px; font-family: var(--font-mono, monospace); font-size: 12px; }
.ajw-md pre { background: var(--gray-2, #FBFBFE); border: 1px solid var(--border-secondary, #E7E9F4); border-radius: 6px; padding: 10px; overflow-x: auto; margin: 8px 0; }
.ajw-md pre code { background: transparent; padding: 0; }
.ajw-md table { border-collapse: collapse; margin: 8px 0; width: 100%; }
.ajw-md th, .ajw-md td { border: 1px solid var(--border-secondary, #E7E9F4); padding: 4px 8px; text-align: left; }
.ajw-md blockquote { border-left: 3px solid var(--border, #E0E3F0); margin: 6px 0; padding-left: 10px; color: var(--text-secondary, #4F5274); }
.ajw-md a { color: var(--ant-primary, #7C5CFF); }
