$headerHeight: 34px;
$internalHeaderHeight: 34px;
$cardContentHeight: calc(100% - #{$headerHeight});
$cardContentHeightInternal: calc(100% - #{$internalHeaderHeight});

.cardPanel {
    background-color: transparent;
    box-shadow: 0px 1px 3px rgba(0, 0, 0, 0.15);
    border-radius: 5px;
    border: 1px solid silver;
    height: 100%;
    display: flex;
    flex-direction: column-reverse;
    flex: 1;
    max-width: 695px;
    position: relative;
}

.cardPanel.wide {
    max-width: 100%;
}

.cardPanel.internal {
    background-color: transparent;

    box-shadow: none;
    border: none;
    border-radius: 0;
    margin-bottom: 0;
}

.cardPanel.contentAutoHeight {
    height: auto;
}

.cardHeader {
    border-top-left-radius: 5px;
    border-top-right-radius: 5px;
    display: flex;
    justify-content: space-between;
    height: $headerHeight;
    align-items: center;
    padding: 0 2px 0 10px;
    border-bottom: 1px solid silver;
    overflow: hidden;

    &.themeDark {
        background-color: #E6E6E6;
    }

    &.themeLight {
        background-color: white;
        border-bottom: 0;
    }

    &.sticky {
        position: sticky;
        top: 0;
    }
}

.cardHeader.isCollapsed {
    border-bottom-left-radius: 5px;
    border-bottom-right-radius: 5px;
    border-bottom: 0;
}

.cardPanel.internal {
    .cardHeader.isCollapsed {
        border-bottom-left-radius: 0;
        border-bottom-right-radius: 0;
    }
    .collapseIcon {
        margin-right: 0;
    }
}

.cardPanel.internal > .cardHeader {
    padding: 0 0 2px 0;
    background-color: transparent;
    border-bottom-width: 1px;
    border-bottom-style: solid;
    border-bottom-color: silver;
    height: $internalHeaderHeight;
}

.cardPanel:not(.internal) {
    .collapseIcon {
        margin-left: 4px;
        margin-right: 8px;
        cursor: pointer;
        transition: transform .2s;
        line-height: 0;
    }
    & > .cardHeader {
        border-bottom-width: 0;
    }
}

.cardTitle {
    display: flex;
    align-items: center;
    font-weight: bold;
    text-transform: uppercase;
    font-family: 'PT Sans', serif;
}

.cardPanel.internal .cardTitle {
    background-color: transparent;
}

.leftItems {
    display: flex;
    overflow: hidden;
}

.leftExtraItemsContainer > :last-child:not(:empty) {
    margin-right: 5px;
}

.extraItemsContainer {
    display: flex;
    align-items: center;
}

.cardContent {
    background: #ffffff;
    border-bottom-left-radius: 5px;
    border-bottom-right-radius: 5px;
    padding: 15px 25px 35px 25px;
    overflow: auto;
    height: $cardContentHeight;
    // todo Brauer Ilya: create animations later
    //transition: height, padding .2s;

    &.flexRow {
        display: flex;
        flex-direction: row;
        justify-content: space-between;
        align-items: flex-start;

        &.flexWrap {
            display: grid;
            justify-content: space-around;

            @media (min-width: 1320px) {
                grid-template-columns: minmax(435px, 695px) minmax(435px, 695px);
                grid-template-rows: minmax(90%, 100%);
                grid-column-gap: 25px;
            }

            @media (max-width: 1319px) {
                grid-template-columns: minmax(435px, 695px);
                align-content: flex-start;
                justify-content: center;
            }
        }

        .childContainer {
            height: 100%;
            overflow: hidden;
            padding: 8px 8px 8px 8px;
            box-sizing: border-box;
            flex: auto;
            min-width: 300px;

            &.resizableContainer {
                flex-shrink: 0;
                flex-grow: 0;
            }
        }
    }

    &.flexColumn {
        display: flex;
        flex-direction: column;
    }

    :global(.ud-field) {
        padding-bottom: 10px;

        &:last-of-type {
            padding-bottom: 0;
        }
    }

    > .cardPanel:last-child > .cardContent.internal {
        padding-bottom: 0;
    }
}

.cardContent.internal {
    background-color: transparent;
    height: $cardContentHeightInternal;
    padding: 15px 15px 30px 15px;
}

.cardContent.noOverflow {
    overflow: hidden;
}

.cardContent.contentAutoHeight {
    height: auto;
}

.cardContent.isCollapsed {
    height: 0;
    overflow: hidden;
    padding: 0;
}

.cardContent.withoutHeader {
    border-radius: 5px;
    height: 100%;
}

.cardPanel.noBodyPadding, .cardContent.noBodyPadding {
    padding: 0;

    .cardContent:not(.internal) {
        padding: 0 0 0 0;
    }
}

.cardPanel.internal, .cardContent.internal {
    background-color: transparent;
}

.cardContainer {
    display: flex;
    &.verticalGroup {
        flex-direction: column;
    }

    .cardPanel, .cardHeader, .cardHeader.isCollapsed {
        border-radius: 0;
    }

    &.verticalGroup .cardPanel:not(:first-child) {
        margin-top: -1px;
    }
    &.horizontalGroup .cardPanel:not(:first-child) {
        margin-left: -1px;
    }

    &.horizontalGroup {
        .cardPanel {
            flex-grow: 1;
            &:first-child {
                border-top-left-radius: 5px;
                border-bottom-left-radius: 5px;

                .cardHeader {
                    border-top-left-radius: 5px;
                    &.isCollapsed {
                        border-bottom-left-radius: 5px;
                    }
                }
            }
            &:last-child {
                border-top-right-radius: 5px;
                border-bottom-right-radius: 5px;

                .cardHeader, .cardHeader.isCollapsed {
                    border-top-right-radius: 5px;
                }
            }
        }
    }

    &.verticalGroup {
        & > .cardPanel.internal:not(:first-of-type) {
            margin-top: 4px;
        }

        .cardPanel:not(.internal) {
            &:first-child {
                border-top-left-radius: 5px;
                border-top-right-radius: 5px;

                .cardHeader, .cardHeader.isCollapsed {
                    border-top-left-radius: 5px;
                    border-top-right-radius: 5px;
                }
            }
            &:last-child {
                border-bottom-left-radius: 5px;
                border-bottom-right-radius: 5px;

                .cardHeader.isCollapsed {
                    border-bottom-left-radius: 5px;
                    border-bottom-right-radius: 5px;
                }
            }
        }
    }
}

.gridLayout {
    .cardPanel.internal {
        border: 1px solid transparent;
    }
    .cardPanel.internal:hover {
        border: 1px solid #F2F2F2;
    }
}

.helperContainer {
    position: absolute;
    height: 43px;
    background-color: transparent;
    width: 43px;
    transition: height 0.3s, background-color 0.3s, width 0s 0.3s;

    &.showHelp {
        width: 100%;
        background-color: #efefef;
        border-bottom-left-radius: 5px;
        border-bottom-right-radius: 5px;
        border-top: 1px solid #e1e1e1;
        display: flex;
        align-items: flex-start;
        height: 114px;
        overflow: hidden;
        transition: height 0.3s, background-color 0.3s;
    }

    &.hideHelp {
        animation-name: hideHelp;
        animation-duration: 0.3s;
    }

    .helperIcon {
        margin: 12px;

        &:hover {
            cursor: pointer;
        }
    }

    .helperTextContainer {
        border-left: 1px solid grey;
        flex: auto;
        padding: 0 12px;
        margin: 12px 0;
        height: calc(100% - 24px);

        h3 {
            font-weight: bold;
            text-transform: uppercase;
            font-family: 'PT Sans', serif;
        }

        .helperText {
            column-count: 3;
            column-gap: 20px;
            overflow-y: auto;
            height: calc(100% - 20px);
        }
    }
}
