@import '../../styles/variables';
@import '../../styles/mixins/buttons';

/**************************************
 * Modal
 **************************************/
@keyframes popup_bounce_in {
    0% {
        transform: scale3d(0.1, 0.1, 1);
    }

    100% {
        transform: scale3d(1, 1, 1);
    }
}

// Container modal div
.modal {
    position: fixed;
    inset: 0;
    z-index: $modal-dialog-z-index;
    display: flex;
    flex: 1;
    align-items: center;
    padding: 30px;
    overflow: auto;
    outline: 0;

    .modal-dialog {
        border: none;
        box-shadow: none;
        animation: popup_bounce_in 0.3s;
    }

    .modal-header {
        margin-right: 20px;
    }

    hr {
        margin: 20px 0;
        border: none;
        border-top: 1px solid $bdl-gray-20;
    }
}

.modal-dialog-container {
    flex-basis: 100%;
    width: 100%;
    margin: auto;
}

.modal-dialog {
    position: relative;
    display: flex;
    flex-direction: column;
    width: 460px;
    max-width: 100%;
    margin: auto;
    padding: 30px;
    background-color: $white;
    background-clip: padding-box;
    border-radius: $bdl-border-radius-size-xlarge;
    box-shadow: 0 1px 1px 1px fade-out($black, 0.95);
}

.modal-title {
    display: inline-block;
    flex: 1;
    max-width: 100%;
    margin: 0;
    overflow: hidden;
    font-weight: bold;
    font-size: 16px;
    line-height: inherit;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.modal-content {
    margin-top: 20px;
}

.modal-back-button {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    background: none;
    border: 0;
    transform: rotate(180deg);
    cursor: pointer;
}

.modal-back-button + .modal-title {
    margin-left: 12px;
}

.modal-close-button {
    position: absolute;
    top: 20px;
    right: 20px;
    padding: 2px;
    color: $bdl-gray-50;
    font-weight: bold;
    font-size: 11px;
    background: none;
    border: 0;
    cursor: pointer;
}

.modal-backdrop {
    position: fixed;
    inset: 0;
    z-index: -1; // .modal creates a new stacking context. Let's just make sure that backdrop is below dialog.
    background: fade-out($black, 0.25);
}

.modal-actions {
    display: flex;
    flex: none;
    align-items: center;
    justify-content: flex-end;
    margin-top: 30px;
    text-align: right;

    .btn:last-of-type {
        margin-right: 0;
    }

    .btn {
        @include bdl-Button--large;

        margin-top: 0;
        margin-bottom: 0;
    }
}

.modal-container {
    position: fixed;
    inset: 0;
    z-index: 89;
    display: flex;
}

@include breakpoint($small-medium-screen) {
    $responsive-modal-header-height: 64px;
    $responsive-modal-actions-height: 60px;

    .modal-title {
        @include bdl-lineClamp(2);
    }

    .modal {
        flex-direction: column;
        padding: 0;
    }

    .modal-header-container {
        position: absolute;
        top: 0;
        left: 0;
        display: flex;
        align-items: center;
        width: 100%;
        height: $responsive-modal-header-height;
    }

    .modal-header {
        display: flex;
        align-items: center;
        padding: 0 16px;
    }

    .modal-content {
        flex-basis: 100%;
        margin-top: $responsive-modal-header-height;
        margin-bottom: $responsive-modal-actions-height;
        padding: 24px 16px 12px;
        overflow: auto;
    }

    .modal-dialog {
        height: 100%;
        padding: 0;
        border-radius: 0;
    }

    .modal-close-button {
        top: 0;
        right: 10px;
        display: flex;
        align-items: center;
        height: 100%;
        padding: 20px 0;
    }

    .modal-actions {
        position: fixed;
        right: 0;
        bottom: 0;
        width: 100%;
        height: $responsive-modal-actions-height;
        padding: 10px 16px;
        background-color: $white;
    }

    .modal-dialog-container {
        overflow: hidden;
    }
}
