body, html {
    height: 100%;
    margin: 0;
    padding: 0;
    overflow: hidden;
    background-color: #0A192F; /* deep space */
    position: relative;
}

/* Starfield goes behind everything */
#starfield-container {
    position: absolute;
    inset: 0;
    z-index: 1;
    pointer-events: none;
}

/* Glow sits above stars but below the map */
#glow-container {
    position: absolute;
    inset: 0;
    z-index: 2;
    pointer-events: none;
}

/* Map should be topmost interactive layer */
#map {
    position: absolute;
    inset: 0;
    width: 100vw;
    height: 100vh;
    z-index: 3;
    background: none !important;
}

.maplibregl-control-container {
    font-size: 14px;
}

/* Layer control container */
/* Wrapper for both the toggle button and control panel */
.layer-control-wrapper {
    position: absolute;
    top: 10px;
    left: 10px;
    z-index: 1001;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    pointer-events: auto;
}

/* Toggle button for showing/hiding the layer panel */
.layer-toggle-button {
    background-color: #3182bd;
    color: white;
    border: none;
    padding: 6px 12px;
    font-size: 14px;
    font-family: Arial, sans-serif;
    border-radius: 4px;
    cursor: pointer;
    margin-bottom: 6px;
    z-index: 1002;
    transition: background-color 0.2s ease;
}

.layer-toggle-button:hover {
    background-color: #0056b3;
}

/* Main layer control panel */
.layer-control {
    width: 250px;
    background-color: white;
    padding: 10px;
    font-size: 12px;
    font-family: Arial, sans-serif;
    border-radius: 5px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
    display: flex;
    flex-direction: column;
    gap: 10px;
    pointer-events: auto;
}

.layer-group {
    border: 1px solid #ccc;
    border-radius: 4px;
    padding: 8px;
    background-color: #f9f9f9;
    margin-bottom: 10px;
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}

/* Ensure dropdowns inside layer groups are spaced consistently */
.layer-group .dropdown {
    margin-top: 6px;
}


/* Hidden state */
.layer-control.collapsed {
    display: none;
}

/* Dropdown menu styling */
.dropdown {
    position: relative;
    display: inline-block;
}

.dropdown-button {
    background-color: white;
    border: 1px solid #ccc;
    padding: 8px 10px;
    font-size: 12px;
    cursor: pointer;
    border-radius: 3px;
    text-align: left;
}

.dropdown-content {
    display: none;
    position: absolute;
    left: 0;
    z-index: 2;
    background-color: white;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
    border-radius: 3px;
    overflow: hidden;
}

.dropdown-content button {
    width: 100%;
    padding: 8px 10px;
    text-align: left;
    font-size: 12px;
    border: none;
    background: none;
    cursor: pointer;
}

.layer-group .dropdown-content {
    width: max-content;
    padding: 5px 5px;
}

.layer-group .dropdown-content label {
    display: block;
    margin-bottom: 6px;
}

.dropdown-content button:hover {
    background-color: #f0f0f0;
}

/* Show dropdown content when open class is set */
.dropdown.open .dropdown-content {
    display: block;
}

.layer-group-title {
    font-size: 14px;
    font-weight: bold;
    color: #333;
    margin-bottom: 5px; /* Add spacing before sublayers */
    padding-left: 5px; /* Align it with sublayers */
}

.sublayers {
    margin-left: 20px; /* Indent sublayers */
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.sublayer {
    background-color: white;
    border: 1px solid #ccc;
    padding: 6px 10px;
    font-size: 12px;
    border-radius: 3px;
    cursor: pointer;
    text-align: left;
    transition: background-color 0.2s ease, color 0.2s ease;
}

/* Highlight active layer buttons */
.toggle-layer.active,
.sublayer.active {
    background-color: #d3d3d3;
    font-weight: bold;
    color: black;
    border-color: #aaa;
}

.toggle-layer:disabled {
    background-color: #e0e0e0;
    color: #828282;
    border: 1px solid #ccc;
    cursor: not-allowed;
    opacity: 0.6;
}



/* Logo styling */
.logo {
    position: absolute;
    top: 10px;
    right: 10px;
    z-index: 1;
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 12px;
}

.logo-extra {
    display: flex;
    align-items: center;
    background: rgba(255, 255, 255, 0.8);
}

.logo-image {
    width: 140px;
    height: auto;
    max-width: 100%;
}

.toggle-layer {
    background-color: white;
    border: 1px solid #ccc;
    padding: 8px 10px;
    font-size: 12px;
    border-radius: 3px;
    cursor: pointer;
    text-align: left;
    transition: background-color 0.2s ease, color 0.2s ease;
}

/* Highlight active buttons */
.toggle-layer.active {
    background-color: #3182bd; /* Light blue background */
    color: white; /* White text for contrast */
    font-weight: bold;
    border-color: #0056b3; /* Darker blue border */
}


/* Legend item styling */
#legend {
    position: absolute;
    bottom: 40px;
    right: 10px;
    z-index: 1000;
    background-color: rgba(255, 255, 255, 0.9);
    padding: 10px;
    border: 1px solid #ccc;
    border-radius: 5px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
    max-width: 200px;
    font-family: Arial, sans-serif;
    font-size: 12px;
    color: #333;
}

/* Legend item styling */
.legend-item {
    display: flex;
    align-items: center;
    margin-bottom: 5px;
}

.legend-color {
    width: 20px;
    height: 20px;
    margin-right: 10px;
    border-radius: 3px;
}

.legend-item:last-child {
    margin-bottom: 0;
}

.legend-icon {
    width: 18px;
    height: 18px;
    object-fit: contain;
    margin-right: 8px;
    border-radius: 50%;
    background: white;
    box-shadow: 0 0 2px rgba(0,0,0,0.2);
}

/* General Popup Styling */
.maplibregl-popup {
    z-index: 1100;
}

.maplibregl-popup-content {
    width: 500px;
    padding: 10px;
    font-family: Arial, sans-serif;
    font-size: 13px;
    line-height: 1.5;
}

.maplibregl-popup-content h4,
.popup-header h4 {
    margin-top: 0;
    font-size: 16px;
    font-weight: bold;
    color: #333;
}

.maplibregl-popup-content p,
.popup-details p {
    margin: 5px 0;
    color: #555;
}

/* Scrollable Description Styling */
.popup-description {
    max-height: 150px;
    overflow-y: auto;
    margin-top: 10px;
    color: #666;
    line-height: 1.5;
    padding-right: 5px;
}

/* Scrollbar Styling for WebKit Browsers */
.popup-description::-webkit-scrollbar {
    width: 8px;
}

.popup-description::-webkit-scrollbar-thumb {
    background-color: #ccc;
    border-radius: 4px;
}

/* Navigation Styling */
.popup-navigation {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 10px;
}

.popup-navigation button {
    background-color: rgba(0, 123, 255, 0.8);
    color: white;
    border: none;
    padding: 8px 12px;
    border-radius: 4px;
    font-size: 14px;
    cursor: pointer;
    transition: background-color 0.3s ease;
}

.popup-navigation button:hover {
    background-color: #0056b3;
}

.popup-navigation button:disabled {
    background-color: #cccccc;
    color: #666666;
    cursor: not-allowed;
}

.maplibregl-popup-content {
    overflow: hidden;
    white-space: normal;
    word-wrap: break-word;
}

.maplibregl-popup-anchor-top .maplibregl-popup-content {
    transform-origin: bottom;
}

.maplibregl-popup-anchor-bottom .maplibregl-popup-content {
    transform-origin: top;
}

.maplibregl-popup-anchor-left .maplibregl-popup-content {
    transform-origin: right;
}

.maplibregl-popup-anchor-right .maplibregl-popup-content {
    transform-origin: left;
}

.maplibregl-popup-anchor-top-left .maplibregl-popup-content,
.maplibregl-popup-anchor-top-right .maplibregl-popup-content,
.maplibregl-popup-anchor-bottom-left .maplibregl-popup-content,
.maplibregl-popup-anchor-bottom-right .maplibregl-popup-content {
    transform-origin: center;
}

.popup-link {
    color: #1a73e8;
    text-decoration: none;
    font-weight: bold;
    font-size: 13px;
}

.popup-link:hover {
    text-decoration: underline;
}



.country-info-row-wrapper {
    position: relative;
}

.country-info-row.collapsed {
    max-height: 100px; /* Adjust as needed */
    overflow: hidden;
}

.country-info-row {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
}

.toggle-country-info {
    margin-top: 10px;
    background-color: #3182bd;
    color: white;
    border: none;
    border-radius: 5px;
    padding: 5px 10px;
    cursor: pointer;
}

.toggle-country-info:hover {
    background-color: #0056b3;
}


.country-chip {
    display: inline-flex;
    align-items: center;
    padding: 5px 5px;
    margin: 0;
    border: 1px solid #ddd;
    border-radius: 10px;
    background-color: #f9f9f9;
    white-space: nowrap;
}

.popup-flag {
    width: 20px;
    height: 14px;
    margin-right: 8px;
    border-radius: 2px;
    border: 1px solid #ccc;
    font-size: 12px;;
}

.risklevel-chip {
    display: inline-block;
    padding: 5px 15px;
    margin: 10px 0;
    border-radius: 20px;
    color: white;
    font-weight: bold;
    text-align: center;
}

.risklevel-negligible {
    background-color: #8CC740; /* Negligible Risk */
}

.risklevel-low {
    background-color: #D2E038; /* Moderate Risk */
}

.risklevel-medium {
    background-color: #FFC629; /* Medium Risk */
}

.risklevel-high {
    background-color: #F78F28; /* High Risk */
}

.risklevel-critical {
    background-color: #F24F25; /* Critical Risk */
}

.severity-chip {
    display: inline-block;
    background-color: #f78f28;
    color: white;
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: bold;
    margin-bottom: 8px;
}

.popup-image {
    display: block;
    max-width: 100%;
    margin-top: 10px;
    border-radius: 4px;
}


button[title] {
    position: relative;
}

button[title]:hover::after {
    content: attr(title);
    position: absolute;
    top: 100%; /* Position below the button */
    left: 50%;
    transform: translateX(-50%);
    background-color: #333;
    color: #fff;
    padding: 4px 8px;
    border-radius: 4px;
    white-space: nowrap;
    font-size: 12px;
    z-index: 10;
    pointer-events: none;
    opacity: 1;
    transition: opacity 0.2s ease-in-out;
}

button[title]:hover::before {
    content: "";
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    border-width: 5px;
    border-style: solid;
    border-color: #333 transparent transparent transparent;
    z-index: 10;
}

.info-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    font-size: 14px;
    font-weight: bold;
    color: white; /* White text */
    background-color: #3182bd; /* Blue background */
    border-radius: 50%; /* Fully rounded */
    cursor: pointer;
    text-align: center;
    line-height: 18px;
}


.info-icon:hover {
    color: #0056b3; /* Darker blue on hover */
}

.gdacs-marker {
    width: 36px;
    height: 36px;
    background-size: cover;
    background-repeat: no-repeat;
    border-radius: 50%;
    box-shadow: 0 0 4px rgba(0, 0, 0, 0.3);
    border: 2px solid white;
    cursor: pointer;
}

.gdacs-map-icon {
    width: 8px;
    height: 8px;
    background-size: cover;
    background-position: center;
    border-radius: 50%;
    border: 2px solid white;
    box-shadow: 0 0 3px rgba(0, 0, 0, 0.5);
    cursor: pointer;
}


.gdacs-popup-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 8px;
}

.gdacs-popup-header .popup-image {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    object-fit: cover;
}

.gdacs-title {
    margin: 0;
    font-size: 16px;
}

.popup {
    display: none;
    position: absolute;
    background-color: #fff;
    border: 1px solid #ccc;
    border-radius: 5px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    padding: 10px;
    width: 300px;
    z-index: 1300;
    font-size: 14px;
    color: #333;
}

.popup.show {
    display: block;
}


.baselayer-toggle-group {
    display: flex;
    align-items: center;
    gap: 10px;
}

/* Existing styles */
.projection-toggle {
    position: relative;
    display: inline-flex;
    align-items: center;
    cursor: pointer;
}

.projection-toggle input {
    opacity: 0;
    width: 0;
    height: 0;
}

.projection-toggle .slider {
    width: 36px;
    height: 20px;
    background-color: #ccc;
    border-radius: 34px;
    position: relative;
    transition: 0.2s;
}

.projection-toggle .slider::before {
    content: "";
    position: absolute;
    height: 14px;
    width: 14px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    border-radius: 50%;
    transition: 0.2s;
}

.projection-toggle input:checked + .slider {
    background-color: #4CAF50;
}

.projection-toggle input:checked + .slider::before {
    transform: translateX(16px);
}

.projection-icon {
    margin-left: 4px;
    font-size: 1.2em;
}


.switch-label {
    position: relative;
    display: inline-block;
    width: 42px;
    height: 22px;
}

.switch-label input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0; left: 0;
    right: 0; bottom: 0;
    background-color: #ccc;
    transition: .4s;
    border-radius: 22px;
}

.slider:before {
    position: absolute;
    content: "";
    height: 16px;
    width: 16px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: .4s;
    border-radius: 50%;
}

input:checked + .slider {
    background-color: #4CAF50;
}

input:checked + .slider:before {
    transform: translateX(20px);
}


#embedded-map {
    width: 100% !important;
    height: 200px !important;
    position: relative;
    z-index: 10000;
}

#embedded-map canvas {
    background-color: rgba(255, 0, 0, 0.2) !important;
}




/* Responsive layout for mobile */
@media (max-width: 768px) {
    .logo {
        flex-direction: column;
        right: 10px;
        align-items: flex-end;
    }

    .logo-image {
        width: 120px;
    }

    .layer-control-wrapper {
        bottom: auto;
        top: 10px;
        left: 10px;
    }

    .layer-control {
        width: 90vw;
        max-width: 150px;
    }

    .layer-group {
        padding: 6px;
        margin-bottom: 8px;
    }

    .layer-control.show {
        display: flex;
    }

    .layer-control:not(.collapsed) {
        display: flex;
    }

    .popup {
        width: 90%;
    }

    .maplibregl-popup-content {
        width: 100%;
        height: 90%;
    }

    #legend {
        max-width: 150px;
    }
}

