
/* ==================================
   PLTS MONITORING V1
   Modern Dark Dashboard
================================== */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: Arial, sans-serif;
    background: #0b1220;
    color: #f1f5f9;
    padding: 24px;
    min-height: 100vh;
}

/* HEADER */

header {
    background: linear-gradient(135deg, #172638, #1e3448);
    padding: 28px;
    border-radius: 16px;
    margin-bottom: 22px;
    border: 1px solid #2b4055;
}

header h1 {
    color: #4ade80;
    font-size: 28px;
    letter-spacing: 1px;
}

header p {
    color: #9fb0c2;
    margin-top: 8px;
    font-size: 14px;
}

#connection-status {
    display: inline-block;
    margin-top: 18px;
    padding: 7px 15px;
    background: #14532d;
    color: #86efac;
    border: 1px solid #166534;
    border-radius: 20px;
    font-size: 12px;
    font-weight: bold;
}

/* BATTERY SOC */

.battery {
    background: linear-gradient(135deg, #14532d, #166534);
    padding: 30px;
    border-radius: 16px;
    text-align: center;
    margin-bottom: 22px;
    border: 1px solid #22c55e;
}

.battery h2 {
    font-size: 17px;
    color: #edeee6;
    letter-spacing: 2px;
}

#soc {
    font-size: 60px;
    font-weight: bold;
    margin: 16px 0;
    color: #ffffff;
}

.battery p {
    color: #dcfce7;
    font-size: 13px;
}

/* DASHBOARD GRID */

.dashboard {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 16px;
}

/* DATA CARDS */

.card {
    background: #172536;
    padding: 24px;
    border-radius: 14px;
    border: 1px solid #2a3c50;
    min-width: 0;
    transition: border-color 0.2s ease;
}

.card:hover {
    border-color: #4ade80;
}

.card h3 {
    font-size: 12px;
    color: #c1c6ce;
    margin-bottom: 18px;
    letter-spacing: 1px;
}

.card div {
    font-size: 29px;
    font-weight: bold;
    color: #4ade80;
    overflow-wrap: anywhere;
}

/* HISTORY */

.history {
    background: #172536;
    padding: 25px;
    border-radius: 14px;
    margin-top: 22px;
    border: 1px solid #2a3c50;
    min-height: 160px;
}

.history h2 {
    font-size: 18px;
    margin-bottom: 15px;
    color: #e2e8f0;
}

.history p {
    color: #94a3b8;
    font-size: 14px;
}

/* FOOTER */

footer {
    text-align: center;
    color: #64748b;
    font-size: 12px;
    padding: 30px 0 10px;
}

/* TABLET */

@media (max-width: 900px) {
    body {
        padding: 18px;
    }

    .dashboard {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

/* MOBILE */

@media (max-width: 600px) {
    body {
        padding: 12px;
    }

    header {
        padding: 20px;
    }

    header h1 {
        font-size: 21px;
    }

    header p {
        font-size: 12px;
    }

    .battery {
        padding: 24px 15px;
    }

    #soc {
        font-size: 48px;
    }

    .dashboard {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 10px;
    }

    .card {
        padding: 16px 12px;
    }

    .card h3 {
        font-size: 10px;
        margin-bottom: 14px;
    }

    .card div {
        font-size: 21px;
    }

    .history {
        padding: 18px;
    }
}

/* SMALL MOBILE */

@media (max-width: 360px) {
    .dashboard {
        grid-template-columns: 1fr;
    }

    .card div {
        font-size: 24px;
    }
}
/* STATUS VARIAN */

#connection-status.offline {
    background: #450a0a;
    color: #fca5a5;
    border-color: #7f1d1d;
}

#connection-status.stale {
    background: #422006;
    color: #fcd34d;
    border-color: #78350f;
}

#last-update {
    display: block;
    margin-top: 10px;
    font-size: 11px;
    color: #64748b;
    letter-spacing: 0.5px;
}

/* angka tidak bergoyang saat berubah */
#soc,
.card div {
    font-variant-numeric: tabular-nums;
}
/* ============ GRAFIK ============ */

.range-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 18px;
}

.range-btn {
    padding: 8px 14px;
    border-radius: 8px;
    border: 1px solid #2a3c50;
    background: #0f1c2c;
    color: #94a3b8;
    font-size: 12px;
    font-weight: bold;
    letter-spacing: 0.5px;
    cursor: pointer;
    transition: all 0.15s ease;
}

.range-btn:hover {
    border-color: #4ade80;
    color: #e2e8f0;
}

.range-btn.active {
    background: #166534;
    color: #bbf7d0;
    border-color: #22c55e;
}

.chart-wrap {
    margin-top: 22px;
}

.chart-wrap h3 {
    font-size: 12px;
    color: #94a3b8;
    margin-bottom: 10px;
    letter-spacing: 1px;
}

.chart-wrap canvas {
    width: 100% !important;
    height: 260px !important;
    display: block;
}

@media (max-width: 600px) {
    .chart-wrap canvas {
        height: 200px !important;
    }
}
/* ============ TAHAP 3: SEKSI ============ */

.battery-stat {
    margin-top: 22px;
    padding-top: 18px;
    border-top: 1px solid rgba(34, 197, 94, 0.25);
}

.battery-stat h3 {
    font-size: 11px;
    color: #bbf7d0;
    letter-spacing: 1px;
    margin-bottom: 6px;
}

.battery-stat div {
    font-size: 24px;
    font-weight: bold;
    color: #ffffff;
    font-variant-numeric: tabular-nums;
}

.group {
    margin-bottom: 22px;
}

.group-title {
    font-size: 13px;
    color: #4ade80;
    letter-spacing: 2px;
    margin-bottom: 12px;
    padding-left: 10px;
    border-left: 3px solid #22c55e;
}

.group-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
}

@media (min-width: 901px) {
    .group-grid.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .group-grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .group-grid.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

@media (max-width: 600px) {
    .group-grid { gap: 10px; }
}

@media (max-width: 330px) {
    .group-grid { grid-template-columns: 1fr; }
}

@media (max-width: 400px) {
    .group-grid .card {
        padding: 14px 10px;
    }
    .group-grid .card h3 {
        font-size: 9px;
        letter-spacing: 0.5px;
    }
    .group-grid .card div {
        font-size: 19px;
    }
}
/* ============ TAHAP 7: GAUGE ============ */

.battery {
    padding: 22px 20px;
}

.gauge-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin: 8px 0 4px;
}

.gauge-box {
    position: relative;
    height: 150px;
}

.gauge-box canvas {
    width: 100% !important;
    height: 100% !important;
    display: block;
}

.gauge-label {
    text-align: center;
    font-size: 10px;
    letter-spacing: 1.3px;
    color: #9fb0c2;
    margin-top: -8px;
}

@media (max-width: 600px) {
    .gauge-row { gap: 6px; }
    .gauge-box { height: 130px; }
    .gauge-label { font-size: 9px; }
}

/* ============ TAHAP 7b-2: MODERN POLISH ============ */

:root {
    --bg-base: #070d18;
    --bg-elevated: #0f1a2b;
    --line-soft: rgba(148, 163, 184, 0.12);
    --line-strong: rgba(148, 163, 184, 0.22);
    --accent: #4ade80;
    --text-bright: #f8fafc;
    --text-muted: #94a3b8;
}

body {
    font-family: 'Inter', Arial, sans-serif;
    background:
        radial-gradient(circle at 15% 0%, rgba(34, 197, 94, 0.08), transparent 45%),
        radial-gradient(circle at 85% 100%, rgba(56, 189, 248, 0.06), transparent 45%),
        var(--bg-base);
    color: var(--text-bright);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

header {
    background:
        linear-gradient(135deg, rgba(23, 38, 56, 0.95), rgba(30, 52, 72, 0.95));
    backdrop-filter: blur(10px);
    border: 1px solid var(--line-strong);
    box-shadow: 0 10px 32px rgba(0, 0, 0, 0.35);
}

header h1 {
    font-weight: 800;
    letter-spacing: 2px;
    background: linear-gradient(90deg, #4ade80, #22d3ee);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

header p {
    color: var(--text-muted);
    letter-spacing: 0.6px;
}

#connection-status {
    box-shadow:
        0 0 0 1px rgba(34, 197, 94, 0.2),
        0 4px 14px rgba(34, 197, 94, 0.15);
    letter-spacing: 1px;
}

#last-update {
    letter-spacing: 0.7px;
}

/* Battery */

.battery {
    background:
        linear-gradient(135deg, rgba(22, 101, 52, 0.35), rgba(20, 83, 45, 0.15)),
        var(--bg-elevated);
    border: 1px solid rgba(34, 197, 94, 0.35);
    box-shadow:
        0 12px 40px rgba(0, 0, 0, 0.35),
        inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

.battery h2 {
    letter-spacing: 3px;
    font-weight: 700;
}

/* Group titles */

.group-title {
    font-weight: 700;
    letter-spacing: 2.5px;
    color: var(--accent);
}

/* Cards */

.card {
    background:
        linear-gradient(180deg, rgba(23, 37, 54, 0.85), rgba(15, 26, 43, 0.85));
    border: 1px solid var(--line-soft);
    box-shadow:
        0 6px 24px rgba(0, 0, 0, 0.28),
        inset 0 1px 0 rgba(255, 255, 255, 0.03);
    transition: transform 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}

.card:hover {
    transform: translateY(-2px);
    border-color: rgba(74, 222, 128, 0.5);
    box-shadow:
        0 12px 32px rgba(0, 0, 0, 0.4),
        0 0 0 1px rgba(74, 222, 128, 0.15),
        inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

.card h3 {
    font-weight: 600;
    letter-spacing: 1.4px;
}

/* History */

.history {
    background:
        linear-gradient(180deg, rgba(23, 37, 54, 0.85), rgba(15, 26, 43, 0.85));
    border: 1px solid var(--line-soft);
    box-shadow:
        0 12px 36px rgba(0, 0, 0, 0.3),
        inset 0 1px 0 rgba(255, 255, 255, 0.03);
}

.history h2 {
    font-weight: 700;
    letter-spacing: 1.5px;
}

/* Buttons */

.range-btn {
    font-weight: 700;
    letter-spacing: 1px;
    transition: transform 0.15s ease, all 0.2s ease;
}

.range-btn:hover {
    transform: translateY(-1px);
}

.range-btn.active {
    box-shadow:
        0 0 0 1px rgba(34, 197, 94, 0.4),
        0 6px 18px rgba(34, 197, 94, 0.25);
}

/* Chart headings */

.chart-wrap h3 {
    font-weight: 600;
    letter-spacing: 1.4px;
}

/* Footer */

footer {
    letter-spacing: 1px;
}

/* Reduced motion */

@media (prefers-reduced-motion: reduce) {
    .card, .range-btn {
        transition: none;
    }
    .card:hover, .range-btn:hover {
        transform: none;
    }
}

/* ============ TAHAP 8: SKEMA ALIRAN ============ */

.flow {
    background: linear-gradient(180deg, rgba(23,37,54,0.85), rgba(15,26,43,0.85));
    border: 1px solid var(--line-soft);
    box-shadow: 0 12px 36px rgba(0,0,0,0.3);
    padding: 25px;
    border-radius: 14px;
    margin-top: 22px;
}

.flow h2 {
    font-size: 18px;
    margin-bottom: 12px;
    color: #e2e8f0;
    font-weight: 700;
    letter-spacing: 1.5px;
}

.flow-container {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
    padding: 14px 0 6px;
}

.flow-node {
    flex: 0 0 auto;
    text-align: center;
    background: rgba(15,26,43,0.7);
    border: 1px solid rgba(148,163,184,0.15);
    border-radius: 12px;
    padding: 14px 16px;
    min-width: 105px;
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
}

.flow-node.active {
    border-color: rgba(74,222,128,0.6);
    box-shadow: 0 0 0 1px rgba(74,222,128,0.2), 0 6px 20px rgba(74,222,128,0.15);
}

.node-icon { font-size: 26px; margin-bottom: 4px; line-height: 1; }
.node-label {
    font-size: 10px;
    letter-spacing: 1.5px;
    color: var(--text-muted);
    font-weight: 600;
}
.node-value {
    font-size: 18px;
    font-weight: 700;
    margin-top: 4px;
    font-variant-numeric: tabular-nums;
    color: #f8fafc;
}
.node-state {
    font-size: 10px;
    margin-top: 3px;
    color: var(--text-muted);
    letter-spacing: 0.6px;
}

.flow-arrow {
    flex: 1 1 auto;
    min-width: 40px;
    height: 20px;
    opacity: 0.25;
    transition: opacity 0.3s ease;
}

.flow-arrow svg { width: 100%; height: 100%; overflow: visible; }

.flow-line, .flow-head {
    stroke: rgba(148,163,184,0.5);
    fill: rgba(148,163,184,0.5);
}

.flow-arrow.active { opacity: 1; }

.flow-arrow.active .flow-line {
    stroke: #4ade80;
    animation: flow-dash 0.9s linear infinite;
}

.flow-arrow.active .flow-head {
    stroke: #4ade80;
    fill: #4ade80;
}

.flow-arrow.active.load-flow .flow-line { stroke: #f97316; }
.flow-arrow.active.load-flow .flow-head { stroke: #f97316; fill: #f97316; }

@keyframes flow-dash { to { stroke-dashoffset: -24; } }

.flow-status {
    text-align: center;
    font-size: 13px;
    color: var(--text-muted);
    padding-top: 12px;
    letter-spacing: 0.4px;
    min-height: 20px;
}

.flow-status.charging    { color: #4ade80; }
.flow-status.discharging { color: #f97316; }

@media (max-width: 600px) {
    .flow-container {
        flex-wrap: wrap;
        justify-content: center;
        gap: 8px;
    }
    .flow-arrow { min-width: 34px; max-width: 60px; flex: 0 1 auto; }
    .flow-node { min-width: 88px; padding: 10px 10px; }
    .node-icon { font-size: 22px; }
    .node-value { font-size: 15px; }
    .flow-status { font-size: 12px; padding: 10px 4px 0; }
}

@media (prefers-reduced-motion: reduce) {
    .flow-arrow.active .flow-line { animation: none; }
}

/* ============ ALIRAN DAYA: MOBILE SYMMETRIC ============ */

.arrow-mobile { display: none; }

@media (max-width: 600px) {
    .flow-container {
        display: grid;
        grid-template-columns: 1fr 1fr;
        grid-template-areas:
            "pv load"
            "bat bat";
        gap: 65px 12px;
        padding: 24px 0 10px;
        position: relative;
        flex-wrap: nowrap;
        justify-content: initial;
    }

    .flow-node-pv   { grid-area: pv;   justify-self: start; }
    .flow-node-bat  { grid-area: bat;  justify-self: center; }
    .flow-node-load { grid-area: load; justify-self: end; }

    .flow-arrow {
        position: absolute;
        top: 0; left: 0;
        width: 100%; height: 100%;
        flex: none;
        min-width: 0;
        max-width: none;
        opacity: 0.55;
        pointer-events: none;
    }

    .flow-arrow.active { opacity: 1; }

    .arrow-desktop { display: none; }
    .arrow-mobile {
        display: block;
        width: 100%;
        height: 100%;
        overflow: visible;
    }
    .arrow-mobile .flow-line { fill: none; }

    .flow-node { min-width: 88px; padding: 10px 12px; }
    .node-icon { font-size: 22px; }
    .node-value { font-size: 15px; }
    .flow-status { font-size: 12px; padding: 10px 4px 0; }
}