/* Generator dashboard (scripts/gendash.js), shared by PintSize Cloud, the Cloud Client and microgen.
   Colors come from the page's portal.css variables; the fallbacks keep it usable on its own. */

.gd {
    --gd-panel: var(--panel, #17191c);
    --gd-panel-2: var(--panel-2, #202328);
    --gd-border: var(--border, #2d3138);
    --gd-text: var(--text, #e9e9e9);
    --gd-muted: var(--muted, #9aa0a8);
    --gd-accent: var(--accent, #deab04);
    --gd-status: #6e7681;
    color: var(--gd-text);
    margin-bottom: 14px;
}

/* ---------- Collapsible header (cloud list of generators) ---------- */
.gd-collapsible {
    background: var(--gd-panel);
    border: 1px solid var(--gd-border);
    border-left: 6px solid var(--gd-status);
    border-radius: 8px;
}

.gd-head {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    cursor: pointer;
    list-style: none;
}

.gd-head::-webkit-details-marker { display: none; }

.gd-head::after {
    content: "\25BE";
    color: var(--gd-muted);
    transition: transform .15s ease;
}

.gd-collapsible:not([open]) .gd-head::after { transform: rotate(-90deg); }
.gd-head:hover { background: var(--gd-panel-2); }
.gd-collapsible[open] .gd-head { border-bottom: 1px solid var(--gd-border); }

.gd-titles { flex: 1; min-width: 0; }
.gd-name { font-weight: 600; font-size: 16px; }
.gd-sub { color: var(--gd-muted); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.gd-badges { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }

.gd-badge, .gd-pill {
    border-radius: 10px;
    padding: 2px 10px;
    font-size: 12.5px;
    font-weight: 600;
    white-space: nowrap;
}

.gd-badge { background: var(--gd-panel-2); border: 1px solid var(--gd-border); color: var(--gd-accent); }
.gd-badge-bad { color: #ff8a80; border-color: #6b2b2b; }

.gd-pill {
    background: color-mix(in srgb, var(--gd-status) 22%, transparent);
    border: 1px solid var(--gd-status);
}

.gd-collapsible .gd-body { padding: 16px; }

/* ---------- Tiles ---------- */
.gd-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 12px;
    margin-bottom: 12px;
}

.gd-status { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }

.gd-tile {
    background: var(--gd-panel-2);
    border: 1px solid var(--gd-border);
    border-radius: 8px;
    padding: 12px 14px;
    min-width: 0;
}

.gd:not(.gd-collapsible) .gd-tile, .gd:not(.gd-collapsible) .gd-card { background: var(--gd-panel); }

.gd-label {
    color: var(--gd-muted);
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 1px;
    text-transform: uppercase;
}

.gd-stat-value { font-size: 22px; font-weight: 600; margin-top: 4px; overflow-wrap: anywhere; }
.gd-stat-sub { color: var(--gd-muted); font-size: 13px; min-height: 1em; }

/* ---------- Gauges ---------- */
.gd-gauge { text-align: center; padding: 10px 8px 12px; }
.gd-gauge svg { display: block; width: 100%; max-width: 190px; margin: 0 auto; overflow: visible; }

.gd-track, .gd-bar, .gd-zone { fill: none; stroke-linecap: round; }
.gd-track { stroke: var(--gd-border); stroke-width: 14; }
.gd-bar {
    stroke-width: 14;
    stroke-dasharray: 100 100;
    stroke-dashoffset: 100;
    transition: stroke-dashoffset .6s ease, stroke .6s ease;
}
.gd-zone { stroke-width: 5; stroke-linecap: butt; opacity: .85; }

.gd-value { fill: var(--gd-text); font-size: 34px; font-weight: 600; text-anchor: middle; }
.gd-unit { fill: var(--gd-muted); font-size: 14px; text-anchor: middle; }
.gd-scale { fill: var(--gd-muted); font-size: 12px; text-anchor: middle; }
.gd-gauge .gd-label { margin-top: 2px; }

/* ---------- Cards ---------- */
.gd-card {
    background: var(--gd-panel-2);
    border: 1px solid var(--gd-border);
    border-radius: 8px;
    padding: 14px 16px;
    min-width: 0;
}

.gd-card h3 {
    margin: 0 0 10px;
    font-size: 14px;
    font-weight: 600;
}

.gd-power-card { margin-bottom: 12px; }

.gd-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(300px, 100%), 1fr));
    gap: 12px;
}

.gd-list {
    display: grid;
    /* Values keep at least 11em so labels wrap before values do. */
    grid-template-columns: auto minmax(min(11em, 60%), 1fr);
    gap: 6px 16px;
    margin: 0;
    font-size: 14px;
}

.gd-list dt { color: var(--gd-muted); }
.gd-list dd { margin: 0; font-weight: 600; text-align: right; overflow-wrap: anywhere; }

.gd-help { color: var(--gd-muted); font-size: 13px; margin: 6px 0 0; }
.gd-empty { color: var(--gd-muted); margin: 6px 0; }

/* ---------- Actions ---------- */
.gd-action-form { display: grid; gap: 10px; }
.gd-action-form label { display: grid; gap: 4px; color: var(--gd-muted); font-size: 13px; }
.gd-action-form select, .gd-action-form input { width: 100%; }
.gd-pending { font-size: 18px; font-weight: 600; color: var(--gd-accent); margin-bottom: 10px; }

/* ---------- Power history ---------- */
.gd-run-nav { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; }
.gd-run-text { flex: 1; min-width: 0; display: flex; flex-wrap: wrap; gap: 4px 12px; align-items: baseline; }
.gd-run-text span { color: var(--gd-muted); font-size: 13px; }

.gd-run-btn {
    background: transparent;
    border: 1px solid var(--gd-border);
    color: var(--gd-text);
    border-radius: 5px;
    width: 32px;
    height: 30px;
    font-size: 18px;
    line-height: 1;
    cursor: pointer;
}
.gd-run-btn:hover:not(:disabled) { background: var(--gd-panel); }
.gd-run-btn:disabled { opacity: .35; cursor: default; }

.gd-chart { position: relative; }
.gd-chart-svg { display: block; touch-action: pan-y; }

.gd-gridline { stroke: var(--gd-border); stroke-width: 1; }
.gd-axis { stroke: var(--gd-muted); stroke-width: 1; }
.gd-tick { fill: var(--gd-muted); font-size: 12px; text-anchor: middle; }
.gd-tick-y { text-anchor: end; }
.gd-rated { stroke: var(--gd-accent); stroke-width: 1; stroke-dasharray: 4 4; opacity: .7; }
.gd-rated-text { fill: var(--gd-accent); text-anchor: end; }
.gd-line { fill: none; stroke: #7cc4ff; stroke-width: 2; stroke-linejoin: round; }
.gd-area { fill: #7cc4ff; opacity: .15; }
.gd-dot { fill: #7cc4ff; stroke: var(--gd-panel-2); stroke-width: 2; }

.gd-tip {
    display: none;
    position: absolute;
    transform: translate(-50%, -140%);
    background: var(--gd-panel);
    border: 1px solid var(--gd-border);
    border-radius: 5px;
    padding: 3px 8px;
    font-size: 13px;
    white-space: nowrap;
    pointer-events: none;
}

.gd-overview { margin-top: 10px; }
.gd-ov-title { color: var(--gd-muted); font-size: 12px; margin-bottom: 2px; }
.gd-ov-svg { display: block; }
.gd-ov-run { fill: #4c78a8; cursor: pointer; }
.gd-ov-run:hover { fill: #7cc4ff; }
.gd-ov-run.selected { fill: var(--gd-accent); }
.gd-ov-labels { position: relative; height: 16px; color: var(--gd-muted); font-size: 11.5px; }
.gd-ov-labels span { position: absolute; transform: translateX(-50%); white-space: nowrap; }

/* ---------- Wide: power chart beside the info cards ---------- */
.gd-body { container-type: inline-size; }

@container (min-width: 1100px) {
    .gd-body > .gd-wide {
        display: grid;
        grid-template-columns: minmax(0, 3fr) minmax(0, 2fr);
        gap: 12px;
        align-items: start;
    }
    .gd-wide .gd-power-card { margin-bottom: 0; }
    .gd-wide .gd-cards { grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
}

/* Up to about 1650px, split evenly so the two info cards are wide enough to sit side by side. */
@container (min-width: 1100px) and (max-width: 1650px) {
    .gd-body > .gd-wide { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
    .gd-wide .gd-list { font-size: 14px; gap: 5px 10px; }
}

/* ---------- Kiosk (the Cloud Client's full screen dashboard) ---------- */
.gd-kiosk { margin-bottom: 0; }
.gd-kiosk .gd-stat-value { font-size: 28px; }
.gd-kiosk .gd-status .gd-tile { padding: 10px 16px; }
.gd-kiosk .gd-label { font-size: 13px; }
.gd-kiosk .gd-list { font-size: 15px; }
/* One row of gauges on a landscape tablet (9 or so fit from 1280px wide), sized up on bigger screens. */
.gd-kiosk .gd-gauges { grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); }
.gd-kiosk .gd-gauge svg { max-width: 240px; }

@media (max-width: 800px) {
    .gd-grid, .gd-kiosk .gd-gauges { grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 8px; }
    .gd-collapsible .gd-body { padding: 10px; }
    /* Name on its own line; state and badges wrap below it. */
    .gd-head { flex-wrap: wrap; gap: 8px; }
    .gd-titles { flex: 1 1 calc(100% - 30px); }
    .gd-head::after { order: 1; }
    .gd-pill { order: 2; }
    .gd-badges { order: 3; justify-content: flex-start; }
    .gd-status { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .gd-status .gd-tile { padding: 10px; }
    .gd-stat-value { font-size: 16px; }
    .gd-stat-sub { font-size: 12px; }
}
