.panel,
.well {
    border-radius: var(--panel-border-radius);
    border-width: var(--panel-border-width);
    border-color: var(--panel-default-border);
}

.panel-body {
    padding: var(--panel-padding);
    .clearfix();
}

.panel-group {
    > .panel:first-child {
        border-top-left-radius: var(--panel-border-radius);
        border-top-right-radius: var(--panel-border-radius);
    }

    > .panel:last-child {
        border-bottom-left-radius: var(--panel-border-radius);
        border-bottom-right-radius: var(--panel-border-radius);
    }

    .panel + .panel {
        margin-top: var(--4px);
    }
}

.panel > .panel-body.panel-body-form {
    padding-bottom: calc(var(--panel-padding) - var(--form-group-margin-bottom));

    > .alert {
        margin-bottom: var(--form-group-margin-bottom);
    }

    > .button-container {
        padding-bottom: var(--12px);
    }
}

.panel-body > .no-margin {
    margin: calc(0rem - var(--panel-padding));
}

.panel-body > .no-side-margin .revert-margin {
    margin-left: var(--panel-padding);
    margin-right: var(--panel-padding);
}

.panel-body > .no-margin .revert-margin {
    margin: var(--panel-padding);
}

.panel-body.no-padding {
    padding-left: 0 !important;
    padding-top: 0 !important;
    padding-right: 0 !important;
    padding-bottom: 0 !important;
}

.modal-body {
    .panel.no-side-margin,
    .no-side-margin > .panel {
        border-left: 0;
        //border-right: 0;
        border-radius: 0;
    }

    .record.no-side-margin,
    .record-container.no-side-margin {
        > .panel {
            border-left: 0;
            border-right: 0;
            border-radius: 0;
        }

        .left > .middle > .panel,
        .left > .bottom > .panel {
            border-left: 0;
            border-top-left-radius: 0;
            border-bottom-left-radius: 0;

            &.first::before {
                border-top-left-radius: 0;
                border-bottom-left-radius: 0;
            }
            &.last::before {
                border-top-left-radius: 0;
                border-bottom-left-radius: 0;
            }

            @media screen and (max-width: @screen-xs-max) {
                &,
                &.first::before,
                &.last::before {
                    border-radius: 0;
                }
            }
        }

        .side > .panel {
            //border-right: 0;
            border-top-right-radius: 0;
            border-bottom-right-radius: 0;

            &.first::before {
                border-top-right-radius: 0;
                border-bottom-left-radius: 0;
            }
            &.last::before {
                border-top-right-radius: 0;
                border-bottom-right-radius: 0;
            }

            @media screen and (max-width: @screen-xs-max) {
                &,
                &.first::before,
                &.last::before {
                    border-radius: 0;
                }
            }
        }
    }

    .no-side-margin {
        .record-grid-wide {
            .left > .middle > .panel,
            .left > .bottom > .panel {
                //border-right: 0;
                border-top-right-radius: 0;
                border-bottom-right-radius: 0;

                &.first::before {
                    border-top-right-radius: 0;
                }
                &.last::before {
                    border-bottom-right-radius: 0;
                }
            }
        }
    }
}

.panel-body .no-side-margin {
    margin-left: calc(0rem - var(--panel-padding));
    margin-right: calc(0rem - var(--panel-padding));

    > table td:first-child,
    > table th:first-child {
        padding-left: var(--panel-padding);
    }

    > table td:last-child,
    > table th:last-child {
        padding-right: var(--panel-padding);
    }

    > .list-group-item {
        border-left-width: 0;
        border-right-width: 0;
    }

    > .table-bordered {
        border-left: 0;
        border-right: 0;

        td:last-child,
        th:last-child {
            border-right: 0;
        }

        td:first-child,
        th:first-child {
            border-left: 0;
        }
    }
}

.panel-body .no-bottom-margin {
    margin-bottom: calc(0rem - var(--panel-padding)) !important;
}

.panel {
    margin-bottom: var(--vertical-gap);

    > .panel-heading {
        min-height: var(--panel-heading-height);
        user-select: none;

        &.panel-heading-no-title {
            padding-top: var(--6px);
            padding-bottom: var(--6px);
        }

        padding-top: 0;
        padding-bottom: 0;

        > .panel-title {
            font-size: var(--panel-heading-font-size);

            line-height: 1.4;
            padding-top: calc((var(--panel-heading-height) - var(--panel-heading-font-size) * 1.4) / 2);
            padding-bottom: calc((var(--panel-heading-height) - var(--panel-heading-font-size) * 1.4) / 2);
            display: flex;
            white-space: nowrap;
            overflow: hidden;

            > span {
                white-space: nowrap;
                text-overflow: ellipsis;
                overflow: hidden;
            }
        }

        h4 {
            font-weight: 400;
        }

        > .btn-group {
            margin-top: calc((var(--panel-heading-height) - var(--30px)) / 2);
            right: var(--minus-10px);
        }

        .btn:not(.btn-link) {
            background-color: transparent;
            border-color: transparent;
            color: @gray-soft;
        }

        .open .btn {
            border-color: transparent;
        }

        .btn,
        .btn-default {
            &:active,
            &.active {
                .box-shadow(none);
            }

            &:hover,
            &:focus,
            &:active,
            &.active {
                // Prevents the issue that buttons can be visible through a dropdown opened nearby.
                z-index: 1;
            }
        }

        .btn-group .dropdown-toggle,
        .btn-group.open .dropdown-toggle
        {
            &,
            &:active {
                .box-shadow(none);
            }
        }

        > .link-group {
            > a {
                padding-left: var(--20px);
            }
            float: right;
        }

        > .btn-group > .btn + .dropdown-toggle {
            padding-left: var(--padding-small-horizontal);
            padding-right: var(--padding-small-horizontal);
        }
    }
}

body {
    .panel {
        > .panel-heading {
            .btn-group.open {
                > .btn[aria-expanded="true"] {
                    box-shadow: none;
                }
            }
            .btn {
                &:hover:active {
                    box-shadow: none;
                }
            }
        }
    }

    .panel-danger,
    .panel-success,
    .panel-primary,
    .panel-warning,
    .panel-info {
        > .panel-heading {
            .btn-group.open {
                > .btn[aria-expanded="true"] {
                    &,
                    &:active,
                    &:focus {
                        > .fas,
                        > .far {
                            color: var(--btn-text-color);
                        }
                    }
                }
            }
        }
    }


    .panel-styled(
        default;
        var(--panel-default-bg);
        var(--panel-bg);
        var(--panel-default-border);
        var(--gray-soft);
        var(--btn-text-color)
    );

    .panel-styled(
        warning;
        var(--panel-warning-bg);
        var(--panel-bg);
        var(--panel-warning-border);
        var(--panel-warning-text);
        var(--state-warning-text-10)
    );

    .panel-styled(
        danger;
        var(--panel-danger-bg);
        var(--panel-bg);
        var(--panel-danger-border);
        var(--panel-danger-text);
        var(--state-danger-text-10)
    );

    .panel-styled(
        success;
        var(--panel-success-bg);
        var(--panel-bg);
        var(--panel-success-border);
        var(--panel-success-text);
        var(--state-success-text-10)
    );

    .panel-styled(
        info;
        var(--panel-info-bg);
        var(--panel-bg);
        var(--panel-info-border);
        var(--panel-info-text);
        var(--state-info-text-10)
    );

    .panel-styled(
        primary;
        var(--panel-primary-bg);
        var(--panel-bg);
        var(--panel-primary-border);
        var(--panel-primary-text);
        var(--gray-lighter)
    );
}

.panel {
    border-width: var(--panel-border-width);

    .panel-heading {
        h4.panel-title span.color-icon {
            font-size: 61%;
            position: relative;
            left: 0;
            top: var(--minus-2px);
            margin-right: var(--2px);
        }
    }
}

.panel.sticked {
    margin-top: calc(-1 * var(--vertical-gap));
    border-top-width: max(var(--panel-border-width), var(--1px));
}

.panel {
    > .panel-heading {
        .btn:hover:not(.btn-link),
        .btn:focus:not(.btn-link) {
            color: var(--btn-text-color);
            > .fa,
            > .fas,
            > .far {
                color: var(--btn-text-color);
            }
        }
    }
}

.panel {
    > .panel-heading {
        border-top-left-radius: var(--panel-border-radius);
        border-top-right-radius: var(--panel-border-radius);
    }

    > .panel-body {
        .list.bottom-border-radius,
        > .list-container:last-child > .list {
            border-bottom-left-radius: var(--panel-border-radius);
            border-bottom-right-radius: var(--panel-border-radius);

            > table:not(:has(+ .show-more)),
            > table:has(+ .show-more.hidden),
            > .list-group,
            > .list-group:last-child > .list-group-item:last-child,
            > .show-more > a {
                border-bottom-left-radius: var(--panel-border-radius);
                border-bottom-right-radius: var(--panel-border-radius);
            }

            > table:not(:has(+ .show-more)) tr:last-child,
            > table:has(+ .show-more.hidden) tr:last-child {
                > td:first-child {
                    border-bottom-left-radius: var(--panel-border-radius);
                }

                > td:last-child {
                    border-bottom-right-radius: var(--panel-border-radius);
                }
            }
        }

        > .no-margin > table {
            border-bottom-left-radius: var(--panel-border-radius);
            border-bottom-right-radius: var(--panel-border-radius);
        }
    }

    &.first,
    &.in-middle {
        > .panel-body > .list-container:last-child > .list {
            border-bottom-left-radius: 0;
            border-bottom-right-radius: 0;

            > table,
            > table tr:last-child td,
            > .list-group,
            > .list-group:last-child > .list-group-item:last-child,
            > .show-more > a {
                border-bottom-left-radius: 0;
                border-bottom-right-radius: 0;
            }
        }
    }
}

.panel-styled(@style; @panel-style-bg; @panel-bg; @panel-style-border; @panel-style-text; @hover-color) {
    .panel-@{style} {
        &.headered {
            background: linear-gradient(
                to bottom,
                @panel-style-bg 0,
                @panel-style-bg var(--29px),
                @panel-bg var(--29px),
                @panel-bg 100%
            );
        }

        border-color: @panel-style-border;
        > .panel-heading {
            color: @panel-style-text;
            background-color: @panel-style-bg;
            border-color: transparent;
            .btn:not(.btn-link),
            .btn-@{style}:not(.btn-link) {
                &,
                &:focus:not(:hover),
                &:active:not(:hover) {
                    color: @panel-style-text;
                    background-color: transparent;
                    border-color: transparent;
                    > .fas,
                    > .far {
                        color: inherit;
                    }
                }
                &:hover {
                    color: @hover-color;
                    > .fas,
                    > .far {
                        color: inherit;
                    }
                }
            }
            .btn-group,
            .btn-group.open {
                .dropdown-toggle.btn {
                    &,
                    &:focus {
                        color: @panel-style-text;
                        background-color: transparent;
                        border-color: transparent;
                    }
                    &:hover {
                        color: @hover-color;
                    }
                }
            }
            .btn-group.open {
                .dropdown-toggle.btn {
                    color: @hover-color;
                    > .fas,
                    > .far {
                        color: @hover-color !important;
                    }
                }
            }
        }
    }
}

.panel {
    > .table:first-child,
    > .table-responsive:first-child > .table:first-child {
        .border-top-radius(var(--panel-border-radius));

        > thead:first-child,
        > tbody:first-child {
            > tr:first-child {
                border-top-left-radius: var(--panel-border-radius);
                border-top-right-radius: var(--panel-border-radius);

                td:first-child,
                th:first-child {
                    border-top-left-radius: var(--panel-border-radius);
                }

                td:last-child,
                th:last-child {
                    border-top-right-radius: var(--panel-border-radius);
                }
            }
        }
    }

    > .table:last-child,
    > .table-responsive:last-child > .table:last-child {
        .border-bottom-radius(var(--panel-border-radius));

        > tbody:last-child,
        > tfoot:last-child {
            > tr:last-child {
                border-bottom-left-radius: var(--panel-border-radius);
                border-bottom-right-radius: var(--panel-border-radius);

                td:first-child,
                th:first-child {
                    border-bottom-left-radius: var(--panel-border-radius);
                }

                td:last-child,
                th:last-child {
                    border-bottom-right-radius: var(--panel-border-radius);
                }
            }
        }
    }
}

.panel-group-accordion > .panel {
    overflow: hidden;
}

.panel > .panel-body > .list-container > {
    > .list > .list-group {
        > .list-group-item {
            border-width: 0;
            border-bottom-width: var(--1px);
        }

        > li.list-group-item:first-child {
            border-top-width: var(--1px);
            border-top-color: transparent;
        }

        > li.list-group-item:last-child {
            border-bottom-width: 0;
        }
    }

    &:has(+ .list-container) {
        > .list > .list-group {
            > li.list-group-item:last-child {
                border-bottom-width: var(--1px);
            }
        }
    }
}

.panel > .panel-heading {
    .panel-actions-container-left {
        margin-left: calc(var(--10px) * -1);
    }

    .panel-actions-container {
        > span {
            display: inline-block;
            padding: var(--4px) var(--10px);
            font-size: var(--14px);
            line-height: 1.5;
            float: left;
        }

        > .btn-sm {
            .fas, .far {
                font-size: var(--14px);
            }
        }
    }
}

.panel.highlighted {
    outline: var(--2px) solid var(--brand-info);
    outline-offset: var(--minus-1px);
}
