@import "../../../../css/static/mixin";
@import "../../../../css/static/properties";

html:root {
    --modal-content-background: #19191b;
}

.modal {
    color: var(--text); /* base color */

    overflow: auto; /* allow scrolling if a modal is too big */

    background-color: rgba(0, 0, 0, 0.8);

    padding-right: 5%;
    padding-left: 5%;

    z-index: 100000;
    position: fixed;

    top: 0;
    left: 0;
    right: 0;
    bottom: 0;

    display: flex;
    flex-direction: column;

    opacity: 0;
    margin-top: -1000vh;

    $animation_length: .3s;
    @include transition(opacity $animation_length ease-in, margin-top $animation_length ease-in);
    &.shown {
        margin-top: 0;
        opacity: 1;
    }

    &.align-top {
        justify-content: flex-start;
    }

    &.align-center {
        justify-content: center;
    }

    &.align-bottom {
        justify-content: flex-end;
    }

    .dialog {
        display: block;

        margin: 1.75rem 0;

        /* width calculations */
        align-items: center;

        /* height stuff */
        max-height: calc(100% - 3.5em);
    }
}

/* special modal types */
.modal {
    &.header-error .header {
        background-color: #800000;
    }

    &.header-info .header {
        background-color: #014565;
    }

    &.header-warning .header,
    &.header-info .header,
    &.header-error .header {
        border-top-left-radius: .125rem;
        border-top-right-radius: .125rem;
    }
}

.modal {
    .dialog {
        display: flex;
        flex-direction: column;
        justify-content: stretch;

        &.modal-dialog-centered {
            justify-content: stretch;
        }
    }
}

/* special general modals */
.modal {
    /* TODO! */
    .modal-body.modal-blue {
        border-left: 2px solid #0a73d2;
    }
    .modal-body.modal-green {
        border-left: 2px solid #00d400;
    }
    .modal-body.modal-red {
        border: none;
        border-left: 2px solid #d50000;
    }
}


.content {
    background: var(--modal-content-background);

    border: 1px solid black;
    border-radius: $border_radius_middle;

    width: max-content;
    max-width: 100%;
    min-width: 20em;

    min-height: min-content;
    max-height: 100%;

    flex-shrink: 1;
    flex-grow: 0; /* we dont want a grow over the limit set within the content, but we want to shrink the content if necessary */
    align-self: center;

    overflow: hidden;

    display: flex;
    flex-direction: column;
    justify-content: stretch;

    .header {
        background-color: #222224;

        flex-grow: 0;
        flex-shrink: 0;

        display: flex;
        flex-direction: row;
        justify-content: stretch;

        padding: .25em;

        .icon, .button {
            flex-grow: 0;
            flex-shrink: 0;
        }

        .button {
            height: 1.4em;
            width: 1.4em;

            padding: .2em;
            border-radius: .2em;

            cursor: pointer;

            -webkit-app-region: no-drag;
            pointer-events: all;

            &:hover {
                background-color: #1b1b1c;
            }
        }

        .icon {
            margin-left: .25em;
            margin-right: .5em;

            display: flex;
            flex-direction: column;
            justify-content: center;

            img {
                height: 1.2em;
                width: 1.2em;
                margin-bottom: .2em;
            }
        }

        .title, {
            flex-grow: 1;
            flex-shrink: 1;

            color: #9d9d9e;

            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
        }

        h5 {
            margin: 0;
            padding: 0;
        }
    }

    .body {
        max-width: 100%;
        min-width: 20em; /* may adjust if needed */

        min-height: 5em;

        overflow-y: auto;
        overflow-x: auto;

        display: flex;
        flex-direction: column;
        position: relative;

        /* explicitly set the background color so the next element could use background-color: inherited; */
        background: var(--modal-content-background);

        @include chat-scrollbar();
    }
}

.content {
    /* max-height: 500px; */
    min-height: 0; /* required for moz */
    flex-direction: column;
    justify-content: stretch;

    .header {
        flex-shrink: 0;
        flex-grow: 0;
    }

    .body {
        flex-grow: 1;
        flex-shrink: 1;
        display: flex;
        flex-direction: column;
        min-height: 0;
    }
}

.contentInternal {
    /* align us in the center */
    margin-right: auto;
    margin-left: auto;

    .body {
        max-height: calc(100vh - 8em); /* leave some space at the bottom */
    }
}