body {
    font-family: livvic;
}

#map {
    position: relative; /* Allow absolute positioning of child elements */
    width: 90%;
    height: 700px;
    border-radius: 12px;
    margin: 0 auto;
    transition: width 0.3s ease;
}

#map.fullscreen-width {
    width: 100%;
    border-radius: 0;
    transform: translateZ(0); /* Force GPU acceleration */
    will-change: transform; /* Hint browser about upcoming changes */
    backface-visibility: hidden; /* Improve rendering performance */
    -webkit-backface-visibility: hidden; /* Safari support */
    perspective: 1000px; /* Enable 3D transforms for better performance */
    overflow: hidden; /* Ensure map content respects rounded corners */
}

.legend {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    max-width: 600px;
    max-height: calc(100% - 40px); /* Map height minus bottom padding and some margin */
    height: auto;
    width: auto;
    display: block;
    z-index: 1000;
}


#zoom-level-display {
    display: none; /* Hidden for now */
    position: absolute;
    top: 10px;
    left: 10px;
    z-index: 1000;
    background: rgba(255, 255, 255, 0.15);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    padding: 8px 12px;
    border-radius: 12px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1), 0 1px 3px rgba(0, 0, 0, 0.08);
    font-family: livvic;
    font-size: 12px;
    font-weight: bold;
    margin: 0;
}

#loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.3);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 2000;
}

#loading-content {
    background: rgba(255, 255, 255, 0.2);
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
    border: 1px solid rgba(255, 255, 255, 0.3);
    padding: 30px 50px;
    border-radius: 20px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
    text-align: center;
}

#loading-content p {
    font-family: livvic;
    font-size: 24px;
    font-weight: bold;
    color: #333;
    margin: 0 0 15px 0;
}

.loading-spinner {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: conic-gradient(
        green 0deg 72deg,
        blue 72deg 144deg,
        brown 144deg 216deg,
        purple 216deg 288deg,
        mediumvioletred 288deg 360deg
    );
    mask: radial-gradient(circle, transparent 38%, black 40%);
    -webkit-mask: radial-gradient(circle, transparent 38%, black 40%);
    animation: spin 1s linear infinite;
    margin: 0 auto;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

#control-panel-toggle {
    position: absolute;
    top: 10px;
    right: 10px;
    z-index: 1002;
    width: fit-content;
    display: flex;
    gap: 8px;
}

#control-panel-toggle .menu-btn {
    background: rgba(255, 255, 255, 0.15);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 12px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1), 0 1px 3px rgba(0, 0, 0, 0.08);
    color: #333;
    cursor: pointer;
    font-family: livvic;
    font-size: 11px;
    font-weight: bold;
    padding: 6px 12px;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 6px;
}

#control-panel-toggle .menu-btn:hover {
    background: rgba(255, 255, 255, 0.4);
}

#control-panel-toggle .menu-btn .eye-icon {
    display: inline-flex;
    align-items: center;
    vertical-align: middle;
}

#control-panel-toggle .menu-btn .eye-icon svg {
    display: block;
}

#control-panel-toggle .fullscreen-btn {
    background: rgba(255, 255, 255, 0.15);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 12px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1), 0 1px 3px rgba(0, 0, 0, 0.08);
    color: #333;
    cursor: pointer;
    padding: 6px;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
}

#control-panel-toggle .fullscreen-btn:hover {
    background: rgba(255, 255, 255, 0.4);
}

#control-panel-toggle .fullscreen-btn .fullscreen-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

#control-panel-toggle .fullscreen-btn .fullscreen-icon svg {
    display: block;
    width: 16px;
    height: 16px;
}

#control-panel {
    background: rgba(255, 255, 255, 0.15);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    padding: 0 5px;
    border-radius: 12px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1), 0 1px 3px rgba(0, 0, 0, 0.08);
    font-family: livvic;
    font-size: 11px;
    position: absolute;
    top: 50px;          /* Position below the toggle button */
    right: 10px;
    z-index: 1001;      /* Ensure it stays above other map layers but below toggle */
    font-weight: bold;
    width: fit-content;
    box-sizing: border-box;
    max-height: 0;
    overflow: hidden;
    opacity: 0;
    transition: max-height 0.4s ease-in-out, opacity 0.2s ease-in-out 0.1s, padding-top 0.4s ease-in-out, padding-bottom 0.4s ease-in-out;
}

#control-panel.visible {
    max-height: 1000px; /* Large enough to accommodate content */
    opacity: 1;
    padding: 5px;
    transition: max-height 0.4s ease-in-out, opacity 0.2s ease-in-out, padding-top 0.4s ease-in-out, padding-bottom 0.4s ease-in-out;
}

#control-panel.visible.scrollable {
    overflow-y: scroll;
    overflow-x: hidden;
}

#control-panel p {
    margin-top: 0px;
    margin-bottom: 0px;
}

.section-header {
    margin-bottom: 1px;
}

#control-panel label {
    display: flex;
    cursor: pointer;
    font-weight: 600;
    align-items: center;
}

#control-panel input[type="radio"] {
    vertical-align: middle; /* Aligns the checkbox with the text */
    margin: 0 5px 0 0;
}

#control-panel label:hover {
    background: rgba(255, 255, 255, 0.4);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    transform: translateX(3px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
}

#control-panel label {
    transition: all 0.2s ease;
    padding: 1px 5px;
    margin: 0.5px 0;
    border-radius: 8px;
}

#control-panel select {
    background-color: transparent;
    background-image: url('data:image/svg+xml;utf8,<svg fill="%23333" height="12" viewBox="0 0 12 12" width="12" xmlns="http://www.w3.org/2000/svg"><path d="M6 9L1 4h10z"/></svg>');
    background-repeat: no-repeat;
    background-position: right center;
    border: none;
    border-bottom: 1px solid rgba(0, 0, 0, 0.2);
    border-radius: 0;
    padding: 0;
    padding-right: 18px; /* Space for dropdown arrow */
    margin-left: 5px;
    font-family: 'Livvic', sans-serif;
    font-weight: 600;
    font-size: inherit;
    color: #333;
    cursor: pointer;
    transition: all 0.2s ease;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    text-align: left;
    text-align-last: left;
}

#control-panel select option {
    padding: 0;
    margin: 0;
}

#control-panel select:hover {
    background-color: transparent !important;
    background-image: url('data:image/svg+xml;utf8,<svg fill="%23333" height="12" viewBox="0 0 12 12" width="12" xmlns="http://www.w3.org/2000/svg"><path d="M6 9L1 4h10z"/></svg>');
    background-repeat: no-repeat;
    background-position: right center;
    border-bottom: 1px solid rgba(0, 0, 0, 0.4);
}

#control-panel select:focus {
    outline: none;
    background-color: transparent !important;
    background-image: url('data:image/svg+xml;utf8,<svg fill="%23333" height="12" viewBox="0 0 12 12" width="12" xmlns="http://www.w3.org/2000/svg"><path d="M6 9L1 4h10z"/></svg>');
    background-repeat: no-repeat;
    background-position: right center;
    border-bottom: 1px solid rgba(100, 150, 255, 0.6);
}

#control-panel select:active {
    background-color: transparent !important;
    background-image: url('data:image/svg+xml;utf8,<svg fill="%23333" height="12" viewBox="0 0 12 12" width="12" xmlns="http://www.w3.org/2000/svg"><path d="M6 9L1 4h10z"/></svg>');
    background-repeat: no-repeat;
    background-position: right center;
}

#species-select {
    margin-left: 0;
    width: 100%;
    font-family: livvic;
    font-weight: bold;
}

#biomass-label {
    color: green;
}

#species-label {
    color: mediumvioletred;
}

#soil_nitrogen-label {
    color: blue;
}

#soil_organic_carbon-label {
    color: brown;
}

#soil_pH-label {
    color: purple;
}

hr {
    border: none;           /* Remove default border */
    border-top: 1px solid #ccc; /* Add a light gray line */
    margin: 6px 0;          /* Add vertical spacing */
}

.no-bottom-margin {
    margin-bottom: 0px;
}

#pixel-level-modalities-container {
    display: none;
    margin-bottom: 0px;
}

#hover-panel {
    display: none; /* Hide by default */
    position: absolute;
    box-sizing: border-box; /* Include padding and border in width/height */
    background: rgba(255, 255, 255, 0.25);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.3);
    padding: 10px;
    border-radius: 12px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1), 0 1px 3px rgba(0, 0, 0, 0.08);
    z-index: 1000;
    pointer-events: auto;
    overflow-y: scroll; /* Always show scrollbar for scrolling */
    overflow-x: hidden;
    font-family: livvic;
    font-size: 11px;
    font-weight: bold;
}

#hover-panel label {
    pointer-events: auto; /* Enable pointer events for the checkbox and label */
    cursor: pointer;
    display: flex;
    align-items: center;
}

#hover-panel input[type="checkbox"] {
    vertical-align: middle; /* Aligns the checkbox with the text */
    cursor: pointer;
}

#task-value-container {
    margin-top: 0px;
    margin-bottom: 5px;
}

#biomass-values-container {
    display: none;
    align-items: center;
}

#task-value-container input[type="checkbox"] {
    margin-left: 5px;
    margin-right: 5px;
}

#tile-level-modalities-container {
    margin-top: 10px;
}

#tile-level-modalities-container input[type="checkbox"] {
    margin: 0 10px 0 0;
}

#tile-level-modalities-data {
    display: none;
    margin-top: 5px;
    margin-bottom: 0;
    line-height: 20px;
}

.leaflet-control-zoom {
    border: 1px solid rgba(255, 255, 255, 0.2) !important;
    border-radius: 12px !important;
    overflow: hidden;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1), 0 1px 3px rgba(0, 0, 0, 0.08) !important;
    margin-top: 10px !important;
    margin-left: 10px !important;
}

.leaflet-control-zoom a {
    background: rgba(255, 255, 255, 0.15) !important;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: none !important;
    color: #333 !important;
    font-weight: 300 !important;
    font-family: Arial, sans-serif !important;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

.leaflet-control-zoom a:hover {
    background: rgba(255, 255, 255, 0.7) !important;
    transform: scale(1.15);
    box-shadow: 0 0 15px rgba(255, 255, 255, 0.6), 0 4px 8px rgba(0, 0, 0, 0.2) !important;
    transition: all 0.2s ease;
}

.leaflet-control-zoom a {
    transition: all 0.2s ease;
}

.leaflet-control-zoom a:first-child {
    border-top-left-radius: 12px;
    border-top-right-radius: 12px;
}

.leaflet-control-zoom a:last-child {
    border-bottom-left-radius: 12px;
    border-bottom-right-radius: 12px;
}

.leaflet-control-scale {
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
    font-family: livvic !important;
    font-size: 11px !important;
    margin-bottom: 10px !important;
    margin-left: 10px !important;
}

.leaflet-control-scale-line {
    border: 2px solid rgba(0, 0, 0, 0.5) !important;
    border-top: none !important;
    background: rgba(255, 255, 255, 0.3) !important;
    color: #333 !important;
    font-weight: bold !important;
}