/***** LEAFLET OVERRIDE *******************************************************/

.leaflet-container {
    font-family: inherit;
    font-size: 12pt;
}

.leaflet-control-attribution {
    height: 0;
}

.leaflet-popup-content-wrapper {
    background: var(--bg-primary);
    color: inherit;
    border-radius: .4rem;
}

.leaflet-popup-close-button {
    height: 34px !important;
    line-height: 30px !important;
}

.leaflet-popup-content {
    margin: 0;
}

.leaflet-popup-tip {
    background: var(--bg-secondary);
}

/***** LAYOUT *****************************************************************/

.map-layout {
    display: flex;
    flex-direction: row;
    height: 100%;
}

.map-layout>*{
    width: 100%;
}

/***** DASHBOARD **************************************************************/

.map-dashboard {
    box-sizing: border-box;
    flex-basis: 350px;
    border-right: 1px solid var(--border-primary);
    background: var(--bg-primary);
    flex-shrink: 0;
    padding: .4rem;
    display: flex;
    flex-direction: column;
    gap: .4rem;
    flex-grow: 0;
    overflow: hidden;
}

.map-layout.embedded .map-dashboard {
    position: absolute;
    top: .2rem;
    left: .2rem;
    z-index: 401;
    max-width: 25%;
    border-radius: .4rem;
    max-height: 80%;
}

.map-header {
    display: flex;
    align-items: baseline;
    gap: .2rem;
}

.map-title {
    font-weight: bold;
}

.map-layers {
    display: flex;
    flex-direction: column;
    gap: .2rem;
    flex-basis: 100%;
    flex-shrink: 1;
    overflow: auto;
}

.map-layer {
    padding: .4rem;
    border-radius: .2rem;
    background: var(--bg-primary-alt);
    border: 1px solid var(--border-primary);
}

.map-layer.selected {
    background: var(--bg-accent);
}

.map-layer-summary {
    display: flex;
    width: 100%;
    user-select: none;
    align-items: baseline;
}

.map-layer-toggle {
    margin-right: .2rem;
    width: 19px;
    transform-origin: 6px 8px;
}

.map-layer.open .map-layer-toggle {
    transform: rotate(90deg);
}

.map-layer.open .map-layer-title {
    font-weight: bold;
}

.map-layer-label {
    width: 100%;
}

.map-layer-summary input[type=text] {
    width: fit-content;
    border-radius: .2rem;
    height: 19px;
    padding: 0;
    background: none;
}

.map-layer-visible,
.map-layer-summary .dropdown-toggle {
    color: var(--text-muted);
}

.map-layer-count {
    margin-left: .2rem;
    font-size: small;
}

.map-features {
    padding: 0;
    list-style: none;
    margin: .2rem 0 0 0;
    line-height: 1.6 !important;
    display: flex;
    flex-direction: column;
}

.map-layer:not(.open) .map-features {
    display: none;
}

.map-feature {
    cursor: pointer;
    overflow: hidden;
    user-select: none;
    display: flex;
    gap: .2rem;
}

.map-feature i {
    color: var(--text-muted);
}

.map-feature-label {
    width: 100%;
    height: 1.6rem;
}

.map-feature-buttons {
    display: none;
    gap: .1rem;
    flex-shrink: 0;
}

.map-feature:hover .map-feature-buttons {
    display: inline;
}

.map-feature-buttons button {
    padding: 0;
    border: none;
    border-radius: .1rem;
    background: none;
    color: var(--text-muted);
}

/***** MAP ********************************************************************/

.map-container {
    height: 100%;
    display: flex;
    flex-direction: row;
}

.marker-icon {
    background: none;
    border: none;
}

.contextmenu {
    z-index: 1000;
}

/***** FEATURES POPUP *********************************************************/

.feature-popup {
    display: flex;
    flex-direction: column;
    font-size: 16px;
}

.feature-popup-header {
    display: flex;
    flex-direction: column;
    background: var(--bg-secondary);
    padding: .4rem 1.4rem .4rem .4rem;
}

.feature-label {
    padding: 0 !important;
}

.feature-layer-label {
    font-size: small;
    font-style: italic;
}

.feature-geometry::before {
    content: " ";
}

.feature-geometry {
    font-size: small;
    color: var(--text-muted);
}

.feature-properties-wrapper {
    max-height: min(500px, 40vh);
    overflow: auto;
    border-top: 1px solid var(--border-secondary);
}

.feature-properties {
    display: flex;
    flex-direction: column;
    width: 100%;
}

.feature-properties-wrapper:not(:has(.feature-property)) {
    display: none;
}

.feature-property:nth-child(even) {
    background: var(--bg-primary-alt);
}

.feature-property {
    display: flex;
}

.feature-property-label {
    font-weight: bold;
    text-transform: capitalize;
    width: 33%;
    padding: 0;
    overflow: auto;
}

.feature-property-value {
    width: 67%;
    padding: 0;
}

.feature-property-buttons {
    padding: 0 1ch 0 0;
    display: flex;
    align-items: center;
}

.feature-property > * > * {
    padding: .2rem .4rem;
}

.feature-property button {
    padding: 0;
    background: none;
    border: none;
    color: var(--text-muted);
}

.feature-buttons {
    background: var(--bg-secondary);
    padding: .2rem .4rem;
    border-top: 1px solid var(--border-secondary);
    display: flex;
    gap: .2rem;
}

.feature-buttons button {
    border: none;
    background: none;
    padding: .2rem;
}

.feature-buttons button:hover {
    background: var(--bg-secondary-hover);
}

/***** STYLE FORM *************************************************************/

.style-form {
    display: flex;
    gap: .4rem;
}

.style-form-dialog {
    padding: .2rem 0;
}

.style-form-popup {
    border-top: 1px solid var(--border-secondary);
    padding: .2rem .4rem .4rem .4rem;
}

.style-form-group {
    display: flex;
    flex-direction: column;
    flex-basis: content;
    flex-shrink: 0;
}

.style-form-inputs {
    display: flex;
    gap: .1rem;
    align-items: stretch;
    height: 100%;
}

.style-form-label {
    font-size: small;
    color: var(--text-muted);
}

.style-form input,
.style-form select {
    flex-shrink: 0;
    height: 100%;
}

.style-form input[type=color] {
    width: 2rem;
    padding: 0;
}

.style-form ::-webkit-color-swatch,
.style-form ::-moz-color-swatch {
    border: none;
}

.style-form input[type=number] {
    width: 4rem;
}

.style-form select {
    width: 3rem;
}

/***** SEARCH RESULTS *********************************************************/

.search-results {
    border-top: 1px solid var(--border-primary);
    background: var(--bg-primary-alt);
    padding: .4rem;
    display: flex;
    flex-direction: column;
    gap: .2rem;
}

.search-result {
    display: flex;
    gap: .4rem;
    padding: .4rem;
    border-radius: .2rem;
    cursor: pointer;
}

.search-result:hover,
.search-result.hover {
    background-color: var(--bg-primary-hover);
}

/***** RESPONSIVE LAYOUT ******************************************************/

@media (max-width: 500px) {

    .map-layout {
        flex-direction: column;
    }

    .map-dashboard {
        flex-basis: content;
        max-height: 40%;
        overflow: auto;
    }

    .map-layout.embedded .map-dashboard {
        max-width: 50%;
    }

    .map-layers {
        flex-shrink: 0;
        flex-basis: content;
    }

}