/* ===========================================================================
   OpenBench - UX layer

   Loaded after style.css and builds on its design tokens ( --color*, --accent,
   --line, ... ). Everything new lives here, so the base theme stays untouched
   and this file is easy to review, tweak, or drop.
   =========================================================================== */

:root {

    /* Slightly softer corners than the base theme ( 2px ).
       Set this back to 2px to revert the rounding everywhere. */
    --radius: 4px;

    --purple: #A78BFA;
    --purple-soft: rgba(167, 139, 250, 0.14);
    --shadow-card: inset 0 1px 0 rgba(255, 255, 255, 0.025), 0 1px 3px rgba(0, 0, 0, 0.3);
}

/* ---------- Depth + interaction polish ---------- */

.card {
    box-shadow: var(--shadow-card);
}

#content table.hoverable tr:not(.table-header):not(.table-spacer):not(.table-spacer-small):hover > td:first-child {
    box-shadow: inset 2px 0 0 var(--accent);
}

#content tr[data-href] {
    cursor: pointer;
}

#content th.numeric {
    text-align: right;
}

#content th.sorted {
    color: var(--color-font1);
}

.muted-small {
    color: var(--muted);
    font-size: 12.5px;
}

/* ---------- Sidebar: collapsible sections ---------- */

#sidebar .nav-title.collapsible {
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;
    user-select: none;
    border-radius: var(--radius);
}

#sidebar .nav-title.collapsible:hover {
    color: var(--color-font2);
}

#sidebar .nav-title.collapsible::after {
    content: '';
    width: 6px;
    height: 6px;
    margin-right: 4px;
    border-right: 1.5px solid currentColor;
    border-bottom: 1.5px solid currentColor;
    transform: rotate(45deg) translate(-1px, -1px);
    transition: transform 0.15s ease;
}

#sidebar .nav-section.collapsed .nav-title.collapsible::after {
    transform: rotate(-45deg);
}

#sidebar .nav-section.collapsed ul {
    display: none;
}

/* ---------- Stat cards ---------- */

.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
    gap: 12px;
    margin-bottom: 20px;
}

.stat-card {
    display: flex;
    align-items: center;
    gap: 14px;
    min-width: 0;
    padding: 14px 16px;
    background-color: var(--color2);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow-card);
}

.stat-icon {
    display: grid;
    place-items: center;
    flex: none;
    width: 40px;
    height: 40px;
    border-radius: var(--radius);
    background-color: var(--accent-soft);
    color: var(--accent-hover);
    font-size: 16px;
}

.stat-green  .stat-icon { background-color: rgba(52, 211, 153, 0.13); color: var(--ok);     }
.stat-yellow .stat-icon { background-color: rgba(245, 185, 65, 0.13); color: var(--warn);   }
.stat-purple .stat-icon { background-color: var(--purple-soft);       color: var(--purple); }

.stat-value {
    color: var(--color-font1);
    font-family: var(--font-mono);
    font-size: 22px;
    font-weight: 650;
    line-height: 1.1;
    font-variant-numeric: tabular-nums;
}

.stat-label {
    margin-top: 2px;
    color: var(--muted);
    font-size: 11.5px;
    font-weight: 600;
    letter-spacing: 0.1em;
    text-transform: uppercase;
}

.stat-sub {
    margin-top: 2px;
    color: var(--muted);
    font-size: 12px;
}

/* ---------- Test progress ---------- */

.ob-progress {
    min-width: 96px;
    height: 3px;
    margin-top: 7px;
    border-radius: 2px;
    background-color: var(--line);
    overflow: hidden;
}

.ob-progress > span {
    display: block;
    height: 100%;
    border-radius: inherit;
    background-color: var(--accent);
    transition: width 0.4s ease;
}

.ob-progress-pos > span { background-color: var(--ok);  }
.ob-progress-neg > span { background-color: var(--bad); }

/* ---------- Empty states ---------- */

#content .empty-row td {
    padding: 38px 14px;
}

#content .empty-row i {
    display: block;
    margin-bottom: 10px;
    font-size: 24px;
    opacity: 0.55;
}

.empty-state {
    padding: 52px 20px;
    color: var(--muted);
    text-align: center;
}

.empty-state i {
    display: block;
    margin-bottom: 12px;
    font-size: 28px;
    opacity: 0.5;
}

.empty-state p {
    margin: 0;
}

/* ---------- Segmented control ---------- */

.seg {
    display: inline-flex;
    gap: 2px;
    padding: 3px;
    background-color: var(--color2);
    border: 1px solid var(--line);
    border-radius: calc(var(--radius) + 2px);
}

#content a.seg-btn:link,
#content a.seg-btn:visited {
    padding: 5px 13px;
    border-radius: var(--radius);
    color: var(--color-font2);
    font-size: 13px;
    font-weight: 500;
    transition: background-color 0.15s ease, color 0.15s ease;
}

#content a.seg-btn:hover {
    background-color: var(--surface-hover);
    color: var(--color-font1);
}

#content a.seg-btn.active {
    background-color: var(--accent-soft);
    box-shadow: inset 0 0 0 1px rgba(76, 141, 255, 0.4);
    color: var(--color-font1);
}

/* ---------- Users: STC / LTC split ---------- */

.splitbar {
    display: flex;
    min-width: 150px;
    height: 8px;
    border-radius: 4px;
    background-color: var(--line);
    overflow: hidden;
}

.splitbar-lg {
    height: 12px;
    border-radius: 6px;
}

.splitbar > span {
    display: block;
    height: 100%;
}

.splitbar-stc   { background-color: var(--accent); }
.splitbar-ltc   { background-color: var(--purple); }
.splitbar-other { background-color: #566074;      }

.legend {
    display: flex;
    flex-wrap: wrap;
    gap: 4px 16px;
    color: var(--color-font2);
    font-size: 12.5px;
    font-weight: 500;
}

.legend .dot {
    display: inline-block;
    width: 9px;
    height: 9px;
    margin-right: 7px;
    border-radius: 2px;
    vertical-align: middle;
}

.dot-stc   { background-color: var(--accent); }
.dot-ltc   { background-color: var(--purple); }
.dot-other { background-color: #566074;      }

.split-overview {
    padding: 16px;
}

.split-overview p {
    margin: 12px 0 0;
}

#content td.num-stc { color: var(--accent-hover); }
#content td.num-ltc { color: var(--purple);       }

#content td.rank {
    width: 44px;
    color: var(--muted);
    font-family: var(--font-mono);
}

/* ---------- Errors table ---------- */

#content a.ev-open:link,
#content a.ev-open:visited {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    font-weight: 600;
}

#content a.ev-open i {
    font-size: 11px;
    transition: transform 0.15s ease;
}

#content tr:hover a.ev-open i {
    transform: translateX(3px);
}

.tc-chip {
    margin-left: 8px;
    color: var(--muted);
    font-family: var(--font-mono);
    font-size: 12px;
}

/* ---------- Event viewer ---------- */

#content a.crumb:link,
#content a.crumb:visited {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
    color: var(--muted);
    font-size: 13px;
    font-weight: 500;
}

#content a.crumb:hover {
    color: var(--color-font1);
}

.ev-meta {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 1px;
    margin: 0 0 20px;
    background-color: var(--line);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    overflow: hidden;
}

.ev-meta > div {
    min-width: 0;
    padding: 11px 14px;
    background-color: var(--color2);
}

.ev-meta dt {
    margin-bottom: 4px;
    color: var(--muted);
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.1em;
    text-transform: uppercase;
}

.ev-meta dd {
    margin: 0;
    overflow: hidden;
    color: var(--color-font1);
    font-size: 14px;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.ev-versus {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
    align-items: center;
    gap: 16px;
    padding: 24px 20px;
}

.ev-player {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 0;
}

.ev-player strong {
    overflow: hidden;
    color: var(--color-font1);
    font-size: 18px;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.ev-player small {
    display: flex;
    align-items: center;
    gap: 7px;
    color: var(--muted);
    font-size: 11.5px;
    font-weight: 600;
    letter-spacing: 0.1em;
    text-transform: uppercase;
}

.ev-black {
    align-items: flex-end;
    text-align: right;
}

.ev-black small {
    flex-direction: row-reverse;
}

.ev-piece {
    display: inline-block;
    width: 10px;
    height: 10px;
    border: 1px solid var(--line-strong);
    border-radius: 50%;
}

.ev-white .ev-piece { background-color: #F1F4FA; }
.ev-black .ev-piece { background-color: #0B0E14; }

.ev-result {
    padding: 6px 16px;
    background-color: var(--color1);
    border: 1px solid var(--line-strong);
    border-radius: var(--radius);
    color: var(--color-font1);
    font-size: 22px;
    font-weight: 650;
}

.ev-callout {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    margin: 0 20px 18px;
    padding: 12px 14px;
    background-color: var(--color1);
    border: 1px solid var(--line);
    border-left: 3px solid currentColor;
    border-radius: var(--radius);
}

.ev-callout i {
    margin-top: 3px;
}

.ev-callout-bad  { color: var(--bad);    }
.ev-callout-warn { color: var(--warn);   }
.ev-callout-info { color: var(--accent); }

.ev-callout-body {
    min-width: 0;
    color: var(--color-font2);
    word-break: break-word;
}

.ev-callout-body strong {
    display: block;
    color: var(--color-font1);
}

.ev-facts {
    display: flex;
    flex-wrap: wrap;
    gap: 10px 32px;
    margin: 0;
    padding: 14px 20px 16px;
    border-top: 1px solid var(--line);
}

.ev-facts > div {
    min-width: 0;
}

.ev-facts dt {
    margin-bottom: 2px;
    color: var(--muted);
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.1em;
    text-transform: uppercase;
}

.ev-facts dd {
    margin: 0;
    color: var(--color-font1);
    font-size: 13px;
    word-break: break-all;
}

.ev-headers {
    border-top: 1px solid var(--line);
}

.ev-headers summary {
    padding: 11px 20px;
    color: var(--muted);
    font-size: 12.5px;
    font-weight: 600;
    cursor: pointer;
    user-select: none;
}

.ev-headers summary:hover {
    color: var(--color-font1);
}

.ev-headers table {
    width: 100%;
    margin: 0 0 8px;
}

.ev-headers td:first-child {
    width: 180px;
    color: var(--muted);
}

.ev-movelist {
    position: relative;
    max-height: 580px;
    padding: 8px;
    overflow-y: auto;
    font-family: var(--font-mono);
    font-size: 13px;
    outline: none;
}

.ev-row {
    display: grid;
    grid-template-columns: 46px minmax(0, 1fr) minmax(0, 1fr);
    gap: 2px;
}

.ev-num {
    padding: 7px 8px;
    color: var(--muted);
    text-align: right;
}

.ev-move {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 7px 10px;
    background: transparent;
    border: 1px solid transparent;
    border-radius: var(--radius);
    color: var(--color-font1);
    font: inherit;
    text-align: left;
    cursor: pointer;
    transition: background-color 0.12s ease;
}

button.ev-move:hover {
    background-color: var(--surface-hover);
}

.ev-move.is-active {
    background-color: var(--accent-soft);
    border-color: rgba(76, 141, 255, 0.45);
}

.ev-move.is-final {
    box-shadow: inset 2px 0 0 var(--bad);
}

.ev-move.ev-empty {
    color: var(--muted);
    cursor: default;
}

.ev-eval {
    color: var(--muted);
    font-size: 11.5px;
    font-style: normal;
}

.ev-eval.pos, #sel-eval.pos { color: var(--ok);  }
.ev-eval.neg, #sel-eval.neg { color: var(--bad); }

.ev-sel {
    padding: 16px;
}

.ev-sel-main {
    display: flex;
    align-items: baseline;
    gap: 8px;
}

.ev-sel-label {
    color: var(--muted);
    font-size: 15px;
}

.ev-sel-san {
    color: var(--color-font1);
    font-size: 28px;
    font-weight: 650;
}

.ev-sel-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    margin-top: 14px;
}

.ev-sel-stats > div {
    padding: 9px 11px;
    background-color: var(--color1);
    border: 1px solid var(--line);
    border-radius: var(--radius);
}

.ev-sel-stats span {
    display: block;
    margin-bottom: 2px;
    color: var(--muted);
    font-size: 10.5px;
    font-weight: 600;
    letter-spacing: 0.1em;
    text-transform: uppercase;
}

.ev-sel-stats strong {
    color: var(--color-font1);
    font-size: 14px;
}

.ev-sel-note {
    margin: 12px 0 0;
    padding: 9px 11px;
    border-left: 3px solid var(--warn);
    border-radius: var(--radius);
    background-color: rgba(245, 185, 65, 0.08);
    color: var(--color-font2);
    font-size: 13px;
}

.ev-sel-note[hidden] {
    display: none;
}

/* Plain text logs */

.ev-tools {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px 14px;
}

.ev-input {
    width: 220px;
    max-width: 100%;
    padding: 6px 10px;
    background-color: var(--color1);
    border: 1px solid var(--line-strong);
    border-radius: var(--radius);
    color: var(--color-font1);
    font-family: var(--font-sans);
    font-size: 13px;
}

.ev-input::placeholder {
    color: var(--muted);
}

.ev-toggle {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: var(--color-font2);
    font-size: 12.5px;
    cursor: pointer;
    user-select: none;
}

.ev-logbody {
    max-height: 70vh;
    padding: 8px 0;
    overflow: auto;
    background-color: var(--color1);
    font-family: var(--font-mono);
    font-size: 12.5px;
    line-height: 1.55;
}

.ev-line {
    display: flex;
    gap: 14px;
    padding: 0 14px;
    border-left: 2px solid transparent;
}

.ev-line[hidden] {
    display: none;
}

.ev-line:hover {
    background-color: var(--surface-hover);
}

.ev-ln {
    flex: 0 0 48px;
    color: #4A5469;
    text-align: right;
    user-select: none;
}

.ev-lt {
    min-height: 1.55em;
    color: var(--color-font2);
    white-space: pre;
}

.ev-wrap .ev-lt {
    min-width: 0;
    white-space: pre-wrap;
    word-break: break-word;
}

.ev-line-bad  { background-color: rgba(248, 113, 113, 0.08); border-left-color: var(--bad);  }
.ev-line-warn { background-color: rgba(245, 185, 65, 0.07);  border-left-color: var(--warn); }
.ev-line-bad  .ev-lt { color: #FFB4B4; }
.ev-line-warn .ev-lt { color: #FFD479; }

.ev-log-note {
    padding: 8px 14px;
    border-bottom: 1px solid var(--line);
    color: var(--muted);
    font-size: 12.5px;
}

/* ---------- Pipelines ---------- */

.pl-scroll {
    padding: 14px 12px 12px;
    overflow-x: auto;
}

.pl-graph {
    display: block;
    max-width: none;
    font-family: var(--font-sans);
}

/* Steps. A step that has not run is quiet, one that has takes on the colour of how it ended */

.pl-box {
    fill: var(--color3);
    stroke: var(--line-strong);
    stroke-width: 1;
}

.pl-name {
    fill: var(--color-font1);
    font-size: 13.5px;
    font-weight: 600;
}

.pl-what,
.pl-speed {
    fill: var(--muted);
    font-family: var(--font-mono);
    font-size: 12px;
}

.pl-status {
    fill: var(--muted);
    font-size: 11.5px;
    font-weight: 600;
}

.pl-play {
    fill: var(--accent);
}

.pl-s-queued .pl-box,
.pl-s-launching .pl-box {
    stroke: #566074;
    stroke-dasharray: 4 3;
}

.pl-s-running .pl-box   { fill: var(--accent-soft);            stroke: var(--accent); stroke-width: 1.6; }
.pl-s-passed .pl-box    { fill: rgba(52, 211, 153, 0.08);      stroke: var(--ok);   }
.pl-s-failed .pl-box    { fill: rgba(248, 113, 113, 0.09);     stroke: var(--bad);  }
.pl-s-stopped .pl-box   { fill: rgba(245, 185, 65, 0.08);      stroke: var(--warn); }
.pl-s-error .pl-box     { fill: rgba(248, 113, 113, 0.09);     stroke: var(--bad); stroke-dasharray: 4 3; }

.pl-s-running .pl-status { fill: var(--accent-hover); }
.pl-s-passed .pl-status  { fill: var(--ok);   }
.pl-s-failed .pl-status,
.pl-s-error .pl-status   { fill: var(--bad);  }
.pl-s-stopped .pl-status { fill: var(--warn); }

.pl-unreachable {
    opacity: 0.5;
}

.pl-unreachable .pl-box {
    stroke-dasharray: 4 3;
}

.pl-graph a {
    outline: none;
}

.pl-graph a:hover .pl-box {
    stroke-width: 2;
}

.pl-graph a:focus-visible .pl-box {
    stroke: var(--accent-hover);
    stroke-width: 2.5;
}

/* Edges. The colour says what has to happen for the edge to be followed */

.pl-edge .pl-line {
    fill: none;
    stroke: #566074;
    stroke-width: 1.6;
}

.pl-arrow { fill: #566074; }
.pl-end   { fill: #566074; }

.pl-c-passed .pl-line  { stroke: var(--ok);   }
.pl-c-failed .pl-line  { stroke: var(--bad);  }
.pl-c-stopped .pl-line { stroke: var(--warn); }

.pl-arrow.pl-c-passed  { fill: var(--ok);   }
.pl-arrow.pl-c-failed  { fill: var(--bad);  }
.pl-arrow.pl-c-stopped { fill: var(--warn); }

.pl-back .pl-line {
    stroke-dasharray: 5 4;
}

/* On a run, the way that was gone along stands out and the rest steps back */

.pl-taken .pl-line {
    stroke-width: 3;
}

.pl-idle .pl-line  { opacity: 0.22; }
.pl-idle .pl-label { opacity: 0.45; }

.pl-label rect {
    fill: var(--color1);
    stroke: var(--line-strong);
}

.pl-label text {
    fill: var(--color-font2);
    font-size: 11.5px;
    font-weight: 500;
}

@media (prefers-reduced-motion: no-preference) {

    /* The one thing that moves: the step that is going right now */

    @keyframes pl-pulse {
        50% { stroke-opacity: 0.4; }
    }

    .pl-s-running .pl-box {
        animation: pl-pulse 2.4s ease-in-out infinite;
    }
}

/* Around the graph */

.page-actions form,
.pl-toolbar form {
    margin: 0;
}

.pl-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    min-height: 38px;
    margin-bottom: 16px;
}

.pl-checks {
    margin: 0;
    padding: 6px 0;
    list-style: none;
}

.pl-check {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 9px 16px;
    color: var(--color-font2);
}

.pl-check i {
    margin-top: 4px;
}

.pl-check strong {
    color: var(--color-font1);
}

.pl-check-error i   { color: var(--bad);    }
.pl-check-warning i { color: var(--warn);   }
.pl-check-info i    { color: var(--accent); }

#content td.pl-leads {
    white-space: normal;
}

#content .pl-message {
    max-width: 52ch;
    white-space: pre-wrap;
    word-break: break-word;
}

/* On the page of a test that a pipeline started */

.pl-chip {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 14px;
    padding: 6px 12px;
    background-color: var(--accent-soft);
    border: 1px solid rgba(76, 141, 255, 0.4);
    border-radius: var(--radius);
    color: var(--color-font1);
    font-size: 13px;
}

/* ---------- Responsive ---------- */

@media (max-width: 767px) {

    .ev-versus {
        grid-template-columns: 1fr;
        gap: 10px;
    }

    .ev-black {
        align-items: flex-start;
        text-align: left;
    }

    .ev-black small {
        flex-direction: row;
    }

    .ev-result {
        justify-self: start;
    }

    .ev-meta dd {
        white-space: normal;
    }
}
