/* Bot and Backtick position editor (sys/botForm.php). Every rule is scoped to .bot-form-root, the
   wrapper botForm() prints, so no other page is affected. Colors and radii come from the tokens
   ts-styling.css already defines. */

/* Pick-one groups read as a slider: one track, and the selected option is the thumb. The radio
   inputs and their btn-outline-* labels are unchanged, so each option keeps its own selected color
   (put, call, long, short). segmented-slider.js adds the glide and the drag. */
.bot-form-root .btn-group:has(input[type="radio"].btn-check) {
    position: relative;
    gap: 2px;
    padding: 2px;
    border: 1px solid var(--ts-field-border);
    border-radius: var(--ts-radius);
    background-color: #0f0f1a;
    vertical-align: middle;
    -webkit-user-select: none;
    user-select: none;
    touch-action: pan-y;
}

.bot-form-root .btn-group:has(input[type="radio"].btn-check) .btn {
    position: relative;
    z-index: 1;
    flex: 0 1 auto;
    margin: 0;
    border-color: transparent;
    border-radius: calc(var(--ts-radius) - 2px) !important;
    box-shadow: none;
    transition: color 0.15s ease, background-color 0.15s ease;
}

@media (min-width: 768px) {
    .bot-form-root .btn-group:has(input[type="radio"].btn-check) .btn {
        padding-top: calc(0.5rem - 4px);
        padding-bottom: calc(0.5rem - 4px);
    }
}

.bot-form-root .btn-group:has(input[type="radio"].btn-check) .btn-check:not(:checked) + .btn {
    background-color: transparent;
    color: #c4c9d4;
}

.bot-form-root .btn-group:has(input[type="radio"].btn-check) .btn-check:not(:checked):not(:disabled) + .btn:hover {
    background-color: rgba(255, 255, 255, 0.07);
    color: #fff;
}

.bot-form-root .btn-group:has(input[type="radio"].btn-check) .btn-check:focus-visible + .btn {
    outline: 2px solid #78a7ff;
    outline-offset: 1px;
}

.bot-form-root .btn-group:has(input[type="radio"].btn-check) .btn-check.is-invalid + .btn,
.bot-form-root .btn-group:has(input[type="radio"].btn-check) .btn-check + .btn.btn-check-invalid {
    box-shadow: 0 0 0 0.15rem rgba(249, 49, 84, 0.25);
}

.bot-form-root .btn-group:has(input[type="radio"].btn-check) .btn-check:disabled:not(:checked) + .btn {
    opacity: 0.45;
}

/* While the thumb is gliding or being dragged, the moving ghost stands in for the selected fill. */
.bot-form-root .btn-group.ts-sliding .btn-check:checked + .btn {
    border-color: transparent !important;
    background-color: transparent !important;
}

.bot-form-root .ts-slider-ghost {
    position: absolute;
    z-index: 0;
    border-radius: calc(var(--ts-radius) - 2px);
    pointer-events: none;
}

.bot-form-root .ts-slider-ghost-moving {
    transition: left 0.18s ease, top 0.18s ease, width 0.18s ease, height 0.18s ease;
}

@media (prefers-reduced-motion: reduce) {
    .bot-form-root .btn-group:has(input[type="radio"].btn-check) .btn,
    .bot-form-root .ts-slider-ghost-moving {
        transition: none;
    }
}

/* Trading strategy: the fields in two rows, with the outcome right beside them from xl up and below them
   on smaller screens. */
.bot-form-root .ts-strategy {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.bot-form-root .ts-strategy-fields {
    flex: 0 1 auto;
    min-width: 0;
}

@media (min-width: 1200px) {
    .bot-form-root .ts-strategy {
        flex-direction: row;
        justify-content: flex-start;
        align-items: flex-start;
        gap: 2rem;
    }
}

.bot-form-root .ts-outcome {
    flex: 0 0 auto;
    width: 272px;
    max-width: 100%;
    padding: 0.625rem 0.75rem;
    border: 1px solid rgba(163, 177, 221, 0.18);
    border-radius: var(--ts-radius);
    background-color: #2c2c42;
}

.bot-form-root .ts-outcome-title {
    margin-bottom: 0.25rem;
    color: #c4c9d4;
    font-size: 0.8125rem;
    font-weight: 600;
}

.bot-form-root .ts-outcome-svg {
    display: block;
    width: 100%;
    height: auto;
}

.bot-form-root .ts-outcome-name {
    margin-top: 0.25rem;
    font-size: 0.875rem;
    font-weight: 600;
}

.bot-form-root .ts-outcome-note {
    margin: 0;
    color: #b4bacb;
    font-size: 0.75rem;
    line-height: 1.35;
}

.bot-form-root .ts-outcome-note strong {
    color: #f1f3f9;
}

/* An empty graph with a label in a box over it, for a position that is not a named template. */
.bot-form-root .ts-outcome-empty {
    display: block;
    position: relative;
}

.bot-form-root .ts-outcome-box {
    position: absolute;
    top: 50%;
    left: 50%;
    padding: 0.25rem 0.75rem;
    border: 1px solid var(--ts-field-border);
    border-radius: var(--ts-radius-sm);
    background-color: #383852;
    color: #f1f3f9;
    font-size: 0.875rem;
    font-weight: 600;
    white-space: nowrap;
    transform: translate(-50%, -50%);
}

.bot-form-root .ts-outcome-profit {
    fill: rgba(56, 166, 113, 0.3);
}

.bot-form-root .ts-outcome-loss {
    fill: rgba(249, 49, 84, 0.26);
}

.bot-form-root .ts-outcome-zero,
.bot-form-root .ts-outcome-tick {
    stroke: var(--ts-field-border);
    stroke-width: 1;
}

.bot-form-root .ts-outcome-now {
    stroke: #78a7ff;
    stroke-width: 1;
    stroke-dasharray: 3 3;
}

.bot-form-root .ts-outcome-line {
    fill: none;
    stroke: #f1f3f9;
    stroke-width: 2;
    stroke-linejoin: round;
    stroke-linecap: round;
}

.bot-form-root .ts-outcome-breakeven {
    fill: #f1f3f9;
}

.bot-form-root .ts-outcome-label {
    fill: #78a7ff;
    font-size: 8px;
}

/* Trade template menu. The button lies over the select and opens the menu; the select underneath shows
   the value. */
.bot-form-root .ts-template-field {
    position: relative;
}

.bot-form-root .ts-template-select {
    pointer-events: none;
}

.bot-form-root .ts-template-button {
    position: absolute;
    inset: 0;
    width: 100%;
    padding: 0;
    border: 0;
    border-radius: var(--ts-radius);
    background: transparent;
    cursor: pointer;
}

.bot-form-root .ts-template-button:disabled {
    cursor: not-allowed;
}

.bot-form-root .ts-template-button:focus-visible,
.bot-form-root .ts-template-button.show {
    outline: none;
    box-shadow: 0 0 0 0.2rem var(--ts-focus-ring);
}

.bot-form-root .ts-template-menu {
    width: min(960px, calc(100vw - 2rem));
    padding: 0.75rem;
    overflow-y: auto;
    background-color: #2c2c42;
}

/* dark.css pins every open menu to top: 0 at 992px and below. A menu that opens upward is placed from the
   bottom of the screen, so that rule would push it off the top. */
.bot-form-root .ts-template-menu.show[data-popper-placement^="top"] {
    top: auto !important;
}

.bot-form-root .ts-template-group {
    margin: 0.75rem 0 0.375rem;
    color: #b4bacb;
    font-size: 0.75rem;
    font-weight: 600;
}

.bot-form-root .ts-template-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(132px, 1fr));
    gap: 0.5rem;
}

.bot-form-root .ts-template-menu .ts-template-tile {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    width: auto;
    padding: 0.375rem 0.5rem 0.5rem;
    border: 1px solid rgba(163, 177, 221, 0.18);
    border-radius: var(--ts-radius);
    background-color: #383852;
    color: #e6e8f0;
    font-size: 0.8125rem;
    font-weight: 600;
    line-height: 1.25;
    text-align: left;
    white-space: normal;
}

.bot-form-root .ts-template-menu .ts-template-tile:hover,
.bot-form-root .ts-template-menu .ts-template-tile:focus-visible {
    border-color: #78a7ff;
    outline: none;
}

.bot-form-root .ts-template-menu .ts-template-tile.active {
    border-color: #78a7ff;
    background-color: #3a4a80;
}

.bot-form-root .ts-template-tile .ts-outcome-line {
    stroke-width: 1.75;
}
