/* Dashboard component (dashboard.js). Reuses the votes modal (.modal-votes,
   .votes-header) and the body of the pools window (.pools-body). One view on a
   laptop screen: the key figures, the chart with the largest DReps beside it,
   the two bars side by side, the flows in one row and the lookup in one line;
   the explanation folds away. Colours from the site palette: gold #FFD700,
   green #28a745, greys; orange and red mark a second role. */

.modal-dashboard {
    max-width: 1140px;
    max-height: calc(100vh - 40px);
    padding: 20px 26px;
}

.modal-dashboard .votes-header {
    top: -20px;
    margin: -20px -26px 8px;
    padding: 20px 26px 8px;
}

.modal-dashboard .modal-title {
    font-size: 1.3rem;
}

.dash-body {
    font-size: 0.9rem;
    line-height: 1.4;
}

.dash-body h3 {
    font-size: 0.95rem;
    margin: 0 0 4px 0;
}

.dash-meta {
    flex: 1;
    font-size: 0.78rem;
    color: #777;
    line-height: 1.3;
    text-align: right;
}

.dash-lookup h3 {
    margin: 0 6px 0 0;
}

.dash-hint {
    font-size: 0.75rem;
    color: #777;
    margin: 2px 0 0 0;
}

.pools-body p.dash-hint {
    margin: 2px 0 0 0;
}

.dash-panel {
    margin-bottom: 10px;
}

.dash-row {
    display: grid;
    gap: 18px;
}

/* a grid item may be narrower than its content: the chart scrolls inside its
   own box on a phone instead of widening the whole panel */
.dash-row > *,
.dash-panel {
    min-width: 0;
}

.dash-row-chart {
    grid-template-columns: 3fr 1fr;
}

.dash-row-bars {
    grid-template-columns: 1fr 1fr;
}

.dash-paneltitle {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    justify-content: space-between;
    gap: 4px 16px;
}

/* the key figures */
.dash-cards {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
    margin: 0 0 10px;
}

.dash-card {
    background: #f5f5f5;
    border-top: 3px solid #FFD700;
    border-radius: 6px;
    padding: 6px 10px 6px;
    display: grid;
    grid-template-columns: auto 1fr;
    grid-template-rows: auto auto auto;
    column-gap: 12px;
    align-items: center;
    line-height: 1.25;
}

.dash-big {
    grid-row: 1 / span 3;
    font-size: 2.2rem;
    font-weight: 700;
    color: #333;
    line-height: 1;
}

.dash-line {
    font-size: 0.88rem;
}

.dash-was {
    font-size: 0.72rem;
    color: #777;
}

/* the two bars */
.dash-bar {
    display: flex;
    height: 22px;
    border: 1px solid #ccc;
    border-radius: 4px;
    overflow: hidden;
    margin: 2px 0 5px;
}

.dash-seg {
    flex-basis: 0;
    min-width: 1px;
}

.dash-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 2px 12px;
    font-size: 0.75rem;
}

.dash-key {
    display: inline-flex;
    align-items: center;
    gap: 5px;
}

.dash-swatch {
    width: 10px;
    height: 10px;
    border-radius: 2px;
    flex: none;
}

.dash-g4 { background: #1e7a37; }
.dash-g3 { background: #28a745; }
.dash-g2 { background: #8fd19e; }
.dash-g1 { background: #d9f2df; }

.dash-v-active { background: #28a745; }
.dash-v-nc { background: #555; }
.dash-v-inactive { background: #b0b0b0; }
.dash-v-abstain { background: #d6d6d6; }
.dash-v-none { background: #f0f0f0; }

/* every active DRep */
.dash-chart {
    position: relative;
    margin: 2px 0 0;
}

.dash-svg {
    width: 100%;
    height: auto;
    display: block;
}

.dash-grid {
    stroke: #e6e6e6;
    stroke-width: 1;
}

.dash-axis {
    font-size: 11px;
    fill: #777;
}

/* the invisible area over the full height of a column */
.dash-hit {
    fill: transparent;
    cursor: pointer;
}

.dash-hit:focus {
    outline: none;
}

.dash-hit.dash-col {
    fill: rgba(255, 215, 0, 0.18);
}

.dash-c-spo { fill: #e8892b; }
.dash-c-cc { fill: #c0392b; }
.dash-c-drep { fill: #9a9a9a; }
.dash-on { fill: #FFD700; }
.dash-mine { fill: #FFD700; stroke: #333; stroke-width: 1; }

.dash-mark {
    stroke: #333;
    stroke-width: 1.2;
    stroke-dasharray: 4 3;
}

.dash-marktext {
    font-size: 12px;
    font-weight: 700;
    fill: #333;
}

.dash-tip {
    position: absolute;
    z-index: 2;
    width: 270px;
    background: #fff;
    border: 1px solid #333;
    border-radius: 6px;
    padding: 8px 10px;
    font-size: 0.8rem;
    line-height: 1.35;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.2);
    pointer-events: none;
}

.dash-tipwhy {
    color: #555;
    margin-top: 4px;
}

.dash-sw-spo { background: #e8892b; }
.dash-sw-cc { background: #c0392b; }
.dash-sw-drep { background: #9a9a9a; }

.dash-largest {
    margin: 4px 0 0 22px;
    padding: 0;
    font-size: 0.76rem;
    font-weight: 700;
    line-height: 1.17;
}

.dash-c-spo-text { color: #c46a12; }
.dash-c-cc-text { color: #c0392b; }
.dash-c-drep-text { color: #555; }

/* where it moved */
.dash-flows {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 8px;
}

.dash-flow {
    background: #f5f5f5;
    border-radius: 6px;
    padding: 5px 9px;
}

.dash-flowlabel {
    font-size: 0.75rem;
    line-height: 1.25;
}

.dash-flownum {
    font-size: 1.05rem;
    font-weight: 700;
}

.dash-neg { color: #b23b3b; }
.dash-pos { color: #28a745; }

/* the lookup */
.dash-lookup {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
}

.dash-lookup input {
    flex: 1 1 260px;
    padding: 7px 10px;
    font: inherit;
    border: 1px solid #ccc;
    border-radius: 4px;
}

.dash-btn {
    font: inherit;
    color: #333;
    background-color: #fffdf0;
    border: 2px solid #FFD700;
    border-radius: 4px;
    padding: 6px 16px;
    cursor: pointer;
    transition: background-color 0.3s ease;
}

.dash-btn:hover,
.dash-btn:focus-visible {
    background-color: #fff5bf;
}

.dash-wallets {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 6px;
}

.dash-result {
    background: #fffdf0;
    border: 1px solid #FFD700;
    border-radius: 6px;
    padding: 8px 12px;
    margin-top: 6px;
}

.pools-body .dash-resline {
    margin: 0 0 6px 0;
}

.dash-resnote {
    color: #555;
}

.dash-go {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

/* the explanation, folded */
.dash-details {
    border-top: 1px solid #eee;
    padding-top: 6px;
    font-size: 0.85rem;
}

.dash-details summary {
    cursor: pointer;
    color: #28a745;
    font-weight: 700;
}

.dash-details[open] summary {
    margin-bottom: 8px;
}

@media (max-width: 900px) {
    .dash-cards {
        grid-template-columns: repeat(2, 1fr);
    }

    .dash-row-chart,
    .dash-row-bars {
        grid-template-columns: 1fr;
    }

    .dash-flows {
        grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    }

    .dash-largest {
        columns: 2 150px;
    }
}

@media (max-width: 640px) {
    .modal-dashboard {
        padding: 20px 16px;
    }

    .modal-dashboard .votes-header {
        flex-wrap: wrap;
        margin: -20px -16px 8px;
        padding: 20px 16px 8px;
    }

    .modal-dashboard .votes-header .modal-title {
        flex: 1;
    }

    .dash-meta {
        order: 3;
        flex-basis: 100%;
        text-align: left;
    }

    .dash-largest {
        columns: 1;
    }

    .dash-lookup h3 {
        flex-basis: 100%;
        margin: 0 0 2px 0;
    }

    .dash-lookup input {
        flex-basis: 100%;
        order: 4;
    }

    .dash-lookup #dashLook {
        order: 5;
    }

    .dash-cards {
        grid-template-columns: 1fr;
    }

    /* the chart keeps a readable width and scrolls sideways */
    .dash-chart {
        overflow-x: auto;
    }

    .dash-svg {
        min-width: 720px;
    }
}

/* a low laptop screen: drop the hints and tighten, so it stays one view */
@media (min-width: 901px) and (max-height: 820px) {
    .dash-body .dash-hint {
        display: none;
    }

    .dash-meta {
        margin-bottom: 4px;
    }

    .dash-cards {
        margin-bottom: 6px;
    }

    .dash-big {
        font-size: 1.8rem;
    }

    .dash-panel {
        margin-bottom: 6px;
    }

    .dash-largest {
        font-size: 0.72rem;
        line-height: 1.12;
    }

    .dash-bar {
        height: 18px;
    }
}

.dash-pools {
    font-weight: 400;
    color: #777;
}

/* a lower window still: smaller type, the same view */
@media (min-width: 901px) and (max-height: 760px) {
    .modal-dashboard .modal-title {
        font-size: 1.15rem;
    }

    .dash-cards {
        gap: 8px;
    }

    .dash-card {
        padding: 3px 10px;
    }

    .dash-big {
        font-size: 1.55rem;
    }

    .dash-line {
        font-size: 0.8rem;
    }

    .dash-body h3 {
        font-size: 0.86rem;
        margin-bottom: 2px;
    }

    .dash-largest {
        font-size: 0.68rem;
        line-height: 1.08;
    }

    .dash-legend {
        font-size: 0.68rem;
    }

    .dash-flow {
        padding: 3px 8px;
    }

    .dash-flownum {
        font-size: 0.92rem;
    }

    .dash-lookup input {
        padding: 4px 8px;
    }

    .dash-btn {
        padding: 3px 12px;
    }

    .dash-details {
        padding-top: 3px;
    }

    .dash-panel {
        margin-bottom: 3px;
    }

    .dash-cards {
        margin-bottom: 4px;
    }
}

.dash-tick {
    stroke: #999;
    stroke-width: 1;
}

/* the switch between the two views */
.dash-tabs {
    display: flex;
    gap: 6px;
    margin: 0 0 10px;
    border-bottom: 2px solid #FFD700;
}

.dash-tab {
    font: inherit;
    font-weight: 700;
    color: #333;
    background: #fffdf0;
    border: 2px solid #FFD700;
    border-bottom: none;
    border-radius: 6px 6px 0 0;
    padding: 5px 18px;
    margin-bottom: -2px;
    cursor: pointer;
}

.dash-tab:hover,
.dash-tab:focus-visible {
    background: #fff5bf;
}

.dash-tab.dash-tab-on {
    background: #FFD700;
}

/* the stake pools view: an owner with several pools */
.dash-c-multi { fill: #5f5f5f; }
.dash-sw-multi { background: #5f5f5f; }
.dash-c-multi-text { color: #333; }

@media (min-width: 901px) and (max-height: 760px) {
    .dash-tab {
        padding: 3px 14px;
    }

    .dash-tabs {
        margin-bottom: 6px;
    }

    .modal-dashboard {
        padding: 14px 26px;
    }

    .modal-dashboard .votes-header {
        top: -14px;
        margin: -14px -26px 6px;
        padding: 14px 26px 6px;
    }
}

/* the complete lists beside the charts: the owners who hold half in two columns */
#dashView-pools .dash-row-chart {
    grid-template-columns: 4fr 3fr;
}

#dashLargest-pools .dash-largest {
    columns: 2;
    column-gap: 30px;
}

#dashLargest-pools .dash-largest li {
    break-inside: avoid;
}

@media (max-width: 900px) {
    #dashView-pools .dash-row-chart {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 640px) {
    #dashLargest-pools .dash-largest {
        columns: 2 130px;
    }
}

/* the counts: one more card in the row of figures */
.dash-cards.dash-cards-5 {
    grid-template-columns: repeat(4, 1fr) minmax(190px, 0.95fr);
}

.dash-countcard {
    grid-template-columns: auto 1fr;
    grid-template-rows: none;
    align-items: baseline;
    align-content: center;
    column-gap: 8px;
    row-gap: 0;
    font-size: 0.8rem;
    line-height: 1.25;
}

.dash-countstitle {
    grid-column: 1 / -1;
    font-weight: 700;
    color: #28a745;
}

.dash-countn {
    font-weight: 700;
    text-align: right;
}

@media (max-width: 900px) {
    .dash-cards.dash-cards-5 {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 640px) {
    .dash-cards.dash-cards-5 {
        grid-template-columns: 1fr;
    }
}

@media (min-width: 901px) and (max-height: 760px) {
    .dash-countcard {
        font-size: 0.72rem;
        line-height: 1.15;
    }
}

/* both views take the height of the taller one, so the window does not change
   size when the view is switched; the view that is off stays in place, unseen */
@media (min-width: 901px) {
    .dash-views {
        display: grid;
    }

    .dash-views > .dash-view {
        grid-area: 1 / 1;
        min-width: 0;
    }

    .dash-views > .dash-view[hidden] {
        display: block;
        visibility: hidden;
    }
}
