:root {
    --green: #28a745;
    --red: #dc3545;
    --blue: #007bff;
    --yellow: #ffc107;
    --card-bg: #fff;
    --text-color: #333;
    --text-secondary: #666;
    --border-color: #dee2e6;
    --shadow: 0 2px 4px rgba(0,0,0,0.1);
    --hover-shadow: 0 10px 20px rgba(0,0,0,0.1);
    --transition: all 0.3s ease;
    --border-radius: 8px;
    --primary-color: #007bff;
    --dark-blue: #0056b3;
    --voltage-bg: #f0f0f0;
    --status-online-bg: #d4edda;
    --status-online-color: #155724;
    --status-offline-bg: #f8d7da;
    --status-offline-color: #721c24;
    --recommendation-bg: rgba(0,123,255,0.1);
}

@media (prefers-color-scheme: dark) {
    :root {
        --card-bg: #2d2d2d;
        --text-color: #f0f0f0;
        --text-secondary: #b0b0b0;
        --border-color: #404040;
        --shadow: 0 2px 4px rgba(0,0,0,0.3);
        --hover-shadow: 0 10px 20px rgba(0,0,0,0.4);
        --voltage-bg: #404040;
        --status-online-bg: rgba(40,167,69,0.2);
        --status-online-color: #4caf50;
        --status-offline-bg: rgba(220,53,69,0.2);
        --status-offline-color: #f44336;
        --recommendation-bg: rgba(0,123,255,0.2);
    }
}

body.dark-theme {
    --card-bg: #2d2d2d;
    --text-color: #f0f0f0;
    --text-secondary: #b0b0b0;
    --border-color: #404040;
    --shadow: 0 2px 4px rgba(0,0,0,0.3);
    --hover-shadow: 0 10px 20px rgba(0,0,0,0.4);
    --voltage-bg: #404040;
    --status-online-bg: rgba(40,167,69,0.2);
    --status-online-color: #4caf50;
    --status-offline-bg: rgba(220,53,69,0.2);
    --status-offline-color: #f44336;
    --recommendation-bg: rgba(0,123,255,0.2);
}

/* Ngăn chặn biến động layout */
html {
    scroll-behavior: auto !important;
    height: 100%;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

body {
    min-height: 100%;
    padding-bottom: 70px;
    overscroll-behavior: none;
}

.dashboard {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 1.5rem;
    margin-top: 1rem;
    margin-bottom: 2rem;
    contain: content;
}

.dashboard-card {
    background: var(--card-bg);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    padding: 1.5rem;
    transition: var(--transition);
    height: auto;
    contain: layout;
    touch-action: pan-y;
    will-change: transform;
    border: 1px solid var(--border-color);
    color: var(--text-color);
}

.dashboard-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--hover-shadow);
}

.dashboard-card h3 {
    margin-top: 0;
    display: flex;
    align-items: center;
    color: var(--primary-color);
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 0.75rem;
    margin-bottom: 1rem;
    font-size: 1.2rem;
}

.dashboard-card h3 i {
    margin-right: 0.5rem;
}

.data-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.75rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px dashed var(--border-color);
    flex-wrap: wrap;
    gap: 0.5rem;
}

.data-row:last-child {
    border-bottom: none;
}

.data-label {
    font-weight: bold;
    color: var(--text-color);
    flex: 1;
    min-width: 0;
}

.data-value {
    font-size: 1.1rem;
    font-weight: 600;
    min-height: 1.6rem;
    line-height: 1.6rem;
    color: var(--text-color);
    text-align: right;
    flex-shrink: 0;
}

.highlight {
    font-size: 1.5rem;
    color: var(--primary-color);
    min-height: 1.6rem;
    line-height: 1.6rem;
}

.comparison {
    display: flex;
    justify-content: space-around;
    margin-top: 1.5rem;
    gap: 1rem;
}

.comparison-item {
    text-align: center;
    flex: 1;
}

.comparison-label {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

.comparison-value {
    font-size: 1.5rem;
    font-weight: bold;
    color: var(--blue);
    min-height: 1.6rem;
    line-height: 1.6rem;
}

.voltage-meter {
    position: relative;
    height: 20px;
    background: var(--voltage-bg);
    border-radius: 10px;
    margin: 0.75rem 0;
    overflow: hidden;
}

.voltage-bar {
    height: 100%;
    background: #44ff44;
    border-radius: 10px;
    transition: width 0.3s ease;
    width: 0%;
}

.voltage-value {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-weight: bold;
    color: var(--text-color);
    font-size: 0.9rem;
}

.status {
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-size: 0.9rem;
    font-weight: bold;
    min-height: 1.6rem;
    line-height: 1.6rem;
}

.status.online {
    background: var(--status-online-bg);
    color: var(--status-online-color);
}

.status.offline {
    background: var(--status-offline-bg);
    color: var(--status-offline-color);
}

.power-gauge {
    text-align: center;
    margin-bottom: 1.5rem;
    color: var(--text-color);
}

.chart-container {
    margin: 1.5rem 0;
    height: 200px;
    position: relative;
}

canvas {
    max-height: 100%;
    width: 100% !important;
    height: 100% !important;
}

.last-updated {
    text-align: center;
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-top: 1.5rem;
    padding: 0.75rem;
    background: var(--card-bg);
    border-radius: var(--border-radius);
    border: 1px solid var(--border-color);
}

#manualUpdate {
    margin-left: 0.5rem;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    border: 1px solid var(--border-color);
    background: var(--blue);
    color: white;
    cursor: pointer;
    transition: background-color 0.3s ease;
    min-height: 32px;
}

#manualUpdate:hover {
    background: var(--dark-blue) !important;
}

#manualUpdate:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* Responsive Design */
@media (max-width: 768px) {
    .dashboard {
        grid-template-columns: 1fr;
        gap: 1rem;
        margin-bottom: 1.5rem;
    }
    
    body {
        padding-bottom: 50px;
    }
    
    .last-updated {
        margin-top: 1rem;
        font-size: 0.8rem;
    }
    
    .dashboard-card {
        padding: 1rem;
    }
    
    .container {
        padding: 0.5rem;
    }
    
    html, body {
        overflow-x: hidden;
    }
    
    .data-row {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.25rem;
    }
    
    .data-value {
        text-align: left;
        width: 100%;
    }
    
    .comparison {
        flex-direction: column;
        gap: 1rem;
    }
    
    .comparison-item {
        text-align: center;
    }
    
    .chart-container {
        height: 180px;
    }
    
    .highlight {
        font-size: 1.3rem;
    }
    
    .comparison-value {
        font-size: 1.3rem;
    }
}

@media (max-width: 480px) {
    .dashboard-card {
        padding: 0.75rem;
    }
    
    .dashboard-card h3 {
        font-size: 1.1rem;
    }
    
    .data-label {
        font-size: 0.9rem;
    }
    
    .data-value {
        font-size: 1rem;
    }
    
    .highlight {
        font-size: 1.2rem;
    }
    
    .comparison-value {
        font-size: 1.2rem;
    }
    
    .chart-container {
        height: 160px;
    }
    
    .voltage-meter {
        height: 16px;
    }
    
    .voltage-value {
        font-size: 0.8rem;
    }
    
    #manualUpdate {
        padding: 0.2rem 0.4rem;
        font-size: 0.8rem;
    }
}

/* Touch optimizations */
@media (hover: none) and (pointer: coarse) {
    .dashboard-card:hover {
        transform: none;
    }
    
    #manualUpdate:hover {
        background: var(--blue) !important;
    }
} 