/* CSV-to-JSON Record Mapper - MicroSim Stylesheet
 * ==============================================
 * Rows: title / controls / main-row (CSV panel + JSON panel) / try-your-own.
 * Each CSV field has a colour, and the JSON key it becomes carries the same
 * colour — the colour correspondence IS the mapping, with the SVG connector
 * making it literal.
 */

/* Must stay in sync with CANVAS_HEIGHT in csv-to-json-record-mapper.js */
:root {
    --sim-height: 480px;

    /* one colour per CSV field, shared by the JSON key it maps to */
    --c-id:   #1e88e5;   /* ConceptID     */
    --c-lab:  #2e7d32;   /* ConceptLabel  */
    --c-dep:  #ef6c00;   /* Dependencies  */
    --c-tax:  #6a1b9a;   /* TaxonomyID    */
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: Arial, Helvetica, sans-serif;
    background-color: aliceblue;
}

.container {
    display: flex;
    flex-direction: column;
    width: 100%;
    height: var(--sim-height);
    padding: 6px 8px 8px 8px;
    gap: 6px;
}

/* ===========================================
   TITLE
   =========================================== */
.title {
    flex: 0 0 auto;
    text-align: center;
    font-size: 17px;
    font-weight: bold;
    color: black;
    line-height: 1.2;
}

/* ===========================================
   CONTROLS
   =========================================== */
.controls {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    flex-wrap: wrap;
    background-color: rgba(255, 255, 255, 0.95);
    border-radius: 8px;
    padding: 6px 10px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.step-counter {
    font-size: 13px;
    font-weight: bold;
    color: #37474f;
    white-space: nowrap;
}

.step-name {
    flex: 1 1 auto;
    font-size: 12px;
    color: #607d8b;
    min-width: 0;
}

.ctl-buttons {
    display: flex;
    gap: 6px;
}

.btn {
    padding: 6px 12px;
    font-size: 12.5px;
    font-weight: bold;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    transition: background-color 0.2s;
    white-space: nowrap;
}

.btn-primary { background-color: #1e88e5; color: white; }
.btn-primary:hover:not(:disabled) { background-color: #1565c0; }

.btn-primary:disabled {
    background-color: #cfd8dc;
    color: #90a4ae;
    cursor: not-allowed;
}

.btn-secondary { background-color: #757575; color: white; }
.btn-secondary:hover:not(:disabled) { background-color: #616161; }

.btn-gold { background-color: #f9a825; color: #3e2723; }
.btn-gold:hover:not(:disabled) { background-color: #f57f17; }

/* ===========================================
   MAIN ROW
   =========================================== */
.main-row {
    position: relative;
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    gap: 10px;
}

.panel {
    display: flex;
    flex-direction: column;
    background-color: white;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    overflow: hidden;
}

.csv-panel  { flex: 0 0 300px; min-width: 0; }
.json-panel { flex: 1 1 auto;  min-width: 0; }

.panel-head {
    flex: 0 0 auto;
    font-family: "Courier New", Courier, monospace;
    font-size: 10.5px;
    font-weight: bold;
    color: #546e7a;
    padding: 4px 8px;
    background-color: #eceff1;
    border-bottom: 1px solid #cfd8dc;
}

.panel-body {
    flex: 1 1 auto;
    min-height: 0;
    padding: 8px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

/* ===========================================
   CSV PANEL
   =========================================== */
.csv-header {
    font-family: "Courier New", Courier, monospace;
    font-size: 10px;
    color: #90a4ae;
    border-bottom: 1px dashed #cfd8dc;
    padding-bottom: 3px;
    word-break: break-all;
}

.csv-row {
    font-family: "Courier New", Courier, monospace;
    font-size: 14px;
    font-weight: bold;
    line-height: 1.9;
    word-break: break-all;
}

/* one span per field; dim until its step arrives */
.field {
    border-radius: 3px;
    padding: 1px 3px;
    color: #b0bec5;
    background-color: #f5f5f5;
    transition: color 0.25s, background-color 0.25s;
}

.field.lit {
    color: white;
}

.field.lit.f-id  { background-color: var(--c-id); }
.field.lit.f-lab { background-color: var(--c-lab); }
.field.lit.f-dep { background-color: var(--c-dep); }
.field.lit.f-tax { background-color: var(--c-tax); }

/* the field whose step just fired */
.field.active {
    outline: 2px solid #212121;
    outline-offset: 1px;
}

.comma {
    color: #cfd8dc;
    padding: 0 1px;
}

/* the pipe inside Dependencies, called out at the split step */
.pipe {
    color: #fff;
    background-color: #b71c1c;
    border-radius: 2px;
    padding: 0 2px;
}

.csv-note {
    font-size: 10.5px;
    line-height: 1.4;
    color: #78909c;
    font-style: italic;
    margin-top: auto;
}

/* ===========================================
   JSON PANEL
   =========================================== */
.json-empty {
    font-size: 12px;
    color: #b0bec5;
    font-style: italic;
    margin: auto;
}

.json-block[hidden] {
    display: none;
}

.json-block {
    animation: slide-in 0.3s ease-out;
}

@keyframes slide-in {
    from { opacity: 0; transform: translateY(-4px); }
    to   { opacity: 1; transform: none; }
}

.json-label {
    font-size: 9.5px;
    font-weight: bold;
    color: #607d8b;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    margin-bottom: 2px;
}

.split-note {
    text-transform: none;
    letter-spacing: 0;
    font-style: italic;
    color: #ef6c00;
    font-size: 10px;
}

.json-code {
    font-family: "Courier New", Courier, monospace;
    font-size: 12px;
    line-height: 1.55;
    background-color: #fafafa;
    border: 1px solid #eceff1;
    border-radius: 4px;
    padding: 4px 7px;
    color: #37474f;
    white-space: pre;
    overflow-x: auto;
}

/* JSON keys carry the colour of the CSV field they came from */
.k-id  { color: var(--c-id);  font-weight: bold; }
.k-lab { color: var(--c-lab); font-weight: bold; }
.k-dep { color: var(--c-dep); font-weight: bold; }
.k-tax { color: var(--c-tax); font-weight: bold; }

.punct { color: #b0bec5; }

/* ===========================================
   CONNECTOR OVERLAY
   =========================================== */
.map-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 5;
}

.map-line {
    fill: none;
    stroke-width: 2.5;
    stroke-dasharray: 4 2.5;
    animation: draw 0.45s ease-out;
}

.map-head {
    animation: draw 0.45s ease-out;
}

@keyframes draw {
    from { opacity: 0; }
    to   { opacity: 1; }
}

/* ===========================================
   TRY YOUR OWN ROW
   =========================================== */
.try-row {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    background-color: rgba(255, 255, 255, 0.95);
    border-radius: 8px;
    padding: 6px 10px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.try-label {
    font-size: 11px;
    font-weight: bold;
    color: #607d8b;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    white-space: nowrap;
}

#try-input {
    flex: 1 1 200px;
    min-width: 120px;
    font-family: "Courier New", Courier, monospace;
    font-size: 12.5px;
    padding: 5px 8px;
    border: 1px solid #b0bec5;
    border-radius: 5px;
}

#try-input:focus {
    outline: 2px solid #f9a825;
    outline-offset: -1px;
}

.try-error[hidden] {
    display: none;
}

.try-error {
    font-size: 11px;
    color: #c62828;
    font-weight: bold;
}

/* ===========================================
   RESPONSIVE
   =========================================== */
@media (max-width: 600px) {
    .title { font-size: 14px; }

    .step-name { display: none; }

    .btn { padding: 5px 9px; font-size: 11px; }

    /* spec: CSV and JSON panels stack vertically below 600px */
    .main-row {
        flex-direction: column;
        gap: 6px;
    }

    .csv-panel  { flex: 0 0 40%; }
    .json-panel { flex: 1 1 auto; }

    .csv-row { font-size: 12px; line-height: 1.7; }
    .csv-note { display: none; }
    .json-code { font-size: 10.5px; }

    .try-label { display: none; }
}
