:root{
    --background:#fff;
    --secondary-bacground: rgba(191, 221, 240, 1);
    --xunta-default:rgba(0, 123, 196, 1);
    --xunta-dark:rgba(0, 43, 74, 1);
    --secondary:rgba(95, 99, 99, 1);
    --shadow: -0.25rem 0 0.25rem 0 rgba(0, 0, 0, 0.15);
    --text-title:rgba(0, 43, 74, 1);
    --text-default:rgba(45, 50, 50, 1);
    --option-active:rgba(45, 50, 50, 1);
    --option-disable:rgba(151, 153, 153, 1);
    --disable-bg:rgba(243, 243, 246, 1);

    --default-bg:#fff;
    --default-color:#2D3232;
    
    --active-color:#fff;
    --hover-color:#fff;

    --header-bg:rgba(38, 44, 48, 0.7);
    --header-color:rgba(255, 255, 255, 1);
    --footer-bg:rgba(38, 44, 48, 0.7);
    --footer-color:rgba(255, 255, 255, 1);

    --header-height:1.5rem;
    --footer-height:3rem;

    font-size: 16px;
}
@media (min-width: 2000px){
    :root{
        font-size: calc(16px + 1vmin);
    }
}
@font-face {
    font-family: Xunta Sans;
    src: url(../font/XuntaSans-Regular.woff2);
    font-weight: normal;
}
@font-face {
    font-family: Xunta Sans;
    src: url(../font/XuntaSans-Bold.woff2);
    font-weight: bold;
}
*{
    font-family: Xunta Sans;
    outline: unset;
    -webkit-tap-highlight-color: transparent !important;
    box-sizing: border-box;
}

body{
    padding: 0;
    margin: 0;

    header{
        width: 100vw;
        height: var(--header-height);
        color: var(--header-color);
        background-color: var(--header-bg);
        display: flex;

        > div:first-child{
            flex-grow: 1;
        }

        > div:last-child{
            width: fit-content;
            margin-right: 2rem;

            .lang{
                width: fit-content;
                margin: 0 auto;
                font-family: Xunta Sans;
                font-size: 0.6875rem;
                font-weight: 400;
                line-height: 1.625rem;
                text-align: left;

                span{
                    height: 100%;
                    display: inline-block;
                    position: relative;
                    margin: 0 0.625rem;
                    cursor: pointer;
                }

                span:first-child::after{
                    content: '';
                    position: absolute;
                    right: -0.75rem;
                    top: 0.25rem;
                    height: 0.75rem;
                    width: 0.125rem;
                    background: var(--header-color);
                }
                span.active{
                    font-weight: 700;
                }
                span.active::before{
                    content: '';
                    display: block;
                    width: 100%;
                    height: 0.125rem;
                    background-color: var(--header-color);
                }
            }
        }
    }

    main{
        width: 100vw;
        height: calc(100dvh - var(--header-height) - var(--footer-height));
    }

    footer{
        width: 100vw;
        height: var(--footer-height);
        color: var(--footer-color);
        background-color: var(--footer-bg);

        div{
            margin: 0 auto;
            height: 100%;
            display: table;
            box-sizing: border-box;

            span{
                display: table-cell;
                vertical-align: middle;
                font-family: Xunta Sans;
                font-size: 0.625rem;
                font-weight: 400;
                line-height: 0.75rem;
                text-align: left;
            }
        }
    }

    #map-container,
    #map{
        width: 100%;
        height: 100%;
        cursor: pointer;
    }
    #map-container{
        position: relative;

        #map{
            .leaflet-popup-close-button{
                color: var(--active-color);
            }
            .leaflet-control-container{
                svg:not(.leaflet-attribution-flag){
                    margin: 0 auto;
                    display: block;
                    pointer-events: none;
                    width: 100%;
                    height: 100%;
                }
            }
            .leaflet-popup{
                box-shadow: 0.25rem 0.25rem 0.25rem 0 #00000026;

                .leaflet-popup-content-wrapper{
                    overflow: hidden;
                    padding: unset;

                    .leaflet-popup-content{
                        margin: 0;
                        min-width: 12rem;

                        p{
                            margin: 0.4em;
                        }

                        .custom-popup-content-header{
                            background-color: var(--xunta-default);
                            color: var(--active-color);
                            padding: 0.75rem;

                            p:first-child{
                                font-size: 0.7rem;
                                font-weight: 400;
                                line-height: 1.225rem;
                                text-align: left;
                            }
                            p:last-child{
                                font-size: 1.125rem;
                                font-weight: 700;
                                line-height: 1.35rem;
                                text-align: left;
                            }
                        }
                        .custom-popup-content-body{
                            padding: 0.75rem;

                            .custom-popup-content-body-ul{
                                list-style: none;
                                padding: 0;

                                li{
                                    margin: 1rem 0;

                                    p:first-child{
                                        font-size: 0.8125rem;
                                        font-weight: 700;
                                        line-height: 0.975rem;
                                        text-align: left;
                                        color: var(--xunta-dark);
                                    }
                                    p:last-child{
                                        font-size: 0.8125rem;
                                        font-weight: 400;
                                        line-height: 0.975rem;
                                        text-align: left;
                                        color: var(----default-color);
                                    }
                                }
                            }
                        }
                        .custom-popup-footer{
                            >div{
                                display: flex;
                                width: fit-content;
                                margin: 1rem auto;

                                >div{
                                    border: 0.1rem solid black;
                                    padding: 0.2rem 0.4rem 0.2rem 0.4rem;
                                    margin: 0rem 0.1rem 0rem 0.1rem;
                                    cursor: pointer;

                                    svg{
                                        display: block;
                                        pointer-events: none;
                                    }
                                }
                                >div:hover{
                                    background-color: var(--xunta-dark);
                                    color: var(--hover-color);
                                }
                                span{
                                    font-size: 1rem;
                                    line-height: 2rem;
                                    padding: 0rem 0.6rem;
                                }
                            }
                        }
                    }
                }
            }
            .home{
                width: 2rem;
                height: 2rem;
                background-color: var(--background);
                background-image: unset;
                /*background-image: url(../svg/home.svg);
                background-repeat: no-repeat;
                background-position: center;*/
                cursor: pointer;
            }
            .fullscreen{
                width: 2rem;
                height: 2rem;
                background-color: var(--background);
                background-image: unset;
                /*background-image: url(../svg/fullscreen.svg);
                background-repeat: no-repeat;
                background-position: center;*/
                cursor: pointer;
            }
            .legend.leaflet-control{
                .legend-button{
                    border: unset;
                    border-top-left-radius: 0.3125rem;
                    border-bottom-left-radius: 0.3125rem;
                    cursor: pointer;
                    width: 2rem;
                    height: 2rem;
                    box-shadow: var(--shadow);
                }
                .legend-container{
                    display: none;
                    position: absolute;
                    max-height: calc(100dvh - var(--header-height) - var(--footer-height));
                    margin-top: 0.5rem;
                    padding: 0.5rem, 1rem, 1rem, 1rem;
                    width: 22rem;
                    right: 0;
                    background-color: var(--default-bg);
                    box-shadow: -0.25rem 0 0.25rem 0 #00000026;
                    border-top: 0.125rem solid var(--xunta-default);
                    padding: 0.75rem;
                    text-align: left;
                }
            }
            .legend.leaflet-control.active{
                .legend-button{
                    background-color: var(--xunta-default);
                    color: var(--active-color);
                }
                .legend-container{
                    display: block;
                    box-sizing: border-box;
                    overflow-y: scroll;

                    p{
                        font-weight: bold;
                        text-decoration: underline;
                    }
                }
            }
            .leaflet-control,
            .leaflet-draw-toolbar.leaflet-bar{
                margin-right: 0;
                margin-left: 0;

                >a, >div.icon,
                a.leaflet-draw-draw-polyline,
                a.leaflet-draw-draw-polygon,
                a.leaflet-draw-draw-rectangle{
                    padding: 0.25rem 0;
                    background-color: var(--default-bg);
                    color: var(--default-color);
                }

                /*>a:hover, >div.icon:hover,
                a.leaflet-draw-draw-polyline:hover,
                a.leaflet-draw-draw-polygon:hover,
                a.leaflet-draw-draw-rectangle:hover{
                    background-color: var(--xunta-dark);
                    color: var(--hover-color);
                }*/

                a.leaflet-draw-toolbar-button-enabled,
                a.leaflet-draw-draw-polyline.leaflet-draw-toolbar-button-enabled,
                a.leaflet-draw-draw-polygon.leaflet-draw-toolbar-button-enabled,
                a.leaflet-draw-draw-rectangle.leaflet-draw-toolbar-button-enabled{
                    color: var(--active-color);
                    background-color: var(--xunta-default);
                    border-top-left-radius: unset;
                    border-bottom-left-radius: unset;
                }
            }
            .leaflet-control-attribution a{
                padding: 0 !important;
            }
            /*.leaflet-control-attribution a:hover{
                background-color: var(--default-bg) !important;
                color: var(--default-color) !important;
            }*/
            ul.leaflet-draw-actions{
                border-top-left-radius: 0.3125rem;
                border-bottom-left-radius: 0.3125rem;
                margin-top: 0.0625rem;

                li:first-child{
                    border-top-left-radius: 0.3125rem;
                    border-bottom-left-radius: 0.3125rem;
                }

                li a{
                    background-color: var(--xunta-default);
                    color: var(--active-color);
                    height: 2rem;
                    border-color: var(--active-color);
                }
                /*li a:hover{
                    background-color: var(--xunta-dark);
                }*/
            }
            .leaflet-draw-tooltip{
                color: var(--active-color);
                background-color: var(--xunta-dark);

                > span.leaflet-draw-tooltip-subtext{
                    color: var(--active-color);
                }
            }
            .leaflet-draw-tooltip:before{
                border-right-color: var(--xunta-dark);
            }
            .leaflet-tooltip{
                color: var(--xunta-dark);
            }
            .leaflet-right{
                *{
                    border-top-right-radius: 0;
                    border-bottom-right-radius: 0;
                    border-right: 0;
                }
            }
            .leaflet-left{
                *{
                    border-top-left-radius: 0;
                    border-bottom-left-radius: 0;
                    border-left: 0;
                }
            }
            .leaflet-control-layers.leaflet-control{
                border: unset;
                background: unset;
                pointer-events: none;

                > a{
                    display: block;
                    pointer-events: all;
                    width: 2rem;
                    height: 2rem;
                    background-color: var(--background);
                    background-image: unset;
                    /*background-image: url(../svg/layers.svg);
                    background-repeat: no-repeat;
                    background-position: center;*/
                    cursor: pointer;
                    border-top-right-radius: 0.25rem;
                    border-bottom-right-radius: 0.25rem;
                }
                .leaflet-control-layers-separator{
                    display: none;
                }
            }
            .leaflet-control-layers.leaflet-control.leaflet-control-layers-expanded{
                padding: 0;

                > a{
                    color: var(--active-color);
                    background-color: var(--xunta-default);
                    /*background-image: url(../svg/layers-active.svg);*/
                }

                section{
                    margin-top: 2.25rem;
                    background-color: var(--background);
                    padding: 1rem 1.125rem 1rem 0.5rem;
                    border-top: 0.125rem solid var(--xunta-default);
                    pointer-events: all;
                    box-shadow: 0.25rem 0 0.25rem 0 #00000026;

                    label{
                        margin-bottom: 1.25rem;
                    }

                    p{
                        font-size: 0.8125rem;
                        font-weight: 700;
                        line-height: 0.975rem;
                        text-align: left;
                        color: var(--text-title);
                    }

                    input {
                        cursor: pointer;
                        margin: 0 1rem;
                        width: 0.1rem;
                        height: 1px;
                    }
                    input[type="radio"]:after{
                        position: absolute;
                        width: 0.9076rem;
                        height: 0.9076rem;
                        border-radius: 100%;
                        top: -1rem;
                        left: -0.6rem;
                        background-color: var(--background);
                        content: '';
                        display: inline-block;
                        visibility: visible;
                        border: 0.2rem solid var(--background);
                        box-shadow: 0 0 0 0.16rem var(--secondary);
                    }
                    input[type='radio']:checked:after {
                        box-shadow: 0 0 0 0.16rem var(--xunta-default);
                        background-color: var(--xunta-default);
                    }
                    /*input[type='radio']:checked:before {
                        position: absolute;
                        width: 0.6875rem;
                        height: 0.6875rem;
                        border-radius: 1.25rem;
                        top: -0.22505rem;
                        left: 0.12505rem;
                        background-color: var(--xunta-default);
                        content: '';
                        display: inline-block;
                        visibility: visible;
                        z-index: 1;
                    }*/
                    input[type="checkbox"]:after{
                        position: absolute;
                        width: 1.8rem;
                        height: 1.5rem;
                        top: -0.125rem;
                        left: -0.6rem;
                        content: '';
                        display: inline-block;
                        visibility: visible;
                        background-color: var(--background);
                        background-image: url(../svg/layer-hidden.svg);
                        background-position: center;
                        background-repeat: no-repeat;
                        background-size: contain;
                    }
                    input[type='checkbox']:checked:after {
                        background-image: url(../svg/layer-visible.svg);
                    }
                    .leaflet-control-layers-overlays,
                    .leaflet-control-layers-overlays > div[data-group] > div[data-group]{
                        > label > span{
                            display: flex;
                            position: relative;

                            > span{
                                flex-basis: 68%;
                                margin: 0 1.3rem;
                                display: block;
                                word-break: break-all;
                            }
                        }
                        .opacity-control-button{
                            opacity: 0.7;
                            width: 1rem;
                            height: 1rem;
                            margin: 0 0.75rem;
                            background-image: url(../svg/opacity.svg);
                            background-position: center;
                            background-repeat: no-repeat;
                            background-size: contain;
                            cursor: pointer;
                        }
                        .opacity-control-button.active{
                            opacity: 1;
                        }
                        .opacity-control{
                            display: none;
                            z-index: 1;
                            position: absolute;
                            width: 14.25rem;
                            /*right: -14.5rem;*/
                            right: 2.5rem;
                            top: -1rem;
                            padding: 1.25rem 0.625rem 0.25rem 0.625rem;
                            border-radius: 0.1875rem;
                            background-color: var(--secondary-bacground);
                            box-shadow: 0.25rem 0.25rem 0.25rem 0 rgba(0, 0, 0, 0.14);
                        }
                        .opacity-control:before{
                            content:'';
                            position: absolute;
                            right: -0.625rem;
                            top: 1.25rem;
                            width: 0;
                            height: 0;
                            border-top: 0.375rem solid transparent;
                            border-bottom: 0.375rem solid transparent;
                            border-left: 0.625rem solid var(--secondary-bacground);
                        }
                        .opacity-control.active{
                            display: block;
                        }
                        .opacity-text-container{
                            display: flex;
                            font-family: Xunta Sans;
                            font-size: 0.8125rem;
                            font-weight: 400;
                            line-height: 0.975rem;
                            text-align: left;
                            color: var(--text-title);

                            > div:first-child{
                                flex-grow: 1;
                            }
                        }
                        input[type='range']{
                            margin: 0.375rem 0;
                            width: 100%;
                            accent-color: var(--xunta-default);
                        }
                    }
                    .leaflet-control-layers-overlays > div[data-group]{
                        padding-left: 1rem;

                        > span[data-group]{
                            color: var(--text-title);
                            font-weight: bold;
                        }

                        > div[data-group]{
                            padding-top: 1rem;
                            border: 0.1rem solid black;
                            border-radius: 0.3rem;
                            margin-bottom: 0.6rem;
                        }
                    }
                }
            }
            .leaflet-draw.leaflet-control{
                box-shadow: var(--shadow);

                .leaflet-draw-toolbar.leaflet-bar.leaflet-draw-toolbar-top{
                    border-bottom: unset;
                    border-bottom-left-radius: 0;
                    border-bottom-right-radius: 0;

                    a:last-child{
                        border-bottom-left-radius: 0;
                        border-bottom-right-radius: 0;
                    }
                }
                .leaflet-draw-section:nth-child(2) .leaflet-draw-toolbar.leaflet-bar{
                    border-top-left-radius: 0;
                    border-top-right-radius: 0;

                    a:first-child{
                        border-top-left-radius: 0;
                        border-top-right-radius: 0;
                    }
                }
                .leaflet-draw-toolbar.leaflet-bar{
                    border: 0;
                    margin: 0;
                }
                a.leaflet-draw-draw-polyline{
                    width: 2rem;
                    height: 2rem;
                    background-color: var(--background);
                    background-image: unset;
                    /*background-image: url(../svg/line.svg);
                    background-repeat: no-repeat;
                    background-position: center;
                    background-size: unset;*/
                }
                a.leaflet-draw-draw-polygon{
                    width: 2rem;
                    height: 2rem;
                    background-color: var(--background);
                    background-image: unset;
                    /*background-image: url(../svg/polygon.svg);
                    background-repeat: no-repeat;
                    background-position: center;
                    background-size: unset;*/
                }            
                a.leaflet-draw-draw-rectangle{
                    width: 2rem;
                    height: 2rem;
                    background-color: var(--background);
                    background-image: unset;
                    /*background-image: url(../svg/rectangle.svg);
                    background-repeat: no-repeat;
                    background-position: center;
                    background-size: unset;*/
                }
                a.leaflet-draw-edit-edit{
                    width: 2rem;
                    height: 2rem;
                    background-image: unset;
                    /*/background-image: url(../svg/edit.svg);
                    background-repeat: no-repeat;
                    background-position: center;
                    background-size: unset;*/
                }
                a.leaflet-draw-edit-remove{
                    width: 2rem;
                    height: 2rem;
                    background-image: unset;
                    /*background-image: url(../svg/delete.svg);
                    background-repeat: no-repeat;
                    background-position: center;
                    background-size: unset;*/
                }
                .leaflet-disabled{
                    cursor: not-allowed;
                    background-color: var(--disable-bg);
                    color: var(--option-disable);
                }
            }
            .leaflet-custom-group{
                border: unset;
                box-shadow: var(--shadow);

                > div{
                    margin: 0;
                    border: unset;
                }
                > div:first-child{
                    border-bottom-left-radius: 0;
                }
                > div:last-child{
                    border-top-left-radius: 0;

                    a:first-child{
                        border-top-left-radius: 0;
                    }
                }
                .leaflet-control-zoom-in{
                    width: 2rem;
                    height: 2rem;
                    background-color: var(--background);
                    background-image: unset;
                    /*background-image: url(../svg/zoomin.svg);
                    background-repeat: no-repeat;
                    background-position: center;*/

                    span{
                        display: none;
                    }
                }
                .leaflet-control-zoom-out{
                    width: 2rem;
                    height: 2rem;
                    background-color: var(--background);
                    background-image: unset;
                    /*background-image: url(../svg/zoomout.svg);
                    background-repeat: no-repeat;
                    background-position: center;*/

                    span{
                        display: none;
                    }
                }
            }
            .leaflet-bar a {
                border-bottom: unset;
            }
            .logo{
                background-color: var(--xunta-default);
                padding: 0.75rem;
                margin: 0.625rem;
                border-radius: 0.3125rem;

                div{
                    background-image: url(../svg/logo.svg);
                    background-size: contain;
                    background-repeat: no-repeat;
                    background-position: center;
                    width: 9.5rem;
                    height: 2.375rem;
                    pointer-events: none;
                }
            }
        }
        .loader {
            position: absolute;
            z-index: 9999999;
            top: 0.75rem;
            left: calc(50% - 2.125rem);
            display: none;
            border: 0.375rem solid var(--background);
            border-radius: 50%;
            border-top: 0.375rem solid var(--xunta-default);
            width: 4.25rem;
            height: 4.25rem;
            -webkit-animation: spin 2s linear infinite; /* Safari */
            animation: spin 2s linear infinite;
        }
        .loader.active{
            display: block;
        }
    }
}

@media (hover: hover){
    body{
        #map-container{
            position: relative;
    
            #map{
                .leaflet-control,
                .leaflet-draw-toolbar.leaflet-bar{    
                    >a:hover, >div.icon:hover,
                    a.leaflet-draw-draw-polyline:hover,
                    a.leaflet-draw-draw-polygon:hover,
                    a.leaflet-draw-draw-rectangle:hover{
                        background-color: var(--xunta-dark);
                        color: var(--hover-color);
                    }
                }
                .leaflet-control-attribution a:hover{
                    background-color: var(--default-bg) !important;
                    color: var(--default-color) !important;
                }
                ul.leaflet-draw-actions{
                    li a:hover{
                        background-color: var(--xunta-dark);
                    }
                }
            }
        }
    }
}

@media (max-width: 500) or (orientation: portrait){
    body{
        /*header > div:last-child {
            width: 190.125rem;
        }*/
        footer div {
            padding: 0.75rem;
        }
        #map-container{
            #map{
                .leaflet-left{
                    z-index: 9999;
                }
                .legend.leaflet-control{
                    .legend-button{
                        border-top-left-radius: 0;
                        border-bottom-left-radius: 0;
                        border-top-right-radius: 0.3125rem;
                        border-bottom-right-radius: 0.3125rem;
                        box-shadow: unset;
                    }
                }
                .legend.leaflet-control.active{
                    position: absolute;
                    top: 0;
                    left: 0;
                    margin: 0;
                    width: 100vw;
                    height: calc(100dvh - var(--header-height) - var(--footer-height));
                    background-color: var(--background);
                    border: unset;
                    border-radius: unset;
                    pointer-events: all;
                    box-sizing: border-box;

                    .legend-button{
                        margin: 0;
                        border:unset;
                        background-color: var(--default-bg);
                        width: 2.25rem;
                        height: 2.25rem;

                        position: absolute;
                        right: 0;

                        svg{
                            display: none;
                        }
                    }
                    .legend-button:after{
                        content:'';
                        display: block;
                        width: 100%;
                        height: 100%;
                        background-image: url(../svg/close.svg);
                        background-repeat: no-repeat;
                        background-size: contain;
                        background-position: center;
                    }
                    .legend-container{
                        margin: 0;
                        margin-top: 2.5rem;
                        box-shadow: unset;
                        border: unset;
                        width: 100%;
                        box-sizing: border-box;
                    }
                }
                .leaflet-control-layers.leaflet-control.leaflet-control-layers-expanded{
                    position: absolute;
                    top: 0;
                    left: 0;
                    margin: 0;
                    width: 100vw;
                    height: calc(100dvh - var(--header-height) - var(--footer-height));
                    background-color: var(--background);
                    border: unset;
                    border-radius: unset;
                    pointer-events: all;

                    ~ .legend{
                        display: none;
                    }

                    > a{
                        position: absolute;
                        right: 0;
                        background-color: var(--default-bg);
                        width: 2.25rem;
                        height: 2.25rem;

                        svg{
                            display: none;
                        }
                    }
                    > a:after{
                        content:'';
                        display: block;
                        width: 100%;
                        height: 100%;
                        background-image: url(../svg/close.svg);
                        background-repeat: no-repeat;
                        background-size: contain;
                        background-position: center;
                    }

                    section{
                        border: unset;
                        box-shadow: unset;

                        .opacity-control {                            
                            width: 94vw;
                            right: 0;
                            top: -1.625rem;
                            padding: 2.25rem 0.625rem 0.25rem 0.625rem;
                        }
                    }
                }
            }
        }
    }
}

@media (min-device-width: 500) and (orientation: portrait){
    a,div.icon{
        width: 60 !important;
        height: 60 !important;
    }
    body {
        #map-container {
            #map {
                .leaflet-control-container {
                    svg:not(.leaflet-attribution-flag) {
                        margin: 0 auto;
                        display: block;
                        pointer-events: none;
                    }
                }
                .legend.leaflet-control.active {
                    .legend-container {
                        margin: 0;
                        margin-top: 60.5rem;
                    }
                }
            }
        }
    }
}

/* Safari */
@-webkit-keyframes spin {
    0% { -webkit-transform: rotate(0deg); }
    100% { -webkit-transform: rotate(360deg); }
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}