/* JSON Object Structure Visualizer stylesheet
 * ==========================================
 * Layout (top to bottom): title, legend, tree drawing area, control panel.
 *
 * This sim does NOT use the right-hand panel of the standard vis-network layout.
 * A left-to-right tree is wide and short, so it gets the full width of the iframe
 * and the controls sit underneath it, like the control region of a p5.js MicroSim.
 */

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

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

/* ===========================================
   MAIN CONTAINER
   =========================================== */
.container {
    display: flex;
    flex-direction: column;
    width: 100%;
    height: 100vh;
    min-height: 600px;
    background-color: aliceblue;
    border: 1px solid silver;
}

.title {
    flex: 0 0 auto;
    padding: 8px 10px 2px 10px;
    text-align: center;
    font-size: 22px;
    color: black;
}

/* ===========================================
   LEGEND (one row under the title)
   =========================================== */
.legend {
    flex: 0 0 auto;
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 2px 14px;
    padding: 2px 10px 4px 10px;
    font-size: 13px;
    color: black;
}

.legend-item {
    display: flex;
    align-items: center;
    white-space: nowrap;
}

.swatch {
    display: inline-block;
    width: 22px;
    height: 13px;
    margin-right: 5px;
    border: 2px solid #333;
}

.swatch-root   { width: 15px; height: 15px; border-radius: 50%; background-color: #1976D2; border-color: #0D47A1; }
.swatch-object { background-color: #81C784; border-color: #2E7D32; }
.swatch-array  { background-color: #FFB74D; border-color: #E65100; border-radius: 7px; }
.swatch-dot    { width: 11px; height: 11px; border-radius: 50%; border-width: 1px; }
.swatch-string  { background-color: #2E7D32; border-color: #1B5E20; }
.swatch-number  { background-color: #1565C0; border-color: #0D47A1; }
.swatch-boolean { background-color: #EF6C00; border-color: #BF360C; }
.swatch-null    { background-color: #9E9E9E; border-color: #616161; }

/* ===========================================
   NETWORK (takes all remaining height)
   =========================================== */
#network {
    flex: 1 1 auto;
    min-height: 200px;
    width: 100%;
    background-color: aliceblue;
}

/* ===========================================
   NAVIGATION BUTTONS
   One compact row in each bottom corner so the buttons never cover the drawing.
   (vis-network's default is a 75px-tall cluster of 34px buttons.)
   =========================================== */
#network div.vis-navigation div.vis-button {
    width: 28px;
    height: 28px;
    background-size: 24px 24px;
    background-position: 2px 2px;
}
#network div.vis-navigation div.vis-button.vis-left        { left: 8px;   bottom: 6px; }
#network div.vis-navigation div.vis-button.vis-up          { left: 40px;  bottom: 6px; }
#network div.vis-navigation div.vis-button.vis-down        { left: 72px;  bottom: 6px; }
#network div.vis-navigation div.vis-button.vis-right       { left: 104px; bottom: 6px; }
#network div.vis-navigation div.vis-button.vis-zoomOut     { right: 72px; bottom: 6px; }
#network div.vis-navigation div.vis-button.vis-zoomIn      { right: 40px; bottom: 6px; }
#network div.vis-navigation div.vis-button.vis-zoomExtends { right: 8px;  bottom: 6px; }

/* ===========================================
   CONTROL PANEL (white, below the drawing area)
   =========================================== */
.bottom-panel {
    flex: 0 0 156px;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto minmax(0, 1.3fr);
    gap: 10px;
    padding: 8px 10px;
    background-color: white;
    border-top: 1px solid silver;
    min-height: 0;
}

.input-col {
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.input-col label {
    font-size: 13px;
    font-weight: bold;
    margin-bottom: 3px;
}

#json-input {
    flex: 1 1 auto;
    width: 100%;
    min-height: 0;
    resize: none;
    padding: 4px 6px;
    font-family: monospace;
    font-size: 12px;
    line-height: 15px;
    white-space: pre;
    border: 1px solid #999;
    border-radius: 4px;
}

.controls-col {
    display: grid;
    grid-template-columns: auto auto;
    grid-auto-rows: min-content;
    gap: 6px;
    align-content: start;
    padding-top: 18px;
}

.btn {
    padding: 6px 10px;
    font-size: 13px;
    font-weight: bold;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    white-space: nowrap;
}

.btn-primary { background-color: #1976D2; color: white; }
.btn-primary:hover { background-color: #1565C0; }
.btn-secondary { background-color: #616161; color: white; }
.btn-secondary:hover { background-color: #424242; }

.check {
    grid-column: 1 / -1;
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 14px;
    cursor: pointer;
}

.info-col {
    min-height: 0;
    overflow-y: auto;
    padding: 6px 10px;
    background-color: #F5F9FF;
    border: 1px solid #C5D5E8;
    border-radius: 6px;
    font-size: 13px;
    line-height: 1.4;
}

.info-title {
    font-weight: bold;
    font-size: 14px;
    margin-bottom: 3px;
}

.info-title.error { color: #C62828; }

.info-row { margin: 1px 0; overflow-wrap: anywhere; }
.info-key { color: #555; font-weight: bold; }
.info-path { font-family: monospace; font-size: 12px; }
.info-hint { color: #555; }

/* ===========================================
   RESPONSIVE
   =========================================== */
@media (max-width: 620px) {
    .title { font-size: 18px; }
    .legend { font-size: 11px; gap: 2px 8px; }
    .bottom-panel { gap: 6px; padding: 6px; }
    .controls-col { grid-template-columns: auto; gap: 4px; padding-top: 0; }
    .btn { padding: 4px 6px; font-size: 11px; }
    .check { font-size: 12px; }
    .info-col { font-size: 12px; padding: 4px 6px; }
}
