/* Common styles for both themes */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: Arial, sans-serif;
    font-size: 16px;
    line-height: 1.5;
    min-height: 100vh;
    transition: background-color 0.3s ease, color 0.3s ease;
}

.container {
    max-width: 900px; /* Added max-width to limit width on larger screens */
    min-height: 100vh; /* Changed from height to min-height */
    margin: 0 auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    height: auto; /* Allow container to expand naturally */
}

/* Header Section */
.header {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 10px;
}

.location-container h1 {
    font-size: 1.8rem;
    margin-bottom: 5px;
}

.time-container {
    text-align: center;
}

.date-display {
    margin-bottom: 5px;
}

.time-display {
    display: flex;
    justify-content: center;
    gap: 15px;
}

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

#theme-switch {
    padding: 8px 15px;
    cursor: pointer;
    border-radius: 5px;
    transition: all 0.3s ease;
}

/* Current Weather Section */
.current-weather {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    align-items: center;
    margin-bottom: 20px;
    padding: 20px;
    border-radius: 10px;
}

.current-temp {
    text-align: center;
}

.current-temp h2 {
    font-size: 3rem;
    margin-bottom: 5px;
}

.current-conditions {
    text-align: center;
}

.weather-icon {
    font-size: 2.5rem;
    margin-bottom: 10px;
}

.sun-times {
    text-align: center;
}

/* Hourly Forecast Section */
.hourly-forecast {
    margin-bottom: 20px;
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    border-radius: 10px;
    position: relative;
    min-height: 200px; /* Add minimum height */
    overflow: hidden; /* Ensure rounded corners are visible */
}

.date-header {
    padding: 10px;
    font-weight: bold;
    text-align: center;
    position: sticky;
    top: 0;
    z-index: 10;
    background-color: inherit; /* Inherit background color from parent */
    border-top-left-radius: 10px; /* Match container's radius */
    border-top-right-radius: 10px; /* Match container's radius */
}

.hourly-container {
    overflow-y: auto;
    padding: 0;
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    position: relative;
    min-height: 150px; /* Ensure minimum height */
    max-height: 400px; /* Limit height on desktop to avoid excessive scrolling */
}

.hourly-header-row {
    display: grid;
    grid-template-columns: 0.5fr 1fr 1fr 1fr 1fr 1fr;
    padding: 10px;
    margin: 0;
    font-weight: bold;
    border-bottom: 1px solid rgba(255, 255, 255, 0.2);
    position: sticky;
    top: 0;
    left: 0;
    right: 0;
    background-color: var(--bg-color, #1e1e2e); /* Add a more opaque background */
    opacity: 1;
    z-index: 5; /* Lower z-index than date header */
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.hourly-container .hourly-item:first-of-type {
    border-top: none;
}

.hourly-item {
    display: grid;
    grid-template-columns: 0.5fr 1fr 1fr 1fr 1fr 1fr;
    padding: 10px;
    margin-bottom: 5px;
    border-radius: 5px;
}

.hourly-item:nth-child(even) {
    background-color: rgba(255, 255, 255, 0.05);
}

.hourly-time {
    font-weight: bold;
}

.date-separator {
    margin: 15px 10px;
    padding: 5px;
    text-align: center;
    font-weight: bold;
    border-bottom: 1px solid rgba(255, 255, 255, 0.2);
    border-top: 1px solid rgba(255, 255, 255, 0.2);
}

/* Footer Section */
.footer {
    padding: 10px 0;
    text-align: center;
    font-size: 0.8rem;
    opacity: 0.7;
}

.footer-actions {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 15px;
    margin-top: 10px;
}

#refresh-button {
    padding: 5px 10px;
    cursor: pointer;
    border-radius: 5px;
    transition: all 0.3s ease;
    font-size: 0.8rem;
}

#refresh-button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* For modern theme charts */
.chart-container {
    width: 100%;
    height: 200px;
    margin: 10px 0;
}

/* Loading indicators */
.loading-indicator {
    text-align: center;
    padding: 20px;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    body {
        height: auto; /* Remove any height constraints */
    }
    
    .container {
        min-height: auto; /* Allow container to grow based on content */
        height: auto;
    }
    
    .header {
        grid-template-columns: 1fr;
        grid-template-rows: auto auto auto;
        gap: 10px;
    }
    
    .location-container {
        text-align: center;
    }
    
    .theme-toggle {
        text-align: center;
    }
    
    .current-weather {
        grid-template-columns: 1fr;
        grid-template-rows: auto auto auto;
        gap: 20px;
    }
    
    .hourly-forecast {
        flex: 0 1 auto; /* Don't try to grow to fill space */
        height: auto;
        max-height: none;
        /* Keep overflow property to allow scrolling */
        overflow: hidden; 
    }
    
    .hourly-container {
        /* Keep overflow-y: auto to maintain scrolling functionality */
        overflow-y: auto; 
        height: auto;
        /* Set a fixed height for scrolling on mobile */
        max-height: 400px; 
    }
    
    .hourly-header-row {
        /* Hide the header row on mobile to save space */
        display: none; 
    }

    .hourly-item {
        /* Change to a single column layout */
        grid-template-columns: 1fr; 
        /* Remove fixed rows, let content flow */
        grid-template-rows: auto; 
        gap: 8px; /* Adjust gap */
        padding: 10px; /* Adjust padding */
        margin-bottom: 10px; /* Add margin between items */
        text-align: left; /* Align text left for readability */
    }

    /* Add labels back for mobile view since header is hidden */
    .hourly-item .hourly-time::before { content: "Time: "; font-weight: normal; }
    .hourly-item .hourly-temp::before { content: "Temp: "; font-weight: normal; }
    .hourly-item .hourly-precip::before { content: "Precip Prob: "; font-weight: normal; }
    .hourly-item .hourly-precip-amount::before { content: "Precip Amt: "; font-weight: normal; }
    .hourly-item .hourly-cloud::before { content: "Cloud Cover: "; font-weight: normal; }
    .hourly-item .hourly-conditions::before { content: "Conditions: "; font-weight: normal; }

    .hourly-time {
         font-weight: bold; /* Keep time bold */
    }
    
    .footer-actions {
        flex-direction: column;
        gap: 10px;
    }
    
    /* Make date header sticky on mobile */
    .date-header {
        position: sticky;
        top: 0;
        background-color: inherit;
        z-index: 10;
    }
}