/* DET bottom placement and theme for the shared Petra result-chat client. */
.det-practice-container.det-petra-visible .det-main-content {
    padding-bottom: calc(32px + var(--prepex-bottom-activity-bar-offset, 52px));
}

.bottom-activity-bar.det-petra-sidebar {
    background: linear-gradient(180deg, var(--det-card), var(--det-bg));
    border-top: 1px solid var(--det-border);
    border-radius: 16px 16px 0 0;
    bottom: 0;
    box-shadow: 0 -8px 28px rgba(26, 24, 22, 0.1);
    box-sizing: border-box;
    color: var(--det-text);
    display: flex;
    flex-direction: column;
    font: 13px/1.6 'Poppins', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    height: min(55dvh, 420px);
    left: 0;
    overflow: hidden;
    position: fixed;
    right: 0;
    top: auto;
    transform: none;
    width: 100%;
    transition: height 0.24s ease;
    z-index: 1004;
}

.det-petra-sidebar *, .det-petra-sidebar *::before, .det-petra-sidebar *::after { box-sizing: border-box; }
.det-petra-sidebar[aria-hidden="true"], .det-petra-sidebar .hidden { display: none !important; }
.det-petra-sidebar .bottom-activity-bar-header {
    align-items: center;
    border-bottom: 1px solid var(--det-border);
    display: flex;
    flex: 0 0 52px;
    gap: 6px;
    position: relative;
    cursor: pointer;
}
.det-petra-sidebar .petra-header-title {
    align-items: center;
    color: var(--det-primary);
    display: flex;
    font-weight: 600;
    gap: 8px;
    padding-left: 14px;
    white-space: nowrap;
    background: transparent;
    border: 0;
    flex: 1;
    align-self: stretch;
    text-align: left;
}
.det-petra-sidebar .header-right { align-items: center; display: flex; gap: 8px; margin-left: auto; padding-right: 8px; }
.det-petra-sidebar button { cursor: pointer; font: inherit; }
.det-petra-sidebar .activity-bar-action-btn {
    align-items: center;
    background: var(--det-card);
    border: 1px solid var(--det-border);
    border-radius: 6px;
    color: var(--det-primary);
    display: flex;
    height: 28px;
    justify-content: center;
    width: 28px;
}
.det-petra-sidebar .bottom-activity-bar-toggle {
    align-items: center;
    background: var(--det-primary);
    border: 1px solid var(--det-primary);
    border-radius: 6px;
    color: #fff;
    display: flex;
    height: 32px;
    justify-content: center;
    padding: 0;
    position: relative;
    width: 32px;
}
.det-petra-sidebar button:hover { background: var(--det-primary-light); }
.det-petra-sidebar .bottom-activity-bar-toggle:hover { background: var(--det-primary-dark); border-color: var(--det-primary-dark); }
.det-petra-sidebar button:focus-visible, .det-petra-sidebar [tabindex]:focus-visible {
    outline: 2px solid var(--det-primary);
    outline-offset: -3px;
}
.det-petra-sidebar .expand-btn, .det-petra-sidebar .petra-collapsed-label,
.det-petra-sidebar:not(.collapsed) .toggle-text-expand,
.det-petra-sidebar.collapsed .toggle-text-collapse { display: none; }
.det-petra-sidebar .toggle-text-expand, .det-petra-sidebar .toggle-text-collapse { font-size: 0; }
.det-petra-sidebar .toggle-text-expand { align-items: center; display: flex; justify-content: center; }
.det-petra-sidebar:not(.collapsed) .toggle-text-expand { display: none; }
.det-petra-sidebar .petra-content-area, .det-petra-sidebar .petra-chat-container,
.det-petra-sidebar .petra-history-view { display: flex; flex: 1; flex-direction: column; min-height: 0; }
.det-petra-sidebar .petra-messages, .det-petra-sidebar .petra-sessions-list {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 18px;
    scrollbar-width: thin;
}
.det-petra-sidebar .petra-input-area { align-items: end; border-top: 1px solid var(--det-border); display: flex; gap: 8px; padding: 12px; padding-bottom: max(12px, env(safe-area-inset-bottom)); }
.det-petra-sidebar textarea {
    background: var(--det-bg);
    border: 1px solid var(--det-border);
    border-radius: 8px;
    color: var(--det-text);
    flex: 1;
    font: inherit;
    max-height: 100px;
    min-width: 0;
    padding: 9px;
    resize: none;
}
.det-petra-sidebar textarea:focus { border-color: var(--det-primary); outline: 1px solid var(--det-primary); }
.det-petra-sidebar textarea::placeholder { color: var(--det-meta, var(--det-muted)); }
.det-petra-sidebar .petra-send-btn {
    align-items: center;
    background: var(--det-primary);
    border: 0;
    border-radius: 8px;
    color: #fff;
    display: flex;
    flex: 0 0 38px;
    height: 38px;
    justify-content: center;
}
.det-petra-sidebar .petra-send-btn:hover:not(:disabled) { background: var(--det-primary-dark); }
.det-petra-sidebar button:disabled { cursor: default; opacity: 0.45; }
.det-petra-sidebar .petra-message { display: flex; gap: 8px; margin: 0 0 10px; max-width: 92%; }
.det-petra-sidebar .petra-avatar { align-items: center; background: linear-gradient(135deg, var(--det-primary), var(--det-primary-dark)); border-radius: 50%; color: #fff; display: flex; flex: 0 0 22px; height: 22px; justify-content: center; }
.det-petra-sidebar .message-bubble { background: var(--det-primary-light); border-radius: 11px; font-size: 12px; line-height: 1.45; min-width: 0; padding: 9px 11px; }
.det-petra-sidebar .petra-message.petra .message-bubble { border-bottom-left-radius: 4px; }
.det-petra-sidebar .message-content { overflow-wrap: anywhere; }
.det-petra-sidebar .message-content p { margin: 0 0 10px; }
.det-petra-sidebar .message-content p:last-child { margin-bottom: 0; }
.det-petra-sidebar .message-content ul, .det-petra-sidebar .message-content ol { padding-left: 20px; }
.det-petra-sidebar .message-content pre { overflow-x: auto; }
.det-petra-sidebar .petra-message.user { flex-direction: row-reverse; margin-left: auto; }
.det-petra-sidebar .petra-message.user .message-bubble { background: var(--det-primary); border-bottom-right-radius: 4px; color: #fff; }
.det-petra-sidebar .petra-message.system, .det-petra-sidebar .petra-error { color: var(--det-danger); }
.det-petra-sidebar .petra-result-preview { display: flex; flex-direction: column; gap: 12px; justify-content: center; min-height: 100%; }
.det-petra-sidebar .petra-result-preview-kicker { color: var(--det-primary); font-size: 11px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; }
.det-petra-sidebar .petra-result-chat-ready { align-items: center; background: var(--det-primary-light); border: 1px solid var(--det-border); border-radius: 8px; color: var(--det-primary); display: flex; font-size: 12px; font-weight: 600; gap: 8px; line-height: 1.4; padding: 10px 12px; }
.det-petra-sidebar .petra-result-chat-ready svg { flex-shrink: 0; }
.det-petra-sidebar .petra-result-preview-note, .det-petra-sidebar .empty-hint,
.det-petra-sidebar .session-meta { color: var(--det-meta, var(--det-muted)); font-size: 11px; }
.det-petra-sidebar .petra-result-preview-note { line-height: 1.45; text-align: center; }
.det-petra-sidebar .usage-badge { background: var(--det-primary-light); border-radius: 12px; font-size: 10px; padding: 1px 5px; }
.det-petra-sidebar .petra-history-header { align-items: center; border-bottom: 1px solid var(--det-border); display: flex; justify-content: space-between; padding: 12px; }
.det-petra-sidebar .history-back-btn { align-items: center; background: transparent; border: 0; color: var(--det-primary); display: flex; gap: 4px; }
.det-petra-sidebar .petra-session-card { border: 1px solid var(--det-border); border-radius: 8px; cursor: pointer; margin-bottom: 10px; padding: 12px; }
.det-petra-sidebar .petra-empty-state, .det-petra-sidebar .petra-loading, .det-petra-sidebar .petra-error { padding: 16px; text-align: center; }
.det-petra-sidebar .typing-dots { display: flex; gap: 4px; }
.det-petra-sidebar .typing-dots span { background: var(--det-primary); border-radius: 50%; height: 5px; width: 5px; }

.det-petra-sidebar.collapsed { height: calc(52px + env(safe-area-inset-bottom)); }
.det-petra-sidebar.collapsed .history-btn,
.det-petra-sidebar.collapsed .petra-content-area { display: none; }
.det-petra-sidebar.collapsed .bottom-activity-bar-header { flex-basis: calc(52px + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom); }
.det-petra-sidebar.collapsed.has-result-context .bottom-activity-bar-toggle::after { background: #b56a2d; border: 2px solid var(--det-card); border-radius: 50%; content: ''; height: 9px; position: absolute; right: -3px; top: -3px; width: 9px; }

@media (max-width: 768px) {
    .bottom-activity-bar.det-petra-sidebar:not(.collapsed) { height: min(70dvh, 600px); }
}

@media (prefers-reduced-motion: reduce) {
    .bottom-activity-bar.det-petra-sidebar, .det-main-content { transition: none; }
}

@media (forced-colors: active) {
    .bottom-activity-bar.det-petra-sidebar { border: 1px solid CanvasText; }
    .det-petra-sidebar .bottom-activity-bar-toggle { border: 1px solid ButtonText; }
    .det-petra-sidebar.collapsed.has-result-context .bottom-activity-bar-toggle::after { background: Highlight; border-color: Canvas; }
}
