.pad-hidden{
    display: none;
    opacity: 0;
}

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

.pad-spinner {
    width: 50px;
    height: 50px;
    border: 5px solid #f3f3f3;
    border-top: 5px solid #3498db;
    border-radius: 50%;
    animation: pad-spin 1s ease-in-out infinite;
    margin: 20px auto;
}

li.pad-server-side-error{
    color: orangered;
}

li.pad-server-side-errors > a {
    color: orangered;
}

li.pad-invalid > a{
    color: darkred;
}

.pad-server-side-errors > :not(.pad-form-group, .pad-tab-content, .pad-input:not(.pad-server-side-errors)) {
    color: orangered;
}

.pad-invalid > :not(.pad-form-group, .pad-tab-content, .pad-input:not(.pad-invalid)) {
    color: darkred;
}

.pad-form{
    font-weight: 400;
    font-size: 14px;

    * {
        box-sizing: border-box;
    }

    .pad-submit-button{
        margin: 10px 0;
    }

    .pad-message{
        position:relative;
        border-left: 4px solid #00ff00;
        background-color: #ffffff;
        box-shadow: 0 1px 3px 0 rgba(0, 0, 0, .1);
        padding: 5px;
        border-radius: 2px;
        cursor: pointer;

        .pad-invalid &{
            border-left: 4px solid #ff0000;
        }

        .pad-close-button{
            position: absolute;
            top: 0;
            right: 0;
            padding: 2px;
            cursor: pointer;
            width: 15px;
            height: 15px;
            display: block;
            text-align: center;
            align-content: center;
            font-size: 12px;

            &.pad-hidden{
                display: none;
            }
        }

        .pad-error &{
            border-left: 4px solid #ff0000;
        }
    }

    p {
        margin: 0;
    }

    div.pad-warning {
        color: orange;
        margin: 0;
        padding-left: 20px;
    }

    h1 {
        font-size: 25px;
    }

    h2 {
        font-size: 18px;
    }

    .pad-popup-background {
        position: fixed;
        top: 0;
        left: 0;
        width: 100vw;
        height: 100vh;
        background-color: rgba(0, 0, 0, 0.5);
        z-index: 1000;
        cursor: pointer;
    }

    .pad-popup-group{
        border-top: 1px dashed gray;
        padding: 10px;
    }

    .pad-popup {
        position: fixed;
        top: max(5vh, 30px);
        left: max(5vw, 30px);
        max-height: min(calc(100vh - 60px), 90vh);
        width: min(calc(100vw - 60px), 90vw);
        background-color: white;
        padding: 10px 10px 40px 10px;
        border-radius: 5px;
        z-index: 1001;
        overflow-y: auto;

        .pad-popup-notice{
            min-height: 30px;
            width: calc(100% - 75px);
        }

        .pad-close-button{
            position: sticky;
            top: 0;
            cursor: pointer;
            display: block;
            text-align: center;
            align-content: center;
            font-size: 12px;
            z-index: 1;
            margin-left: auto;
            margin-bottom: -30px;

            &.pad-hidden{
                display: none;
            }

            :not(button)&{
                padding: 2px;
                width: 15px;
                height: 15px;
            }
        }
    }

    .pad-collapsible-group {
        padding: 10px 5px 10px 15px;
        border-top: 1px dashed gray;

        .pad-header-box{
            cursor: pointer;
        }

        .pad-header{
            font-weight: bold;
            font-size: 16px;
        }

        .pad-expand-arrow {
            display: inline-block;
            width: 0.8rem;
            height: 1rem;
            margin-left: -0.8rem;

            &.pad-hidden{
                display: none;
            }

            &::before{
                content: '';
                display: block;
                position: relative;
                top: 0.45em;
                transition-property: transform;
                transition-duration: 0.3s;
                transition-timing-function: ease-in-out;
                transform: rotate(135deg);
                width: 0.4em;
                height: 0.4em;
                border-top: solid 2px gray;
                border-right: solid 2px gray;
                border-top-right-radius: 1px;
            }

            .pad-collapsed &::before{
                transform: rotate(45deg);
            }
        }
    }

    .pad-question-cluster{
        display: grid;
        grid-template-columns: 3fr 7fr;
        grid-template-areas:
                "name description"
                ". questions";
        padding: 10px 0;

        &.pad-hidden{
            display: none;
        }

        & > .pad-name{
            grid-area: name;
            font-weight: bold;
        }

        & > .pad-description{
            grid-area: description;
        }

        & > .pad-questions{
            grid-area: questions;
            padding-left: 10px;
        }
    }

    .pad-input {
        display: grid;
        grid-template-columns: 3fr 7fr;
        grid-template-areas:
                "warnings warnings"
                "name input"
                ". description"
                ". notice";
        padding: 10px 0;

        &.pad-hidden{
            display: none;
        }

        .pad-block-settings &{
            grid-template-columns: 1fr;
            grid-template-areas:
                    "warnings"
                    "name"
                    "description"
                    "input"
                    "notice"
        }

        .pad-question-cluster &{
            grid-template-columns: 3fr 7fr;
            grid-template-areas:
                    "warnings warnings"
                    "input name"
                    ". notice";

            padding: 2px 0;
            border-top-width: 0;

            & > .pad-description{
                display: none;
            }
        }

        &.pad-bool-input{
            grid-template-columns: calc( 30% ) 20px calc(70% - 20px);
            grid-template-areas:
                    "warnings warnings warnings"
                    "name input description"
                    ". . notice";

            .pad-question-cluster &{
                grid-template-columns: 20px 1fr;
                grid-template-areas:
                    "warnings warnings"
                    "input name"
                    ". notice";
            }

            .pad-block-settings &{
                grid-template-columns: 20px calc( 100% - 20px );
                grid-template-areas:
                        "warnings warnings"
                        "name name"
                        "input description"
                        "notice notice"
            }
        }

        &.pad-radio-input{
            grid-template-columns: 30% 70%;
            grid-template-areas:
                    "warnings warnings"
                    "name description"
                    ". input"
                    ". customInput"
                    ". notice";

            .pad-block-settings &{
                grid-template-columns: 1fr;
                grid-template-areas:
                        "warnings"
                        "name"
                        "description"
                        "input"
                        "customInput"
                        "notice";
            }
        }

        &.pad-select-input{
            grid-template-columns: 30% 70%;
            grid-template-areas:
                    "warnings warnings"
                    "name description"
                    ". input"
                    ". customInput"
                    ". notice";

            .pad-block-settings &{
                grid-template-columns: 1fr;
                grid-template-areas:
                        "warnings"
                        "name"
                        "description"
                        "input"
                        "customInput"
                        "notice";
            }
        }

        .pad-radio-options{
            display: grid;
            grid-template-columns: 1fr;

            &.pad-hidden{
                display: none;
            }
        }

        .pad-multi-select-options{
            display: grid;
            grid-template-columns: 1fr;

            &.pad-hidden{
                display: none;
            }
        }

        .pad-layered-checkbox-options{
            display: grid;
            grid-template-columns: 1fr;

            &.pad-hidden{
                display: none;
            }
        }

        &.pad-layered-checkbox-input{
            grid-template-columns: 30% 70%;
            grid-template-areas:
                    "warnings warnings"
                    "name description"
                    ". input"
                    ". notice";

            .pad-layered-checkbox-children{
                display: grid;
                grid-template-columns: 1fr;
                padding-left: 20px;

                &.pad-hidden{
                    display: none;
                }
            }
        }

        &.pad-multi-select-input{
            grid-template-columns: 30% 70%;
            grid-template-areas:
                    "warnings warnings"
                    "name description"
                    ". input"
                    ". customInput"
                    ". notice";

            .pad-block-settings &{
                grid-template-columns: 1fr;
                grid-template-areas:
                        "warnings"
                        "name"
                        "description"
                        "input"
                        "customInput"
                        "notice";
            }
        }

        .pad-custom-input-container{
            grid-area: customInput;
            display: grid;
            grid-template-columns: 20px calc(100% - 20px);
            grid-template-areas:
                        "button input";

            &.pad-hidden{
                display: none;
            }

            .pad-add-custom-option{
                grid-area: button;
                align-self: end;
                cursor: pointer;
                height: 30px;
            }

            .pad-input{
                grid-area: input;
                grid-template-areas:
                        "name"
                        "warnings"
                        "input";
                grid-template-columns: 1fr;
                border-top-width: 0;
                padding: 0;

                .pad-notice-area{
                    display: none;
                }
                .pad-description{
                    display: none;
                }
                .pad-label{
                    font-size: 0.8rem;
                }
            }
        }

        .pad-warning {
            grid-area: warnings;
            color: red;
            margin: 0;
            padding-left: 20px;
            list-style: initial;
        }

        .pad-notice-area {
            grid-area: notice;
            margin: 0;
            color: gray;
        }

        .pad-description {
            grid-area: description;
            margin: 0;

            .pad-server-side-errors > & {
                color: orangered;
            }

            .pad-invalid > & {
                color: darkred;
            }
        }

        .pad-label {
            grid-area: name;
            font-weight: bold;

            .pad-question-cluster &{
                font-weight: inherit;
            }
        }

        .pad-input-field {
            grid-area: input;

            &[type="checkbox"] {
                justify-self: start;
                align-self: center;
            }
        }
    }

    .pad-form-group.pad-grouping {
        border-top: 1px dashed gray;

        & > .pad-input, & > .pad-form-group {
            margin-left: 10px;
        }
    }

    .pad-subgroup{
        padding-left: 10px;
    }

    .pad-input, .pad-question-cluster {
        border-top: 1px dashed gray;
    }

    .pad-radio-options{
        display: grid;

        &.pad-hidden{
            display: none;
        }
    }
}

@media (max-width: 768px) {
    .pad-form{
        input[type="checkbox"] {
            width: 20px;
            height: 20px;
            min-height: 20px;
        }

        .pad-input{
            grid-template-columns: 1fr;
            grid-template-areas:
                    "warnings"
                    "name"
                    "input"
                    "description"
                    "notice";
            grid-gap: 5px;

            &.pad-bool-input{
                grid-template-columns: 20px 1fr;
                grid-template-areas:
                    "warnings warnings"
                    "name name"
                    "input description"
                    ". notice";
            }
        }

        .pad-question-cluster {
            grid-template-columns: 1fr;
            grid-template-areas:
                    "name"
                    "description"
                    "questions";
            grid-gap: 5px;
        }
    }
}