/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #1e3c72 0%, #2a5298 100%);
    color: #ffffff;
    min-height: 100vh;
    overflow-x: hidden;
}

.dashboard-container {
    min-height: 100vh;
    position: relative;
}

/* Header Styles */
.dashboard-header {
    background: rgba(0, 0, 0, 0.3);
    backdrop-filter: blur(10px);
    padding: 1rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.header-left h1 {
    font-size: 1.8rem;
    margin-bottom: 0.2rem;
    color: #00d4ff;
}

.facility-name {
    font-size: 0.9rem;
    color: #b0c4de;
}

.header-right {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 0.5rem;
}

.status-indicator {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.9rem;
}

.status-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    animation: pulse 2s infinite;
}

.status-online {
    background: #00ff88;
    box-shadow: 0 0 10px #00ff88;
}

.status-warning {
    background: #ffa500;
    box-shadow: 0 0 10px #ffa500;
}

.status-critical {
    background: #ff4444;
    box-shadow: 0 0 10px #ff4444;
}

@keyframes pulse {
    0% { opacity: 1; }
    50% { opacity: 0.5; }
    100% { opacity: 1; }
}

.last-update {
    font-size: 0.8rem;
    color: #b0c4de;
}

/* Main Dashboard */
.dashboard-main {
    padding: 2rem;
    max-width: 1400px;
    margin: 0 auto;
}

/* Overview Cards */
.overview-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.metric-card {
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    border-radius: 12px;
    padding: 1.5rem;
    border: 1px solid rgba(255, 255, 255, 0.2);
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.metric-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, #00d4ff, #0099cc);
}

.power-card::before {
    background: linear-gradient(90deg, #ff6b6b, #ee5a52);
}

.voltage-card::before {
    background: linear-gradient(90deg, #4ecdc4, #44a08d);
}

.current-card::before {
    background: linear-gradient(90deg, #feca57, #ff9ff3);
}

.temperature-card::before {
    background: linear-gradient(90deg, #ff9a9e, #fecfef);
}

.metric-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.card-header h3 {
    font-size: 1rem;
    color: #e0e0e0;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.info-btn {
    background: rgba(255, 255, 255, 0.1);
    border: none;
    border-radius: 50%;
    width: 30px;
    height: 30px;
    color: #00d4ff;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.info-btn:hover {
    background: rgba(0, 212, 255, 0.2);
    transform: scale(1.1);
}

.card-content {
    text-align: center;
}

.metric-value {
    font-size: 2.5rem;
    font-weight: bold;
    color: #ffffff;
    margin-bottom: 0.2rem;
}

.metric-unit {
    font-size: 1rem;
    color: #b0c4de;
    margin-bottom: 0.5rem;
}

.metric-status {
    padding: 0.3rem 0.8rem;
    border-radius: 20px;
    font-size: 0.8rem;
    margin-bottom: 0.5rem;
    display: inline-block;
}

.status-normal {
    background: rgba(0, 255, 136, 0.2);
    color: #00ff88;
    border: 1px solid #00ff88;
}

.status-warning {
    background: rgba(255, 165, 0, 0.2);
    color: #ffa500;
    border: 1px solid #ffa500;
}

.status-critical {
    background: rgba(255, 68, 68, 0.2);
    color: #ff4444;
    border: 1px solid #ff4444;
}

.metric-detail {
    font-size: 0.8rem;
    color: #b0c4de;
}

/* Circuit Section */
.circuit-section {
    margin-bottom: 2rem;
}

.circuit-section h2 {
    margin-bottom: 1rem;
    color: #00d4ff;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.circuits-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 1rem;
}

.circuit-card {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    padding: 1rem;
    border-left: 4px solid #00d4ff;
    transition: all 0.3s ease;
}

.circuit-card:hover {
    transform: translateX(5px);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
}

.circuit-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
}

.circuit-name {
    font-weight: bold;
    color: #ffffff;
}

.circuit-status {
    width: 10px;
    height: 10px;
    border-radius: 50%;
}

.circuit-load {
    font-size: 0.9rem;
    color: #b0c4de;
}

.circuit-current {
    font-size: 1.2rem;
    font-weight: bold;
    color: #00d4ff;
}

/* Environmental Section */
.environmental-section {
    margin-bottom: 2rem;
}

.environmental-section h2 {
    margin-bottom: 1rem;
    color: #00d4ff;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.environmental-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
}

.env-card {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    padding: 1rem;
    transition: all 0.3s ease;
}

.env-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
}

/* Power Factor Calculation Display */
.power-factor-calculation {
    margin-top: 0.8rem;
    padding: 0.8rem;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 6px;
    border-left: 3px solid #00d4ff;
}

.calculation-formula {
    font-size: 0.9rem;
    font-weight: bold;
    color: #00d4ff;
    margin-bottom: 0.3rem;
}

.calculation-values {
    font-size: 0.85rem;
    color: #ffffff;
    margin-bottom: 0.3rem;
    font-family: monospace;
}

.calculation-reactive {
    font-size: 0.75rem;
    color: #b0c4de;
}

/* Alerts Section */
.alerts-section h2 {
    margin-bottom: 1rem;
    color: #ffa500;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.alerts-container {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    padding: 1rem;
    min-height: 100px;
}

.alert-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.8rem;
    margin-bottom: 0.5rem;
    border-radius: 6px;
    border-left: 4px solid;
}

.alert-warning {
    background: rgba(255, 165, 0, 0.1);
    border-left-color: #ffa500;
}

.alert-critical {
    background: rgba(255, 68, 68, 0.1);
    border-left-color: #ff4444;
}

.alert-icon {
    font-size: 1.2rem;
}

.alert-content {
    flex: 1;
}

.alert-title {
    font-weight: bold;
    margin-bottom: 0.2rem;
}

.alert-description {
    font-size: 0.9rem;
    color: #b0c4de;
}

.alert-time {
    font-size: 0.8rem;
    color: #888;
}

/* Information Panel */
.info-panel {
    position: fixed;
    top: 0;
    right: -400px;
    width: 400px;
    height: 100vh;
    background: rgba(0, 0, 0, 0.9);
    backdrop-filter: blur(20px);
    border-left: 1px solid rgba(255, 255, 255, 0.2);
    transition: right 0.3s ease;
    z-index: 1000;
    overflow-y: auto;
}

.info-panel.active {
    right: 0;
}

.info-panel-content {
    padding: 2rem;
    height: 100%;
}

.info-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.2);
    padding-bottom: 1rem;
}

.info-header h3 {
    color: #00d4ff;
    font-size: 1.3rem;
}

.close-btn {
    background: none;
    border: none;
    color: #ffffff;
    font-size: 1.5rem;
    cursor: pointer;
    transition: color 0.3s ease;
}

.close-btn:hover {
    color: #ff4444;
}

.info-body {
    line-height: 1.6;
}

.info-body h4 {
    color: #00d4ff;
    margin-bottom: 0.5rem;
    margin-top: 1.5rem;
}

.info-body p {
    margin-bottom: 1rem;
    color: #e0e0e0;
}

.info-body ul {
    margin-left: 1rem;
    margin-bottom: 1rem;
}

.info-body li {
    margin-bottom: 0.5rem;
    color: #b0c4de;
}

.threshold-table {
    width: 100%;
    margin: 1rem 0;
    border-collapse: collapse;
}

.threshold-table th,
.threshold-table td {
    padding: 0.5rem;
    text-align: left;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.threshold-table th {
    color: #00d4ff;
    font-weight: bold;
}

.threshold-table td {
    color: #e0e0e0;
}

/* Info Overlay */
.info-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    z-index: 999;
}

.info-overlay.active {
    opacity: 1;
    visibility: visible;
}

/* Responsive Design */
@media (max-width: 768px) {
    .dashboard-header {
        flex-direction: column;
        gap: 1rem;
        text-align: center;
    }

    .header-right {
        align-items: center;
    }

    .dashboard-main {
        padding: 1rem;
    }

    .overview-cards {
        grid-template-columns: 1fr;
    }

    .circuits-grid {
        grid-template-columns: 1fr;
    }

    .environmental-cards {
        grid-template-columns: 1fr;
    }

    .info-panel {
        width: 100%;
        right: -100%;
    }

    .metric-value {
        font-size: 2rem;
    }
}

@media (max-width: 480px) {
    .metric-value {
        font-size: 1.8rem;
    }

    .card-header h3 {
        font-size: 0.9rem;
    }

    .dashboard-header h1 {
        font-size: 1.5rem;
    }
}

/* Loading Animation */
.loading {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: #00d4ff;
    animation: spin 1s ease-in-out infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* Utility Classes */
.text-center {
    text-align: center;
}

.text-right {
    text-align: right;
}

.mb-1 {
    margin-bottom: 1rem;
}

.mt-1 {
    margin-top: 1rem;
}

.hidden {
    display: none;
}

.fade-in {
    animation: fadeIn 0.5s ease-in;
}

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

/* Image Styles */
.info-image {
    cursor: pointer;
    border-radius: 8px;
    transition: all 0.3s ease;
    border: 2px solid transparent;
}

.info-image:hover {
    border-color: #00d4ff;
    box-shadow: 0 4px 15px rgba(0, 212, 255, 0.3);
    transform: scale(1.02);
}

/* Image Modal */
.image-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 2000;
    backdrop-filter: blur(5px);
}

.image-modal.active {
    display: flex;
}

.image-modal-content {
    position: relative;
    max-width: 90%;
    max-height: 90%;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.5);
}

.image-modal-close {
    position: absolute;
    top: 10px;
    right: 10px;
    background: rgba(255, 68, 68, 0.8);
    color: white;
    border: none;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    cursor: pointer;
    font-size: 1.2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    z-index: 2001;
}

.image-modal-close:hover {
    background: #ff4444;
    transform: scale(1.1);
}

#modalImage {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    border-radius: 8px;
}