/* Sienergy Solar View - Premium Public Theme 2.0 */

:root {
    /* Palette: Eco-Tech Premium */
    --ssv-primary: #059669;       /* Emerald 600 */
    --ssv-primary-hover: #047857; /* Emerald 700 */
    --ssv-primary-light: #d1fae5; /* Emerald 100 */
    
    --ssv-secondary: #3b82f6;     /* Blue 500 */
    --ssv-secondary-hover: #2563eb; /* Blue 600 */
    --ssv-secondary-light: #eff6ff; /* Blue 50 */
    
    --ssv-accent: #f59e0b;        /* Amber 500 */
    --ssv-danger: #ef4444;        /* Red 500 */
    --ssv-danger-light: #fee2e2;  /* Red 100 */
    --ssv-success: #10b981;       /* Emerald 500 */
    
    /* Neutral / Surface */
    --ssv-bg: #f3f4f6;            /* Cool Gray 100 */
    --ssv-surface: #ffffff;
    --ssv-surface-hover: #f9fafb;
    
    /* Typography */
    --ssv-text-main: #111827;     /* Gray 900 */
    --ssv-text-secondary: #4b5563; /* Gray 600 */
    --ssv-text-muted: #9ca3af;    /* Gray 400 */
    
    /* Borders & Dividers */
    --ssv-border: #e5e7eb;        /* Gray 200 */
    --ssv-border-focus: #059669;
    
    /* Effects */
    --ssv-shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --ssv-shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --ssv-shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --ssv-radius: 16px; /* Slightly larger for public UI */
    --ssv-radius-sm: 8px;
    --ssv-transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    
    /* Font Stack */
    --ssv-font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

.ssv-dashboard-wrapper {
    font-family: var(--ssv-font-family);
    width: 100%;
    margin: 0 auto;
    background: var(--ssv-bg);
    border-radius: var(--ssv-radius);
    overflow: hidden;
    box-shadow: var(--ssv-shadow-lg);
    color: var(--ssv-text-main);
    position: relative;
    border: 1px solid var(--ssv-border);
}

/* --- Header --- */
.ssv-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 30px;
    background: var(--ssv-surface);
    border-bottom: 1px solid var(--ssv-border);
    flex-wrap: wrap;
    gap: 15px;
    position: relative;
    z-index: 100;
}

.ssv-header-left, .ssv-header-right {
    display: flex;
    align-items: center;
    gap: 20px;
}

.ssv-inverter-selector-wrapper {
    display: flex;
    align-items: center;
    gap: 12px;
}

.header-icon {
    font-size: 24px;
    color: var(--ssv-primary);
    background: var(--ssv-primary-light);
    padding: 8px;
    border-radius: 10px;
    width: auto;
    height: auto;
}

.ssv-inverter-select {
    padding: 10px 16px;
    border-radius: var(--ssv-radius-sm);
    border: 1px solid var(--ssv-border);
    font-size: 1.1em;
    font-weight: 600;
    color: var(--ssv-text-main);
    background: var(--ssv-surface);
    cursor: pointer;
    outline: none;
    transition: var(--ssv-transition);
}

.ssv-inverter-select:hover, .ssv-inverter-select:focus {
    border-color: var(--ssv-primary);
    box-shadow: 0 0 0 3px var(--ssv-primary-light);
}

.ssv-inverter-title {
    font-size: 1.5em;
    font-weight: 800;
    color: var(--ssv-text-main);
    letter-spacing: -0.02em;
}

/* Weather Widget */
.ssv-weather-widget {
    position: relative;
    cursor: pointer;
    background: var(--ssv-secondary-light);
    border-radius: 24px;
    color: var(--ssv-secondary);
    transition: var(--ssv-transition);
    border: 1px solid transparent;
}

.ssv-weather-widget:hover {
    background: #fff;
    border-color: var(--ssv-secondary-light);
    box-shadow: var(--ssv-shadow-sm);
}

.ssv-weather-current {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 16px;
    font-weight: 600;
}

.ssv-weather-forecast-dropdown {
    display: none;
    position: absolute;
    top: calc(100% + 10px);
    right: 0;
    width: 260px;
    background: var(--ssv-surface);
    border-radius: var(--ssv-radius);
    padding: 16px;
    box-shadow: var(--ssv-shadow-lg);
    border: 1px solid var(--ssv-border);
    z-index: 200;
}

.ssv-weather-widget:hover .ssv-weather-forecast-dropdown {
    display: block;
    animation: fadeIn 0.2s ease-out;
}

.ssv-weather-forecast-dropdown h4 {
    margin: 0 0 12px 0;
    font-size: 14px;
    color: var(--ssv-text-secondary);
    border-bottom: 1px solid var(--ssv-border);
    padding-bottom: 8px;
}

.ssv-forecast-grid {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.ssv-forecast-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 14px;
    color: var(--ssv-text-main);
}

/* Language Switcher */
.ssv-lang-switcher {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 600;
    font-size: 14px;
}

.ssv-lang-switcher a {
    color: var(--ssv-text-muted);
    text-decoration: none;
    transition: var(--ssv-transition);
}

.ssv-lang-switcher a.active {
    color: var(--ssv-primary);
}

.ssv-lang-switcher .sep {
    color: var(--ssv-border);
}

/* --- Tabs --- */
.ssv-tabs {
    display: flex;
    background: var(--ssv-surface);
    padding: 0 30px;
    border-bottom: 1px solid var(--ssv-border);
    gap: 30px;
}

.ssv-tab-btn {
    background: none;
    border: none;
    padding: 20px 0;
    font-size: 16px;
    font-weight: 600;
    color: var(--ssv-text-secondary);
    cursor: pointer;
    transition: var(--ssv-transition);
    position: relative;
    display: flex;
    align-items: center;
    gap: 8px;
}

.ssv-tab-btn:hover {
    color: var(--ssv-primary);
}

.ssv-tab-btn.active {
    color: var(--ssv-primary);
}

.ssv-tab-btn.active::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 3px;
    background: var(--ssv-primary);
    border-radius: 3px 3px 0 0;
}

.ssv-tab-content {
    display: none;
    padding: 30px;
    animation: fadeIn 0.3s ease-out;
}

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

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

/* --- Visual Container (Energy Flow) --- */
.ssv-visual-container {
    position: relative;
    width: 100%;
    padding-bottom: 56.25%; /* 16:9 Aspect Ratio */
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    border-radius: var(--ssv-radius);
    overflow: hidden;
    box-shadow: inset 0 0 100px rgba(0,0,0,0.2);
    background-color: #1e293b; /* Fallback dark blue */
}

/* Edit Button */
.ssv-edit-bg-btn {
    position: absolute;
    top: 20px;
    right: 20px;
    background: rgba(255, 255, 255, 0.2);
    backdrop-filter: blur(8px);
    border: 1px solid rgba(255,255,255,0.3);
    border-radius: 50%;
    width: 40px;
    height: 40px;
    cursor: pointer;
    color: white;
    transition: var(--ssv-transition);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 20;
}

.ssv-edit-bg-btn:hover {
    background: rgba(255, 255, 255, 0.4);
    transform: scale(1.05);
}

/* Energy Grid Layout */
.ssv-energy-grid {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: grid;
    grid-template-columns: 1fr 1.5fr 1fr;
    grid-template-rows: 1fr 1.5fr 1fr;
    z-index: 10;
    padding: 20px;
    box-sizing: border-box;
}

/* Energy Nodes */
.ssv-energy-node {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    position: relative;
}

.node-pv { grid-area: 1 / 1 / 2 / 2; align-self: start; justify-self: start; margin: 20px; }
.node-grid { grid-area: 1 / 3 / 2 / 4; align-self: start; justify-self: end; margin: 20px; }
.node-home { grid-area: 2 / 2 / 3 / 3; align-self: center; justify-self: center; }
.node-battery { grid-area: 3 / 1 / 4 / 2; align-self: end; justify-self: start; margin: 20px; }
.node-kpi { grid-area: 3 / 3 / 4 / 4; align-self: end; justify-self: end; margin: 20px; }

/* Node Styling */
.node-icon {
    width: 60px;
    height: 60px;
    background: rgba(255, 255, 255, 0.15);
    backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
    color: white;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
    margin-bottom: 8px;
    transition: var(--ssv-transition);
}

.node-home .node-icon.main {
    width: 90px;
    height: 90px;
    font-size: 40px;
    background: rgba(255, 255, 255, 0.25);
    border: 2px solid rgba(255, 255, 255, 0.5);
}

.node-data {
    text-align: center;
    color: white;
    text-shadow: 0 2px 4px rgba(0,0,0,0.5);
}

.node-data .val {
    font-size: 24px;
    font-weight: 800;
    line-height: 1;
}

.node-data .unit {
    font-size: 12px;
    font-weight: 500;
    opacity: 0.9;
}

.node-data .sub-label {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    opacity: 0.8;
    margin-top: 4px;
    background: rgba(0,0,0,0.3);
    padding: 2px 8px;
    border-radius: 10px;
}

/* Specific Colors */
.node-pv .node-icon { color: #fbbf24; }
.node-grid .node-icon { color: #60a5fa; }
.node-battery .node-icon { color: #34d399; }
.node-home .node-icon { color: #f8fafc; }

/* KPI Styling */
.node-kpi {
    background: rgba(0,0,0,0.4);
    backdrop-filter: blur(8px);
    border-radius: 12px;
    padding: 10px 15px;
    border: 1px solid rgba(255,255,255,0.1);
    align-items: stretch;
    gap: 8px;
}

.kpi-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 15px;
    font-size: 13px;
    color: white;
}

.kpi-val { font-weight: 700; color: var(--ssv-primary-light); }

/* SVG Flow Layer */
.ssv-flow-svg {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1;
}

.flow-dot {
    filter: drop-shadow(0 0 5px rgba(255,255,255,0.5));
}

/* --- Statistics Section --- */
.ssv-stats-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
}

.ssv-btn-group {
    display: flex;
    background: var(--ssv-bg);
    padding: 4px;
    border-radius: var(--ssv-radius-sm);
}

.ssv-btn {
    padding: 8px 16px;
    border: none;
    background: transparent;
    color: var(--ssv-text-secondary);
    font-weight: 600;
    cursor: pointer;
    border-radius: 6px;
    transition: var(--ssv-transition);
}

.ssv-btn.active {
    background: var(--ssv-surface);
    color: var(--ssv-primary);
    box-shadow: var(--ssv-shadow-sm);
}

.ssv-chart-container {
    background: var(--ssv-surface);
    padding: 24px;
    border-radius: var(--ssv-radius);
    box-shadow: var(--ssv-shadow-sm);
    border: 1px solid var(--ssv-border);
    height: 400px;
    margin-bottom: 30px;
}

.ssv-metrics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
}

.ssv-metric-card {
    background: var(--ssv-surface);
    padding: 20px;
    border-radius: var(--ssv-radius);
    border: 1px solid var(--ssv-border);
    text-align: center;
}

.ssv-metric-card h4 {
    margin: 0 0 10px 0;
    color: var(--ssv-text-secondary);
    font-size: 14px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.ssv-metric-value {
    font-size: 28px;
    font-weight: 800;
    color: var(--ssv-text-main);
    margin-bottom: 4px;
}

.ssv-metric-sub {
    font-size: 12px;
    color: var(--ssv-text-muted);
}

/* --- Settings Section --- */
.ssv-settings-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 24px;
}

.ssv-settings-card {
    background: var(--ssv-surface);
    padding: 24px;
    border-radius: var(--ssv-radius);
    border: 1px solid var(--ssv-border);
    box-shadow: var(--ssv-shadow-sm);
}

.ssv-settings-card h3 {
    margin-top: 0;
    color: var(--ssv-text-main);
    font-size: 18px;
    border-bottom: 1px solid var(--ssv-border);
    padding-bottom: 15px;
    margin-bottom: 20px;
}

/* --- Modal --- */
.ssv-modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.6);
    backdrop-filter: blur(4px);
    align-items: center;
    justify-content: center;
}

.ssv-modal.active {
    display: flex;
    animation: fadeIn 0.2s ease-out;
}

.ssv-modal-content {
    background-color: var(--ssv-surface);
    padding: 30px;
    border-radius: var(--ssv-radius);
    width: 90%;
    max-width: 500px;
    box-shadow: var(--ssv-shadow-lg);
    position: relative;
}

.ssv-close-modal {
    position: absolute;
    top: 20px;
    right: 20px;
    font-size: 24px;
    cursor: pointer;
    color: var(--ssv-text-muted);
}

.ssv-close-modal:hover {
    color: var(--ssv-danger);
}

/* Responsive */
@media (max-width: 768px) {
    .ssv-header {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .ssv-header-right {
        width: 100%;
        justify-content: space-between;
    }

    .ssv-tabs {
        padding: 0 15px;
        gap: 15px;
        overflow-x: auto;
    }

    .ssv-tab-btn {
        padding: 15px 0;
        white-space: nowrap;
    }

    .ssv-visual-container {
        padding-bottom: 100%; /* More height on mobile */
    }

    .ssv-node-circle {
        width: 70px;
        height: 70px;
    }

    .ssv-node-value { font-size: 16px; }
    .ssv-node-unit { font-size: 10px; }
}

/* --- Battery Detailed Stats Panel --- */
.ssv-battery-stats-panel {
    background: var(--ssv-surface);
    border-radius: var(--ssv-radius);
    padding: 25px;
    box-shadow: var(--ssv-shadow-md);
    border: 1px solid var(--ssv-border);
    margin-bottom: 30px;
}

.ssv-panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 25px;
    border-bottom: 1px solid var(--ssv-border);
    padding-bottom: 15px;
    flex-wrap: wrap;
    gap: 15px;
}

.ssv-panel-header h3 {
    margin: 0;
    font-size: 18px;
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--ssv-text-main);
}

.ssv-bat-live-status {
    display: flex;
    align-items: center;
    gap: 12px;
}

.status-badge {
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
}

.status-badge.charging { background: var(--ssv-primary-light); color: var(--ssv-primary); }
.status-badge.discharging { background: var(--ssv-danger-light); color: var(--ssv-danger); }
.status-badge.idle { background: var(--ssv-bg); color: var(--ssv-text-muted); }

.time-est {
    font-size: 13px;
    color: var(--ssv-text-secondary);
    font-weight: 600;
}

/* Battery Dashboard Grid */
.ssv-bat-dashboard-grid {
    display: grid;
    grid-template-columns: 300px 1fr;
    gap: 30px;
}

/* Visual Card (Left) */
.ssv-bat-visual-card {
    background: var(--ssv-bg);
    border-radius: var(--ssv-radius);
    padding: 30px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    position: relative;
}

.battery-big-level {
    width: 100px;
    height: 180px;
    border: 4px solid var(--ssv-text-secondary);
    border-radius: 12px;
    position: relative;
    padding: 4px;
    margin-bottom: 20px;
}

.battery-big-level::before {
    content: '';
    position: absolute;
    top: -10px;
    left: 50%;
    transform: translateX(-50%);
    width: 40px;
    height: 10px;
    background: var(--ssv-text-secondary);
    border-radius: 4px 4px 0 0;
}

.level-fill {
    background: linear-gradient(to top, var(--ssv-primary), #34d399);
    width: 100%;
    border-radius: 6px;
    position: absolute;
    bottom: 4px;
    left: 4px;
    width: calc(100% - 8px);
    transition: height 0.5s ease;
}

.level-text {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 32px;
    font-weight: 800;
    color: white;
    text-shadow: 0 2px 4px rgba(0,0,0,0.3);
    z-index: 2;
}

.bat-power-display {
    font-size: 24px;
    font-weight: 700;
    color: var(--ssv-text-main);
}

/* Metrics Grid (Right) */
.ssv-bat-metrics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 20px;
}

.metric-card {
    background: var(--ssv-surface);
    border: 1px solid var(--ssv-border);
    border-radius: var(--ssv-radius);
    padding: 20px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    position: relative;
    transition: var(--ssv-transition);
}

.metric-card:hover {
    border-color: var(--ssv-primary);
    transform: translateY(-2px);
    box-shadow: var(--ssv-shadow-sm);
}

.metric-card .m-label {
    font-size: 13px;
    color: var(--ssv-text-muted);
    font-weight: 600;
    text-transform: uppercase;
    margin-bottom: 10px;
}

.metric-card .m-val {
    font-size: 24px;
    font-weight: 700;
    color: var(--ssv-text-main);
}

.metric-card .m-icon {
    position: absolute;
    bottom: 20px;
    right: 20px;
    font-size: 24px;
    color: var(--ssv-primary-light); /* Subtle icon color */
    opacity: 0.5;
}

/* Responsive Battery */
@media (max-width: 900px) {
    .ssv-bat-dashboard-grid {
        grid-template-columns: 1fr;
    }
    
    .ssv-bat-visual-card {
        flex-direction: row;
        gap: 30px;
        padding: 20px;
    }
    
    .battery-big-level {
        width: 60px;
        height: 100px;
        margin-bottom: 0;
    }
    
    .level-text { font-size: 20px; }
}
