/* Fleet shell Bob: fixed FAB, and a chat panel that sits beside the page on a
   wide screen (no backdrop: the page stays usable) and is a sheet on a phone.
   Inline answers (bob-inline.js) are at the end. */

.fleet-bob-fab {
    position: fixed;
    left: calc(12px + env(safe-area-inset-left, 0px));
    bottom: calc(12px + env(safe-area-inset-bottom, 0px));
    z-index: 8500;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    border: none;
    background: transparent;
    box-shadow: none;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
}

.fleet-bob[hidden],
.fleet-bob-fab[hidden] {
    display: none !important;
}

.fleet-bob-fab-orb {
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 0;
}

.fleet-bob-backdrop {
    position: fixed;
    inset: 0;
    z-index: 8550;
    background: rgba(var(--shadow-rgb), 0.55);
    border: none;
    padding: 0;
    margin: 0;
    cursor: pointer;
}

.fleet-bob-backdrop[hidden] {
    display: none !important;
}

.fleet-bob-sheet {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    top: auto;
    height: min(78dvh, 640px);
    z-index: 8600;
    display: flex;
    flex-direction: column;
    background: var(--bg);
    border-top: 1px solid var(--border);
    border-radius: var(--radius-xl) var(--radius-xl) 0 0;
    box-shadow: 0 -8px 32px rgba(var(--shadow-rgb), 0.5);
    padding-bottom: env(safe-area-inset-bottom, 0);
}

.fleet-bob-sheet[hidden] {
    display: none !important;
}

.fleet-bob-sheet-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.fleet-bob-heading {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-width: 0;
    line-height: 1.2;
}

.fleet-bob-title {
    font-weight: 600;
    font-size: var(--font-size-md);
}

/* What Bob sees: the page "this" means. */
.fleet-bob-where {
    font-size: var(--font-size-xs);
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.fleet-bob-memory {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: var(--font-size-xs);
    color: var(--text-secondary);
    cursor: pointer;
    user-select: none;
    white-space: nowrap;
}

.fleet-bob-memory-input {
    width: 16px;
    height: 16px;
    accent-color: var(--primary);
    margin: 0;
}

.fleet-bob-new {
    width: 40px;
    height: 40px;
    border: none;
    background: transparent;
    color: var(--text-body);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    border-radius: var(--radius-md);
    padding: 0;
    -webkit-tap-highlight-color: transparent;
}

.fleet-bob-new svg {
    width: 20px;
    height: 20px;
}

.fleet-bob-new:hover {
    background: rgba(var(--ink-rgb), 0.06);
}

.fleet-bob-close {
    width: 44px;
    height: 44px;
    border: none;
    background: transparent;
    color: var(--text-body);
    font-size: var(--font-size-2xl);
    line-height: 1;
    cursor: pointer;
}

.fleet-bob-transcript {
    flex: 1;
    overflow-y: auto;
    padding: 12px 14px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    min-height: 0;
}

.fleet-bob-msg {
    display: flex;
}

.fleet-bob-msg--user {
    justify-content: flex-end;
}

.fleet-bob-msg--assistant {
    justify-content: flex-start;
}

.fleet-bob-thinking-row {
    align-items: center;
    gap: 8px;
}

.fleet-bob-thinking-orb {
    flex-shrink: 0;
    line-height: 0;
}

.fleet-bob-bubble {
    max-width: 88%;
    padding: 10px 12px;
    border-radius: var(--radius-lg);
    font-size: var(--font-size-sm);
    line-height: 1.4;
    white-space: pre-wrap;
    word-break: break-word;
}

.fleet-bob-bubble--thinking {
    font-style: italic;
    color: var(--text-secondary);
}

.fleet-bob-msg--user .fleet-bob-bubble {
    background: rgba(var(--primary-rgb), 0.35);
    border: 1px solid rgba(var(--primary-rgb), 0.5);
}

.fleet-bob-msg--assistant .fleet-bob-bubble {
    background: var(--bg-surface);
    border: 1px solid var(--border);
}

.fleet-bob-composer {
    display: flex;
    gap: 8px;
    padding: 10px 12px;
    border-top: 1px solid var(--border);
    flex-shrink: 0;
}

.fleet-bob-input {
    flex: 1;
    min-height: 44px;
    border-radius: 22px;
    border: 1px solid var(--border-light);
    background: var(--bg-surface);
    color: var(--text-body);
    padding: 0 14px;
    font-size: var(--font-size-md);
}

.fleet-bob-input:disabled {
    opacity: 0.6;
}

.fleet-bob-send {
    min-height: 44px;
    min-width: 64px;
    border-radius: 22px;
    border: 1px solid var(--key-action-border);
    background: var(--key-action-bg);
    color: var(--key-action-text);
    font-weight: 600;
    font-size: var(--font-size-sm);
    cursor: pointer;
    padding: 0 14px;
}

.fleet-bob-send:disabled {
    border-color: var(--key-action-border-disabled);
    color: var(--key-action-text-disabled);
    cursor: not-allowed;
}

@media (min-width: 769px) {
    .fleet-bob-sheet {
        left: auto;
        right: 24px;
        bottom: 24px;
        width: 380px;
        height: 520px;
        border-radius: var(--radius-xl);
        border: 1px solid var(--border);
    }

    .fleet-bob-fab {
        left: auto;
        right: 24px;
        bottom: 24px;
    }

    /* Alongside the page, not over it: no backdrop. */
    .fleet-bob-backdrop {
        display: none !important;
    }

    .fleet-bob-sheet {
        height: min(620px, calc(100dvh - 48px));
        box-shadow: var(--shadow-modal);
    }
}

/* Suggested questions under the greeting, and links in Bob's replies. */
.fleet-bob-suggestions {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding-left: 2px;
}

.fleet-bob-suggestion {
    font-size: var(--font-size-xs);
    color: var(--text-primary);
    background: rgba(var(--primary-rgb), 0.18);
    border: 1px solid rgba(var(--primary-rgb), 0.45);
    border-radius: var(--radius-pill);
    padding: 6px 10px;
    cursor: pointer;
    text-align: left;
}

.fleet-bob-suggestion:hover {
    background: rgba(var(--primary-rgb), 0.3);
}

.fleet-bob-suggestion:focus-visible,
.fleet-bob-link:focus-visible {
    outline: 2px solid var(--focus-ring);
    outline-offset: 2px;
}

.fleet-bob-link {
    color: var(--primary-light);
    text-decoration: underline;
    text-underline-offset: 2px;
}

/* Bob answering on the page (bob-inline.js) */

.bob-inline {
    margin-top: var(--space-sm);
    color: var(--text-body);
    padding: var(--space-sm);
    border: 1px solid rgba(var(--primary-rgb), 0.45);
    border-radius: var(--radius-lg);
    background: var(--bg-surface);
    display: flex;
    flex-direction: column;
    gap: var(--space-xs);
}

.bob-inline-head {
    display: flex;
    align-items: center;
    gap: var(--space-xs);
}

.bob-inline-orb {
    line-height: 0;
}

.bob-inline-title {
    font-weight: 600;
    font-size: var(--font-size-sm);
    flex: 1;
}

.bob-inline-close {
    width: 32px;
    height: 32px;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    font-size: var(--font-size-lg);
    line-height: 1;
    cursor: pointer;
    border-radius: var(--radius-md);
}

.bob-inline-close:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.bob-inline-close:focus-visible {
    outline: 2px solid var(--focus-ring);
    outline-offset: 2px;
}

.bob-inline-thread {
    display: flex;
    flex-direction: column;
    gap: var(--space-xs);
    max-height: 360px;
    overflow-y: auto;
}

.bob-inline-q {
    margin: 0;
    font-size: var(--font-size-xs);
    color: var(--text-secondary);
}

.bob-inline-a {
    font-size: var(--font-size-sm);
    line-height: 1.45;
    color: var(--text-body);
    white-space: pre-wrap;
    word-break: break-word;
}

.bob-inline-thinking {
    margin: 0;
    font-size: var(--font-size-sm);
    font-style: italic;
    color: var(--text-secondary);
}

.bob-inline-follow {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--space-xs);
}

.bob-inline-input {
    flex: 1 1 200px;
    min-width: 0;
    height: 36px;
    padding: 0 var(--space-sm);
    border-radius: var(--radius-md);
    border: 1px solid var(--border-light);
    background: var(--bg-panel);
    color: var(--text-body);
    font-size: var(--font-size-md);
}

.bob-inline-input:focus-visible {
    outline: 2px solid var(--focus-ring);
    outline-offset: 1px;
}

.bob-inline-chat {
    margin-left: auto;
}

/* What Bob checked, under an answer (chat and inline) */
.bob-steps {
    margin: var(--space-xs) 0 0;
    font-size: var(--font-size-xs);
    color: var(--text-secondary);
    white-space: normal;
}

.bob-steps summary {
    cursor: pointer;
    width: fit-content;
}

.bob-steps summary:focus-visible {
    outline: 2px solid var(--focus-ring);
    outline-offset: 2px;
    border-radius: var(--radius-sm);
}

.bob-steps ul {
    margin: var(--space-xs) 0 0;
    padding-left: var(--space-md);
}

.fleet-bob-msg--failed .fleet-bob-bubble,
.bob-inline-a--failed {
    border-style: dashed;
    color: var(--text-secondary);
}

.fleet-bob-retry {
    align-self: flex-start;
}

.bob-inline-open {
    display: block;
    margin-top: var(--space-xs);
    white-space: normal;
}

/* An answer under a table row gets a row of its own */
.bob-inline-row > td {
    padding: 0 var(--space-sm) var(--space-sm);
}

/* The Ask Bob button any view can place (data-bob-inline) */
.bob-ask {
    font-size: var(--font-size-xs);
    color: var(--primary-light);
    background: none;
    border: 0;
    padding: 2px 0;
    cursor: pointer;
    text-decoration: underline;
    text-underline-offset: 2px;
    white-space: nowrap;
}

.bob-ask:hover,
.bob-ask[aria-expanded="true"] {
    color: var(--text-primary);
}

.bob-ask:focus-visible {
    outline: 2px solid var(--focus-ring);
    outline-offset: 2px;
    border-radius: var(--radius-sm);
}

/* Bob is for the screen: a printed page (a QA passport) leaves him out */
@media print {
    .bob-ask,
    .bob-inline,
    .bob-inline-row {
        display: none !important;
    }
}
