* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    padding: 20px;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
}

.header {
    background: white;
    padding: 30px;
    border-radius: 15px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);
    margin-bottom: 30px;
}

.header h1 {
    color: #333;
    margin-bottom: 15px;
    font-size: 2em;
}

.status-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 15px;
}

.status {
    display: inline-block;
    padding: 8px 20px;
    border-radius: 20px;
    font-weight: bold;
    font-size: 0.9em;
}

.status.online {
    background: #4CAF50;
    color: white;
}

.status.offline {
    background: #f44336;
    color: white;
}

.last-update {
    color: #666;
    font-size: 0.9em;
}

.dashboard {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.card {
    background: white;
    padding: 30px;
    border-radius: 15px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);
    transition: transform 0.3s;
}

.card:hover {
    transform: translateY(-5px);
}

.card h2 {
    color: #667eea;
    margin-bottom: 20px;
    font-size: 1.3em;
}

.reading {
    font-size: 3.5em;
    font-weight: bold;
    color: #333;
    margin: 20px 0;
}

.reading .unit {
    font-size: 0.4em;
    color: #999;
}

.secondary-reading {
    color: #666;
    font-size: 1.2em;
}

.control-card {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.switch-status {
    font-size: 1.1em;
    color: #666;
    margin-bottom: 20px;
}

.switch-status strong {
    color: #667eea;
    font-size: 1.2em;
}

.controls {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px 0;
}

.toggle-switch {
    position: relative;
    display: inline-block;
    width: 200px;
    height: 60px;
    cursor: pointer;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, #f44336 0%, #da190b 100%);
    transition: 0.4s;
    border-radius: 30px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.2);
}

.toggle-slider:before {
    position: absolute;
    content: "";
    height: 46px;
    width: 46px;
    left: 7px;
    bottom: 7px;
    background-color: white;
    transition: 0.4s;
    border-radius: 50%;
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
}

.toggle-switch input:checked + .toggle-slider {
    background: linear-gradient(135deg, #4CAF50 0%, #45a049 100%);
}

.toggle-switch input:checked + .toggle-slider:before {
    transform: translateX(140px);
}

.toggle-switch input:disabled + .toggle-slider {
    opacity: 0.5;
    cursor: not-allowed;
}

.timeframe-selector {
    background: white;
    padding: 20px;
    border-radius: 15px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);
    margin-bottom: 30px;
    display: flex;
    justify-content: center;
    gap: 15px;
    flex-wrap: wrap;
}

.timeframe-btn {
    padding: 12px 30px;
    border: 2px solid #667eea;
    background: white;
    color: #667eea;
    border-radius: 10px;
    font-size: 1em;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s;
    min-width: 100px;
}

.timeframe-btn:hover {
    background: #f0f0f0;
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(102, 126, 234, 0.3);
}

.timeframe-btn.active {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-color: #667eea;
}

.charts-section {
    display: grid;
    grid-template-columns: 1fr;
    gap: 20px;
}

.chart-card {
    width: 100%;
    position: relative;
    min-height: 300px;
    background: white;
    padding: 30px;
    border-radius: 15px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);
}

.chart-card-full {
    width: 100%;
}

.chart-card h2 {
    color: #667eea;
    margin-bottom: 20px;
    font-size: 1.3em;
}

canvas {
    width: 100% !important;
    height: auto !important;
    max-height: 400px;
    touch-action: pan-x;
    cursor: grab;
}

canvas:active {
    cursor: grabbing;
}

@media (max-width: 768px) {
    .header h1 {
        font-size: 1.5em;
    }
    
    .dashboard {
        grid-template-columns: 1fr;
    }
    
    .charts-section {
        grid-template-columns: 1fr;
    }
    
    .reading {
        font-size: 2.5em;
    }
    
    .controls {
        flex-direction: column;
    }
    
    .btn {
        width: 100%;
    }
}

/* Loading animation */
@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
}

.loading {
    animation: pulse 1.5s ease-in-out infinite;
}

/* Raspberry Pi Stats - uses device-group styling */
.rpi-data {
    font-size: 12px;
    color: #000;
    font-family: monospace;
    line-height: 1.5;
}

/* Device Group Styling */
.device-group {
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.25), rgba(255, 255, 255, 0.05));
    border-radius: 16px;
    padding: 24px;
    margin: 20px 0;
    box-shadow: 0 4px 12px rgba(103, 58, 183, 0.08);
}

.device-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 16px;
    border-bottom: 2px solid rgba(103, 58, 183, 0.2);
}

.device-title h2 {
    margin: 0;
    color: #000000;
    font-size: 1.5rem;
    font-weight: 600;
}

.device-status-bar {
    display: flex;
    gap: 15px;
    align-items: center;
}

/* Adjust existing status to work within device group */
.device-group .status {
    padding: 6px 14px;
    border-radius: 20px;
    font-weight: 500;
    font-size: 0.9rem;
}

.device-group .last-update {
    color: #000000;
    font-size: 0.85rem;
}

/* Responsive adjustments for device groups */
@media (max-width: 768px) {
    .device-group {
        padding: 16px;
        margin: 15px 0;
    }
    
    .device-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }
    
    .device-title h2 {
        font-size: 1.2rem;
    }
    
    .device-status-bar {
        width: 100%;
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }
}
