* {
    border: 0;
    padding: 0;
    margin: 0;
    box-sizing: border-box;
    font-family: "Lato", sans-serif;
}

html, body {
    height: 100%;
    overflow: hidden;
}

body {
    background: rgb(248, 248, 248);
    overflow-y: auto;
    height: 100vh;
}

/* Menu Styles */
.menu {
    margin: 0;
    padding: 0;
    height: 100vh;
    width: 15.7rem;
    position: fixed;
    top: 0;
    left: 0;
    overflow-y: auto;
    overflow-x: hidden;
    background: linear-gradient(145deg, #f0f2f8 0%, #dce1f2 20%, #c5cae9 50%, #a9b4df 100%);
    box-shadow: 2px 0 20px rgba(0, 0, 0, 0.15), inset -1px 0 0 rgba(255, 255, 255, 0.6);
    scrollbar-width: thin;
    scrollbar-color: #9fa8da #e8eaf6;
    z-index: 100;
}

.menu::-webkit-scrollbar {
    width: 6px;
}

.menu::-webkit-scrollbar-track {
    background: #e8eaf6;
    border-radius: 3px;
}

.menu::-webkit-scrollbar-thumb {
    background: #9fa8da;
    border-radius: 3px;
}

.menu-logo {
    width: 203px;
    margin: 10% 10% 10% 7%;
}

.menu-user-pic {
    margin: 1.5rem auto;
    width: 3.5rem;
    height: 3.5rem;
    border-radius: 50%;
    background: linear-gradient(135deg, #5bae77 0%, #c7e9fb 100%);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
}

.menu-user-pic-text {
    font-family: Arial, sans-serif;
    font-size: 1.5rem;
    color: #2c3e50;
    font-weight: 700;
    text-align: center;
    line-height: 1;
}

/* Menu Links - Font size matched to icon height */
.menu a {
    text-decoration: none;
    display: flex;
    align-items: center;
    padding: 12px 20px;
    margin: 6px 16px;
    border-radius: 16px;
    color: #2c3e50;
    font-weight: 500;
    font-size: 1rem;
    background: rgba(255, 255, 255, 0.4);
    backdrop-filter: blur(4px);
    transition: all 0.3s ease;
    border: 1px solid rgba(255, 255, 255, 0.3);
    gap: 10px;
}

.menu-icons {
    width: 20px;
    height: 20px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.menu-icons svg {
    width: 100%;
    height: 100%;
}

.menu a.active {
    background: linear-gradient(135deg, rgba(100, 0, 255, 0.2) 0%, rgba(100, 0, 255, 0.1) 100%);
    border: 1px solid rgba(100, 0, 255, 0.3);
    color: #4a1d96;
    box-shadow: 0 4px 12px rgba(100, 0, 255, 0.1);
}

.menu a:hover:not(.active) {
    background: rgba(255, 255, 255, 0.6);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

/* Main Content Area */
div.content {
    margin-left: 250px;
    padding: 1rem 1.5rem;
    height: 100vh;
    overflow-y: auto;
}

/* Dashboard Container */
.dashboard-container {
    max-width: 1400px;
    margin: 0 auto;
}

/* Controls Section - Consistent font size with menu */
.controls {
    background: white;
    padding: 1rem;
    border-radius: 12px;
    margin-bottom: 1rem;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
}

.control-group {
    flex: 1;
    min-width: 180px;
}

.control-group label {
    display: block;
    margin-bottom: 0.25rem;
    font-weight: 600;
    color: #333;
    font-size: 1rem;
}

select {
    width: 100%;
    padding: 0.5rem;
    border: 1px solid #ddd;
    border-radius: 8px;
    font-size: 1rem;
    background: white;
    cursor: pointer;
}

/* Timespan Buttons */
.timespan-buttons {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.25rem;
}

.timespan-btn {
    flex: 1;
    padding: 0.5rem 0.5rem;
    border: 1px solid #c5cae9;
    background: white;
    border-radius: 8px;
    cursor: pointer;
    font-size: 1rem;
    transition: all 0.3s ease;
    text-align: center;
}

.timespan-btn.active {
    background: #e6e1e8;
    border-color: #6400ff;
    color: #4a1d96;
    font-weight: 600;
}

/* Cards Layout */
.live-readings {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
}

.reading-card {
    background: white;
    padding: 2rem 1rem;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    display: flex;
    flex-direction: column;
    justify-content: center;
    min-height: 160px;
}

.reading-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.reading-label {
    font-size: 1rem;
    color: #666;
    letter-spacing: 1px;
    font-weight: 600;
    text-transform: uppercase;
    margin-bottom: 0.5rem;
}

.reading-value {
    font-size: 2.5rem;
    font-weight: bold;
    margin: 0.5rem 0;
}

.reading-unit {
    font-size: 1rem;
    font-weight: normal;
    color: #888;
}

.reading-card-status {
    font-size: 1rem;
    font-weight: 500;
    margin-top: 0.5rem;
}

/* Card Color Variants */
.card-temperature .reading-value {
    color: #ff6b6b;
}

.card-humidity .reading-value {
    color: #4dabf7;
}

.card-irrigation .reading-value {
    color: #51cf66;
}

/* Signal Strength */
.signal-strength-card {
    font-size: 1rem;
    font-weight: 500;
    margin-top: 0.5rem;
}

.signal-good { color: #4CAF50; }
.signal-fair { color: #FF9800; }
.signal-poor { color: #f44336; }

/* Charts Wrapper */
.charts-wrapper {
    display: flex;
    gap: 1rem;
    margin: 1rem 0 0 0;
    flex-wrap: wrap;
}

/* Line Chart Container */
.line-chart-container {
    flex: 2;
    min-width: 300px;
    background: white;
    padding: 0.5rem;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    position: relative;
    height: 350px;
}

.line-chart-container canvas {
    max-height: 310px !important;
    height: 310px !important;
}

/* Pie Chart Container */
.pie-chart-container {
    flex: 1;
    min-width: 250px;
    background: white;
    padding: 0.5rem;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.pie-chart-wrapper {
    position: relative;
    width: 100%;
    max-width: 220px;
    margin: 0 auto;
}

.pie-chart-container canvas {
    max-height: 200px !important;
    height: 200px !important;
}

/* Pie Chart Totals */
.pie-totals {
    text-align: center;
    margin-top: 0.5rem;
    padding-top: 0.5rem;
    border-top: 1px solid #eee;
    width: 100%;
}

.pie-total-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.25rem 0;
    font-size: 1rem;
}

.pie-total-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.color-box {
    width: 12px;
    height: 12px;
    border-radius: 2px;
}

.pie-total-value {
    font-weight: bold;
    color: #333;
    font-size: 1rem;
}

/* Empty Chart State */
.empty-chart-message {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.95);
    border-radius: 12px;
    z-index: 10;
}

.empty-chart-message-content {
    text-align: center;
    color: #999;
}

.empty-chart-message-content .icon {
    font-size: 2.5rem;
    margin-bottom: 0.5rem;
}

.empty-chart-message-content .title {
    font-size: 1rem;
    font-weight: 500;
    margin-bottom: 0.25rem;
}

.empty-chart-message-content .subtitle {
    font-size: 1rem;
    color: #bbb;
}

/* Loading and Error States */
.loading {
    text-align: center;
    padding: 1rem;
    color: #666;
    font-size: 1rem;
}

.error {
    color: #f44336;
    text-align: center;
    padding: 0.75rem;
    font-size: 1rem;
}

/* Responsive Design */
@media (max-width: 768px) {
    div.content {
        margin-left: 0;
        padding: 0.75rem;
        height: auto;
        min-height: 100vh;
    }
    
    .controls {
        flex-direction: column;
        gap: 0.75rem;
        padding: 0.75rem;
    }
    
    .control-group {
        min-width: auto;
    }
    
    .control-group label {
        font-size: 0.9rem;
    }
    
    select {
        font-size: 0.9rem;
    }
    
    .timespan-btn {
        font-size: 0.9rem;
    }
    
    .timespan-buttons {
        flex-direction: row;
    }
    
    .live-readings {
        grid-template-columns: 1fr;
        gap: 0.75rem;
        margin: 10% 0;
    }
    
    .reading-card {
        padding: 1.5rem 1rem;
    }
    
    .reading-value {
        font-size: 2rem;
    }
    
    .reading-label {
        font-size: 0.9rem;
    }
    
    .reading-card-status {
        font-size: 0.9rem;
    }
    
    .signal-strength-card {
        font-size: 0.9rem;
    }
    
    /* Hide line chart on mobile */
    .line-chart-container {
        display: none;
    }
    
    .pie-chart-container {
        flex: auto;
        width: 100%;
        min-width: auto;
    }
    
    .charts-wrapper {
        gap: 0;
        margin: 0.75rem 0 0 0;
    }
    
    .pie-chart-container canvas {
        max-height: 220px !important;
        height: 220px !important;
    }
    
    .pie-total-item {
        font-size: 0.9rem;
    }
    
    .pie-total-value {
        font-size: 0.9rem;
    }
}

/* Desktop optimization */
@media (min-width: 1400px) {
    .reading-card {
        padding: 2.5rem 1.5rem;
    }
    
    .reading-value {
        font-size: 3rem;
    }
    
    .line-chart-container {
        height: 400px;
    }
    
    .line-chart-container canvas {
        max-height: 360px !important;
        height: 360px !important;
    }
    
    .pie-chart-container canvas {
        max-height: 220px !important;
        height: 220px !important;
    }
}

/* Menu Responsive */
@media screen and (max-width: 800px) {
    .menu a {
        text-align: center;
        justify-content: center;
    }
}

@media screen and (max-width: 799px) {
    .menu {
        width: 220px;
    }
    
    .menu-logo {
        width: 180px;
    }
    
    .nav-label {
        display: none;
    }
    
    div.content {
        margin-left: 220px;
    }
}

@media screen and (max-width: 600px) {
    .menu {
        width: 100%;
        height: auto;
        position: relative;
    }
    
    .menu-logo {
        display: none;
    }
    
    .menu a {
        float: left;
        width: auto;
        margin: 0.25rem;
    }
    
    div.content {
        margin-left: 0;
    }
}