/**
 * The input entry form
 */
.dokuwiki .struct_entry_form {
    margin-bottom: 1em;

    fieldset {
        width: 100%;
        padding: 0.5em 0;
        text-align: left;

        legend {
            text-align: left;
            padding-left: 17px;
            cursor: pointer;
            background: transparent url(../../images/open.png) 5px center no-repeat;
            font-weight: bold;
        }
    }

    fieldset.closed {
        padding: 0;

        div.field {
            display: none;
        }

        legend {
            display: block;
            background: transparent url(../../images/closed.png) 5px center no-repeat;
        }
    }

    div.field {
        display: flex;
        padding: 0.5em;

        &:hover {
            background-color: @ini_background_alt;
        }

        > label {
            text-align: left;
            font-weight: normal;
            width: 12em;
            flex-shrink: 0;

            span.label {
                padding-right: 16px;
                display: block;

                // fixes for bootstrap3 template
                color: @ini_text;
                font-size: 100%;
                text-align: left;


                &.hashint {
                    background: url(../../images/info.png) no-repeat right 5px top;
                }
            }
        }

        > span.input {
            display: flex;
            text-align: left;
            flex-grow: 1;
            flex-wrap: wrap;

            // general input fields
            input:not([type='checkbox']):not([type='color']),
            textarea,
            select {
                width: 100%;

                // smaller input types
                &.struct_media,
                &.struct_date {
                    width: 30%;
                }
            }

            // checkboxes
            label {
                margin-right: 1em;
                white-space: nowrap;
            }

            // wrap multi-value fields
            .multiwrap, .newtemplate {
                display: inline;
                width: fit-content;
            }

            // space multi-value fields
            .multiwrap {
                margin: 0 0.25em 0.25em 0;
            }

            // overlay media button on top of input field
            button.struct_media {
                width: 2.5em;
                margin-left: -2.5em;
            }

            // input hints
            small {
                display: block;
                color: @ini_text_alt;
            }
        }
    }
}

/*responsive - small screen*/
@media (max-width: 480px) {
    .dokuwiki .struct_entry_form div.field {
        flex-wrap: wrap;

        label {
            > span {
                text-align: left;
                width: 100%;
            }
        }

        span.input {
            width: 100%;
        }
    }
}

/**
 * Bureaucracy form adjustments
 */

.dokuwiki form.bureaucracy__plugin div.field {
    display: flex;
    justify-content: flex-end;

    label {
        clear: both; // this is somehow missing in the bootstrap template
        flex-grow: 1;
    }

    span {
        line-height: 2em;
        float: left;
        text-align: right;
    }

    span.label {
        vertical-align: top;
        width: 100%;

        // fixes for bootstrap3 template
        color: @ini_text;
        font-size: 100%;
    }

    span.input {
        width: 50%;
        display: inline-block;
        text-align: left;
        padding-left: 0.25em;
        color: @ini_text;

        input, select, textarea {
            width: 100%;
        }

        input[type='checkbox'] {
            width: auto;
            margin-right: 0;
        }

        label {
            text-align: left;
            line-height: 1.5em;
        }
    }
}

/*responsive - small screen*/
@media (max-width: 480px) {
    .dokuwiki form.bureaucracy__plugin div.field {
        flex-wrap: wrap;

        label {
            > span {
                text-align: left;
                width: 100%;
            }
        }

        span.input {
            width: 100%;
        }
    }
}

/**
 * Tabs in the Schema Editor
 */

#plugin__struct_delete,
#plugin__struct_json {
    border: 1px solid @ini_border;
    border-top: none;
    display: block;
    padding: 2em;

    fieldset {
        margin-bottom: 1em;
        width: 500px;

        label.block {
            font-weight: normal;
        }
    }
}

form.struct_newschema {
    label {
        display: block;
        text-align: left;

        span {
            display: inline-block;
            width: 45%;
            text-align: right;
            padding-right: 1em;
        }
    }
}

/**
 * The Schema Editor
 */

#plugin__struct_editor {
    table.inline {
        width: 100%;
        border-top: none;

        tr:first-child {
            border-top: none;

            th {
                border-top: none;
            }
        }
    }

    tr.disabled {
        td {
            opacity: 0.5;
        }

        // collapse config block
        td.config > div {
            overflow: auto;
            height: 2em;

            div.jsoneditor-outer {
                margin: 0;
                padding: 0;
            }
        }

        td.isenabled {
            opacity: 1;
        }
    }

    fieldset {
        width: 100%;
        padding-left: 0;
        padding-right: 0;
        margin-bottom: 1em;

        div.jsoneditor {
            margin: auto;
        }
    }
}

/**
 * In page output
 */

#plugin__struct_output {
    margin-right: 16em; // space for the TOC
    border: 1px solid @ini_border;
    margin-bottom: 1.2em;

    div.table {
        margin: 0;

        table {
            font-size: 90%;
            width: 100%;
            border: none;
            margin: 0;

            td, th {
                background-color: transparent;
                vertical-align: top;
                border: none;
            }

            tbody th {
                width: 20%;
                text-align: right;

                &::after {
                    content: ':';
                }
            }

            thead th {
                background-color: @ini_background_alt;
                text-align: center;
                font-size: 110%;
                font-weight: normal;
            }
        }
    }
}

/**
 * Aggregation
 */

.dokuwiki .structaggregation {

    &.structaggregationtable,
    &.structaggregationeditortable {
        table.inline td > *:last-child {
            margin-bottom: 0;
        }
    }

    &.structaggregationlist > ul li div {
        display: inline;

        p {
            display: inline;
            margin: 0;
        }
    }

    /* Indexed List */

    &.structaggregationlist.is-indexed > ul {
        list-style: none;
        display: flex;
        flex-wrap: wrap;
        padding: 0;
        gap: 0.5em;


        > li {
            flex: 1 1 30%;
            min-width: 18em;
            max-width: 100%;
            margin: 0;
            overflow: hidden;

            > div.li {
                font-size: 1.5em;
                font-weight: bold;
            }
        }
    }


    table th {
        a {
            color: @ini_link;
            font-weight: bold;

            &.sort-up::before {
                content: '↑';
            }

            &.sort-down::before {
                content: '↓';
            }

            &.next {
                float: right;
            }
        }

        input {
            width: 20px;
            background-image: url(../../tpl/dokuwiki/images/search.png);
            background-repeat: no-repeat;
            background-position: 2px center;
            padding-left: 20px;
        }

        input:not([value]) {
            opacity: 0.5;
        }

        input:focus {
            width: auto;
            opacity: 1;
        }
    }

    img.media {
        box-shadow: 1px 1px 5px 1px rgba(0, 0, 0, 0.5);
    }

    div.table {
        margin-bottom: 2.4em;
    }

    a.export {
        float: left;
        margin-top: -2.4em;
        margin-left: 1em;
        border: 1px solid @ini_border;
        border-top: none;
        border-bottom-right-radius: 4px;
        border-bottom-left-radius: 4px;
        padding: 2px 5px 2px 22px;
        background-position-x: 2px;
    }
}

.dokuwiki .structaggregationcloud {
    ul {
        text-align: center;

        li {
            list-style: none;
            margin: 0 1em 0 0;
            padding: 0;
            display: inline-block;

            .struct_color, .struct_media {
                a {
                    display: block;
                    height: 100%;
                }
            }

            .struct_media a {
                background-size: cover;
                background-position: center;
                box-shadow: 1px 1px 5px 1px rgba(0, 0, 0, 0.5)
            }
        }
    }
}

/**
 * Lookup Aggregation Editor
 */

.dokuwiki .structaggregationeditor {
    table.inline {
        min-width: 100%;

        th.action {
            width: 30px; //16px icon + margins
        }
    }
}

/**
 * General Output styles
 */

.dokuwiki div.struct_color {
    width: 1.2em;
    height: 1.2em;
    display: inline-block;
    margin-right: 0.5em;
}

/**
 * Inline Editor Overlay
 */

.dokuwiki .struct_inlineditor {
    position: absolute;
    top: 0;
    left: 0;
    width: 300px;

    background-color: @ini_background;
    color: @ini_text;
    border: 1px solid @ini_border;
    padding: 5px;

    box-shadow: 5px 5px 10px 0 rgba(0, 0, 0, 0.5);

    .ctl {
        margin-top: 5px;
    }

}

/**
 * Errors on AJAX
 */

.dokuwiki .structaggregationeditor form,
.dokuwiki .struct_inlineditor {
    .err {
        font-size: 90%;
        margin-top: 5px;
        padding: 5px;
        background-color: @ini_highlight;
        color: @ini_text;
        text-align: left;
    }
}

/**
 * Struct Filter
 */
.dokuwiki .structaggregationfilter {
    display: flex;
    flex-wrap: wrap;
    gap: 1em;
    box-sizing: border-box;

    details {
        position: relative;
        max-width: 30%;
        border: 1px solid transparent;
        padding: 0.25em 0.5em;
        cursor: pointer;

        &[open] {
            background-color: @ini_background_alt;

            ul {
                z-index: 10;
                min-width: 15em;
                border: 1px solid @ini_border;
            }
        }

        /** needed for Sprintdoc template */
        summary {
            display: list-item;
        }

        ul {
            left: -1px;
            right: -1px;
            position: absolute;
            padding: 0;
            background-color: @ini_background;
            max-height: 33vh;
            overflow-y: auto;

            li {
                margin: 0;
                text-overflow: ellipsis;
                overflow: hidden;
                padding: 0.25em 0.5em;

                &.active {
                    background-color: @ini_background_alt;
                    a {
                        font-weight: bold;
                    }
                }

                &:hover {
                    background-color: @ini_background_alt;
                }

                a {
                    display: block;
                }
            }
        }
    }
}
