/* "My assembly" builder under the custom catalog card (home page): combined backtest curve on top, the pair bots as the
   table of the bot page below it (pairs-table.css), summary bar and the inline connect block (exchange -> API keys -> deposit).
   Reuses the catalog layout classes of bot-catalog.css and the onboarding form classes of onboarding.css.
   Source: resources/css/assembly-module.css -> public/css. */
.asm-module { border-top: 1px solid var(--catalog-border); }
.asm-module[hidden] { display: none; }
.asm-open[aria-expanded="true"] .bi::before { content: "\f286"; } /* bi-chevron-up */

/* one column: the chart block takes the whole width, the table sits under it */
.asm-overview.catalog-overview { grid-template-columns: minmax(0, 1fr); }
.asm-overview .catalog-performance { padding: 24px 28px 22px; }
/* table of trading bots under the chart (pairs-table.js / pairs-table.css); the --pg-* tokens of the bot page map to the catalog ones */
.asm-table-section { padding: 20px 28px 24px; border-top: 1px solid var(--catalog-border); background: var(--catalog-panel); }
.asm-table-section .catalog-section-title { margin-bottom: 14px; }
.asm-panel-tip { margin-left: 4px; font-size: 12px; vertical-align: 1px; }
.asm-table.ptb { --pg-border: var(--catalog-border); --pg-muted: var(--catalog-muted); --pg-panel: var(--catalog-panel); --pg-surface: var(--catalog-surface); --pg-heading: var(--x-heading-color, #fff); --pg-danger: #ec6a87; }
.asm-table .ptb-scroll { max-height: 640px; background: var(--catalog-surface); }
.asm-table .ptb-card, .asm-table .ptb-search, .asm-table .ptb-risk-input { background: var(--catalog-surface); }
.asm-table .ptb-search { border-color: var(--catalog-border); color: var(--x-heading-color, #fff); }
.asm-table .ptb-search:focus { border-color: var(--bot-accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--bot-accent) 22%, transparent); }
.asm-table .ptb-limit { text-align: left; }
/* composition of the selection: compact third tile next to P&L and trades */
.asm-kpi-composition { margin: 0; gap: 0; justify-content: space-between; padding-block: 10px; }
/* the lines themselves are .catalog-kpi-line (bot-catalog.css), shared with the catalog composition tile */
.asm-kpi-risk { color: var(--bot-accent) !important; }
.asm-alert { margin: 12px 0 0; }

/* monthly result under the chart: a caption, then the catalog's scrollable month cells */
.asm-monthly { flex-direction: column; align-items: stretch; gap: 12px; }
.asm-monthly-title { display: flex; align-items: baseline; flex-wrap: wrap; gap: 6px 8px; margin: 0; font-size: 12px; font-weight: 600; color: var(--x-heading-color, #fff); }
.asm-monthly-title i { color: var(--bot-accent); font-size: 11px; }
.asm-monthly-title small { font-size: 10.5px; font-weight: 400; color: var(--catalog-muted); }
.asm-monthly-row { display: flex; align-items: center; gap: 8px; min-width: 0; }

/* summary bar: counts, strategy name, "Connect" */
.asm-bar { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; padding: 16px 28px; border-top: 1px solid var(--catalog-border); background: var(--catalog-panel); }
.asm-bar-summary { display: flex; gap: 16px; font-size: 12px; color: var(--catalog-muted); white-space: nowrap; }
.asm-bar-summary strong { color: var(--x-heading-color, #fff); font-size: 15px; font-variant-numeric: tabular-nums; margin-right: 4px; }
.asm-bar .asm-name { flex: 1 1 220px; min-width: 0; max-width: 360px; margin: 0 0 0 auto; border-radius: 10px; font-size: 13px; height: 44px; min-height: 0; padding: 0 14px; line-height: 42px; background: var(--catalog-surface); border-color: var(--catalog-border); color: var(--x-heading-color, #fff); }
.asm-bar .asm-name:focus { border-color: var(--bot-accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--bot-accent) 25%, transparent); }
.asm-bar .asm-connect-btn { font-size: 12px; border-radius: 10px; height: 44px; padding: 0 16px; margin: 0; display: inline-flex; align-items: center; gap: 12px; }
.asm-bar .asm-connect-btn:disabled { opacity: .45; }
.asm-bar .asm-cta-note { flex: 1 1 260px; margin: 0 0 0 auto; max-width: 440px; font-size: 12px; line-height: 1.45; color: var(--catalog-muted); text-align: right; }
.asm-bar .asm-cta { font-size: 13px; border-radius: 10px; height: 44px; padding: 0 18px; margin: 0; display: inline-flex; align-items: center; gap: 12px; white-space: nowrap; }
/* public page: the CTA bar sticks to the bottom of the screen while the builder is in view */
/* (overflow: clip instead of the card's hidden, which would make the card a scroll container and break sticky) */
.catalog-bot:has(> .asm-module--public) { overflow: clip; }
.asm-module--public .asm-bar { position: sticky; bottom: 0; z-index: 5; background: rgba(11, 18, 34, .96); -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px); box-shadow: 0 -10px 24px rgba(4, 8, 18, .45); }
.asm-bar .asm-connect-btn[aria-expanded="true"] { background: var(--catalog-surface); border-color: var(--bot-accent); color: var(--bot-accent); }

/* inline connect block: the onboarding form styles need the --ob-* tokens (the modal defines them on #connectModal) */
.asm-connect.edvi-onboarding {
    --ob-bg: var(--x-body-bg, #0e192e); --ob-panel: var(--x-tertiary-bg, #172439); --ob-border: var(--x-border-color, #334155);
    --ob-text: var(--x-body-color, #cbd5e1); --ob-muted: var(--x-secondary-color, #94a3b8); --ob-accent: #2fa89f; --ob-soft: rgba(16, 99, 94, .2);
    --ob-track: #27354c; --ob-success: #28c9a2;
    color: var(--ob-text); border-top: 1px solid var(--catalog-border); padding: 24px 28px 0;
}
.asm-connect[hidden] { display: none; }
.asm-connect .asm-form { max-width: none; }
.asm-connect-head { display: flex; flex-direction: column; gap: 14px; margin-bottom: 22px; }
.asm-connect-head .onboard-description { margin: 0; max-width: 620px; }
.asm-connect-title { margin: 0; font-size: 19px; font-weight: 650; letter-spacing: -.04em; }
.asm-connect .asm-track { grid-template-columns: repeat(3, 1fr); margin-bottom: 20px; }
.asm-step-title { font-size: 20px; font-weight: 650; letter-spacing: -.04em; line-height: 1.3; margin: 0; }
.asm-step[hidden] { display: none; }
.asm-step { animation: asm-step-in .25s ease; }
@keyframes asm-step-in { from { opacity: 0; transform: translateX(10px); } to { opacity: 1; transform: none; } }
.asm-connect .onboard-exchange-option input:disabled + .onboard-exchange { opacity: .45; cursor: not-allowed; }
.asm-connect.is-keys-locked .onboard-exchange { pointer-events: none; }
/* deposit asset switch (Binance only); stepform.js toggles .onboard-asset globally, so the block has its own class */
.asm-asset { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 16px; padding: 12px 16px; border: 1px solid var(--ob-border); border-radius: 13px; }
.asm-asset__label { font-size: 12px; font-weight: 600; display: inline-flex; align-items: center; gap: 6px; }
.asm-asset__label i { color: var(--ob-muted); font-size: 11px; }
.asm-asset__options { display: inline-flex; gap: 4px; padding: 3px; border: 1px solid var(--ob-border); border-radius: 10px; }
.asm-asset__options label { margin: 0; cursor: pointer; position: relative; }
.asm-asset__options input { position: absolute; opacity: 0; pointer-events: none; }
.asm-asset__options span { display: inline-block; padding: 6px 12px; border-radius: 8px; font-size: 12px; font-weight: 600; color: var(--ob-muted); }
.asm-asset__options input:checked + span { background: var(--ob-soft); color: var(--ob-text); box-shadow: inset 0 0 0 1px var(--ob-accent); }
.asm-connect .asm-footer { position: static; background: transparent; }
.asm-connect .asm-footer .btn-primary, .asm-connect .asm-footer .btn-neutral { height: auto; min-height: 43px; line-height: 1.4; padding: 11px 18px; border-radius: 11px; font-size: 13px; }
.asm-connect .asm-footer { justify-content: flex-end; }
/* back / forward next to the step counter */
.asm-connect .asm-nav { display: inline-flex; align-items: center; gap: 8px; flex-shrink: 0; }
.asm-connect .asm-nav-btn { width: 34px; height: 34px; display: inline-flex; align-items: center; justify-content: center; padding: 0; border-radius: 10px; border: 1px solid var(--ob-border); background: var(--ob-panel); color: var(--ob-text); font-size: 15px; transition: border-color .15s, color .15s, background .15s; }
.asm-connect .asm-nav-btn:hover:not(:disabled) { border-color: var(--ob-accent); color: var(--ob-accent); }
.asm-connect .asm-nav-btn:focus-visible { outline: 2px solid var(--ob-accent); outline-offset: 2px; }
.asm-connect .asm-nav-btn:disabled { opacity: .3; cursor: default; }
.asm-connect .asm-error.is-warning { background: rgba(224,169,74,.08); border-color: rgba(224,169,74,.35); color: #e0a94a; }
.asm-connect .asm-finish .loader-success { display: none; }

/* four tiles (P&L, drawdown, trades, composition) in a row; two per row when the left column is narrow */
.asm-overview .catalog-kpis { grid-template-columns: minmax(0, 1fr) minmax(0, .8fr) minmax(0, 1fr) minmax(0, 1.2fr); }
@container catalog-performance (max-width: 880px) {
    .asm-overview .catalog-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .asm-overview .catalog-kpi--trades { grid-column: auto; }
}
@container catalog-performance (max-width: 500px) { .asm-overview .catalog-kpis { grid-template-columns: minmax(0, 1fr); } }
@media (max-width: 767px) {
    .asm-overview .catalog-performance { padding-right: 18px; }
    .asm-table-section { padding: 16px 18px 20px; }
    .asm-bar { padding: 14px 18px; }
    .asm-bar .asm-name { max-width: none; margin-left: 0; flex-basis: 100%; }
    .asm-bar .asm-connect-btn { width: 100%; justify-content: center; }
    .asm-bar .asm-cta-note { max-width: none; margin-left: 0; flex-basis: 100%; text-align: left; }
    .asm-bar .asm-cta { width: 100%; justify-content: center; }
    .asm-connect.edvi-onboarding { padding: 20px 18px 0; }
}
@media (prefers-reduced-motion: reduce) { .asm-step { animation: none; } }
/* loading after a change of the selection or risk: chart cleared, shimmering skeleton, KPI values as placeholders */
@keyframes asm-shimmer { from { background-position: 150% 0; } to { background-position: -50% 0; } }
.asm-is-loading .asm-chart { visibility: hidden; }
.asm-is-loading .catalog-chart-wrap:has(.asm-chart)::after {
    content: ""; position: absolute; inset: 8px 4px 4px; border-radius: 14px; pointer-events: none;
    background:
        linear-gradient(100deg, transparent 30%, color-mix(in srgb, var(--bot-accent, #2fa89f) 14%, transparent) 50%, transparent 70%) 0 0 / 200% 100%,
        repeating-linear-gradient(to bottom, transparent 0 47px, color-mix(in srgb, var(--catalog-border, #263044) 70%, transparent) 47px 48px),
        linear-gradient(to top, color-mix(in srgb, var(--bot-accent, #2fa89f) 10%, transparent), transparent 70%);
    -webkit-mask: linear-gradient(to bottom, #000 0 100%);
    animation: asm-shimmer 1.4s linear infinite;
}
.asm-is-loading .catalog-chart-wrap:has(.asm-chart) .catalog-chart-empty { display: none !important; }
.asm-is-loading .catalog-kpi strong, .asm-is-loading .catalog-kpi [data-field="trades-rate"], .asm-is-loading [data-field="drawdown-open"] {
    color: transparent !important; border-radius: 6px;
    background: linear-gradient(100deg, color-mix(in srgb, var(--catalog-border, #263044) 70%, transparent) 30%, color-mix(in srgb, var(--bot-accent, #2fa89f) 22%, transparent) 50%, color-mix(in srgb, var(--catalog-border, #263044) 70%, transparent) 70%) 0 0 / 200% 100%;
    animation: asm-shimmer 1.4s linear infinite;
}
.asm-is-loading .catalog-winbar { opacity: .35; }
@media (prefers-reduced-motion: reduce) { .asm-is-loading .catalog-chart-wrap:has(.asm-chart)::after, .asm-is-loading .catalog-kpi strong, .asm-is-loading .catalog-kpi [data-field="trades-rate"], .asm-is-loading [data-field="drawdown"] { animation: none; } }
/* the table comes first now, the chart below it */
.asm-table-section { border-top: 0; border-bottom: 1px solid var(--catalog-border); }
.asm-overview { scroll-margin-top: 76px; }
/* "View chart": sticky at the bottom left of the table while it is scrolled through, appears after every change */
.asm-chart-jump { position: sticky; bottom: calc(16px + env(safe-area-inset-bottom, 0px)); z-index: 6; height: 0; }
.asm-chart-jump-btn { position: absolute; left: 10px; bottom: 10px; display: inline-flex; align-items: center; gap: 7px; height: 34px; padding: 0 14px; border: 0; border-radius: 999px; background: var(--bot-accent, #2fa89f); color: #0b1222; font-size: 12.5px; font-weight: 650; cursor: pointer; box-shadow: 0 8px 22px rgba(0, 0, 0, .45), 0 0 0 4px color-mix(in srgb, var(--bot-accent, #2fa89f) 22%, transparent); animation: asm-jump-in .25s ease; }
.asm-chart-jump-btn[hidden] { display: none; }
.asm-chart-jump-btn:hover { filter: brightness(1.08); }
.asm-chart-jump-btn:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }
@keyframes asm-jump-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@media (max-width: 767px) { .asm-chart-jump-btn { left: 0; height: 40px; font-size: 13.5px; } }
@media (prefers-reduced-motion: reduce) { .asm-chart-jump-btn { animation: none; } }
/* the custom card clips its corners with overflow: clip (not hidden), so the sticky "View chart" button follows the viewport */
.catalog-bot:has(#assembly-module) { overflow: clip; }
/* public page: the sticky CTA bar (.asm-bar) also sits at the bottom, so "View chart" floats just above it */
.asm-module--public .asm-chart-jump { bottom: calc(var(--asm-public-bar, 78px) + 6px + env(safe-area-inset-bottom, 0px)); }
@media (max-width: 767px) {
    .asm-module--public { --asm-public-bar: 118px; }
    .asm-module--public .asm-bar-summary { display: none; } /* the counts are in the composition tile too; keeps the sticky bar low on phones */
    .asm-module--public .asm-bar { gap: 8px 14px; padding: 10px 16px calc(10px + env(safe-area-inset-bottom, 0px)); }
    .asm-module--public .asm-bar .asm-cta-note { font-size: 11px; line-height: 1.35; }
    .asm-module--public .asm-bar .asm-cta { height: 40px; }
}

/* custom date range of the chart (between the title and 1W/1M/3M/All), 2026-10-24 */
.asm-module .asm-dates { display: inline-flex; flex-shrink: 0; align-items: center; gap: 6px; margin-left: auto; padding: 3px 6px; border: 1px solid var(--catalog-border); border-radius: 10px; background: rgba(128,145,178,.04); }
.asm-module .asm-dates + .catalog-range { margin-left: 0; }
.asm-module .asm-dates label { display: inline-flex; align-items: center; gap: 5px; margin: 0; font-size: 11px; font-weight: 600; color: var(--catalog-muted); }
.asm-module .asm-dates-sep { color: var(--catalog-muted); font-size: 11px; }
.asm-module .asm-date { color-scheme: dark; width: 124px; height: 26px; padding: 2px 6px; border: 1px solid transparent; border-radius: 7px; background: rgba(128,145,178,.08); color: var(--x-heading-color, #fff); font: inherit; font-size: 11px; font-weight: 600; }
.asm-module .asm-date:focus { outline: none; border-color: color-mix(in srgb, var(--bot-accent) 55%, transparent); box-shadow: 0 0 0 2px color-mix(in srgb, var(--bot-accent) 18%, transparent); }
.asm-module .asm-date:disabled { opacity: .45; }
.asm-module .asm-date::-webkit-calendar-picker-indicator { opacity: .6; cursor: pointer; }
.asm-module .asm-drawdown-date { display: flex; margin-top: 4px; }
.asm-module .asm-drawdown-date[hidden] { display: none; }
@media (max-width: 575px) {
    .asm-module .asm-dates { width: 100%; margin-left: 0; justify-content: space-between; }
    .asm-module .asm-dates label { flex: 1; }
    .asm-module .asm-date { width: 100%; flex: 1; min-width: 0; }
}
