/* From Hook to Dashboard - layout and styling
   Fixed-height column: title row with step buttons, legend, Mermaid diagram,
   shared infobox panel. The height of <main> must equal the CANVAS_HEIGHT
   comment in hook-to-dashboard-pipeline.js. */

html, body {
    margin: 0;
    padding: 0;
    font-family: Arial, Helvetica, sans-serif;
}

main {
    box-sizing: border-box;
    height: 390px;
    display: flex;
    flex-direction: column;
    background-color: aliceblue;
    border: 1px solid silver;
    overflow: hidden;
}

.sim-header {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 4px 12px;
    padding: 8px 14px 0 14px;
}

.sim-header h1 {
    margin: 0;
    font-size: 22px;
    font-weight: normal;
    color: #111;
}

/* Previous / Next step-through controls */
.stepper {
    display: flex;
    align-items: center;
    gap: 8px;
}

.stepper button {
    font-size: 15px;
    padding: 3px 12px;
    cursor: pointer;
}

.stepper button:disabled {
    cursor: default;
}

.step-label {
    font-size: 15px;
    color: #1f2937;
    min-width: 96px;
    text-align: center;
}

/* Legend */
.legend {
    display: flex;
    flex-wrap: wrap;
    gap: 2px 18px;
    padding: 6px 14px 0 14px;
    font-size: 14px;
    color: #334155;
}

.swatch {
    display: inline-block;
    vertical-align: middle;
    margin-right: 6px;
    width: 16px;
    height: 12px;
}

.swatch.process {
    border-radius: 3px;
    background-color: #b2dfdb;
    border: 1px solid #00695c;
}

.swatch.file {
    background-color: #fff8e1;
    border: 1px solid #8a5a00;
    clip-path: polygon(0 0, 68% 0, 100% 40%, 100% 100%, 0 100%);
}

.swatch.dashboard {
    border-radius: 3px;
    background-color: #00695c;
    border: 1px solid #003d33;
}

/* Mermaid diagram: scales down with the container */
.diagram {
    flex: 0 0 auto;
    padding: 6px 8px 8px 8px;
    text-align: center;
}

.diagram svg {
    max-height: 130px;
}

.diagram .node {
    cursor: pointer;
    transition: opacity 0.15s;
}

.diagram .node:hover rect,
.diagram .node:hover path {
    filter: brightness(1.06);
}

.diagram .node:focus {
    outline: none;
}

/* The selected node gets a dark halo. (Mermaid writes each node's own stroke
   as an inline !important style, so the highlight is a filter, not a stroke.) */
.diagram .node.selected,
.diagram .node:focus-visible {
    filter: drop-shadow(0 0 1px #111) drop-shadow(0 0 3px #111);
}

/* Stages and arrows the example event has not reached yet */
.diagram .dimmed {
    opacity: 0.45;
}

/* Shared infobox panel below the diagram */
.infobox {
    flex: 1 1 auto;
    display: flex;
    align-items: flex-start;
    gap: 18px;
    padding: 10px 14px;
    background-color: white;
    border-top: 1px solid silver;
    font-size: 15px;
    line-height: 1.4;
    color: #1f2937;
    overflow: hidden;
}

.info-text {
    flex: 1 1 52%;
    min-width: 0;
}

.info-text h2 {
    margin: 0 0 4px 0;
    font-size: 18px;
    color: #00695c;
}

.info-text p {
    margin: 0 0 6px 0;
}

.info-text .label {
    font-weight: bold;
}

/* What the example event looks like at the selected stage */
.data-panel {
    flex: 1 1 48%;
    min-width: 0;
    border: 1px solid #94a3b8;
    border-radius: 4px;
    background-color: #f8fafc;
}

.data-panel.file {
    background-color: #fff8e1;
    border-color: #8a5a00;
}

.data-label {
    padding: 4px 8px;
    font-size: 14px;
    font-weight: bold;
    border-bottom: 1px solid #cbd5e1;
}

.data-panel pre {
    margin: 0;
    padding: 6px 8px;
    font-family: Menlo, Consolas, "Courier New", monospace;
    font-size: 13px;
    line-height: 1.4;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    color: #0f172a;
}

/* Narrow iframes: stack the text above the data panel */
@media (max-width: 620px) {
    .sim-header h1 {
        font-size: 19px;
    }
    .legend {
        font-size: 12px;
        gap: 2px 10px;
        padding-top: 4px;
    }
    .infobox {
        flex-direction: column;
        gap: 6px;
        font-size: 13px;
        line-height: 1.3;
        padding: 8px 10px;
    }
    .info-text h2 {
        font-size: 16px;
    }
    .info-text p {
        margin-bottom: 4px;
    }
    .info-text,
    .data-panel {
        flex: 0 0 auto;
        width: 100%;
        box-sizing: border-box;
    }
    .data-label {
        font-size: 12px;
        padding: 2px 8px;
    }
    .data-panel pre {
        font-size: 11px;
        line-height: 1.25;
        padding: 4px 8px;
    }
}
