/* ── Brand colours ─────────────────────────────────── */
.bg-pt-dark   { background-color: #1a1a1a !important; }
.text-pt-dark  { color: #1a1a1a !important; }
.border-pt-accent { border-color: #efaa39 !important; }

.btn-pt-accent {
    background-color: #efaa39;
    color: #1a1a1a;
    border-color: #efaa39;
}
.btn-pt-accent:hover,
.btn-pt-accent:focus-visible {
    background-color: #d8942a;
    border-color: #d8942a;
    color: #1a1a1a;
}

/* ── Navbar tweaks ────────────────────────────────── */
.navbar .nav-link.active {
    background: #efaa39;
    color: #1a1a1a !important;
    border-radius: 4px;
}

/* ── Form inputs — match Bootstrap control styling on Django widgets ── */
input:not([type="hidden"]),
select,
textarea {
    display: block;
    width: 100%;
    padding: .375rem .75rem;
    font-size: 1rem;
    font-weight: 400;
    line-height: 1.5;
    color: var(--bs-body-color);
    background-color: var(--bs-body-bg);
    border: var(--bs-border-width) solid var(--bs-border-color);
    border-radius: var(--bs-border-radius);
    transition: border-color .15s ease-in-out, box-shadow .15s ease-in-out;
}
/* Checkboxes and radio buttons keep their own size: the rule above is for
   text inputs. */
input.form-check-input {
    display: inline-block;
    width: 1em;
    padding: 0;
}

input:focus,
select:focus,
textarea:focus {
    border-color: #efaa39;
    outline: 0;
    box-shadow: 0 0 0 .25rem rgba(239, 170, 57, .25);
}

/* ── Error lists (Django) ─────────────────────────── */
.errorlist {
    list-style: none;
    padding: .5rem .75rem;
    margin: .25rem 0 0;
    font-size: .875rem;
    color: var(--bs-danger);
}

/* ── Copy-button success state ────────────────────── */
.copied {
    background-color: #d9f2e3 !important;
    border-color: #8ecaa4 !important;
    color: #1d5b34 !important;
}

/* ── Hotspot labels on the zoomed-out map ───────────── */
.track-hotspot {
    position: absolute;
    transform: translate(-50%, calc(-100% - 9px));
    padding: 1px 6px;
    border: 1px solid #fff;
    border-radius: 9px;
    font-weight: 700;
    font-size: 11px;
    line-height: 1.4;
    white-space: nowrap;
    cursor: pointer;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.45);
}

.track-hotspot::after {
    content: '';
    position: absolute;
    left: 50%;
    top: 100%;
    margin-left: -4px;
    border: 4px solid transparent;
    border-bottom-width: 0;
}

.track-hotspot-red {
    background: #c62828;
    color: #fff;
}

.track-hotspot-red::after { border-top-color: #c62828; }

.track-hotspot-orange {
    background: #ffa726;
    color: #1a1a1a;
}

.track-hotspot-orange::after { border-top-color: #ffa726; }

/* ── Run chart under the map ────────────────────────── */
.track-chart {
    flex: 0 0 auto;
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 6px;
    overflow: hidden;
}

.track-chart[hidden] { display: none; }

/* The map gives the chart its height, so the page does not scroll. The chart
   is hidden on a narrow window, so the map keeps its height there. */
@media (min-width: 768px) {
    .map-page-root:has(.track-chart:not([hidden])) .map-page-shell,
    .map-page-root:has(.track-chart:not([hidden])) .map-canvas,
    .map-page-root:has(.track-chart:not([hidden])) #map {
        /* 210 px as without the chart, the chart itself, and the gap above it */
        min-height: calc(100vh - 222px - var(--chart-height, 0px));
    }
}

/* Below 992 px the map without the chart leaves 200 px, not 210 px */
@media (min-width: 768px) and (max-width: 991.98px) {
    .map-page-root:has(.track-chart:not([hidden])) .map-page-shell,
    .map-page-root:has(.track-chart:not([hidden])) .map-canvas,
    .map-page-root:has(.track-chart:not([hidden])) #map {
        min-height: calc(100vh - 212px - var(--chart-height, 0px));
    }
}

.track-chart-readout {
    font-size: 11px;
    line-height: 18px;
    color: #333;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

@media (max-width: 767.98px) {
    .track-chart { display: none; }
}

/* ── Section details in the sidebar ─────────────────── */
.cell-pass-table {
    font-size: .8rem;
}

.cell-pass-table .is-low td {
    background: #fdecea;
}

.cell-worst-images {
    display: flex;
    gap: 6px;
}

.cell-worst-images button {
    flex: 1 1 0;
    min-width: 0;
    padding: 0;
    border: 2px solid transparent;
    border-radius: 4px;
    background: none;
    font-size: .75rem;
    color: #555;
}

.cell-worst-images button:hover { border-color: #efaa39; }

.cell-worst-images img {
    display: block;
    width: 100%;
    aspect-ratio: 4 / 3;
    object-fit: cover;
    border-radius: 2px;
    background: #eee;
}

/* ── Session list on the map ────────────────────────── */
.session-panel {
    position: absolute;
    left: 10px;
    bottom: 24px;
    width: 250px;
    max-height: 55%;
    display: flex;
    flex-direction: column;
    background: #fff;
    border-radius: 6px;
    box-shadow: 0 1px 6px rgba(0, 0, 0, 0.35);
    z-index: 900;
    font-size: 12px;
}

.session-panel[hidden] { display: none; }

.session-panel-header {
    padding: 6px 10px;
    font-weight: 700;
    color: #333;
    border-bottom: 1px solid #e0e0e0;
    flex-shrink: 0;
}

.session-list {
    overflow-y: auto;
}

.session-row {
    display: block;
    width: 100%;
    padding: 6px 10px;
    border: 0;
    border-left: 3px solid transparent;
    border-bottom: 1px solid #eee;
    background: none;
    text-align: left;
    color: #333;
}

.session-row:hover { background: #f5f5f5; }

.session-row.active {
    background: #fdf3e0;
    border-left-color: #efaa39;
}

.session-row-title,
.session-row-detail {
    display: block;
}

.session-row-title { font-weight: 600; }

.session-row-detail { color: #666; }

.session-bar {
    display: flex;
    height: 5px;
    margin-top: 4px;
    border-radius: 3px;
    overflow: hidden;
    background: #ddd;
}

/* The friction of one session in time order. The page sets the width: a
   longer bar means more images. */
.session-strip {
    display: block;
    height: 7px;
    max-width: 100%;
    margin-top: 4px;
    border-radius: 2px;
    background: #f1f1f1;
    image-rendering: pixelated;
}

/* ── Map toolbar ──────────────────────────────────── */
.map-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: .5rem;
}

.map-toolbar-box {
    width: 160px;
}

/* A small panel that opens under a toolbar button */
.map-popover-anchor {
    position: relative;
}

.map-popover {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    width: 290px;
    padding: .75rem;
    background: #fff;
    border: 1px solid #ccc;
    border-radius: 6px;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.25);
    z-index: 1100;
}

.map-popover[hidden] { display: none; }

.map-popover-end {
    left: auto;
    right: 0;
    width: 220px;
}

/* ── Legend on the map ────────────────────────────── */
.display-panel {
    position: absolute;
    top: 10px;
    right: 10px;
    display: flex;
    flex-direction: column;
    gap: .4rem;
    padding: .5rem;
    background: #fff;
    border-radius: 6px;
    box-shadow: 0 1px 6px rgba(0, 0, 0, 0.35);
    z-index: 900;
    transition: right 0.3s ease-in-out;
}

/* Stay visible next to the open details sidebar */
.map-page-shell:has(.image-sidebar.show) .display-panel {
    right: 410px;
}

.display-panel-row {
    display: flex;
    align-items: center;
    gap: .5rem;
}

.display-panel-row[hidden] { display: none; }

.display-panel-row label {
    width: 3.2rem;
    flex-shrink: 0;
}

.display-panel-count:empty { display: none; }

.display-panel-help {
    max-width: 340px;
    line-height: 1.35;
    color: #333;
}

.display-panel-caption {
    margin-bottom: -.25rem;
}

/* ── Friction band filter: a legend that also filters ── */
.friction-band-filter {
    display: flex;
    height: 28px;
    border-radius: .25rem;
    overflow: hidden;
    border: 1px solid #b5b5b5;
}

.friction-band-btn {
    flex: 1 1 auto;
    padding: 0 .5rem;
    border: 0;
    border-right: 1px solid rgba(0, 0, 0, 0.25);
    font-size: .8rem;
    font-weight: 600;
    white-space: nowrap;
    cursor: pointer;
    /* Off: no color, struck through */
    background: #f1f1f1;
    color: #8a8a8a;
    text-decoration: line-through;
    transition: background-color 0.15s, color 0.15s;
}

.friction-band-btn:last-child { border-right: 0; }

.friction-band-btn.active { text-decoration: none; }

.friction-band-btn.active[data-band="red"]    { background-color: #d32f2f; color: #fff; }
.friction-band-btn.active[data-band="orange"] { background-color: orange; color: #1a1a1a; }
.friction-band-btn.active[data-band="yellow"] { background-color: yellow; color: #1a1a1a; }
.friction-band-btn.active[data-band="green"]  { background-color: green; color: #fff; }
/* Same purple as the rejected dots on the map */
.friction-band-btn.active[data-band="reject"] { background-color: purple; color: #fff; }

.detail-reject { color: purple; }

/* ── Map page ─────────────────────────────────────── */
.map-page-root {
    display: flex;
    flex: 1 1 auto;
    flex-direction: column;
    gap: .75rem;
    min-height: 0;
    padding: .75rem 1rem 1rem;
}

.map-page-shell {
    position: relative;
    flex: 1 1 auto;
    min-height: calc(100vh - 210px);
    overflow: hidden;
}

.download-progress {
    margin-top: -0.5rem;
}

.download-progress .progress {
    height: 0.75rem;
}

.map-loading {
    position: absolute;
    inset: 0;
    background: rgba(255, 255, 255, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 999;
    pointer-events: none;
}

.map-loading-inner {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.map-canvas,
#map {
    width: 100%;
    height: 100%;
    min-height: calc(100vh - 210px);
}

/* ── Live track ───────────────────────────────────── */
.live-track-btn.active,
.live-track-btn.active:hover {
    background-color: #efaa39;
    border-color: #efaa39;
    color: #000;
}

.live-track-btn.active::before {
    content: "";
    display: inline-block;
    width: 0.55rem;
    height: 0.55rem;
    margin-right: 0.4rem;
    border-radius: 50%;
    background-color: #c0392b;
    animation: live-track-pulse 1.4s ease-in-out infinite;
}

@keyframes live-track-pulse {
    0%, 100% { opacity: 1; }
    50%      { opacity: 0.25; }
}

@media (prefers-reduced-motion: reduce) {
    .live-track-btn.active::before { animation: none; }
}

/* ── Image Sidebar ────────────────────────────────── */
.image-sidebar {
    position: absolute;
    right: -400px;
    top: 0;
    width: 400px;
    height: 100%;
    background-color: #fff;
    box-shadow: -2px 0 8px rgba(0, 0, 0, 0.15);
    overflow-y: auto;
    transition: right 0.3s ease-in-out;
    z-index: 1000;
    display: flex;
    flex-direction: column;
}

.image-sidebar.show {
    right: 0;
}

.sidebar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px;
    border-bottom: 1px solid #e0e0e0;
    background-color: #f5f5f5;
    flex-shrink: 0;
}

.sidebar-header h5 {
    color: #333;
}

.sidebar-content {
    flex: 1;
    overflow-y: auto;
    padding: 15px;
}

/* As wide as the image below it, so the marked column lines up with the rail */
.sidebar-roi-bar {
    position: relative;
    height: 10px;
    margin-bottom: 4px;
    background: #e5e5e5;
    border-radius: 2px;
    overflow: hidden;
}

.sidebar-roi-column {
    position: absolute;
    top: 0;
    bottom: 0;
    background: #efaa39;
}

.sidebar-image {
    display: block;
    width: 100%;
    height: auto;
    border-radius: 4px;
    object-fit: cover;
}

.sidebar-details {
    font-size: 0.9rem;
    line-height: 1.6;
}

.sidebar-details p {
    margin-bottom: 0.5rem;
    word-break: break-word;
}

.sidebar-details strong {
    color: #555;
}

.report-problem {
    margin-top: 1rem;
    padding-top: 0.75rem;
    border-top: 1px solid #e5e5e5;
}

/* Reports page */
.report-image {
    position: relative;
    display: block;
    width: 420px;
    line-height: 0;
}

.report-thumbnail {
    width: 100%;
    height: auto;
    border-radius: 4px;
}

/* The ROI of the analysis, placed in percentages of the image */
.report-roi {
    position: absolute;
    box-sizing: border-box;
    border: 2px solid #efaa39;
    background: rgba(239, 170, 57, 0.12);
    pointer-events: none;
}

.report-model-select {
    width: auto;
    font-weight: normal;
}

.report-analysis-cell {
    min-width: 21rem;
}

.report-analysis-heading {
    font-weight: 600;
    margin-bottom: 0.15rem;
}

/* Label and value in two columns, one pair per row */
.report-analysis {
    display: grid;
    grid-template-columns: max-content 1fr;
    column-gap: 0.75rem;
    row-gap: 0.1rem;
    margin-bottom: 0.75rem;
}

.report-analysis dt {
    font-weight: 600;
    color: #555;
}

.report-analysis dd {
    margin: 0;
}

/* The reported model and the other models: label above value */
.report-analysis-others {
    grid-template-columns: 1fr;
    margin-bottom: 0;
    padding-top: 0.5rem;
    border-top: 1px solid #e5e5e5;
    color: #6c757d;
}

.report-analysis-others dt {
    color: inherit;
}

.report-analysis-others dd {
    margin-bottom: 0.35rem;
}

/* A result that the pipeline itself scored as doubtful */
.report-warning {
    margin-bottom: 0.35rem;
    padding: 0.3rem 0.5rem;
    border-left: 3px solid #dc3545;
    background: #fbeaec;
    color: #842029;
}

.report-low-reliability {
    font-weight: 600;
    color: #b02a37;
}

.report-comment {
    min-width: 10rem;
    max-width: 24rem;
    word-break: break-word;
}

@media (max-width: 991.98px) {
    .map-page-shell {
        min-height: calc(100vh - 200px);
    }

    .map-canvas,
    #map {
        min-height: calc(100vh - 200px);
    }

    .image-sidebar {
        width: min(100%, 360px);
        right: calc(-1 * min(100%, 360px));
    }
}

