html, body {
    height: 100%;
    margin: 0;
    padding: 0;
    overflow: hidden; /* Prevent body scrolling */
}

#header {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    background-color: #596861;
    color: white;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 5px 10px 5px 5px;
    z-index: 1000;
    box-shadow: 0 2px 4px rgba(0,0,0,0.3);
    font-size: 18px;
    box-sizing: border-box;
}

.header-left {
    padding-left: 5px;
}
.header-right {
    display: flex;
    gap: 5px;
}

.menu-tab {
    background-color: #b4cc90;
    color: rgba(0, 0, 0, 1);
    border: none;
    padding: 3px 5px;
    cursor: pointer;
    transition: background-color 0.3s;
    border-radius: 4px;
    font-size: 11px;
    white-space: nowrap;
}

.menu-tab:hover, .menu-tab.active {
    background-color: #596861;
    color: rgb(255, 255, 255);
}

#viewDiv {
    position: absolute;
    top: 40px; 
    bottom: 0;
    width: 100%;
    overflow: hidden;
}

#layerListContainer {
    position: absolute;
    z-index: 1;
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}

#layerListToggle {
    display: none;
    width: 100%;
    padding: 10px;
    background-color: #0079c1;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
}

#overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 999;
    display: none;
}

#overlay.active {
    display: block;
}

#infoWindow {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background-color: white;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.3);
    z-index: 1000;
    width: 500px;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    font-size: 0.8rem;
    display: none;
}

#infoWindow.active {
    display: flex;
}

.info-box {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background-color: white;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.3);
    z-index: 1000;
    width: 500px;
    max-height: 80vh;
    display: none;
    flex-direction: column;
}

.info-box.active {
    display: flex;
}

.info-header {
    padding: 10px 20px; /* Reduced padding */
}

.info-header h2 {
    margin: 0;
    font-size: 1.2rem;
}

.info-content {
    padding: 0 20px 20px;
    overflow-y: auto;
    flex-grow: 1;
}

.info-content img {
    width: 100%;
    max-width: 100%;
    height: auto;
    margin-bottom: 15px;
}

.info-content p {
    font-size: 14px;
    line-height: 1.4;
    margin-bottom: 10px;
}

.info-footer {
    padding: 10px 20px;
    border-top: 1px solid #e0e0e0;
    text-align: right;
}

.info-footer button {
    padding: 5px 10px;
    background-color: #f0f0f0;
    border: 1px solid #ccc;
    cursor: pointer;
}

.image-container {
    width: 100%;
    max-width: 500px;
    aspect-ratio: 18 / 9;
    object-fit: cover;
    object-position: center;
}

@media screen and (max-width: 600px) {
    #initialInfoBox {
        width: 90%;
    }
    #layerInfoBox {
        width: 90%;
    }
}

#infoWindow p {
    font-size: 0.8rem;
    margin-bottom: 10px;
}

.hidden {
    display: none;
}

/* Ensure the layer list is always visible on desktop */
#layerList {
    display: block;
}

#desktopLayerList {
    position: absolute;
    bottom: 20px;
    left: 20px;
    z-index: 1;
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}

#mobileLayerListContainer {
    display: none;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 80%;
    max-height: 80%;
    overflow-y: auto;
    z-index: 2;
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}

#layerListToggle {
    display: none;
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 2;
    padding: 10px 20px;
    background-color: #0079c1;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
}

@media (max-width: 600px) {
    #desktopLayerList {
        display: none;
    }

    #layerListToggle {
        display: block;
    }
}

/* Hide the visibility toggle (eye icon) */
.esri-layer-list__item-toggle {
    display: none !important;
}

/* Style for active layer */
.active-layer > .esri-layer-list__item-container {
    background-color: #e6f2ff !important;
    border-left: 4px solid #0079c1 !important;
}

.active-layer > .esri-layer-list__item-container .esri-layer-list__item-title {
    font-weight: bold !important;
    color: #0079c1 !important;
}

/* Style for group layers */
.esri-layer-list__item--has-children > .esri-layer-list__item-container {
    font-weight: bold;
}

/* Indent sublayers */
.esri-layer-list__child-list > .esri-layer-list__item {
    padding-left: 20px;
}

/* Ensure the layer list items are clickable */
.esri-layer-list__item {
    cursor: pointer;
}

/* Override any conflicting styles */
.esri-layer-list__item-container {
    background-color: transparent !important;
}

.esri-layer-list__item-title {
    font-weight: normal !important;
    color: #000000 !important;
}

#customLayerList {
    position: absolute;
    bottom: 20px;
    left: 20px;
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
    padding: 10px;
    max-height: 80vh;
    overflow-y: auto;
    z-index: 1;
    width: 300px; /* Increased width */
    font-size: 12px; /* Smaller font size */
}

#activeLayerText, .togglediv {
    font-size: 12px;
    margin-bottom: 10px;
    font-weight: bold;
}

.layer-group h3 {
    margin: 0 0 10px 0;
    font-size: 16px;
    cursor: pointer; /* Make group titles clickable */
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.layer-group h3::after {
    content: "▼";
    font-size: 12px;
    transition: transform 0.3s;
}

.layer-group h3.group-open::after {
    transform: rotate(180deg);
}

.layer-group h3.group-closed::after {
    transform: rotate(0deg);
}

.layer-item {
    padding: 5px 2px 5px 10px;
    cursor: pointer;
    transition: background-color 0.3s;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.layer-item:hover {
    background-color: #f0f0f0;
}

.layer-item.active-layer {
    background-color: #e6f2ff;
    border-left: 4px solid #0079c1;
    font-weight: bold;
    color: #0079c1;
}

.layer-info-icon {
    margin-left: 5px;
    cursor: pointer;
}

.layer-item.hidden {
    display: none;
}

@media (max-width: 600px) {
    #customLayerList {
        display: none;
        position: fixed;
        bottom: 60px; /* Adjusted to be above the button */
        left: 10px; /* Slight margin from the left */
        right: 10px; /* Slight margin from the right */
        width: auto; /* Adjust width to fit within margins */
        max-height: 50%; /* Cover half the screen */
        overflow-y: auto; /* Ensure it scrolls if content overflows */
    }

    #layerListToggle {
        display: block;
        position: fixed;
        bottom: 10px; /* Adjusted to be at the bottom */
        left: 50%;
        transform: translateX(-50%);
        z-index: 2;
        padding: 10px 20px;
        background-color: #596861;
        color: white;
        border: none;
        border-radius: 4px;
        cursor: pointer;
    }

    .header-right {
        gap: 5px; /* Reduced gap for mobile */
    }
}

#menu {
    position: fixed;
    top: 0;
    right: 0; /* Changed to right */
    width: 300px;
    height: 100%;
    background-color: white;
    box-shadow: -2px 0 5px rgba(0,0,0,0.3); /* Adjusted shadow direction */
    z-index: 1001;
    display: flex;
    flex-direction: column;
    transform: translateX(100%); /* Adjusted transform direction */
    transition: transform 0.3s;
}

#menu.active {
    transform: translateX(0);
}

.menu-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 5px 10px; /* Reduced padding */
    background-color: #596861;
    color: white;
    font-size: 14px;
}

.menu-header h2 {
    margin: 0;
    font-size: 1rem; /* Adjusted font size */
}

.menu-content {
    flex-grow: 1;
    overflow-y: auto;
    padding: 10px;
}

.menu-tab-content {
    display: none;
}

.menu-tab-content.active {
    display: block;
}

.hidden {
    display: none;
}

/* Adjustments for mobile view */
@media (max-width: 600px) {
    #menu {
        width: 100%;
        height: 50%;
        bottom: 0;
        top: auto;
        right: 0; /* Ensure it opens from the bottom */
        transform: translateY(100%);
    }

    #menu.active {
        transform: translateY(0);
    }
}

.subcategory {
    font-size: larger;
    padding: 5px 2px;
}

input[type="checkbox"] {
    accent-color: #596861;
}

input[type="range"] {
    accent-color: #596861;
}

.slider {
    float: right;
 }
