/* The generator's own rules, for what Bootstrap 5.2 has no class for.
 *
 * The pages are Bootstrap 5.2 and feather icons, the two things every
 * application shell of a SPLENT product brings. What is left lives here,
 * in classes prefixed gen- beside the rel-, llm- and uvl- ones the pages
 * already had, and reads the shell's colours through Bootstrap's custom
 * properties (--bs-primary, --bs-border-color...) so a theme recolours it:
 * the server-side stepper of the wizard, the icon tiles, the thin progress
 * bars, the distribution sliders, the result lists and the UVL preview.
 * The pages link it from their head block, so no other page loads it.
 */

/* ─── Layout ─────────────────────────────────────────────────────────── */

/* A flex child that may shrink below its content, so text-truncate inside
   it cuts a long filename instead of pushing the buttons out of the row. */
.gen-min-w-0 {
    min-width: 0;
}

.gen-measure {
    max-width: 500px;
}

.gen-landing {
    max-width: 800px;
}

.gen-landing-lead {
    max-width: 600px;
}

.gen-choice {
    color: inherit;
    transition: box-shadow .15s ease-in-out, border-color .15s ease-in-out;
}

.gen-choice:hover,
.gen-choice:focus-visible {
    border-color: var(--bs-primary) !important;
    box-shadow: 0 .25rem .75rem rgba(var(--bs-primary-rgb), .15) !important;
}

/* ─── Icons ──────────────────────────────────────────────────────────── */

/* The info mark beside a field, with its tooltip. */
.gen-info {
    display: inline-flex;
    align-items: center;
    margin-left: .25rem;
    color: var(--bs-gray-500);
    cursor: help;
}

.gen-info:focus-visible {
    outline: 2px solid rgba(var(--bs-primary-rgb), .5);
    border-radius: 50%;
}

.gen-info .feather {
    width: 14px;
    height: 14px;
}

.gen-icon-sm {
    width: 14px;
    height: 14px;
}

/* The leading icon of an alert. */
.gen-alert-icon {
    flex-shrink: 0;
    width: 24px;
    height: 24px;
    margin-right: .75rem;
}

/* A square tile around an icon, light in the colour it is drawn with. */
.gen-icon-tile {
    display: inline-flex;
    flex-shrink: 0;
    align-items: center;
    justify-content: center;
    width: 50px;
    height: 50px;
    border-radius: .5rem;
}

.gen-icon-tile .feather {
    width: 26px;
    height: 26px;
}

.gen-icon-tile-lg {
    width: 80px;
    height: 80px;
}

.gen-icon-tile-lg .feather {
    width: 40px;
    height: 40px;
}

.gen-icon-tile-primary {
    background: rgba(var(--bs-primary-rgb), .12);
    color: var(--bs-primary);
}

.gen-icon-tile-success {
    background: rgba(var(--bs-success-rgb), .12);
    color: var(--bs-success);
}

.gen-icon-tile-warning {
    background: rgba(var(--bs-warning-rgb), .18);
    color: var(--bs-warning);
}

.gen-icon-tile-danger {
    background: rgba(var(--bs-danger-rgb), .12);
    color: var(--bs-danger);
}

/* ─── Progress bars ──────────────────────────────────────────────────── */

.gen-progress-thin {
    height: 6px;
}

.gen-progress {
    height: 8px;
}

/* ─── Wizard: two cards, the steps beside the form ───────────────────── */

.gen-wizard {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.gen-wizard > .card {
    margin-bottom: 0;
}

.gen-wizard-main > .card-body > form {
    max-width: 900px;
}

@media (min-width: 1200px) {
    .gen-wizard {
        flex-direction: row;
        align-items: flex-start;
    }

    .gen-wizard-aside {
        flex: 0 0 300px;
    }

    .gen-wizard-main {
        flex: 1 1 auto;
        min-width: 0;
    }
}

@media (min-width: 1400px) {
    .gen-wizard-aside {
        flex-basis: 360px;
    }
}

/* ─── Wizard: the steps, drawn by the server ─────────────────────────── */

.gen-stepper {
    margin: 0;
    padding: 0;
    list-style: none;
}

.gen-stepper-item {
    position: relative;
    display: flex;
    align-items: flex-start;
    gap: .85rem;
    padding-bottom: 1.5rem;
}

.gen-stepper-item:last-child {
    padding-bottom: 0;
}

/* The dashed line from one step down to the next. */
.gen-stepper-item:not(:last-child)::before {
    content: "";
    position: absolute;
    top: 46px;
    bottom: 6px;
    left: 19px;
    border-left: 2px dashed var(--bs-border-color);
}

.gen-stepper-icon {
    display: inline-flex;
    flex: 0 0 40px;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: .5rem;
    background: rgba(var(--bs-primary-rgb), .12);
    color: var(--bs-primary);
    font-size: 1rem;
    font-weight: 600;
}

.gen-stepper-icon .feather {
    width: 20px;
    height: 20px;
}

.gen-stepper-item.is-current .gen-stepper-icon {
    background: var(--bs-primary);
    color: var(--bs-white);
}

.gen-stepper-label {
    display: flex;
    flex-direction: column;
    padding-top: .15rem;
}

.gen-stepper-title {
    color: var(--bs-gray-700);
    font-size: 1rem;
    font-weight: 600;
}

.gen-stepper-item.is-current .gen-stepper-title {
    color: var(--bs-gray-900);
}

.gen-stepper-desc {
    color: var(--bs-gray-600);
    font-size: .8rem;
    font-weight: 500;
}

/* ─── Wizard: the distribution sliders (noUiSlider) ──────────────────── */

.rel-swatch {
    display: inline-block;
    flex-shrink: 0;
    width: 14px;
    height: 14px;
    border-radius: 3px;
}

.rel-slider.noUi-target.noUi-horizontal {
    height: 18px !important;
    padding: 0 !important;
    border: none !important;
    border-radius: 9px !important;
    box-shadow: none !important;
}

.rel-slider.noUi-target .noUi-base,
.rel-slider.noUi-target .noUi-connects {
    height: 100% !important;
    border-radius: 9px !important;
}

.rel-slider.noUi-horizontal .noUi-handle {
    top: -3px !important;
    right: -11px !important;
    width: 22px !important;
    height: 22px !important;
    border: 2px solid #fff !important;
    border-radius: 50% !important;
    background: #3f4254 !important;
    box-shadow: 0 2px 6px rgba(0, 0, 0, .25) !important;
    cursor: ew-resize !important;
}

.rel-slider .noUi-handle::before,
.rel-slider .noUi-handle::after {
    display: none !important;
}

/* ─── Step 6: the models as they are generated ───────────────────────── */

/* Generous enough to show some ten rows of a small batch without scrolling,
   capped so a 1000-model run leaves the rest of the page reachable. */
.gen-results {
    max-height: 480px;
    overflow-y: auto;
    padding: .25rem .75rem;
    border: 1px solid var(--bs-border-color);
    border-radius: var(--bs-border-radius);
    background: var(--bs-body-bg);
}

.gen-results:empty {
    display: none;
}

.gen-results .gen-row.new {
    animation: genFade 180ms ease-out;
}

@keyframes genFade {
    from {
        opacity: 0;
        transform: translateY(2px);
    }

    to {
        opacity: 1;
        transform: none;
    }
}

/* ─── LLM generator ──────────────────────────────────────────────────── */

#llm_search_results {
    max-height: 280px;
    overflow-y: auto;
}

.llm-terminal {
    max-height: 260px;
    overflow-y: auto;
    padding: .75rem 1rem;
    border-radius: .5rem;
    background: #15171c;
}

.llm-log-line {
    padding: 1px 0;
    font-family: var(--bs-font-monospace);
    font-size: 12px;
    line-height: 1.5;
}

.llm-log-info {
    color: #9aa1b6;
}

.llm-log-success {
    color: #3fd8a8;
}

.llm-log-warn {
    color: var(--bs-warning);
}

.llm-log-error {
    color: #f07f8a;
}

/* A short green flash on the seed editor once a seed from the hub fills it. */
@keyframes llmSeedFlash {
    0% {
        border-color: var(--bs-success);
        box-shadow: 0 0 0 0 rgba(var(--bs-success-rgb), .6);
    }

    60% {
        border-color: var(--bs-success);
        box-shadow: 0 0 0 6px rgba(var(--bs-success-rgb), 0);
    }

    100% {
        box-shadow: 0 0 0 0 rgba(var(--bs-success-rgb), 0);
    }
}

.llm-seed-flash {
    animation: llmSeedFlash 900ms ease-out;
}

/* ─── UVL preview (CodeMirror, in the View dialogs of both generators) ─── */

/* Scoped to the generator's dialogs, so they do not clash with the dataset
   workbench, which owns its own .CodeMirror rules. The token colours are
   the ones of the dataset's view. */
.uvl-preview .CodeMirror {
    height: auto;
    border: 1px solid var(--bs-border-color);
    border-radius: var(--bs-border-radius);
    font-size: .85rem;
}

.uvl-preview .CodeMirror-scroll {
    min-height: 240px;
    max-height: 60vh;
}

.uvl-preview .CodeMirror pre.CodeMirror-line {
    tab-size: 2;
    -moz-tab-size: 2;
}

.uvl-preview .cm-uvl-comment {
    color: #6b7280;
    font-style: italic;
}

.uvl-preview .cm-uvl-string {
    color: #15803d;
}

.uvl-preview .cm-uvl-keyword {
    color: #1d4ed8;
    font-weight: 600;
}

.uvl-preview .cm-uvl-type {
    color: #7c3aed;
}

.uvl-preview .cm-uvl-atom {
    color: #c2410c;
}

.uvl-preview .cm-uvl-number {
    color: #b91c1c;
}

.uvl-preview .cm-uvl-op {
    color: #2563eb;
}

/* The status of the engine while it loads, under the header on the right,
   where it covers none of the wizard's buttons (scripts.js). */
.gen-runtime-status {
    position: fixed;
    top: 5rem;
    right: 1rem;
    z-index: 1050;
    width: min(20rem, calc(100vw - 2rem));
}

/* On the smallest phones no corner is free, so it takes its place in the page. */
@media (max-width: 360px) {
    .gen-runtime-status {
        position: static;
        width: auto;
        margin-bottom: 1rem;
    }
}

.gen-runtime-progress {
    height: 0.4rem;
}
