/* ========================================
   Stromfluss — iSolarCloud Style Exact
   Solar top, House center, Battery bottom-left, Grid bottom-right
   Right-angle lines, clean minimal design
   ======================================== */

.modal-flow { max-width: 720px; }

.flow-container {
    position: relative;
    width: 100%;
    height: 420px;
    margin-bottom: 20px;
    background: var(--bg);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    overflow: hidden;
}

/* ========= SVG Lines ========= */
.flow-svg {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
}

.flow-line-path {
    fill: none;
    stroke: #d0d6de;
    stroke-width: 3;
    stroke-linecap: round;
    stroke-linejoin: round;
    transition: stroke 0.4s;
}
[data-theme="dark"] .flow-line-path { stroke: #252830; }

.flow-line-path.active { stroke: #b8d4ee; stroke-width: 3; }
[data-theme="dark"] .flow-line-path.active { stroke: #2a4a66; }

/* Animated dashed flow overlay — this creates the "moving energy" effect */
.flow-anim-path {
    fill: none;
    stroke-width: 3;
    stroke-linecap: round;
    stroke-linejoin: round;
    stroke-dasharray: 8 16;
    opacity: 0;
    transition: opacity 0.4s;
}
.flow-anim-path.active {
    opacity: 1;
    animation: flowDash 1s linear infinite;
}
.flow-anim-path.reverse.active {
    animation: flowDashReverse 1s linear infinite;
}
@keyframes flowDash {
    to { stroke-dashoffset: -24; }
}
@keyframes flowDashReverse {
    to { stroke-dashoffset: 24; }
}

.flow-anim-solar { stroke: var(--accent); }
.flow-anim-batt { stroke: var(--green); }
.flow-anim-grid-out { stroke: var(--blue); }
.flow-anim-grid-in { stroke: var(--red); }



/* ========= Nodes ========= */
.fn2 {
    position: absolute;
    display: flex;
    flex-direction: column;
    align-items: center;
    z-index: 2;
}

/* Isometric-style icon containers */
.fn2-icon {
    width: 80px;
    height: 80px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 3rem;
    position: relative;
}

/* Solar panel — top center */
.fn2-solar { top: 12px; left: 50%; transform: translateX(-50%); }

/* House — center */
.fn2-house { top: 50%; left: 50%; transform: translate(-50%, -50%); }
.fn2-house .fn2-icon { width: 100px; height: 100px; font-size: 3.5rem; }

/* Battery — bottom left */
.fn2-batt { bottom: 16px; left: 14%; }

/* Grid — bottom right */
.fn2-grid { bottom: 16px; right: 14%; }

/* Power values */
.fn2-val {
    font-family: var(--font-mono);
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text);
    margin-top: 2px;
    white-space: nowrap;
}

.fn2-solar .fn2-val { position: absolute; right: -90px; top: 30px; }
.fn2-batt .fn2-val { margin-top: 4px; }
.fn2-grid .fn2-val { margin-top: 4px; }
.fn2-house .fn2-val { position: absolute; right: -80px; top: 35px; }

/* Battery percentage indicator */
.fn2-batt-wrap {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 4px;
}
.fn2-batt-icon {
    width: 20px;
    height: 32px;
    border: 2px solid #c0c8d4;
    border-radius: 3px;
    position: relative;
    background: var(--bg-card);
    overflow: hidden;
}
[data-theme="dark"] .fn2-batt-icon { border-color: #3a3e48; }

.fn2-batt-icon::before {
    content: '';
    position: absolute;
    top: -4px;
    left: 50%;
    transform: translateX(-50%);
    width: 10px;
    height: 3px;
    background: #c0c8d4;
    border-radius: 1px 1px 0 0;
}
[data-theme="dark"] .fn2-batt-icon::before { background: #3a3e48; }

.fn2-batt-level {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: #6eaadc;
    transition: height 1s;
}

.fn2-batt-pct {
    font-family: var(--font-mono);
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-muted);
}

/* Line value labels */
.fn2-line-val {
    position: absolute;
    font-family: var(--font-mono);
    font-size: 0.82rem;
    font-weight: 500;
    color: var(--text-muted);
    z-index: 3;
    white-space: nowrap;
}

/* Positions for line labels */
.flv-house-batt { bottom: 48%; left: 32%; }
.flv-house-grid { bottom: 48%; right: 28%; display: none; }

/* ========= Summary Stats (below flow) ========= */
.flow-stats {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
}
.flow-stat-item {
    text-align: center;
    padding: 12px 8px;
    background: var(--bg);
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
}
.flow-stat-label {
    display: block;
    font-size: 0.62rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.3px;
    margin-bottom: 3px;
    font-weight: 500;
}
.flow-stat-val {
    display: block;
    font-family: var(--font-mono);
    font-size: 0.95rem;
    font-weight: 600;
}

/* ========= Responsive ========= */
@media (max-width: 600px) {
    .flow-container { height: 350px; }
    .fn2-icon { width: 60px; height: 60px; font-size: 2.2rem; }
    .fn2-house .fn2-icon { width: 76px; height: 76px; font-size: 2.8rem; }
    .fn2-val { font-size: 1.1rem; }
    .fn2-solar .fn2-val { right: -70px; }
    .fn2-house .fn2-val { right: -65px; }
    .flow-stats { grid-template-columns: repeat(2, 1fr); }
}
