/* Universal box-sizing */
*, *::before, *::after {
    box-sizing: border-box;
}

/* General style settings */
body {
    font-family: 'Poppins', sans-serif;
    margin: 0;
    padding: 0;
    background-color: #f4f7f6;
    color: #333;
    line-height: 1.6;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
    /* Center content and add space using Flexbox */
    display: flex;
    flex-direction: column;
    gap: 20px; /* Space between sections */
}

/* Header and Navigation */
header {
    background-color: #2c3e50;
    color: white;
    padding: 15px 0;
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
}

header .container {
    flex-direction: row; /* Horizontal layout for the container inside the header */
    justify-content: space-between;
    align-items: center;
    gap: 0; /* No space between elements inside the header */
}

header h1 {
    margin: 0;
    font-size: 1.8em;
}

nav ul {
    list-style: none;
    margin: 0;
    padding: 0;
}

nav ul li {
    display: inline;
    margin-left: 20px;
}

nav ul li a {
    color: white;
    text-decoration: none;
    font-weight: 600;
}

/* Classes can be added for other Kp levels as well */

/* Card styles */
.card {
    background-color: white;
    border-radius: 8px;
    box-shadow: 0 4px 10px rgba(0,0,0,0.1);
    padding: 25px;
    margin-bottom: 20px; /* Space between cards */
}

.card h2 {
    color: #2c3e50;
    margin-top: 0;
    margin-bottom: 20px;
    border-bottom: 2px solid #eee;
    padding-bottom: 10px;
}

/* Layout for aurora images */
.aurora-images-wrapper {
    display: flex;
    flex-wrap: wrap; /* Stack on top of each other on small screens */
    justify-content: space-around;
    gap: 20px;
    margin-bottom: 20px;
}

.aurora-images-wrapper figure {
    margin: 0;
    text-align: center;
    flex: 1 1 45%; /* Flexible sizing */
    min-width: 280px; /* Minimum width */
}

.aurora-images-wrapper img {
    max-width: 100%;
    height: auto;
    border-radius: 5px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}

.aurora-images-wrapper figcaption {
    margin-top: 10px;
    font-size: 0.9em;
    color: #555;
}

/* Loading indicator styles (can be added to or updated from the current style) */
.loading-spinner {
    display: none; /* Hidden by default */
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 1000;
    background-color: rgba(255, 255, 255, 0.9);
    padding: 20px;
    border-radius: 10px;
    box-shadow: 0 0 15px rgba(0, 0, 0, 0.2);
    text-align: center;
}

.loading-spinner.visible {
    display: block; /* When visible */
}

.spinner {
    border: 4px solid rgba(0, 0, 0, 0.1);
    border-top: 4px solid #3498db;
    border-radius: 50%;
    width: 30px;
    height: 30px;
    animation: spin 1s linear infinite;
    margin: 0 auto 10px auto;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Relative positioning for the map section */
#aurora-map-section {
    position: relative; /* For correct positioning of the legend */
}

.k-index-summary p {
    margin: 0;
    padding: 10px 15px;
    background-color: #e9ecef;
    border-radius: 5px;
    font-size: 1.1em;
    color: #343a40;
}

.k-index-summary .power-value {
    font-weight: bold;
    color: #007bff; /* Blue color highlight */
}

.chart-container {
    position: relative;
    height: 400px; /* Set the height of the chart */
    width: 100%; /* Make it use the full width of the container */
}

/* Responsive Design Improvements */
@media (max-width: 768px) {
    .container {
        padding: 15px;
    }

    header .container {
        flex-direction: column;
        text-align: center;
        gap: 10px;
    }

    nav ul li {
        margin: 0 10px;
    }

    .card {
        padding: 20px;
    }

    .aurora-images-wrapper figure {
        flex: 1 1 100%; /* Single column on small screens */
    }

    .k-index-summary {
        flex-direction: column;
        align-items: stretch;
    }

    .k-index-summary p {
        text-align: center;
    }
}

@media (max-width: 480px) {
    header h1 {
        font-size: 1.5em;
    }

    nav ul li {
        display: block;
        margin: 5px 0;
    }

    .card {
        padding: 15px;
    }
}

/* Geolocation control icon */
.leaflet-control-locate {
    /* SVG icon is embedded as base64. This removes an external file dependency. */
    background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24"><path fill="currentColor" d="M12 8c-2.21 0-4 1.79-4 4s1.79 4 4 4s4-1.79 4-4s-1.79-4-4-4zm8.94 3c-.46-4.17-3.77-7.48-7.94-7.94V1h-2v2.06C6.83 3.52 3.52 6.83 3.06 11H1v2h2.06c.46 4.17 3.77 7.48 7.94 7.94V23h2v-2.06c4.17-.46 7.48-3.77 7.94-7.94H23v-2h-2.06zM12 20c-4.41 0-8-3.59-8-8s3.59-8 8-8s8 3.59 8 8s-3.59 8-8 8z"/></svg>');
    background-size: 16px 16px; /* Icon size */
    background-position: center; /* Center the icon */
    background-repeat: no-repeat; /* Do not repeat */
    width: 26px; /* Standard Leaflet control button width */
    height: 26px; /* Standard Leaflet control button height */
    display: block;
}

/* General style for the custom control button */
.leaflet-control-custom a {
    display: block;
    width: 26px;
    height: 26px;
    background-color: #fff; /* White background */
    border-bottom: 1px solid #ccc; /* Bottom border */
    line-height: 26px; /* Vertical alignment */
    text-align: center; /* Horizontal alignment */
    text-decoration: none;
    color: #444;
    font-size: 1.2em;
}

.leaflet-control-custom a:hover {
    background-color: #f4f4f4; /* Background color on hover */
}

/* K-index summary section */
.k-index-summary {
    justify-content: center;
    align-items: center;
    margin-bottom: 20px;
    display: flex; /* Enable Flexbox */
    flex-wrap: wrap; /* Wrap on small screens */
    gap: 20px; /* Space between elements */
}

/* Kp value display card */
.kp-display-card {
    background-color: #f8f9fa;
    border: 1px solid #e0e0e0;
    border-radius: 10px;
    padding: 20px;
    text-align: center;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
    min-width: 200px;
    flex-shrink: 0; /* Prevent shrinking */
}

.kp-display-card h3 {
    margin-top: 0;
    color: #2c3e50;
    font-size: 1.3em;
    margin-bottom: 15px;
}

.kp-value-circle {
    width: 100px;
    height: 100px;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    margin: 0 auto 15px auto;
    font-size: 2.5em;
    font-weight: bold;
    box-shadow: 0 0 15px rgba(0,0,0,0.1);
    transition: background-color 0.3s ease, color 0.3s ease; /* Animation for color transitions */
}

/* Kp value custom colors */
.kp-value-circle.kp-storm-g3 { background-color: #dc3545; color: white; } /* Red */
.kp-value-circle.kp-storm-g1 { background-color: #ffc107; color: #343a40; } /* Orange */
.kp-value-circle.kp-active { background-color: #17a2b8; color: white; } /* Blue-green */
.kp-value-circle.kp-quiet { background-color: #28a745; color: white; } /* Green (Quiet) */

#current-kp-category {
    font-size: 1.1em;
    font-weight: 600;
    color: #555;
}

/* Kp explanation section */
.kp-explanation {
    background-color: #e9f7ef; /* Light green background */
    border-left: 5px solid #28a745; /* Green left border */
    padding: 20px;
    border-radius: 8px;
    margin-top: 20px;
    line-height: 1.8;
    flex-grow: 1; /* Allows it to fill the available space */
}

.kp-explanation h3 {
    color: #28a745;
    margin-top: 0;
    margin-bottom: 10px;
    font-size: 1.4em;
}

.kp-explanation p {
    margin-bottom: 0;
    color: #333;
}

/* Aurora Power Summary Styles */
.aurora-power-summary {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    margin-top: 15px; /* Leave some space from the images */
    margin-bottom: 20px;
    justify-content: center;
    align-items: stretch; /* Ensures that the elements have the same height */
}

/* Aurora Power Value Display Card */
.aurora-power-display-card {
    background-color: #f8f9fa;
    border: 1px solid #e0e0e0;
    border-radius: 10px;
    padding: 20px;
    text-align: center;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
    min-width: 180px; /* Can be a little smaller */
    flex: 1; /* Flexible growth */
    display: flex; /* Use flex to center the content */
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

.aurora-power-display-card h3 {
    margin-top: 0;
    color: #2c3e50;
    font-size: 1.2em;
    margin-bottom: 10px;
}

.aurora-power-display-card p {
    font-size: 1.8em; /* To make the value appear larger */
    font-weight: bold;
    color: #007bff; /* Blue color highlight */
    margin: 0;
}

/* Aurora Explanation Section (similar to kp-explanation) */
.aurora-power-explanation {
    background-color: #e9f7ef; /* Light green background */
    border-left: 5px solid #28a745; /* Green left border */
    padding: 20px;
    border-radius: 8px;
    line-height: 1.8;
    flex: 2; /* Allows it to take up more space than other cards */
    min-width: 300px; /* Minimum width */
    display: flex;
    flex-direction: column;
    justify-content: center; /* Center the content vertically */
}

.aurora-power-explanation h3 {
    color: #28a745;
    margin-top: 0;
    margin-bottom: 10px;
    font-size: 1.4em;
}

.aurora-power-explanation p {
    margin-bottom: 0;
    color: #333;
}

/* Responsive settings may also need to be updated */
@media (max-width: 768px) {
    .aurora-power-summary {
        flex-direction: column;
        align-items: stretch;
    }
    .aurora-power-display-card,
    .aurora-power-explanation {
        flex: none; /* Remove flexibility */
        width: 100%; /* Full width */
        min-width: unset; /* Reset minimum width */
    }
}

/* Solar Wind Summary Styles */
.solar-wind-summary {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    margin-top: 15px;
    margin-bottom: 20px;
    justify-content: center;
    align-items: stretch; /* Ensures that the elements have the same height */
}

/* Solar Wind Value Display Card */
.solar-wind-display-card {
    background-color: #f8f9fa;
    border: 1px solid #e0e0e0;
    border-radius: 10px;
    padding: 20px;
    text-align: center;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
    min-width: 150px; /* Can be a little smaller */
    flex: 1; /* Flexible growth */
    display: flex; /* Use flex to center the content */
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

.solar-wind-display-card h3 {
    margin-top: 0;
    color: #2c3e50;
    font-size: 1.1em;
    margin-bottom: 10px;
}

.solar-wind-display-card p {
    font-size: 1.5em; /* To make the value appear larger */
    font-weight: bold;
    color: #007bff; /* Blue color highlight */
    margin: 0;
}

/* Responsive settings may also need to be updated */
@media (max-width: 768px) {
    .solar-wind-summary {
        flex-direction: column;
        align-items: stretch;
    }
    .solar-wind-display-card {
        flex: none; /* Remove flexibility */
        width: 100%; /* Full width */
        min-width: unset; /* Reset minimum width */
    }
}

/* Solar Wind Explanation Section (similar to kp-explanation) */
.solar-wind-explanation {
    background-color: #e9f7ef; /* Light green background */
    border-left: 5px solid #28a745; /* Green left border */
    padding: 20px;
    border-radius: 8px;
    line-height: 1.8;
    margin-top: 20px; /* Leave some space from other elements */
}

.solar-wind-explanation h3 {
    color: #28a745;
    margin-top: 0;
    margin-bottom: 10px;
    font-size: 1.4em;
}

.solar-wind-explanation p {
    margin-bottom: 0;
    color: #333;
}