/* companion.css — the inline Syndex companion dock (Surety #89 M0). The financial
   workflow is the PRIMARY plane; this is the collapsible "ask while you work" assistant
   over the same Syndex chat substrate. Slides in from the right; closeable; escalates to
   the full Syndex chat. On wide screens it sits ALONGSIDE (pushes the workflow) rather
   than overlaying — plane primary, companion adjacent. */

.dock-toggle {
    background: rgba(0, 200, 255, 0.08);
    border: 1px solid rgba(0, 200, 255, 0.22);
    color: #00c8ff;
    padding: 5px 14px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 12px;
    font-weight: 500;
    letter-spacing: 0.3px;
    font-family: 'Inter', sans-serif;
    transition: all 0.2s;
}
.dock-toggle:hover { background: rgba(0, 200, 255, 0.15); border-color: rgba(0, 200, 255, 0.4); }

.syndex-dock {
    position: fixed;
    /* Sit BELOW the top nav (height measured by companion.js into --surety-header-h) so the
       header — identity pill, Ask Syndex, Logout — stays fully visible when the dock is open. */
    top: var(--surety-header-h, 49px); right: 0; bottom: 0;
    width: 380px; max-width: 92vw;
    background: #0e1018;
    border-left: 1px solid rgba(120, 134, 160, 0.18);
    box-shadow: -24px 0 60px rgba(0, 0, 0, 0.4);
    display: flex; flex-direction: column;
    z-index: 50;
}
.syndex-dock[hidden] { display: none; }

.dock-head {
    display: flex; align-items: center; justify-content: space-between;
    padding: 12px 14px; border-bottom: 1px solid rgba(120, 134, 160, 0.16);
    background: rgba(12, 18, 32, 0.5);
}
.dock-title { display: flex; align-items: baseline; gap: 8px; min-width: 0; }
.dock-mark { color: #00c8ff; font-size: 14px; }
.dock-name {
    font-family: 'Outfit', sans-serif; font-weight: 500; font-size: 13px;
    letter-spacing: 0.18em; color: #e8ecf4;
}
.dock-sub { font-family: 'Inter', sans-serif; font-size: 11px; color: #6b7689; white-space: nowrap; }
.dock-head-actions { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.dock-escalate {
    font-family: 'Inter', sans-serif; font-size: 11px; color: #00c8ff;
    text-decoration: none; white-space: nowrap;
}
.dock-escalate:hover { text-decoration: underline; }
.dock-close {
    background: none; border: none; color: #8c97ab; font-size: 20px; line-height: 1;
    cursor: pointer; padding: 0 4px;
}
.dock-close:hover { color: #e8ecf4; }

.dock-messages {
    flex: 1; overflow-y: auto; overflow-x: hidden; padding: 14px;
    display: flex; flex-direction: column; gap: 12px;
    scrollbar-width: thin; scrollbar-color: rgba(255,255,255,0.06) transparent;
}
.dock-msg {
    font-family: 'Inter', sans-serif; font-size: 13px; line-height: 1.55;
    padding: 9px 12px; border-radius: 10px; max-width: 92%;
    /* Contain wide content (a figures table, a long accession/URL) to the dock width: min-width:0 lets
       the flex item shrink below its content's intrinsic width, and overflow-wrap:break-word breaks a
       long unbroken token when it WOULD overflow. NOTE: do NOT use `anywhere`/`word-break:break-word`
       here — those drop the min-content width to one character, which `table-layout:auto` then uses to
       collapse a table column to 1ch, rendering its text vertically one-char-per-line. break-word
       wraps long prose tokens without shrinking table columns. */
    min-width: 0; overflow-wrap: break-word;
}
.dock-msg-user {
    align-self: flex-end;
    background: linear-gradient(135deg, rgba(0, 200, 255, 0.14), rgba(120, 80, 255, 0.14));
    border: 1px solid rgba(0, 200, 255, 0.2); color: #e8ecf4;
}
.dock-msg-assistant {
    align-self: flex-start;
    background: rgba(255, 255, 255, 0.03); border: 1px solid rgba(120, 134, 160, 0.14); color: #cfd6e4;
}
.dock-welcome { color: #8c97ab; font-size: 12px; }
.dock-thinking { color: #6b7689; font-style: italic; }
.dock-error { border-color: rgba(255, 68, 102, 0.3); color: #ff8da3; }
.dock-note {
    margin-top: 6px; font-size: 11px; color: #ffaa30;
    border-top: 1px solid rgba(255, 170, 48, 0.2); padding-top: 5px;
}

/* Markdown rendering inside assistant answers — elegant formatting (renderMarkdown in companion.js). */
.dock-msg-assistant p { margin: 0 0 8px; }
.dock-msg-assistant p:last-child { margin-bottom: 0; }
.dock-msg-assistant strong { color: #e8ecf4; font-weight: 600; }
.dock-msg-assistant em { font-style: italic; color: #dbe2ee; }
.dock-msg-assistant .dock-h {
    font-family: 'Outfit', sans-serif; font-weight: 600; font-size: 12.5px;
    color: #cfe3ff; letter-spacing: 0.01em; margin: 11px 0 4px;
}
.dock-msg-assistant .dock-h:first-child { margin-top: 0; }
.dock-list { margin: 4px 0 8px; padding-left: 18px; }
.dock-list li { margin: 2px 0; }
.dock-ic {
    font-family: ui-monospace, 'SFMono-Regular', Menlo, monospace; font-size: 12px;
    background: rgba(0, 200, 255, 0.08); border: 1px solid rgba(0, 200, 255, 0.16);
    border-radius: 4px; padding: 0.5px 5px; color: #9fe0ff;
}
.dock-code {
    background: #06070d; border: 1px solid rgba(120, 134, 160, 0.18);
    border-radius: 8px; padding: 10px 12px; margin: 8px 0; overflow-x: auto;
}
.dock-code code {
    font-family: ui-monospace, 'SFMono-Regular', Menlo, monospace; font-size: 11.5px;
    line-height: 1.5; color: #c5d3e6; white-space: pre; background: none; border: none; padding: 0;
}
.dock-msg-assistant a { color: #00c8ff; text-decoration: none; border-bottom: 1px solid rgba(0, 200, 255, 0.3); }
.dock-msg-assistant a:hover { border-bottom-color: #00c8ff; }
/* display:block + overflow-x:auto makes a too-wide table scroll WITHIN its own box (capped at the
   bubble width) instead of forcing the bubble past the dock edge. */
.dock-msg-assistant .dock-table { width: 100%; max-width: 100%; display: block; overflow-x: auto; border-collapse: collapse; margin: 8px 0; font-size: 12px; }
.dock-msg-assistant .dock-table th,
.dock-msg-assistant .dock-table td { text-align: left; padding: 4px 8px; border-bottom: 1px solid rgba(120, 134, 160, 0.14); vertical-align: top;
    /* size cells to whole words, never to a single char — defends the table against any break-word
       inherited from the bubble (the one-char-per-line column collapse). A genuinely too-wide table
       scrolls instead, via .dock-table { display:block; overflow-x:auto }. */
    word-break: normal; overflow-wrap: normal; }
.dock-msg-assistant .dock-table th { color: #9fb2c8; font-weight: 600; font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.04em; }
.dock-msg-assistant .dock-table td { color: #cfd6e4; }
.dock-msg-assistant .dock-table td:not(:first-child),
.dock-msg-assistant .dock-table th:not(:first-child) { text-align: right; white-space: nowrap; }

/* M1 — two-channel citation chips (RAG corpus + live EDGAR/Treasury/FedReg) under an answer. */
.dock-cites {
    margin-top: 8px; padding-top: 7px;
    border-top: 1px solid rgba(120, 134, 160, 0.14);
    display: flex; flex-wrap: wrap; gap: 5px; align-items: center;
}
.dock-cites-label {
    font-size: 10px; text-transform: uppercase; letter-spacing: 0.08em;
    color: #6b7689; margin-right: 2px;
}
.dock-cite {
    font-size: 10.5px; font-family: 'Inter', sans-serif; color: #9fb2c8;
    background: rgba(0, 200, 255, 0.06); border: 1px solid rgba(0, 200, 255, 0.14);
    border-radius: 5px; padding: 1px 6px; max-width: 100%;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.dock-cite-more { color: #6b7689; background: none; border-color: rgba(120, 134, 160, 0.18); }

/* M2.5 — contextual escalation card (offer the next rung: Syndex full chat / PM project). An
   inviting next-step, not an error: subtle cyan→violet wash matching the dock accent. */
.dock-esc {
    margin-top: 9px; padding: 9px 11px;
    background: linear-gradient(135deg, rgba(0, 200, 255, 0.05), rgba(120, 80, 255, 0.05));
    border: 1px solid rgba(0, 200, 255, 0.18); border-radius: 9px;
}
.dock-esc-reason { font-size: 12px; color: #b9c6d8; line-height: 1.45; margin-bottom: 8px; }
.dock-esc-actions { display: flex; flex-wrap: wrap; gap: 7px; }
.dock-esc-btn {
    font-family: 'Inter', sans-serif; font-size: 11.5px; font-weight: 500; text-decoration: none;
    padding: 4px 11px; border-radius: 6px; white-space: nowrap;
    color: #9fb2c8; border: 1px solid rgba(120, 134, 160, 0.22); background: rgba(255, 255, 255, 0.02);
    transition: all 0.15s;
}
.dock-esc-btn:hover { color: #e8ecf4; border-color: rgba(0, 200, 255, 0.3); }
.dock-esc-primary {
    color: #00c8ff; border-color: rgba(0, 200, 255, 0.3);
    background: linear-gradient(135deg, rgba(0, 200, 255, 0.12), rgba(120, 80, 255, 0.12));
}
.dock-esc-primary:hover { color: #7fe3ff; border-color: rgba(0, 200, 255, 0.45); }

.dock-form {
    display: flex; gap: 8px; padding: 12px 14px;
    border-top: 1px solid rgba(120, 134, 160, 0.16);
}
.dock-input {
    flex: 1; resize: none; background: #06070d;
    border: 1px solid rgba(120, 134, 160, 0.2); border-radius: 8px;
    color: #e0e8f0; font-family: 'Inter', sans-serif; font-size: 13px;
    padding: 9px 11px; outline: none; min-height: 38px; max-height: 120px;
}
.dock-input:focus { border-color: rgba(0, 200, 255, 0.3); }
.dock-input::placeholder { color: #3a4a5a; }
.dock-send {
    background: linear-gradient(135deg, rgba(0, 200, 255, 0.2), rgba(120, 80, 255, 0.2));
    border: 1px solid rgba(0, 200, 255, 0.25); color: #00c8ff;
    border-radius: 8px; padding: 0 16px; cursor: pointer;
    font-family: 'Inter', sans-serif; font-size: 12px; font-weight: 600;
}
.dock-send:hover { background: linear-gradient(135deg, rgba(0, 200, 255, 0.3), rgba(120, 80, 255, 0.3)); }
/* M2a — Send becomes Stop while a stream is in flight. */
.dock-send.dock-stop {
    background: linear-gradient(135deg, rgba(255, 68, 102, 0.18), rgba(255, 68, 102, 0.1));
    border-color: rgba(255, 68, 102, 0.4); color: #ff8da3;
}
.dock-send.dock-stop:hover { background: linear-gradient(135deg, rgba(255, 68, 102, 0.28), rgba(255, 68, 102, 0.16)); }

/* M2a — live streaming caret + a neutral "Stopped." note (distinct from the amber degraded note). */
.dock-cursor {
    display: inline-block; width: 7px; height: 13px; margin-left: 1px; border-radius: 1px;
    vertical-align: text-bottom; background: #00c8ff; opacity: 0.85;
    animation: dock-blink 1s steps(2, start) infinite;
}
@keyframes dock-blink { 0%, 50% { opacity: 0.85; } 50.01%, 100% { opacity: 0; } }
.dock-note-stopped { color: #8c97ab; border-top-color: rgba(120, 134, 160, 0.2); }

/* Wide screens: companion sits alongside the workflow instead of overlaying it. */
@media (min-width: 1200px) {
    body.dock-open #financial-content { margin-right: 392px; }
}
