/* --- Reset & base --- */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

body {
    background: linear-gradient(135deg, #667eea, #764ba2);
    min-height: 100vh;
    color: #f5f5f5;
    padding: 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center; /* Center content vertically */
    overflow-x: hidden; /* Prevent horizontal scroll */
}

/* Notification Bar */
#notification-bar {
    position: fixed;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 90%;
    max-width: 500px;
    background-color: rgba(0, 0, 0, 0.7);
    color: white;
    padding: 15px 20px;
    border-bottom-left-radius: 10px;
    border-bottom-right-radius: 10px;
    text-align: center;
    font-weight: bold;
    font-size: 16px;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease-in-out, visibility 0.3s ease-in-out;
}
#notification-bar.show {
    opacity: 1;
    visibility: visible;
}
#notification-bar.success { background-color: rgba(67, 206, 162, 0.8); } /* Green */
#notification-bar.error { background-color: rgba(220, 36, 48, 0.8); } /* Red */
#notification-bar.info { background-color: rgba(118, 75, 162, 0.8); } /* Purple */


/* Language switch */
.language-switch {
    margin-bottom: 20px;
    user-select: none;
    display: flex;
    justify-content: center;
    align-items: center;
}

.language-switch img {
    width: 28px;
    height: 20px;
    margin-right: 12px;
    cursor: pointer;
    border-radius: 3px;
    box-shadow: 0 0 4px rgba(0,0,0,0.3);
    transition: transform 0.3s ease;
}
.language-switch img:hover {
    transform: scale(1.15);
}

/* Login Section */
#login-page {
    background: rgba(255, 255, 255, 0.15);
    padding: 30px 40px;
    border-radius: 15px;
    box-shadow: 0 8px 20px rgba(0,0,0,0.25);
    width: 100%; /* Make it responsive */
    max-width: 380px; /* Max width for larger screens */
    text-align: center;
    animation: fadeIn 1s ease forwards;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

#login-page h2 {
    font-weight: 700;
    margin-bottom: 25px;
    font-size: 28px;
    letter-spacing: 1.2px;
    text-shadow: 1px 1px 4px rgba(0,0,0,0.4);
}

#login-page input {
    width: 100%;
    padding: 14px 18px;
    margin: 12px 0;
    border: none;
    border-radius: 10px;
    font-size: 16px;
    background: rgba(255, 255, 255, 0.3);
    color: #222;
    transition: background 0.3s ease;
}
#login-page input:focus {
    background: rgba(255, 255, 255, 0.6);
    outline: none;
    box-shadow: 0 0 8px #764ba2;
}

#login-page button {
    margin-top: 18px;
    width: 100%;
    background: #764ba2;
    border: none;
    color: white;
    font-size: 18px;
    padding: 14px;
    border-radius: 12px;
    cursor: pointer;
    font-weight: 700;
    letter-spacing: 1.1px;
    transition: background 0.4s ease, box-shadow 0.4s ease;
    box-shadow: 0 4px 12px rgba(118, 75, 162, 0.6);
}
#login-page button:hover {
    background: #8e5ecb;
    box-shadow: 0 6px 20px rgba(142, 94, 203, 0.8);
}

/* Dashboard container */
#dashboard {
    width: 90%;
    max-width: 900px;
    margin: 30px auto 60px;
    animation: fadeIn 1s ease forwards;
    display: none; /* Hidden by default */
}

/* Dashboard heading */
#dashboard h1 {
    font-size: 36px;
    margin-bottom: 10px;
    text-align: center;
    font-weight: 800;
    letter-spacing: 1.3px;
    color: #f3eafc;
    text-shadow: 1px 1px 6px rgba(0,0,0,0.5);
}

#connection, #lastUpdate {
    font-size: 14px;
    text-align: center;
    margin-bottom: 8px;
    color: #dcd6f7cc;
    font-style: italic;
}

/* Grid layout: two columns */
.grid-2 {
    position: relative;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 24px;
    margin-top: 25px;
}

/* Card style base */
.card {
    background: rgba(255, 255, 255, 0.15);
    border-radius: 20px;
    padding: 30px 25px;
    color: white;
    box-shadow: 0 8px 18px rgba(0,0,0,0.25);
    backdrop-filter: blur(8px);
    position: relative;
    cursor: default;
    user-select: none;
    transition: transform 0.35s ease, box-shadow 0.35s ease;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    min-height: 160px;
    text-align: center; /* Center text within cards */
}

.card h3 {
    margin-bottom: 14px;
    font-size: 22px;
    font-weight: 700;
    letter-spacing: 0.9px;
    text-shadow: 1px 1px 5px rgba(0,0,0,0.5);
}

/* Hover scale and shadow */
.card:hover {
    transform: translateY(-8px);
    box-shadow: 0 14px 30px rgba(0,0,0,0.45);
}

/* Specific cards colors */
.voltage {
    background: linear-gradient(135deg, #43cea2, #185a9d);
}

.power {
    background: linear-gradient(135deg, #ff512f, #dd2476);
    width: 100%; /* Full width on smaller screens */
    min-height: 180px;
    z-index: 10;
    box-shadow: 0 15px 40px rgba(221, 36, 118, 0.7);
}

.backup {
    background: linear-gradient(135deg, #007991, #78ffd6);
}

.alarm {
    background: linear-gradient(135deg, #7b4397, #dc2430);
}
/* Alarm specific states */
.alarm.ok {
    background: linear-gradient(135deg, #43cea2, #185a9d); /* Green for OK */
}
.alarm.fault {
    background: linear-gradient(135deg, #dc2430, #7b4397); /* Red for FAULT */
    animation: pulse-red 1.5s infinite; /* Pulsing animation for fault */
}

.control {
    background: linear-gradient(135deg, #f7971e, #ffd200);
    color: #3c2300;
}

/* Generator button */
#genBtn {
    margin-top: 20px;
    padding: 14px 30px;
    font-weight: 800;
    font-size: 18px;
    border-radius: 30px;
    border: none;
    background: #3c2300;
    color: #ffd200;
    cursor: pointer;
    box-shadow: 0 6px 18px rgba(255, 210, 0, 0.7);
    transition: all 0.3s ease;
    letter-spacing: 1.1px;
}
#genBtn:hover {
    background: #ffd200;
    color: #3c2300;
    box-shadow: 0 12px 28px rgba(255, 210, 0, 0.9);
    transform: scale(1.1);
}
/* Generator button states */
#genBtn.running {
    background: linear-gradient(135deg, #4CAF50, #2E7D32); /* Green for running */
    box-shadow: 0 6px 18px rgba(76, 175, 80, 0.7);
    color: white;
}
#genBtn.stopped {
    background: linear-gradient(135deg, #F44336, #D32F2F); /* Red for stopped */
    box-shadow: 0 6px 18px rgba(244, 67, 54, 0.7);
    color: white;
}
#genBtn.start-anim {
    animation: scale-pulse 0.5s ease-out;
}
#genBtn.stop-anim {
    animation: scale-pulse 0.5s ease-out;
}


/* Smooth fade in animation */
@keyframes fadeIn {
    from {opacity: 0; transform: translateY(10px);}
    to {opacity: 1; transform: translateY(0);}
}

/* Responsive adjustments */
@media (min-width: 768px) {
    .grid-2 {
        grid-template-columns: repeat(2, 1fr); /* Two columns for larger screens */
    }
    .power {
        grid-column: 1 / -1; /* Spans from the first column line to the last */
    }
}

/* New styles for card status and glow animation */
.card.ok {
    box-shadow: 0 0 15px 5px rgba(67, 206, 162, 0.8); /* Green glow */
}
.card.warn {
    box-shadow: 0 0 15px 5px rgba(255, 210, 0, 0.8); /* Yellow glow */
}
.card.error {
    box-shadow: 0 0 15px 5px rgba(220, 36, 48, 0.8); /* Red glow */
}

@keyframes glow {
    0% { box-shadow: 0 0 5px 2px rgba(255, 255, 255, 0.3); }
    50% { box-shadow: 0 0 20px 8px rgba(255, 255, 255, 0.6); }
    100% { box-shadow: 0 0 5px 2px rgba(255, 255, 255, 0.3); }
}

/* Animations for generator button and alarm */
@keyframes scale-pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.05); }
    100% { transform: scale(1); }
}

@keyframes pulse-red {
    0% { box-shadow: 0 0 15px 5px rgba(220, 36, 48, 0.8); }
    50% { box-shadow: 0 0 25px 10px rgba(255, 0, 0, 1); }
    100% { box-shadow: 0 0 15px 5px rgba(220, 36, 48, 0.8); }
}
