/*
 * FGENIO_JOURNAL_STAGE_SURFACE_V1
 *
 * One neutral dark Velzon-compatible surface
 * for Idea / Setup / Live.
 */

/*
 * FGENIO_JOURNAL_STAGE_THEME_FRIENDLY_V2
 *
 * Stage surface follows Velzon Light / Dark theme.
 *
 * Light:
 * - soft neutral secondary surface
 *
 * Dark:
 * - retain the existing dark trading-workspace appearance
 */
:is(#chartSnapshotModal,[data-fgenio-journal-position-workspace-host])
.fgenio-journal-stage-surface {
    margin-inline: -16px;

    background:
        var(--vz-secondary-bg)
        !important;

    color:
        var(--vz-body-color);

    border-top:
        1px solid
        var(--vz-border-color);

    border-bottom:
        1px solid
        var(--vz-border-color);
}

/*
 * Velzon dark mode contract.
 */
[data-bs-theme="dark"]
:is(#chartSnapshotModal,[data-fgenio-journal-position-workspace-host])
.fgenio-journal-stage-surface,
html[data-layout-mode="dark"]
:is(#chartSnapshotModal,[data-fgenio-journal-position-workspace-host])
.fgenio-journal-stage-surface {
    background:
        var(--vz-dark)
        !important;

    border-color:
        rgba(
            255,
            255,
            255,
            .08
        );
}


/*
 * FGENIO_JOURNAL_STAGE_INNER_PADDING_V1
 *
 * Background remains edge-to-edge.
 * Only stage content gets horizontal breathing room.
 */
:is(#chartSnapshotModal,[data-fgenio-journal-position-workspace-host])
.fgenio-journal-stage-surface
[data-custom-journal-panel] {
    padding-inline: 16px;
}

/*
 * FGENIO_JOURNAL_STAGE_FOOTER_PADDING_V1
 *
 * Keep stage background edge-to-edge while restoring
 * horizontal spacing for AI / Reset / Create actions.
 */
:is(#chartSnapshotModal,[data-fgenio-journal-position-workspace-host])
.fgenio-journal-stage-surface
[data-custom-journal-stage-ai-action] {
    margin-inline-start: 16px;
}

:is(#chartSnapshotModal,[data-fgenio-journal-position-workspace-host])
.fgenio-journal-stage-surface
[data-custom-journal-create] {
    margin-inline-end: 16px;
}

/*
 * FGENIO_CUSTOM_JOURNAL_FINANCIAL_COMPACT_UI_V1
 *
 * Compact financial rows aligned with TP1 / TP2 / TP3.
 */

/* Entry / Quantity values */
:is(#chartSnapshotModal,[data-fgenio-journal-position-workspace-host])
[data-custom-journal-entry-quantity-row]
.form-control {
    font-size: 15px;
    font-weight: 500;
}

/*
 * Match Structural / SL / R:R controls to the compact TP row height.
 */
:is(#chartSnapshotModal,[data-fgenio-journal-position-workspace-host])
[data-fgenio-financial-row="structural"],
:is(#chartSnapshotModal,[data-fgenio-journal-position-workspace-host])
[data-fgenio-financial-row="sl"],
:is(#chartSnapshotModal,[data-fgenio-journal-position-workspace-host])
[data-fgenio-financial-row="rr"] {
    min-height: 31px;
}

:is(#chartSnapshotModal,[data-fgenio-journal-position-workspace-host])
[data-fgenio-financial-row="structural"]
.input-group-text,
:is(#chartSnapshotModal,[data-fgenio-journal-position-workspace-host])
[data-fgenio-financial-row="structural"]
.form-control,
:is(#chartSnapshotModal,[data-fgenio-journal-position-workspace-host])
[data-fgenio-financial-row="structural"]
.form-select,
:is(#chartSnapshotModal,[data-fgenio-journal-position-workspace-host])
[data-fgenio-financial-row="sl"]
.input-group-text,
:is(#chartSnapshotModal,[data-fgenio-journal-position-workspace-host])
[data-fgenio-financial-row="sl"]
.form-control,
:is(#chartSnapshotModal,[data-fgenio-journal-position-workspace-host])
[data-fgenio-financial-row="rr"]
.input-group-text,
:is(#chartSnapshotModal,[data-fgenio-journal-position-workspace-host])
[data-fgenio-financial-row="rr"]
.form-control,
:is(#chartSnapshotModal,[data-fgenio-journal-position-workspace-host])
[data-fgenio-financial-row="rr"]
.btn {
    min-height: 31px;
    height: 31px;
}

/*
 * Neutral labels before a price has been set.
 */
:is(#chartSnapshotModal,[data-fgenio-journal-position-workspace-host])
[data-custom-journal-structural-row]
> .input-group-text:first-child,
:is(#chartSnapshotModal,[data-fgenio-journal-position-workspace-host])
[data-custom-journal-sl-row]
> .input-group-text:first-child {
    color: #212529 !important;

    background:
        var(--vz-tertiary-bg, var(--vz-light))
        !important;

    border-color:
        var(--vz-border-color)
        !important;

    font-weight: 500;
}

/*
 * FGENIO_CUSTOM_JOURNAL_FINANCIAL_STATE_COLORS_V2
 *
 * Structural Invalidation is a risk condition.
 * When its price is set, use the danger treatment.
 */
:is(#chartSnapshotModal,[data-fgenio-journal-position-workspace-host])
[data-custom-journal-structural-row].is-set
> .input-group-text:first-child {
    color:
        var(--vz-danger)
        !important;

    background:
        rgba(
            var(--vz-danger-rgb),
            .12
        )
        !important;

    border-color:
        rgba(
            var(--vz-danger-rgb),
            .30
        )
        !important;

    font-weight: 600;
}


/*
 * Hard SL set = danger badge-like label.
 */
:is(#chartSnapshotModal,[data-fgenio-journal-position-workspace-host])
[data-custom-journal-sl-row].is-set
> .input-group-text:first-child {
    color:
        var(--vz-danger)
        !important;

    background:
        rgba(
            var(--vz-danger-rgb),
            .12
        )
        !important;

    border-color:
        rgba(
            var(--vz-danger-rgb),
            .30
        )
        !important;

    font-weight: 600;
}

/*
 * R:R presets:
 * inactive = neutral gray
 * hover / selected = current primary treatment
 */
:is(#chartSnapshotModal,[data-fgenio-journal-position-workspace-host])
[data-custom-journal-rr-preset]:not(.active) {
    color:
        var(--vz-secondary-color)
        !important;

    background:
        var(--vz-secondary-bg)
        !important;

    border-color:
        var(--vz-border-color)
        !important;
}

:is(#chartSnapshotModal,[data-fgenio-journal-position-workspace-host])
[data-custom-journal-rr-preset]:not(.active):hover {
    color:
        var(--vz-primary)
        !important;

    background:
        rgba(
            var(--vz-primary-rgb),
            .12
        )
        !important;

    border-color:
        rgba(
            var(--vz-primary-rgb),
            .30
        )
        !important;
}

:is(#chartSnapshotModal,[data-fgenio-journal-position-workspace-host])
[data-custom-journal-rr-preset].active,
:is(#chartSnapshotModal,[data-fgenio-journal-position-workspace-host])
[data-custom-journal-rr-preset][aria-pressed="true"] {
    color:
        #fff
        !important;

    background:
        var(--vz-primary)
        !important;

    border-color:
        var(--vz-primary)
        !important;
}

/*
 * Dark mode keeps neutral labels readable.
 */
[data-bs-theme="dark"]
:is(#chartSnapshotModal,[data-fgenio-journal-position-workspace-host])
[data-custom-journal-structural-row]
> .input-group-text:first-child:not(.is-set),
[data-bs-theme="dark"]
:is(#chartSnapshotModal,[data-fgenio-journal-position-workspace-host])
[data-custom-journal-sl-row]
> .input-group-text:first-child:not(.is-set),
html[data-layout-mode="dark"]
:is(#chartSnapshotModal,[data-fgenio-journal-position-workspace-host])
[data-custom-journal-structural-row]
> .input-group-text:first-child,
html[data-layout-mode="dark"]
:is(#chartSnapshotModal,[data-fgenio-journal-position-workspace-host])
[data-custom-journal-sl-row]
> .input-group-text:first-child {
    color:
        var(--vz-body-color)
        !important;
}



/*
 * TP1 / TP2 / TP3 set = success treatment.
 */
:is(#chartSnapshotModal,[data-fgenio-journal-position-workspace-host])
.fgenio-tp-row.is-set
> .input-group-text:first-child {
    color:
        var(--vz-success)
        !important;

    background:
        rgba(
            var(--vz-success-rgb),
            .12
        )
        !important;

    border-color:
        rgba(
            var(--vz-success-rgb),
            .30
        )
        !important;

    font-weight: 600;
}


/*
 * FGENIO_CUSTOM_JOURNAL_FIXED_FOOTER_LAYOUT_V1
 *
 * Drawer layout:
 *
 * modal header
 * ----------------
 * internal scroll area
 * ----------------
 * fixed action footer
 */

/*
 * Bootstrap modal body must no longer own vertical scrolling.
 * Journal stage content owns it instead.
 */
:is(#chartSnapshotModal,[data-fgenio-journal-position-workspace-host])
.modal-body {
    overflow:
        hidden
        !important;

    display:
        flex;

    flex-direction:
        column;
}

/*
 * Fill the available drawer height.
 */
:is(#chartSnapshotModal,[data-fgenio-journal-position-workspace-host])
[data-ai-chart-journal-tab-content],
:is(#chartSnapshotModal,[data-fgenio-journal-position-workspace-host])
[data-ai-chart-custom-journal-pane] {
    flex:
        1 1 auto;

    min-height:
        0;

    height:
        100%;
}

:is(#chartSnapshotModal,[data-fgenio-journal-position-workspace-host])
[data-ai-chart-custom-journal-pane] {
    display:
        flex
        !important;

    flex-direction:
        column;
}

/*
 * Stage body fills remaining space.
 *
 * The currently active Idea / Position panel becomes
 * the internal scrolling area.
 */
:is(#chartSnapshotModal,[data-fgenio-journal-position-workspace-host])
[data-custom-journal-stage-body] {
    flex:
        1 1 auto;

    min-height:
        0;

    display:
        flex;

    flex-direction:
        column;

    margin-bottom:
        0
        !important;
}

:is(#chartSnapshotModal,[data-fgenio-journal-position-workspace-host])
[data-custom-journal-stage-body]
> [data-custom-journal-panel]:not(.d-none) {
    flex:
        1 1 auto;

    min-height:
        0;

    overflow-y:
        auto;

    overflow-x:
        hidden;

    padding-bottom:
        16px;
}

/*
 * Actual drawer footer.
 *
 * Never scrolls with Journal content.
 */
:is(#chartSnapshotModal,[data-fgenio-journal-position-workspace-host])
[data-custom-journal-action-footer] {
    flex:
        0 0 auto;

    margin-top:
        0
        !important;

    margin-inline:
        -16px;

    padding:
        14px 16px
        !important;

    min-height:
        66px;

    background:
        var(--vz-modal-bg, var(--vz-body-bg));

    border-top:
        1px solid
        var(--vz-border-color)
        !important;

    position:
        relative;

    z-index:
        5;
}

/*
 * Existing stage background remains edge-to-edge,
 * but footer itself belongs visually to the drawer,
 * not to the scrolling stage panel.
 */
:is(#chartSnapshotModal,[data-fgenio-journal-position-workspace-host])
[data-custom-journal-stage-body]
[data-custom-journal-action-footer] {
    width:
        auto;
}

/*
 * Right-side Reset/Create action group.
 */
:is(#chartSnapshotModal,[data-fgenio-journal-position-workspace-host])
[data-custom-journal-action-footer]
> .d-flex:last-child {
    margin-inline-start:
        auto;
}

/*
 * LIVE:
 * AI action is hidden.
 * Reset/Create must remain aligned to the right.
 */
:is(#chartSnapshotModal,[data-fgenio-journal-position-workspace-host])
[data-custom-journal-stage="executed"]
[data-custom-journal-action-footer] {
    justify-content:
        flex-end
        !important;
}

:is(#chartSnapshotModal,[data-fgenio-journal-position-workspace-host])
[data-custom-journal-stage="executed"]
[data-custom-journal-action-footer]
> .d-flex:last-child {
    margin-inline-start:
        auto;

    margin-inline-end:
        0;
}

/*
 * Keep footer buttons on one line.
 */
:is(#chartSnapshotModal,[data-fgenio-journal-position-workspace-host])
[data-custom-journal-action-footer] {
    flex-wrap:
        nowrap
        !important;
}

:is(#chartSnapshotModal,[data-fgenio-journal-position-workspace-host])
[data-custom-journal-action-footer]
> .d-flex:last-child {
    flex-wrap:
        nowrap;
}


/*
 * Mobile remains horizontally safe.
 */
@media (max-width: 575.98px) {

    :is(#chartSnapshotModal,[data-fgenio-journal-position-workspace-host])
    [data-custom-journal-action-footer] {
        min-height:
            60px;

        padding:
            10px 12px
            !important;
    }
}


/*
 * FGENIO_CUSTOM_JOURNAL_FOOTER_TITLE_STYLE_V1
 */
:is(#chartSnapshotModal,[data-fgenio-journal-position-workspace-host])
[data-custom-journal-action-footer] {
    display:
        grid
        !important;

    grid-template-columns:
        minmax(0, 1fr)
        auto;

    align-items:
        center;

    gap:
        10px 12px;
}

/*
 * Title occupies the full first row.
 */
:is(#chartSnapshotModal,[data-fgenio-journal-position-workspace-host])
[data-custom-journal-footer-title-wrap] {
    grid-column:
        1 / -1;

    width:
        100%;
}

:is(#chartSnapshotModal,[data-fgenio-journal-position-workspace-host])
[data-custom-journal-footer-title] {
    width:
        100%;

    font-size:
        13px;

    font-weight:
        500;
}

/*
 * AI stays left; Reset/Create stay right.
 */
:is(#chartSnapshotModal,[data-fgenio-journal-position-workspace-host])
[data-custom-journal-stage-ai-action] {
    grid-column:
        1;
}

:is(#chartSnapshotModal,[data-fgenio-journal-position-workspace-host])
[data-custom-journal-action-footer]
> .d-flex:last-child {
    grid-column:
        2;

    justify-self:
        end;

    margin-inline-start:
        0
        !important;
}

/*
 * In Live AI is hidden, so actions still stay on the right.
 */
:is(#chartSnapshotModal,[data-fgenio-journal-position-workspace-host])
[data-custom-journal-stage="executed"]
[data-custom-journal-action-footer]
> .d-flex:last-child {
    grid-column:
        2;

    justify-self:
        end;
}

/*
 * Remove any bottom separator/edge under footer actions.
 */
:is(#chartSnapshotModal,[data-fgenio-journal-position-workspace-host])
[data-custom-journal-action-footer] {
    border-bottom:
        0
        !important;

    box-shadow:
        none;
}

:is(#chartSnapshotModal,[data-fgenio-journal-position-workspace-host])
[data-custom-journal-action-footer]
::after,
:is(#chartSnapshotModal,[data-fgenio-journal-position-workspace-host])
[data-custom-journal-action-footer]
::before {
    border-bottom:
        0
        !important;
}


/*
 * FGENIO_CUSTOM_JOURNAL_FOOTER_TITLE_UI_V2
 *
 * Slightly larger editable footer title with horizontal breathing room.
 */
:is(#chartSnapshotModal,[data-fgenio-journal-position-workspace-host])
[data-custom-journal-footer-title-wrap] {
    padding-inline:
        8px;

    box-sizing:
        border-box;
}

:is(#chartSnapshotModal,[data-fgenio-journal-position-workspace-host])
[data-custom-journal-footer-title-label] {
    display:
        block;

    margin-bottom:
        6px;

    padding-inline:
        2px;

    font-size:
        12px;

    font-weight:
        600;

    color:
        var(--vz-secondary-color);
}

:is(#chartSnapshotModal,[data-fgenio-journal-position-workspace-host])
[data-custom-journal-footer-title] {
    min-height:
        38px;

    height:
        38px;

    padding-inline:
        13px;

    font-size:
        14px;

    font-weight:
        500;

    border-radius:
        12px
        !important;
}


/*
 * FGENIO_CUSTOM_JOURNAL_STAGE_BOTTOM_BORDER_REMOVE_V1
 *
 * Footer already has its own top divider.
 * Do not draw another line below the action area.
 */
:is(#chartSnapshotModal,[data-fgenio-journal-position-workspace-host])
.fgenio-journal-stage-surface {
    border-bottom:
        0
        !important;
}


/*
 * FGENIO_CUSTOM_JOURNAL_FOOTER_BOTTOM_SPACING_V3
 *
 * Give the footer itself a little bottom breathing room
 * so the action buttons sit slightly higher while keeping
 * the bottom area the same footer background color.
 */
:is(#chartSnapshotModal,[data-fgenio-journal-position-workspace-host])
[data-custom-journal-action-footer] {
    padding-bottom:
        8px
        !important;

    min-height:
        auto;
}




/*
 * FGENIO_CUSTOM_JOURNAL_RTL_TEXT_STYLE_V1
 *
 * RTL journal title/description fields use the same
 * Persian/Arabic font contract as the FGenio frontend.
 */
:is(#chartSnapshotModal,[data-fgenio-journal-position-workspace-host])
input[dir="rtl"],
:is(#chartSnapshotModal,[data-fgenio-journal-position-workspace-host])
textarea[dir="rtl"],
:is(#chartSnapshotModal,[data-fgenio-journal-position-workspace-host])
.ql-editor[dir="rtl"] {
    direction:
        rtl
        !important;

    text-align:
        right
        !important;

    font-family:
        'Noto Sans Arabic',
        sans-serif
        !important;
}

:is(#chartSnapshotModal,[data-fgenio-journal-position-workspace-host])
input[dir="ltr"],
:is(#chartSnapshotModal,[data-fgenio-journal-position-workspace-host])
textarea[dir="ltr"],
:is(#chartSnapshotModal,[data-fgenio-journal-position-workspace-host])
.ql-editor[dir="ltr"] {
    direction:
        ltr;

    text-align:
        left;
}


/*
 * FGENIO_IDEA_DESCRIPTION_FILL_VIEW_STYLE_V1
 *
 * Idea stage:
 * let the description editor consume all remaining vertical
 * space between Bias and the fixed Journal footer.
 */

:is(#chartSnapshotModal,[data-fgenio-journal-position-workspace-host])
[data-custom-journal-idea-panel] {
    display:
        flex;

    flex-direction:
        column;

    min-height:
        0;
}

/*
 * Bias keeps natural height.
 * Description consumes the remaining space.
 */
:is(#chartSnapshotModal,[data-fgenio-journal-position-workspace-host])
[data-custom-journal-idea-description-wrap] {
    flex:
        1 1 auto;

    min-height:
        0;

    display:
        flex;

    flex-direction:
        column;
}

/*
 * Collapse body must participate in flex growth.
 */
:is(#chartSnapshotModal,[data-fgenio-journal-position-workspace-host])
[data-custom-journal-idea-description-collapse].show {
    flex:
        1 1 auto;

    min-height:
        0;

    display:
        flex;

    flex-direction:
        column;
}

/*
 * Quill wrapper fills the collapse body.
 */
:is(#chartSnapshotModal,[data-fgenio-journal-position-workspace-host])
[data-custom-journal-idea-editor] {
    flex:
        1 1 auto;

    min-height:
        0;

    display:
        flex;

    flex-direction:
        column;
}

/*
 * Toolbar keeps natural height.
 */
:is(#chartSnapshotModal,[data-fgenio-journal-position-workspace-host])
[data-custom-journal-idea-editor]
.ql-toolbar {
    flex:
        0 0 auto;
}

/*
 * Actual Quill container fills all remaining height.
 */
:is(#chartSnapshotModal,[data-fgenio-journal-position-workspace-host])
[data-custom-journal-idea-editor]
.ql-container.ql-snow {
    flex:
        1 1 auto;

    min-height:
        0
        !important;

    height:
        auto
        !important;
}

/*
 * Editor body follows the full available Quill height.
 */
:is(#chartSnapshotModal,[data-fgenio-journal-position-workspace-host])
[data-custom-journal-idea-editor]
.ql-editor {
    min-height:
        100%
        !important;

    height:
        100%;
}

/*
 * The original placeholder host carries an inline min-height:190px.
 * Override it so flex sizing can control the actual viewport height.
 */
:is(#chartSnapshotModal,[data-fgenio-journal-position-workspace-host])
[data-custom-journal-idea-quill] {
    flex:
        1 1 auto;

    min-height:
        0
        !important;

    height:
        auto
        !important;
}


/*
 * FGENIO_CUSTOM_JOURNAL_INTERNAL_DIVIDER_SPACING_STYLE_V1
 *
 * Internal stage sections use whitespace instead of visible divider lines.
 * Header/footer separators remain untouched.
 */
:is(#chartSnapshotModal,[data-fgenio-journal-position-workspace-host])
[data-custom-journal-panel]
.fgenio-journal-section-gap {
    display:
        block;

    width:
        100%;

    height:
        14px;

    min-height:
        14px;

    flex:
        0 0 14px;

    border:
        0
        !important;

    margin:
        0;

    padding:
        0;
}


/*
 * FGENIO_JOURNAL_STAGE_BOTTOM_PADDING_ZERO_V1
 *
 * Bootstrap py-3 on the stage surface adds bottom padding below
 * the fixed Journal footer, producing a second-colored strip.
 *
 * Keep the existing top spacing, remove only the bottom gap.
 */
:is(#chartSnapshotModal,[data-fgenio-journal-position-workspace-host])
.fgenio-journal-stage-surface {
    padding-bottom:
        0
        !important;
}


/*
 * FGENIO_AI_JOURNAL_CHAT_OVERLAY_STYLE_V1
 *
 * AI assistant is an overlay inside the existing Journal drawer.
 * No nested Bootstrap modal / backdrop.
 */

:is(#chartSnapshotModal,[data-fgenio-journal-position-workspace-host])
.modal-content {
    position:
        relative;
}

:is(#chartSnapshotModal,[data-fgenio-journal-position-workspace-host])
.fgenio-ai-journal-chat-layer {
    position:
        absolute;

    inset:
        0;

    z-index:
        40;

    display:
        none;

    flex-direction:
        column;

    min-width:
        0;

    min-height:
        0;

    background:
        var(--vz-modal-bg, var(--vz-body-bg));

    color:
        var(--vz-body-color);
}

:is(#chartSnapshotModal,[data-fgenio-journal-position-workspace-host])
.fgenio-ai-journal-chat-layer.is-open {
    display:
        flex;
}


/*
 * Chat header.
 */
:is(#chartSnapshotModal,[data-fgenio-journal-position-workspace-host])
.fgenio-ai-journal-chat-header {
    flex:
        0 0 auto;

    min-height:
        68px;

    padding:
        12px 14px;

    display:
        flex;

    align-items:
        center;

    justify-content:
        space-between;

    gap:
        12px;

    border-bottom:
        1px solid
        var(--vz-border-color);

    background:
        var(--vz-modal-bg, var(--vz-body-bg));
}

:is(#chartSnapshotModal,[data-fgenio-journal-position-workspace-host])
.fgenio-ai-journal-chat-avatar {
    width:
        38px;

    height:
        38px;

    flex:
        0 0 38px;

    display:
        inline-flex;

    align-items:
        center;

    justify-content:
        center;

    border-radius:
        50%;

    font-size:
        18px;

    color:
        var(--vz-primary);

    background:
        rgba(
            var(--vz-primary-rgb),
            .12
        );
}

:is(#chartSnapshotModal,[data-fgenio-journal-position-workspace-host])
.fgenio-ai-journal-chat-close {
    width:
        38px;

    height:
        38px;

    border:
        1px solid
        var(--vz-border-color);

    border-radius:
        50%;

    display:
        inline-flex;

    align-items:
        center;

    justify-content:
        center;

    color:
        var(--vz-body-color);

    background:
        transparent;

    font-size:
        20px;
}

:is(#chartSnapshotModal,[data-fgenio-journal-position-workspace-host])
.fgenio-ai-journal-chat-close:hover {
    background:
        var(--vz-secondary-bg);
}


/*
 * Message stream.
 */
:is(#chartSnapshotModal,[data-fgenio-journal-position-workspace-host])
.fgenio-ai-journal-chat-stream {
    flex:
        1 1 auto;

    min-height:
        0;

    overflow-y:
        auto;

    overflow-x:
        hidden;

    padding:
        18px 14px;

    display:
        flex;

    flex-direction:
        column;

    gap:
        14px;

    background:
        var(--vz-secondary-bg);
}

:is(#chartSnapshotModal,[data-fgenio-journal-position-workspace-host])
.fgenio-ai-journal-message {
    width:
        100%;

    display:
        flex;

    align-items:
        flex-end;

    gap:
        8px;
}

:is(#chartSnapshotModal,[data-fgenio-journal-position-workspace-host])
.fgenio-ai-journal-message.is-user {
    justify-content:
        flex-end;
}

:is(#chartSnapshotModal,[data-fgenio-journal-position-workspace-host])
.fgenio-ai-journal-message-avatar {
    width:
        28px;

    height:
        28px;

    flex:
        0 0 28px;

    display:
        inline-flex;

    align-items:
        center;

    justify-content:
        center;

    border-radius:
        50%;

    color:
        var(--vz-primary);

    background:
        rgba(
            var(--vz-primary-rgb),
            .12
        );

    font-size:
        13px;
}

:is(#chartSnapshotModal,[data-fgenio-journal-position-workspace-host])
.fgenio-ai-journal-message-content {
    max-width:
        95%;
}

:is(#chartSnapshotModal,[data-fgenio-journal-position-workspace-host])
.fgenio-ai-journal-message-bubble {
    padding:
        10px 12px;

    border:
        1px solid
        var(--vz-border-color);

    border-radius:
        14px 14px 14px 4px;

    background:
        var(--vz-body-bg);

    line-height:
        1.55;

    white-space:
        pre-wrap;

    overflow-wrap:
        anywhere;
}

:is(#chartSnapshotModal,[data-fgenio-journal-position-workspace-host])
.fgenio-ai-journal-message.is-user
.fgenio-ai-journal-message-bubble {
    color:
        #fff;

    background:
        var(--vz-primary);

    border-color:
        var(--vz-primary);

    border-radius:
        14px 14px 4px 14px;
}


/*
 * Apply result row.
 * Disabled until AI Task integration is attached.
 */

:is(#chartSnapshotModal,[data-fgenio-journal-position-workspace-host])
.fgenio-ai-journal-chat-apply
.form-switch
[data-ai-journal-disclaimer-acknowledgement] {
    cursor: pointer;
    margin-top: 0;
}

:is(#chartSnapshotModal,[data-fgenio-journal-position-workspace-host])
.fgenio-ai-journal-chat-apply
.form-switch
.form-check-label {
    margin-left: 0.45rem;
    cursor: pointer;
}




/*
 * Composer.
 */
:is(#chartSnapshotModal,[data-fgenio-journal-position-workspace-host])
.fgenio-ai-journal-chat-composer {
    flex:
        0 0 auto;

    padding:
        10px 12px 12px;

    background:
        var(--vz-modal-bg, var(--vz-body-bg));
}

:is(#chartSnapshotModal,[data-fgenio-journal-position-workspace-host])
.fgenio-ai-journal-chat-input-wrap {
    display:
        flex;

    flex-direction:
        column;

    align-items:
        stretch;

    gap:
        8px;
}

:is(#chartSnapshotModal,[data-fgenio-journal-position-workspace-host])
[data-ai-journal-chat-input] {
    min-height:
        42px;

    max-height:
        120px;

    resize:
        none;

    border-radius:
        12px;

    padding:
        10px 12px;
}

:is(#chartSnapshotModal,[data-fgenio-journal-position-workspace-host])
.fgenio-ai-journal-chat-send {
    width:
        42px;

    height:
        42px;

    flex:
        0 0 42px;

    padding:
        0;

    display:
        inline-flex;

    align-items:
        center;

    justify-content:
        center;

    border-radius:
        12px;
}


/*
 * Dark mode chat stream.
 */
[data-bs-theme="dark"]
:is(#chartSnapshotModal,[data-fgenio-journal-position-workspace-host])
.fgenio-ai-journal-chat-stream,
html[data-layout-mode="dark"]
:is(#chartSnapshotModal,[data-fgenio-journal-position-workspace-host])
.fgenio-ai-journal-chat-stream {
    background:
        rgba(
            0,
            0,
            0,
            .12
        );
}


/*
 * FGENIO_AI_JOURNAL_LANGUAGE_FIELD_STYLE_V2
 */

:is(#chartSnapshotModal,[data-fgenio-journal-position-workspace-host])
.fgenio-ai-journal-language-field {
    width:
        290px;

    max-width:
        42%;

    flex:
        0 0 auto;
}

:is(#chartSnapshotModal,[data-fgenio-journal-position-workspace-host])
.fgenio-ai-journal-language-field
.form-label {
    font-size:
        11px;

    font-weight:
        600;

    color:
        var(--vz-secondary-color);
}

:is(#chartSnapshotModal,[data-fgenio-journal-position-workspace-host])
.fgenio-ai-journal-language-quality {
    display:
        flex;

    flex-wrap:
        wrap;

    gap:
        4px 10px;

    margin-top:
        5px;

    font-size:
        10px;

    color:
        var(--vz-secondary-color);
}

:is(#chartSnapshotModal,[data-fgenio-journal-position-workspace-host])
.fgenio-ai-journal-language-quality
strong {
    color:
        var(--vz-success);
}

@media (max-width: 767.98px) {

    :is(#chartSnapshotModal,[data-fgenio-journal-position-workspace-host])
    .fgenio-ai-journal-chat-header {
        flex-wrap:
            wrap;
    }

    :is(#chartSnapshotModal,[data-fgenio-journal-position-workspace-host])
    .fgenio-ai-journal-language-field {
        width:
            100%;

        max-width:
            none;
    }
}


/*
 * FGENIO_AI_JOURNAL_LANGUAGE_SELECT_RADIUS_V1
 */
:is(#chartSnapshotModal,[data-fgenio-journal-position-workspace-host])
[data-ai-journal-language-select] {
    border-radius:
        12px
        !important;
}


:is(#chartSnapshotModal,[data-fgenio-journal-position-workspace-host])
.fgenio-ai-journal-chat-actions {
    display:
        flex;

    align-items:
        center;

    justify-content:
        space-between;

    gap:
        8px;
}

:is(#chartSnapshotModal,[data-fgenio-journal-position-workspace-host])
[data-ai-journal-chat-input] {
    width:
        100%;
}


/*
 * FGENIO_SHARED_JOURNAL_POSITION_VISUAL_HOST_GEOMETRY_V1
 *
 * Shared host geometry only.
 * All actual component visual rules remain canonical above.
 */
[data-fgenio-journal-position-workspace-host] {
    min-width: 0;
    min-height: 0;
}

[data-fgenio-journal-position-workspace-host]
[data-custom-journal-stage-body] {
    min-width: 0;
    min-height: 0;
}

[data-fgenio-journal-position-workspace-host]
[data-fgenio-journal-position-workspace] {
    min-width: 0;
    min-height: 0;
    width: 100%;
}


/*
 * FGENIO_JOURNAL_FINAL_NARROW_HOST_V2
 */

[data-fgenio-journal-position-workspace-host] {
    container-type: inline-size;
}

[data-fgenio-journal-position-workspace-host]
.journal-stage-gen-body {
    padding: 14px 14px 18px !important;
}


/* Structural row stays one line */
[data-fgenio-journal-position-workspace-host]
[data-custom-journal-structural-row] {
    display: flex;
    flex-wrap: nowrap !important;
    width: 100%;
    min-width: 0;
}

[data-fgenio-journal-position-workspace-host]
[data-custom-journal-structural-row]
> .input-group-text:first-child {
    flex: 0 0 auto;
    width: auto;
    min-width: 0;
    white-space: nowrap;
    padding-inline: 7px;
}

[data-fgenio-journal-position-workspace-host]
.fgenio-structural-select-wrap {
    flex: 0 0 auto;
    width: auto;
    min-width: 0;
}

[data-fgenio-journal-position-workspace-host]
.fgenio-structural-select-wrap
.form-select {
    width: auto !important;
    min-width: 0 !important;
    padding-left: 6px;
    padding-right: 22px;
}

[data-fgenio-journal-position-workspace-host]
[data-fgenio-structural-select="timeframe"]
.form-select {
    width: 58px !important;
}

[data-fgenio-journal-position-workspace-host]
[data-fgenio-structural-select="condition"]
.form-select {
    width: 94px !important;
}

[data-fgenio-journal-position-workspace-host]
[data-custom-journal-position-field="structural-invalidation-price"] {
    flex: 1 1 auto !important;
    width: 0;
    min-width: 54px !important;
}


/* Exact Live footer contract, adapted only for host width */
[data-fgenio-journal-position-workspace-host]
[data-custom-journal-action-footer] {
    display: grid !important;

    grid-template-columns:
        minmax(0, 1fr)
        auto;

    align-items: center;

    gap: 8px 10px;

    /*
     * FGENIO_JOURNAL_STAGE_GEN_FOOTER_CONTAINMENT_V1
     *
     * Footer is a flex sibling of the scrolling body.
     * It must remain fully inside the Journal right column.
     */
    margin:
        0
        !important;

    width:
        100%;

    flex:
        0 0 auto;

    padding:
        12px 14px
        !important;

    min-height: 0;

    background:
        var(
            --vz-modal-bg,
            var(--vz-body-bg)
        );
}

[data-fgenio-journal-position-workspace-host]
[data-custom-journal-footer-title-wrap] {
    grid-column: 1 / -1;
    width: 100%;
    min-width: 0;
}

[data-fgenio-journal-position-workspace-host]
[data-custom-journal-footer-title] {
    width: 100%;
}

[data-fgenio-journal-position-workspace-host]
[data-custom-journal-stage-ai-action] {
    grid-column: 1;
    justify-self: start;
    min-width: 0;
    max-width: 100%;
}

[data-fgenio-journal-position-workspace-host]
[data-custom-journal-action-footer]
> .d-flex:last-child {
    grid-column: 2;
    justify-self: end;
    margin-inline-start: 0 !important;
    flex-wrap: nowrap;
}


/* Setup on very narrow Journal column */
@container (max-width: 390px) {

    [data-fgenio-journal-position-workspace-host]
    [data-custom-journal-action-footer] {
        grid-template-columns: 1fr;
    }

    [data-fgenio-journal-position-workspace-host]
    [data-custom-journal-stage-ai-action] {
        grid-column: 1;
        width: 100%;
        justify-content: center;
    }

    [data-fgenio-journal-position-workspace-host]
    [data-custom-journal-action-footer]
    > .d-flex:last-child {
        grid-column: 1;
        width: 100%;
        justify-self: stretch;
    }

    [data-fgenio-journal-position-workspace-host]
    [data-custom-journal-action-footer]
    > .d-flex:last-child
    .btn {
        flex: 1 1 0;
    }
}


/*
 * FGENIO_JOURNAL_STAGE_GEN_TITLE_PADDING_V1
 *
 * Narrow-host footer title needs less horizontal breathing room
 * than the full Live Chart drawer.
 */
[data-fgenio-journal-position-workspace-host]
[data-custom-journal-action-footer] {
    padding-left:
        8px
        !important;

    padding-right:
        8px
        !important;
}

[data-fgenio-journal-position-workspace-host]
[data-custom-journal-footer-title-wrap] {
    padding-left:
        0
        !important;

    padding-right:
        0
        !important;
}

[data-fgenio-journal-position-workspace-host]
[data-custom-journal-footer-title] {
    padding-inline:
        10px;
}


/*
 * Mixed RTL/LTR fields must not inherit an incorrect host direction.
 * JS sets the final direction and font inline.
 */
[data-fgenio-journal-position-workspace-host]
[data-custom-journal-footer-title],

[data-fgenio-journal-position-workspace-host]
[data-custom-journal-position-title],

[data-fgenio-journal-position-workspace-host]
[data-custom-journal-position-note] {
    unicode-bidi:
        plaintext;
}


/*
 * FGENIO_JOURNAL_STAGE_GEN_TITLE_PADDING_V1
 *
 * Narrow-host footer title needs less horizontal breathing room
 * than the full Live Chart drawer.
 */
[data-fgenio-journal-position-workspace-host]
[data-custom-journal-action-footer] {
    padding-left:
        8px
        !important;

    padding-right:
        8px
        !important;
}

[data-fgenio-journal-position-workspace-host]
[data-custom-journal-footer-title-wrap] {
    padding-left:
        0
        !important;

    padding-right:
        0
        !important;
}

[data-fgenio-journal-position-workspace-host]
[data-custom-journal-footer-title] {
    padding-inline:
        10px;
}


/*
 * Mixed RTL/LTR fields must not inherit an incorrect host direction.
 * JS sets the final direction and font inline.
 */
[data-fgenio-journal-position-workspace-host]
[data-custom-journal-footer-title],

[data-fgenio-journal-position-workspace-host]
[data-custom-journal-position-title],

[data-fgenio-journal-position-workspace-host]
[data-custom-journal-position-note] {
    unicode-bidi:
        plaintext;
}


/*
 * FGENIO_JOURNAL_STAGE_GEN_TITLE_PADDING_V1
 *
 * Narrow-host footer title needs less horizontal breathing room
 * than the full Live Chart drawer.
 */
[data-fgenio-journal-position-workspace-host]
[data-custom-journal-action-footer] {
    padding-left:
        8px
        !important;

    padding-right:
        8px
        !important;
}

[data-fgenio-journal-position-workspace-host]
[data-custom-journal-footer-title-wrap] {
    padding-left:
        0
        !important;

    padding-right:
        0
        !important;
}

[data-fgenio-journal-position-workspace-host]
[data-custom-journal-footer-title] {
    padding-inline:
        10px;
}


/*
 * Mixed RTL/LTR fields must not inherit an incorrect host direction.
 * JS sets the final direction and font inline.
 */
[data-fgenio-journal-position-workspace-host]
[data-custom-journal-footer-title],

[data-fgenio-journal-position-workspace-host]
[data-custom-journal-position-title],

[data-fgenio-journal-position-workspace-host]
[data-custom-journal-position-note] {
    unicode-bidi:
        plaintext;
}

/*
 * FGENIO_JOURNAL_NESTED_POSITION_SCROLL_AND_QUILL_PARITY_V1
 *
 * Shared Position Workspace adds one wrapper between Stage Body and
 * Setup / Live panel. Restore the same internal-scroll contract that
 * Idea panel already has, and keep Setup/Live Quill presentation aligned
 * with Idea Description.
 */

:is(#chartSnapshotModal,[data-fgenio-journal-position-workspace-host])
[data-custom-journal-stage-body]
> [data-fgenio-journal-position-workspace] {
    flex:
        1 1 auto;

    min-height:
        0;

    display:
        flex;

    flex-direction:
        column;

    overflow:
        hidden;
}

:is(#chartSnapshotModal,[data-fgenio-journal-position-workspace-host])
[data-custom-journal-stage-body]
> [data-fgenio-journal-position-workspace]
> [data-custom-journal-panel]:not(.d-none) {
    flex:
        1 1 auto;

    min-height:
        0;

    overflow-y:
        auto;

    overflow-x:
        hidden;

    padding-bottom:
        16px;
}


/*
 * Setup Why / Live Trade Why rich editor.
 * Match the canonical Idea Description Quill surface.
 */

:is(#chartSnapshotModal,[data-fgenio-journal-position-workspace-host])
[data-custom-journal-position-note-editor] {
    display:
        flex;

    flex-direction:
        column;

    min-height:
        190px;
}

:is(#chartSnapshotModal,[data-fgenio-journal-position-workspace-host])
[data-custom-journal-position-note-editor]
.ql-toolbar {
    flex:
        0 0 auto;
}

:is(#chartSnapshotModal,[data-fgenio-journal-position-workspace-host])
[data-custom-journal-position-note-editor]
.ql-container.ql-snow {
    flex:
        1 1 auto;

    min-height:
        150px
        !important;

    height:
        auto
        !important;
}

:is(#chartSnapshotModal,[data-fgenio-journal-position-workspace-host])
[data-custom-journal-position-note-editor]
.ql-editor {
    min-height:
        150px
        !important;
}

:is(#chartSnapshotModal,[data-fgenio-journal-position-workspace-host])
[data-custom-journal-position-note-quill] {
    flex:
        1 1 auto;

    min-height:
        150px
        !important;

    height:
        auto
        !important;
}

