/* Reset and base styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    background-color: white;
    color: #333;
    line-height: 1.6;
}

.container {
    max-width: 100vw;
    padding: 1rem;
    margin: 0 auto;
}

/* Dashboard styles */
.dashboard-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    padding: 1rem;
    background: white;
}

.dashboard-header h1 {
    font-size: clamp(1.5rem, 4vw, 3rem);
    color: #2c3e50;
}

.refresh-indicator {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: clamp(0.8rem, 2vw, 1rem);
    color: #666;
}

.refresh-indicator .dot {
    width: 8px;
    height: 8px;
    background: #2ECC71;
    border-radius: 50%;
    animation: pulse 2s infinite;
}

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

/* Sensor list - vertical list view */
.sensor-grid {
    display: flex;
    flex-direction: column;
    gap: 0;
    margin-bottom: 2rem;
}

.sensor-card {
    background: white;
    padding: 1rem;
    cursor: pointer;
    transition: background-color 0.2s ease;
    border-bottom: 1px solid #e0e0e0;
    display: flex;
    align-items: center;
    min-height: clamp(80px, 10vh, 120px);
}

.sensor-card:hover {
    background-color: #f8f9fa;
}

.sensor-card:last-child {
    border-bottom: none;
}

/* Sensor row layout - horizontal list */
.sensor-header {
    flex: 0 0 15%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding-right: 1rem;
}

.sensor-header h3 {
    font-size: clamp(1rem, 2.5vw, 1.2rem);
    color: #2c3e50;
    margin-bottom: 0.2rem;
}

.sensor-time {
    font-size: clamp(0.7rem, 1.8vw, 0.8rem);
    color: #666;
}

.sensor-data {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 2rem;
}

.metric {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.metric-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: clamp(80px, 15vw, 120px);
}

.metric-value {
    font-size: clamp(1rem, 2.5vw, 2rem);
    font-weight: bold;
    text-align: center;
}

.metric-high,
.metric-low {
    font-size: clamp(0.5rem, 1.25vw, 1rem);
    font-weight: normal;
    text-align: center;
    opacity: 0.7;
}

.metric.temperature .metric-value {
    color: #E74C3C;
}

.metric.temperature .metric-high,
.metric.temperature .metric-low {
    color: #E74C3C;
}

.metric.humidity .metric-value {
    color: #3498DB;
}

.metric.humidity .metric-high,
.metric.humidity .metric-low {
    color: #3498DB;
}

.metric-chart {
    width: clamp(200px, 25vw, 400px);
    height: clamp(60px, 8vh, 100px);
}

/* Detail view styles */
.detail-view {
    max-width: 100%;
}

.detail-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 2rem;
    padding: 1rem;
    background: white;
}

.back-button {
    background: #3498DB;
    color: white;
    border: none;
    padding: 0.5rem 1rem;
    border-radius: 4px;
    cursor: pointer;
    font-size: clamp(0.9rem, 2.5vw, 1rem);
    transition: background 0.3s ease;
    text-decoration: none;
    display: inline-block;
}

.back-button:hover {
    background: #2980B9;
    color: white;
    text-decoration: none;
}

.detail-header h1 {
    font-size: clamp(1.3rem, 4vw, 2.5rem);
    color: #2c3e50;
}

.date-controls {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    align-items: center;
    margin-bottom: 2rem;
    padding: 1rem;
    background: white;
}

.date-controls label {
    font-size: clamp(0.9rem, 2.5vw, 1rem);
    font-weight: bold;
}

.date-controls input {
    padding: 0.5rem;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: clamp(0.8rem, 2vw, 0.9rem);
}

.date-controls button {
    background: #2ECC71;
    color: white;
    border: none;
    padding: 0.5rem 1rem;
    border-radius: 4px;
    cursor: pointer;
    font-size: clamp(0.8rem, 2vw, 0.9rem);
    transition: background 0.3s ease;
}

.date-controls button:hover {
    background: #27AE60;
}

.date-controls button:last-child {
    background: #95A5A6;
}

.date-controls button:last-child:hover {
    background: #7F8C8D;
}

/* Stats grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
}

.stat-card {
    background: white;
    padding: 1.5rem;
    text-align: center;
}

.stat-card h3 {
    font-size: clamp(1rem, 2.5vw, 1.2rem);
    margin-bottom: 0.5rem;
    color: #2c3e50;
}

.stat-card.temperature h3 { color: #E74C3C; }
.stat-card.humidity h3 { color: #3498DB; }
.stat-card.pressure h3 { color: #2ECC71; }
.stat-card.info h3 { color: #9B59B6; }

.current-value {
    font-size: clamp(1.8rem, 5vw, 3rem);
    font-weight: bold;
    margin-bottom: 0.5rem;
}

.stat-card.temperature .current-value { color: #E74C3C; }
.stat-card.humidity .current-value { color: #3498DB; }
.stat-card.pressure .current-value { color: #2ECC71; }
.stat-card.info .current-value { color: #9B59B6; }

.stat-details {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
    font-size: clamp(0.7rem, 1.8vw, 0.8rem);
    color: #666;
}

/* Chart container */
.chart-container {
    background: white;
    padding: 1rem;
    margin-bottom: 2rem;
}

/* Utility classes */
.loading {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 2rem;
    font-size: clamp(1rem, 2.5vw, 1.2rem);
    color: #666;
}

.error {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 2rem;
    font-size: clamp(1rem, 2.5vw, 1.2rem);
    color: #E74C3C;
    background: #ffeaea;
    border: 1px solid #E74C3C;
}

.no-data {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 2rem;
    font-size: clamp(1rem, 2.5vw, 1.2rem);
    color: #666;
    background: white;
    border: 1px solid #ddd;
}

/* Responsive breakpoints */
@media (max-width: 768px) {
    .container {
        padding: 0.25rem;
    }
    
    .sensor-card {
        flex-direction: column;
        align-items: stretch;
        padding: 0.75rem 0.25rem;
        min-height: auto;
    }
    
    .sensor-header {
        flex: none;
        padding-right: 0;
        margin-bottom: 1rem;
        text-align: center;
    }
    
    .sensor-data {
        flex-direction: column;
        gap: 1rem;
    }
    
    .metric {
        justify-content: center;
        flex-direction: column;
        gap: 0.5rem;
    }
    
    .metric-container {
        min-width: auto;
    }
    
    .metric-chart {
        width: 100% !important;
        margin: 0 !important;
        padding: 0 !important;
        box-sizing: border-box;
    }
    
    .metric-chart .plotly {
        width: 100% !important;
    }
    
    .metric-chart .main-svg {
        width: 100% !important;
    }
    
    .metric {
        padding: 0 0.25rem;
        width: 100%;
        box-sizing: border-box;
    }
    
    .dashboard-header {
        flex-direction: column;
        gap: 1rem;
        text-align: center;
    }
    
    .date-controls {
        flex-direction: column;
        align-items: stretch;
        padding: 0.5rem;
        margin-bottom: 1rem;
    }
    
    .date-controls > * {
        width: 100%;
    }
    
    .detail-header {
        padding: 0.5rem;
        margin-bottom: 1rem;
    }
    
    .detail-header h1 {
        font-size: clamp(1.2rem, 5vw, 1.8rem);
    }
    
    .stats-grid {
        grid-template-columns: 1fr 1fr;
    }
}

@media (max-width: 480px) {
    .stats-grid {
        grid-template-columns: 1fr;
    }
    
    .detail-header {
        flex-direction: column;
        text-align: center;
        padding: 0.25rem;
        margin-bottom: 0.5rem;
    }
    
    .detail-header h1 {
        font-size: clamp(1rem, 4vw, 1.4rem);
    }
    
    .sensor-data {
        gap: 0.5rem;
    }
    
    .container {
        padding: 0.125rem;
    }
    
    .sensor-card {
        padding: 0.5rem 0.125rem;
    }
    
    .metric {
        padding: 0 0.125rem;
    }
    
    .metric-chart {
        width: calc(100vw - 1rem) !important;
        max-width: 100% !important;
    }
    
    /* Detail view specific mobile optimizations */
    .date-controls {
        padding: 0.25rem;
        margin-bottom: 0.5rem;
        gap: 0.5rem;
    }
    
    .date-controls label {
        font-size: 0.8rem;
    }
    
    .date-controls input {
        padding: 0.25rem;
        font-size: 0.8rem;
    }
    
    .date-controls button {
        padding: 0.25rem 0.5rem;
        font-size: 0.8rem;
    }
    
    .stats-grid {
        grid-template-columns: 1fr 1fr;
        gap: 0.5rem;
        margin-bottom: 1rem;
    }
    
    .stat-card {
        padding: 0.75rem;
    }
    
    .stat-card h3 {
        font-size: 0.9rem;
        margin-bottom: 0.25rem;
    }
    
    .current-value {
        font-size: clamp(1.2rem, 6vw, 2rem);
        margin-bottom: 0.25rem;
    }
    
    .stat-details {
        font-size: 0.65rem;
        gap: 0.1rem;
    }
    
    .chart-container {
        padding: 0.5rem;
        margin-bottom: 1rem;
    }
}