/* Indegree and Out-Degree Counter - vis-network MicroSim
 * =======================================================
 * Layout: full-height network canvas with absolute-positioned
 * overlay siblings (title, legend, right panel). Overlays are
 * NEVER nested inside #network because vis-network erases its
 * container's innerHTML on init.
 */

/* ===========================================
   RESET & BASE
   =========================================== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

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

/* ===========================================
   CONTAINER & NETWORK CANVAS
   =========================================== */
.container {
    position: relative;
    width: 100%;
    height: 100vh;
}

#network {
    width: 100%;
    height: 100%;
    background-color: aliceblue;
}

/* ===========================================
   TITLE (Top Center)
   =========================================== */
.title {
    position: absolute;
    top: 8px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 18px;
    font-weight: bold;
    color: black;
    background-color: rgba(240, 248, 255, 0.85);
    padding: 4px 12px;
    white-space: nowrap;
    z-index: 10;
}

/* ===========================================
   LEGEND (Upper Left)
   =========================================== */
.legend {
    position: absolute;
    top: 8px;
    left: 8px;
    padding: 6px 8px;
    background-color: rgba(255, 255, 255, 0.95);
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.12);
    z-index: 10;
}

.legend-item {
    display: flex;
    align-items: center;
    margin: 3px 0;
    font-size: 11px;
}

.legend-color {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    margin-right: 5px;
    border: 2px solid #333;
    flex-shrink: 0;
}

.color-gray   { background-color: #d0d3d8; }
.color-blue   { background-color: #2196f3; }
.color-green  { background-color: #2e9e4f; }
.color-orange { background-color: #f28c1e; }

/* ===========================================
   RIGHT PANEL (Counts, Controls, Help)
   =========================================== */
.right-panel {
    position: absolute;
    top: 46px;
    right: 8px;
    width: 232px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    z-index: 10;
}

/* ===========================================
   COUNT PANEL (Live in/out/degree)
   =========================================== */
.count-panel {
    background-color: rgba(255, 255, 255, 0.97);
    border-radius: 8px;
    padding: 10px 12px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.12);
    border: 2px solid #2196f3;
}

.count-node {
    font-size: 13px;
    font-weight: bold;
    color: #1565c0;
    text-align: center;
    margin-bottom: 8px;
    min-height: 18px;
    line-height: 1.3;
}

.count-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 5px 8px;
    border-radius: 6px;
    margin: 4px 0;
}

.count-label {
    font-size: 12px;
    font-weight: bold;
}

.count-value {
    font-size: 20px;
    font-weight: bold;
    font-variant-numeric: tabular-nums;
    min-width: 26px;
    text-align: right;
}

.count-in    { background-color: #e6f4ea; color: #1e6b37; }
.count-out   { background-color: #fdf0e2; color: #b3660f; }
.count-total { background-color: #e8eef7; color: #16457a; }

/* Pulse applied briefly when a count increments */
.count-value.bump {
    animation: bump 0.28s ease;
}

@keyframes bump {
    0%   { transform: scale(1); }
    45%  { transform: scale(1.45); }
    100% { transform: scale(1); }
}

/* ===========================================
   CONTROLS
   =========================================== */
.controls {
    display: flex;
    flex-direction: column;
    gap: 8px;
    background-color: rgba(255, 255, 255, 0.97);
    padding: 10px 12px;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.12);
}

.toggle-group {
    display: flex;
    gap: 0;
    width: 100%;
}

.btn {
    padding: 8px 12px;
    font-size: 13px;
    font-weight: bold;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.15s;
}

.btn-secondary {
    background-color: #757575;
    color: white;
    width: 100%;
}

.btn-secondary:hover {
    background-color: #616161;
}

.btn-toggle {
    flex: 1;
    background-color: #e0e0e0;
    color: #333;
    border-radius: 0;
    border-right: 1px solid #bdbdbd;
}

.btn-toggle:first-child {
    border-top-left-radius: 6px;
    border-bottom-left-radius: 6px;
}

.btn-toggle:last-child {
    border-top-right-radius: 6px;
    border-bottom-right-radius: 6px;
    border-right: none;
}

.btn-toggle:hover {
    background-color: #cfcfcf;
}

.btn-toggle.active {
    background-color: #2196f3;
    color: white;
}

/* ===========================================
   HELP PANEL
   =========================================== */
.status-panel {
    background-color: rgba(255, 255, 255, 0.97);
    border-radius: 8px;
    padding: 10px 12px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.12);
}

.status-title {
    font-weight: bold;
    margin-bottom: 6px;
    font-size: 13px;
    color: #333;
}

.status-text {
    font-size: 11px;
    line-height: 1.5;
}

.status-text ul {
    margin-left: 15px;
    margin-top: 3px;
}

.status-text li {
    margin-bottom: 3px;
}

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

    .legend {
        padding: 4px 6px;
    }

    .legend-item {
        font-size: 10px;
    }

    .right-panel {
        width: 168px;
        top: 40px;
    }

    .count-value {
        font-size: 17px;
    }

    .btn {
        padding: 7px 8px;
        font-size: 12px;
    }

    .status-text {
        font-size: 10px;
    }
}
