/* style_home.css - Shared Green & Black Theme */
body {
    font-family: 'Inter', sans-serif;
    /* Main background - a very dark, slightly greenish-black */
    background-color: #1d2b27;
    /* Default text color - off-white for contrast */
    color: #eaf0e9;
    margin: 0;
}

/* Accent Colors */
/* A more muted, professional green for buttons, active states, and highlights */
.theme-accent { color: #28a745; }
.theme-accent-hover:hover { color: #228b3d; }
.theme-bg-accent { background-color: #28a745; }
.theme-bg-accent-hover:hover { background-color: #228b3d; }
.loading-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: #111827; /* Dark background matching your dashboard */
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 1000; /* Ensure it's on top of all other content */
    transition: opacity 0.5s ease-in-out;
}

.loading-screen.hidden {
    opacity: 0;
    visibility: hidden;
}

.loading-spinner {
    border: 4px solid rgba(255, 255, 255, 0.3);
    border-top: 4px solid #34D399; /* Spinner color matching your theme */
    border-radius: 50%;
    width: 50px;
    height: 50px;
    animation: spin 1s linear infinite;
}

.loading-text {
    margin-top: 20px;
    color: #E5E7EB;
    font-size: 1.2rem;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* --- Sidebar & Navigation (for pages with sidebar) --- */
.sidebar {
    /* Darker green/black for sidebar */
    background-color: #2b3a35;
    width: 250px;
    padding: 1rem; /* p-4 */
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: -250px;
    height: 100%;
    transition: left 0.3s ease-in-out;
    z-index: 40;
}

.sidebar.open {
    left: 0;
}
.sidebar-icon {
    width: 24px;
    height: 24px;
    stroke-width: 2;
    display: inline-block;
    vertical-align: middle;
    margin-right: 0.75rem;
}
.nav-link {
    display: flex;
    align-items: center;
    padding: 0.75rem 1rem;
    border-radius: 0.375rem;
    color: #9ce5a8; /* Soft light green for nav links */
    transition: background-color 0.2s ease-in-out, color 0.2s ease-in-out;
    margin-bottom: 0.5rem;
    text-decoration: none;
}
.nav-link:hover {
    background-color: #226b48; /* Deeper green on hover */
    color: #eaf0e9;
}
.nav-link.active {
    background-color: #28a745; /* Main theme accent */
    color: #ffffff;
    font-weight: 500;
}
.sidebar-header h1 {
    font-size: 1.5rem; /* text-2xl */
    font-weight: bold;
    color: #28a745; /* theme-accent */
}
.sidebar-header .sub-title {
    font-size: 1.125rem; /* text-lg */
    color: #ffffff;
    display: block;
}
.sidebar-footer {
    margin-top: auto;
}
.sidebar-footer .user-info {
    text-align: center;
    font-size: 0.875rem; /* text-sm */
    color: #9ce5a8; /* Soft light green */
    margin-bottom: 0.25rem;
}
.sidebar-footer .user-info strong {
    color: #eaf0e9;
}
.sidebar-footer .logout-button {
    display: block;
    width: 100%;
    text-align: center;
    background-color: #d44a4a; /* Red for destructive action */
    color: #ffffff;
    padding-top: 0.5rem;
    padding-bottom: 0.5rem;
    padding-left: 1rem;
    padding-right: 1rem;
    border-radius: 0.375rem;
    transition: background-color 0.2s ease-in-out;
    text-decoration: none;
}
.sidebar-footer .logout-button:hover {
    background-color: #c03d3d;
}

/* --- Main Content Area (for pages with sidebar) --- */
.main-content-area {
    padding: 1.5rem; /* p-6 */
    transition: margin-left 0.3s ease-in-out;
    margin-left: auto;
    margin-right: auto;
    justify-content: flex-start;
    width: 80%;
}
.main-content-area h2,
.main-content-area h3,
.main-content-area h4 {
    color: #ffffff; /* White headers */
    margin-bottom: 1rem;
}
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}
.page-header h2 {
    font-size: 1.5rem;
    font-weight: 600;
}
.mobile-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}
.mobile-header .menu-button {
    color: #9ce5a8;
}
.mobile-header .menu-button:hover {
    color: #ffffff;
}
.mobile-header .page-title-mobile {
    font-size: 1.25rem;
    font-weight: bold;
    color: #28a745;
    width: auto;
    text-align: left;
}
.overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    z-index: 30;
}
.overlay.active {
    display: block;
}

/* --- General Form Styles (for login, register, add/edit device) --- */
.form-container {
    background-color: #2b3a35; /* Darker background for forms */
    padding: 2rem;
    border-radius: 0.5rem;
    box-shadow: 0 10px 15px -3px rgba(0,0,0,0.1), 0 4px 6px -2px rgba(0,0,0,0.05);
    width: 100%;
    max-width: 42rem;
    margin: 2rem auto;
}
.form-container h1, .form-container h2 {
    text-align: center;
    margin-bottom: 1.5rem;
    color: #28a745;
}
.form-container h2 {
    font-size: 1.25rem;
    color: #9ce5a8;
}
.form-container label {
    display: block;
    color: #9ce5a8;
    font-size: 0.875rem;
    font-weight: 500;
    margin-bottom: 0.5rem;
}
.form-container input[type="text"],
.form-container input[type="email"],
.form-container input[type="password"],
.form-container input[type="date"],
.form-container input[type="number"],
.form-container select,
.form-container textarea {
    width: 100%;
    padding: 0.75rem 1rem;
    border-radius: 0.375rem;
    border: 1px solid #226b48;
    background-color: #1d2b27;
    color: #eaf0e9;
    box-sizing: border-box;
}
.form-container input:focus,
.form-container select:focus,
.form-container textarea:focus {
    border-color: #28a745;
    outline: none;
    box-shadow: 0 0 0 2px rgba(40, 167, 69, 0.5);
}
.form-container button[type="submit"], .form-container .button-primary {
    width: 100%;
    background-color: #28a745;
    color: #ffffff;
    padding: 0.75rem 1rem;
    border-radius: 0.375rem;
    font-weight: 600;
    transition: background-color 0.2s ease-in-out;
    border: none;
    cursor: pointer;
}
.form-container button[type="submit"]:hover, .form-container .button-primary:hover {
    background-color: #228b3d;
}
.form-container .form-link {
    color: #9ce5a8;
    text-decoration: none;
}
.form-container .form-link:hover {
    text-decoration: underline;
    color: #9ce5a8;
}
.form-container .form-footer-text {
    text-align: center;
    font-size: 0.875rem;
    margin-top: 1rem;
}
.form-container .form-footer-text span {
    color: #9ce5a8;
}

/* Alert / Feedback Messages */
.alert-message {
    padding: 0.75rem 1rem;
    border-radius: 0.375rem;
    margin-bottom: 1rem;
    font-weight: 500;
}
.alert-success {
    background-color: #1d4d3d;
    border: 1px solid #28a745;
    color: #eaf0e9;
}
.alert-error {
    background-color: #7f1d1d;
    border: 1px solid #d44a4a;
    color: #fecaca;
}

/* Table Styles (for device/user management) */
.table-container {
    background-color: #2b3a35;
    padding: 0.5rem;
    border-radius: 0.5rem;
    box-shadow: 0 4px 6px -1px rgba(0,0,0,0.1), 0 2px 4px -1px rgba(0,0,0,0.06);
    overflow-x: auto;
}
.table-auto {
    width: 100%;
    border-collapse: collapse;
}
.table-auto th, .table-auto td {
    border: 1px solid #226b48;
    padding: 0.75rem;
    text-align: left;
    color: #9ce5a8;
}
.table-auto th {
    background-color: #1d2b27;
    color: #eaf0e9;
    font-weight: 600;
}
.table-auto tr:nth-child(even) {
    background-color: #1d4d3d;
}
.table-auto tr:hover {
    background-color: #226b48;
}
.table-auto .action-link {
    color: #eab308; /* New golden color for action links */
    text-decoration: none;
    margin-right: 0.5rem;
}
.table-auto .action-link:hover {
    text-decoration: underline;
    color: #f5c94a;
}
.table-auto .delete-button {
    color: #d44a4a;
    background: none;
    border: none;
    padding: 0;
    cursor: pointer;
    text-decoration: none;
}
.table-auto .delete-button:hover {
    text-decoration: underline;
    color: #e07272;
}

/* Button Styles (general purpose, e.g., "Add User", "Add Device") */
.button-primary-page {
    display: inline-flex;
    align-items: center;
    background-color: #28a745;
    color: #ffffff;
    font-weight: 600;
    padding: 0.5rem 1rem;
    border-radius: 0.375rem;
    box-shadow: 0 4px 6px -1px rgba(0,0,0,0.1), 0 2px 4px -1px rgba(0,0,0,0.06);
    transition: background-color 0.15s ease-in-out;
    text-decoration: none;
}
.button-primary-page:hover {
    background-color: #228b3d;
}
.button-icon {
    width: 16px; height: 16px; stroke-width: 2;
    display: inline-block; vertical-align: middle; margin-right: 0.25rem;
}

/* Responsive adjustments for sidebar and main content */
/* --- Corrected Responsive Styles for Sidebar and Main Content --- */
.main-content-area {
    padding: 1.5rem;
    transition: margin-left 0.3s ease-in-out;
    margin-left: 0; /* Default margin for small screens */
    width: 100%; /* Default width for small screens */
}

/* For screens larger than a specific breakpoint */
@media (min-width: 769px) {
    .sidebar {
        left: 0;
        width: 250px;
        position: fixed;
    }
    .main-content-area {
        margin-left: 250px; /* Match sidebar width */
        width: calc(100% - 250px); /* Fill the remaining space */
    }
}

/* On mobile, when the menu is open, the main content can be pushed slightly to the right to reveal a small portion of the sidebar, but not with a hard margin */
@media (max-width: 768px) {
    .sidebar {
        left: -250px;
        position: fixed;
    }
    .sidebar.open {
        left: 0;
    }
    .main-content-area {
        margin-left: 0; /* Start with no margin */
        width: 100%;
    }
}

.home-content-dashboard {
    max-width: 1200px;
    margin: 0 auto;
    justify-content: center;
}

/* Styles specific to dashboard_home.php that are NOT in style_home.css */
.power-flow-outer-container { background-color: #2b3a35; padding: 1.5rem; border-radius: 0.75rem; }
.power-flow-container { background-color: transparent; min-height: 400px; display: flex; flex-direction: column; align-items: center; justify-content: center; width: 100%;}
.power-flow-svg { width: 100%; max-width: 450px; height: auto; min-height: 400px; overflow: visible; }
.node-circle { stroke-width: 1px; fill: #2b3a35; fill-opacity: 0.8; transition: filter 0.3s ease-in-out, fill-opacity 0.3s ease-in-out, stroke 0.3s ease-in-out; cursor: pointer; }
@keyframes beamingGlowGreen { 0%, 100% { filter: drop-shadow(0 0 3px var(--glow-color-soft)) drop-shadow(0 0 6px var(--glow-color-strong)); } 50% { filter: drop-shadow(0 0 5px var(--glow-color-soft)) drop-shadow(0 0 12px var(--glow-color-strong)); } }
.node-grid .node-circle { stroke: #28a745; --glow-color-soft: #9ce5a8; --glow-color-strong: #28a745; animation: beamingGlowGreen 2.5s infinite ease-in-out; }
.node-solar .node-circle { stroke: #eab308; --glow-color-soft: #f5c94a; --glow-color-strong: #eab308; animation: beamingGlowGreen 2.5s infinite ease-in-out; }
.node-house .node-circle { stroke: #226b48; --glow-color-soft: #28a745; --glow-color-strong: #226b48; animation: beamingGlowGreen 2.5s infinite ease-in-out; cursor: default;}
.node-battery .node-circle { stroke: #9ce5a8; --glow-color-soft: #eaf0e9; --glow-color-strong: #9ce5a8; animation: beamingGlowGreen 2.5s infinite ease-in-out; }
.power-flow-node-icon { width: 40px; height: 40px; pointer-events: none; }
.node-label { fill: #9ce5a8; font-size: 13px; font-weight: 500; text-anchor: middle; pointer-events: none; }
.power-value-pf { fill: #eaf0e9; font-size: 12px; font-weight: 600; text-anchor: middle; dominant-baseline: middle; pointer-events: none; }
.flow-track, .flow-dot { stroke-linecap: round; fill: none; opacity: 0; transition: opacity 0.3s ease-in-out; }
.flow-track.active { stroke-width: 2.5px; opacity: 0.8; }
.flow-dot.active { stroke-width: 5px; stroke-dasharray: 2 50; animation: flow-animation-dot 1.2s linear infinite; opacity: 1; }
@keyframes flow-animation-dot { to { stroke-dashoffset: -52; } }
.flow-track.active.grid-source-active, .flow-dot.active.grid-source-active { stroke: #28a745; }
.flow-track.active.solar-source-active, .flow-dot.active.solar-source-active { stroke: #eab308; }
.flow-track.active.battery-source-active, .flow-dot.active.battery-source-active { stroke: #9ce5a8; }
.flow-track { stroke-linecap: round; fill: none; stroke-width: 3px; stroke: #2b3a35; opacity: 0.4; transition: opacity 0.3s ease-in-out, stroke 0.3s ease-in-out; }
.flow-dot { stroke-linecap: round; fill: none; stroke-width: 5px; opacity: 0; transition: opacity 0.3s ease-in-out; }
.flow-dot.active { stroke-dasharray: 2 50; animation: flow-animation-dot 1.2s linear infinite; opacity: 1; }
.node-offline .node-circle { animation: none !important; fill: #2b3a35 !important; fill-opacity: 0.5 !important; stroke: #1d2b27 !important; filter: grayscale(50%) opacity(0.6) !important; }
.node-offline image, .node-offline .node-label, .node-offline .power-value-pf { opacity: 1.0; }
.admin-monitor-controls {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    margin-top: 1rem;
}
.admin-monitor-controls select { background-color: #2b3a35; border-color: #2b3a35; color: #9ce5a8; padding: 0.5rem 0.75rem; border-radius: 0.375rem; font-size: 0.875rem; }
.admin-monitor-controls select:focus { border-color: #28a745; outline: none; box-shadow: 0 0 0 2px rgba(40, 167, 69, 0.5); }
.admin-monitor-controls label { margin-right: 0.5rem; font-size: 0.875rem; color: #9ce5a8; }
.admin-monitor-controls .control-group {
    display: flex;
    align-items: center;
}
.fixed-width-input {
    width: 250px;
    min-width: 150px;
    background-color: #1d2b27;
    border: 1px solid #226b48;
    padding: 0.5rem 0.75rem;
    border-radius: 0.375rem;
    color: #eaf0e9;
}
#deviceMapContainer { height: 400px; width: 100%; border-radius: 0.5rem; margin-top: 2rem; border: 1px solid #2b3a35; background-color: #2b3a35; }
.radial-progress-card { background-color: #2b3a35; padding: 1rem; border-radius: 0.5rem; text-align: center; }
.radial-progress-container { width: 100px; height: 100px; border-radius: 50%; background-color: #2b3a35; display: flex; align-items: center; justify-content: center; position: relative; margin: 0 auto 0.5rem auto; }
.radial-progress-bar { width: 100%; height: 100%; border-radius: 50%; background: conic-gradient(var(--progress-color, #28a745) calc(var(--progress-value, 0) * 1%), #1d2b27 calc(var(--progress-value, 0) * 1%)); transition: --progress-value 0.5s ease-out, box-shadow 0.5s ease-out; box-shadow: 0 0 5px var(--progress-color, #28a745), 0 0 10px var(--progress-color, #28a745), 0 0 15px rgba(40, 167, 69, 0.5); }
#p1-voltage-radial .radial-progress-bar, #p1-current-radial .radial-progress-bar, #p1-power-radial .radial-progress-bar { /* Uses --progress-color set by JS */ }
.radial-progress-inner { width: 80%; height: 80%; background-color: #2b3a35; border-radius: 50%; position: absolute; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.radial-progress-value { font-size: 1.125rem; font-weight: 600; color: #eaf0e9; }
.radial-progress-label { font-size: 0.75rem; color: #9ce5a8; margin-top: 0.125rem; }
#p1-voltage-radial .radial-progress-value, #p1-voltage-radial .radial-progress-label, #p1-current-radial .radial-progress-value, #p1-current-radial .radial-progress-label, #p1-power-radial .radial-progress-value, #p1-power-radial .radial-progress-label { color: #28a745; }
#currentMonitoringInfo { text-align: center; margin-bottom: 1rem; padding: 0.5rem; background-color: #2b3a35; border-radius: 0.375rem; font-size: 0.875rem; color: #eaf0e9; min-height: 1.25em; }
#consumptionChartContainer { background-color: #2b3a35; padding: 1.5rem; border-radius: 0.5rem; margin-top: 2rem; }
#consumptionChart { max-height: 350px; }
.consumption-period-selector select { background-color: #2b3a35; border-color: #2b3a35; color: #9ce5a8; }
.chart-toggle-btn { transition: background-color 0.3s ease, color 0.3s ease; border: 1px solid transparent; }
.chart-toggle-btn.active { background-color: #28a745; color: #ffffff; font-weight: 600; }
.chart-toggle-btn:not(.active):hover { background-color: #226b48; }
#mainChartWrapper { background-color: #2b3a35; padding: 1.5rem; border-radius: 0.5rem; }
#mainChartCanvas { max-height: 350px; }
