:root {
    --bg-color: #0f172a;
    --card-bg: rgba(30, 41, 59, 0.7);
    --border-color: rgba(255, 255, 255, 0.1);
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    
    --color-solar: #fbbf24;
    --color-grid-feed: #10b981;
    --color-grid-draw: #ef4444;
    --color-battery: #4ade80;
    --color-house: #3b82f6;

    --glass-bg: rgba(255, 255, 255, 0.1);
    --glass-border: rgba(255, 255, 255, 0.2);

    --status-ok: #10b981;     
    --status-wait: #ef4444;   
    --status-pending: #64748b; 
    --glass-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-primary);
    width: 100vw;
    min-height: 100vh;
    overflow-x: hidden;
    overflow-y: auto; 
    display: flex;
    flex-direction: column;
}

/* ==================
   Status Banner (Top)
   ================== */
.status-banner {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 25vh;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    padding: 1rem;
    transition: transform 0.6s cubic-bezier(0.16, 1, 0.3, 1), background-color 0.5s ease;
    box-shadow: 0 10px 30px rgba(0,0,0,0.5);
    z-index: 1000;
    cursor: pointer;
    overflow: hidden;
}

.status-banner.collapsed {
    transform: translateY(-100%);
}

.banner-toggle {
    position: fixed;
    top: 22vh; /* Bottom of banner */
    left: 50%;
    transform: translate(-50%, -350%); /* High enough into the banner to not clip during bounce */
    z-index: 1001;
    font-size: 0.8rem;
    padding: 2%;
    color: rgba(255, 255, 255, 0.4); 
    cursor: pointer;
    transition: all 0.6s cubic-bezier(0.16, 1, 0.3, 1);
    animation: bounce-subtle 3s infinite;
}

.status-banner.collapsed + #banner-toggle,
#banner-toggle.banner-collapsed {
    top: 20px; /* More distance from the top edge when collapsed */
    transform: translate(-50%, 0);
    color: var(--text-primary);
    opacity: 0.4;
}

@media (max-width: 768px) {
    .banner-toggle {
        top: 100vh;
        font-size: 1.2rem;
        transform: translate(-50%, -100%); /* Right at the bottom edge on mobile */
    }
}

@keyframes bounce-subtle {
    0%, 20%, 50%, 80%, 100% { transform: translate(-50%, -50%); }
    40% { transform: translate(-50%, calc(-50% + 5px)); }
    60% { transform: translate(-50%, calc(-50% + 3px)); }
}

.banner-main-icon { font-size: 3rem; margin-bottom: 0.5rem; filter: drop-shadow(0 4px 6px rgba(0,0,0,0.3)); }
.status-banner p { font-size: 1.2rem; opacity: 0.9; font-weight: 300; }
.time-display { position: absolute; top: 1rem; right: 2rem; font-size: 1.2rem; font-weight: 600; opacity: 0.8; }

.notif-btn {
    position: absolute;
    top: 1rem;
    left: 2rem;
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    color: white;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    transition: all 0.3s ease;
    backdrop-filter: blur(5px);
    z-index: 1002;
}

.notif-btn:hover { background: rgba(255, 255, 255, 0.2); transform: scale(1.1); }
.notif-btn.active { color: #fbbf24; border-color: #fbbf24; box-shadow: 0 0 10px rgba(251, 191, 36, 0.5); }

/* Main Dashboard Container - SQUARE on Desktop */
.dashboard-container {
    width: 100%;
    height: 75vh;
    margin-top: 25vh; /* Push down by banner height */
    position: relative;
    overflow: visible;
    transition: transform 0.6s cubic-bezier(0.16, 1, 0.3, 1), margin-top 0.6s cubic-bezier(0.16, 1, 0.3, 1), height 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}

.status-banner.collapsed ~ .dashboard-container {
    margin-top: 0;
    height: 100vh;
}

@media (min-width: 769px) {
    .dashboard-container {
        width: 100%;
        max-width: 800px; /* Slightly smaller for tighter grouping */
        aspect-ratio: 1 / 1;
        margin-left: auto;
        margin-right: auto;
    }
}
.banner-wait { background: linear-gradient(135deg, #7f1d1d 0%, #dc2626 100%); color: white; }
.banner-ok { background: linear-gradient(135deg, #064e3b 0%, #10b981 100%); color: white; }

/* ==================
   Main Content Area
   ================== */
.dashboard-container {
    width: 100%;
    height: 75vh;
    flex-grow: 1;
    display: flex;
}

.fullscreen-flow {
    width: 100%;
    height: 100%;
    position: relative;
    overflow: hidden;
}

.flow-container {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    width: 100%; height: 100%;
    /* Create a grid/radial background glow effect */
    background: radial-gradient(circle at center, rgba(30, 41, 59, 0.4) 0%, transparent 70%);
}

/* ==================
   Flow Nodes 
   ================== */
.node {
    position: absolute;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: var(--card-bg);
    border: 2px solid var(--border-color);
    border-radius: 50%;
    box-shadow: 0 4px 15px rgba(0,0,0,0.5);
    z-index: 10;
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

.node .label {
    position: absolute;
    bottom: -25px;
    font-size: 0.9rem;
    color: var(--text-secondary);
    white-space: nowrap;
    text-shadow: 0 2px 4px rgba(0,0,0,0.8);
}

/* MAIN NODES */
.side-node { width: 100px; height: 100px; }
.side-node i { font-size: 2rem; margin-bottom: 5px; }
.side-node .value { font-size: 1rem; font-weight: 700; white-space: nowrap; }

.house-node {
    width: 140px; height: 140px;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    border-color: var(--color-house);
    background: rgba(59, 130, 246, 0.15);
}
.house-node i { color: var(--color-house); font-size: 2.8rem; margin-bottom: 5px; }
.house-node .value { font-size: 1.2rem; font-weight: 700; }

.pulse-ring {
    position: absolute; top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    width: 100%; height: 100%;
    border-radius: 50%;
    border: 2px solid var(--color-house);
    animation: pulse 3s infinite cubic-bezier(0.215, 0.61, 0.355, 1);
    z-index: -1;
}

@keyframes pulse {
    0% { transform: translate(-50%, -50%) scale(0.95); opacity: 0.8; }
    100% { transform: translate(-50%, -50%) scale(1.6); opacity: 0; }
}

/* Base Position of Main Nodes */
.top-node     { top: 5%; left: 50%; transform: translateX(-50%); border-color: var(--color-solar); }
.top-node i   { color: var(--color-solar); }
.left-node    { top: 50%; left: 5%; transform: translateY(-50%); border-color: var(--text-secondary); transition: border-color 0.5s; }
.left-node i  { color: var(--text-secondary); }
.left-node.drawing { border-color: var(--color-grid-draw); }
.left-node.drawing i { color: var(--color-grid-draw); }
.left-node.feeding { border-color: var(--color-grid-feed); }
.left-node.feeding i { color: var(--color-grid-feed); }
.right-node   { top: 50%; right: 5%; transform: translateY(-50%); border-color: var(--color-battery); }
.right-node i { color: var(--color-battery); }
.node .percent { position: absolute; top: -20px; font-size: 0.85rem; color: var(--color-battery); font-weight: 600; }

/* Balkonkraftwerk as Producer closer to PV */
.bottom-node { top: 20%; right: 25%; transform: translate(50%, -50%); border-color: var(--color-solar); }
.bottom-node i { color: var(--color-solar); }
.bottom-node .producer-power { color: var(--color-solar); }

/* SVG Dynamic Scaling */
.node.scale-up { transform: translate(-50%, -50%) scale(1.15); } 
.top-node.scale-up { transform: translateX(-50%) scale(1.15); }
.bottom-node.scale-up { transform: translate(50%, -50%) scale(1.15); }
.left-node.scale-up, .right-node.scale-up { transform: translateY(-50%) scale(1.15); }

/* ==================
   SATELLITE APPLIANCES (Consumers)
   ================== */
/* Position set via JS dynamically or base CSS but we use absolute offsets around the center based on radius */
.satellite-node {
    width: 80px; height: 80px;
    border-color: rgba(100, 116, 139, 0.3);
    /* By default centered, JS will adjust translation based on angle */
    top: 50%; left: 50%;
    transform: translate(-50%, -50%); /* Base */
    transition: background 0.5s ease, border-color 0.5s ease, box-shadow 0.3s ease;
}

.satellite-node i { font-size: 1.5rem; margin-bottom: 2px; transition: color 0.5s ease, filter 0.5s ease; color: var(--text-primary); }
.satellite-node .value { font-size: 0.8rem; font-weight: 600; color: var(--text-secondary); white-space: nowrap; }
.satellite-node .estimate { font-size: 0.7rem; font-weight: 400; }

.satellite-node.wait i { color: var(--status-wait); }

@keyframes pulse-green {
    0% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7); }
    70% { box-shadow: 0 0 0 10px rgba(16, 185, 129, 0); }
    100% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}

/* ==================
   SVG Flow Lines & Dynamic Dots
   ================== */
.flow-lines {
    position: absolute; top: 0; left: 0;
    pointer-events: none; z-index: 5;
}

.base-line { stroke: var(--border-color); stroke-width: 2; stroke-dasharray: 4 4; opacity: 0.5; }
.flow-dot { fill: #fff; filter: url(#glow); transition: r 0.5s ease; }
.dot-pv { fill: var(--color-solar); }
.dot-grid { fill: var(--color-grid-draw); }
.dot-grid.feeding { fill: var(--color-grid-feed); }
.dot-battery { fill: var(--color-battery); }
.dot-satellite { fill: var(--color-house); }
.dot-balkon { fill: var(--color-solar); }
.hidden { display: none; }


/* ==================
   Responsive Adjustments
   ================== */
@media (max-width: 768px) {
    /* Fullscreen Status Banner on Mobile Defaults */
    .status-banner { 
        height: 100vh; 
        padding: 1rem; 
        justify-content: center;
    }
    .banner-toggle {
        top: 50vh;
    }
    .status-banner.collapsed {
        height: 0;
    }
    .status-banner h1 { font-size: 2.2rem; white-space: normal; }
    .status-banner i.banner-main-icon { font-size: 4rem; }
    
    .dashboard-container { 
        height: auto;
        aspect-ratio: 1 / 1.1; /* Slightly taller for mobile labels */
        width: 100%;
        margin-top: 100vh;
        display: block; /* Ensure it stays in flow */
    }
    .status-banner.collapsed ~ .dashboard-container {
        margin-top: 0;
    }
    
    .side-node, .bottom-node { width: 80px; height: 80px; }
    .side-node i, .bottom-node i { font-size: 1.5rem; }
    .side-node .value, .bottom-node .value { font-size: 0.85rem; }
    
    .house-node { width: 110px; height: 110px; }
    .house-node i { font-size: 2rem; }
    .house-node .value { font-size: 1.1rem; }

    /* Symmetrical and centered vertical distribution on mobile */
    .top-node     { top: 27% !important; } /* Center (50%) - 23% gap */
    .bottom-node  { top: 25%; right: 18%; } /* Follows PV area */
    .left-node    { left: 3%; top: 50%; transform: translateY(-50%); } 
    .right-node   { right: 3%; top: 50%; transform: translateY(-50%); } 
    .house-node   { top: 50% !important; transform: translate(-50%, -50%) !important; } 
    .node.side-node { width: 75px; height: 75px; } 
    .node.house-node { width: 105px; height: 105px; }

    .node.scale-up { transform: translate(-50%, -50%) scale(1.1); }
    .top-node.scale-up { transform: translateX(-50%) scale(1.1); }
    .bottom-node.scale-up { transform: translate(50%, -50%) scale(1.1); }
    .left-node.scale-up, .right-node.scale-up { transform: translateY(-50%) scale(1.1); }

    .satellite-node { width: 70px; height: 70px; }
    .satellite-node i { font-size: 1.2rem; }
    .satellite-node .value { font-size: 0.75rem; }
    .satellite-node .label { font-size: 0.8rem; bottom: -20px; }
}
