/**
 * Sunsynk Frontend Dashboard CSS
 */
:root {
    --dash-bg: #0f172a;/* Slate 900 */
    --dash-card: #1e293b;/* Slate 800 */
    --dash-accent: #3b82f6;/* Blue 500 */
    --dash-pv: #f59e0b;/* Amber 500 */
    --dash-grid: #8b5cf6;/* Violet 500 */
    --dash-load: #ef4444;/* Red 500 */
    --dash-battery: #10b981;/* Emerald 500 */
    --dash-text: #f8fafc;/* Slate 50 */
    --dash-muted: #94a3b8;/* Slate 400 */
}

.sunsynk-dash-container {
    background: var(--dash-bg);
    color: var(--dash-text);
    padding: 30px;
    border-radius: 20px;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    max-width: 1000px;
    margin: 20px auto;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
}

/* Powerflow Viz */
.sunsynk-powerflow-card {
    background: rgba(255, 255, 255, 0.03);
    border-radius: 15px;
    padding: 20px;
    margin-bottom: 30px;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.sunsynk-powerflow-viz svg {
    width: 100%;
    height: auto;
    filter: drop-shadow(0 0 10px rgba(0,0,0,0.5));
}

.sunsynk-dash-timestamp {
    text-align: center;
    margin-top: 10px;
    font-size: 11px;
    color: var(--dash-muted);
    font-family: 'JetBrains Mono', monospace;
    letter-spacing: 0.05em;
    opacity: 0.8;
}

/* SVG Nodes */
.node-bg {
    fill: var(--dash-card);
    stroke: rgba(255, 255, 255, 0.1);
    stroke-width: 2;
    transition: all 0.3s ease;
}

.node-group:hover .node-bg {
    stroke: var(--dash-accent);
    filter: drop-shadow(0 0 8px var(--dash-accent));
}

.inv-node {
    fill: var(--dash-accent);
    fill-opacity: 0.1;
    stroke: var(--dash-accent);
    stroke-dasharray: 4;
    animation: rotate-border 20s linear indefinite;
}

.node-label {
    fill: var(--dash-muted);
    font-size: 14px;
    font-weight: 500;
    text-anchor: middle;
}

.node-value {
    fill: var(--dash-text);
    font-size: 18px;
    font-weight: 700;
    text-anchor: middle;
}

.node-sub-value {
    fill: var(--dash-muted);
    font-size: 12px;
    text-anchor: middle;
}

/* Flow Paths */
.flow-path {
    fill: none;
    stroke: rgba(255, 255, 255, 0.05);
    stroke-width: 4;
    stroke-linecap: round;
}

.flow-dot {
    fill: var(--dash-accent);
    filter: blur(1px) drop-shadow(0 0 5px var(--dash-accent));
    opacity: 0;/* Hidden by default, shown when flow > 0 */
}

/* Node Specific Colors */
#node-pv .node-bg { stroke: var(--dash-pv); }
#node-pv .node-value { fill: var(--dash-pv); }
#node-pv .flow-dot { fill: var(--dash-pv); }

#node-grid .node-bg { stroke: var(--dash-grid); }
#node-grid .node-value { fill: var(--dash-grid); }

#node-battery .node-bg { stroke: var(--dash-battery); }
#node-battery .node-value { fill: var(--dash-battery); }

#node-load .node-bg { stroke: var(--dash-load); }
#node-load .node-value { fill: var(--dash-load); }

/* Menu & Tabs */
.sunsynk-tabs {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    padding-bottom: 10px;
    overflow-x: auto;
}

.sunsynk-tab-btn {
    background: transparent;
    border: none;
    color: var(--dash-muted);
    padding: 10px 20px;
    cursor: pointer;
    font-weight: 600;
    border-radius: 8px;
    transition: all 0.2s;
    white-space: nowrap;
}

.sunsynk-tab-btn.active {
    background: var(--dash-accent);
    color: white;
}

.sunsynk-tab-btn:hover:not(.active) {
    background: rgba(255, 255, 255, 0.05);
    color: var(--dash-text);
}

.sunsynk-tab-content {
    display: none;
    animation: fade-in 0.3s ease;
}

.sunsynk-tab-content.active {
    display: block;
}

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
}

.stat-card {
    background: var(--dash-card);
    padding: 20px;
    border-radius: 12px;
    text-align: center;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.stat-card h5 {
    margin: 0 0 10px 0;
    color: var(--dash-muted);
    text-transform: uppercase;
    font-size: 11px;
    letter-spacing: 1px;
}

.stat-card span {
    font-size: 20px;
    font-weight: 700;
    color: var(--dash-accent);
}

/* Tables */
.sunsynk-data-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 10px;
}

.sunsynk-data-table th {
    text-align: left;
    padding: 12px;
    color: var(--dash-muted);
    font-size: 12px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.sunsynk-data-table td {
    padding: 12px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    font-size: 14px;
}

.sunsynk-data-table tr:hover {
    background: rgba(255, 255, 255, 0.02);
}

@keyframes fade-in {
    from { opacity: 0; transform: translateY(5px); }
    to { opacity: 1; transform: translateY(0); }
}

@media (max-width: 600px) {
    .sunsynk-dash-container { padding: 15px; }
    .node-label { font-size: 10px; }
    .node-value { font-size: 14px; }
}

/* Inverter UI Style for System Mode */
.sunsynk-inverter-ui-card {
    background: #fff;
    color: #333;
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
    margin-top: 10px;
}

.inv-ui-header {
    background: #eab308;/* Golden Yellow */
    color: white;
    padding: 10px 20px;
    font-size: 24px;
    font-weight: 600;
}

.inv-ui-tabs {
    background: #64748b;/* Slate 500 */
    display: flex;
    padding: 0 10px;
}

.inv-ui-tab {
    padding: 8px 20px;
    color: #e2e8f0;
    cursor: pointer;
}

.inv-ui-tab.active {
    background: #3b82f6;/* Blue 500 */
    color: white;
}

.inv-ui-table-wrapper {
    display: flex;
    padding: 20px;
    background: #f8fafc;
}

.inv-style-table {
    flex: 2;
    border-collapse: collapse;
}

.inv-style-table th {
    font-size: 14px;
    padding: 10px;
    color: #1e293b;
    text-align: center;
}

.inv-style-table td {
    border: 2px solid #ccc;
    padding: 10px;
    text-align: center;
    font-weight: 500;
    font-size: 18px;
    min-width: 80px;
}

/* Indicator Checks */
.check-indicator, .status-check {
    width: 20px;
    height: 20px;
    border: 1px solid #ccc;
    display: inline-block;
    border-radius: 4px;
    position: relative;
    vertical-align: middle;
}

.check-indicator.active::after, .status-check.active::after {
    content: '✔';
    color: #eab308;
    position: absolute;
    top: -4px;
    left: 2px;
    font-size: 18px;
}

.inv-ui-right-panel {
    flex: 1;
    padding-left: 20px;
    display: flex;
    flex-direction: column;
    gap: 15px;
    font-weight: 500;
}

.panel-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
}

.panel-item span { font-size: 12px; margin-bottom: 5px; }
