@import './colors';
@import './functions';
@import './mixins';
@import './icons';

$modal-padding: 15px 25px;
$modal-tight-padding: 15px;
$header-footer-height: 55px;
$header-footer-height-tight: 45px;
$stacked-footer-height: 101px;
$modal-border: 1px solid $gray-200;

@mixin hc-modal-outer() {
    align-items: center;
    bottom: 0;
    display: flex;
    justify-content: center;
    left: 0;
    position: fixed;
    right: 0;
    top: 0;
}

@mixin hc-modal() {
    display: flex;
    flex-direction: column;
    justify-content: center;
    position: relative;
}

@mixin hc-modal-responsive() {
    @include media-breakpoint-down(md) {
        max-height: 100%;
        height: 100%;
        justify-content: flex-end;
    }

    &.hc-modal-auto {
        @include media-breakpoint-down(md) {
            width: 100%;
            justify-content: flex-end;
        }
    }

    .hc-modal-footer {
        @include media-breakpoint-down(md) {
            flex-direction: column-reverse;
        }

        .hc-button {
            @include media-breakpoint-down(md) {
                margin-left: 0;
                width: 100%;
            }
        }
    }

    .hc-modal-content {
        @include media-breakpoint-down(md) {
            // !important is necessary here to override inline height/width values set by resize
            height: calc(100% - 53px) !important;
            width: 100vw !important;
            border-radius: 0;
        }
    }

    .hc-modal-center-component {
        @include media-breakpoint-down(md) {
            justify-content: flex-end;
        }
    }
}

@mixin hc-modal-auto() {
    width: auto;
    justify-content: center;
}

@mixin hc-modal-sm() {
    width: 300px;
    height: auto;
    border-radius: 6px;

    & .hc-modal-footer {
        justify-content: flex-end;
        flex-direction: row;
        position: relative;
    }
    & .hc-modal-header {
        justify-content: flex-start;
    }
    & .hc-modal-content {
        border-radius: 6px;
    }
    & .hc-modal-body {
        margin-bottom: 0;
    }
}

@mixin hc-modal-md() {
    width: 500px;
}

@mixin hc-modal-lg() {
    width: 768px;
}

@mixin hc-modal-xl() {
    width: 992px;
}

@mixin hc-modal-drag-handle() {
    position: absolute;
    left: 0;
    top: 0;
    cursor: move;
    width: 25px;
    height: 54px;

    background-image: url($ico-grip);
    background-repeat: no-repeat;
    background-position: center;

    // Drag handle is hidden when the modal switches to full-screen on smaller breakpoints
    @include media-breakpoint-down(md) {
        display: none;
    }
}

@mixin hc-modal-drag-handle-tight {
    height: 46px !important;
}

@mixin hc-modal-header() {
    align-items: center;
    border-bottom: $modal-border;
    color: $text;
    display: flex;
    font-size: calculateRem(18px);
    font-weight: 600;
    min-height: $header-footer-height;
    padding: $modal-padding;
    justify-content: flex-start;
}

@mixin hc-modal-header-tight() {
    font-size: calculateRem(16px);
    min-height: $header-footer-height-tight;
    padding: $modal-tight-padding;
}

@mixin hc-modal-header-drag-tight() {
    // Account for the drag handle on the top left of the modal header if a close icon is present
    padding-left: 25px;
}

@mixin hc-modal-body() {
    overflow: auto;
    max-height: 70vh;
    height: inherit;
    padding: $modal-padding;
    margin-bottom: 0;
}

@mixin hc-modal-body-tight() {
    padding: $modal-tight-padding;
}

@mixin hc-modal-close-button() {
    background-color: transparent;
    border: 0;
    color: $text;
    cursor: pointer;
    font-size: 2rem;
    font-weight: bold;
    line-height: 1;
    opacity: 0.5;
    padding: 0;
    text-shadow: 0 1px 0 $white;
    -webkit-appearance: none;

    &:focus,
    &:hover {
        color: $text;
        opacity: 0.75;
        text-decoration: none;
    }
}

@mixin hc-modal-footer() {
    align-items: center;
    bottom: 0;
    display: flex;
    width: 100%;
    border-top: $modal-border;
    padding: $modal-padding;
    justify-content: flex-end;
    flex-direction: row;
    position: relative;
}

@mixin hc-modal-footer-tight() {
    padding: $modal-tight-padding;
}

@mixin hc-modal-footer-minimal() {
    padding: 0 !important;
    min-height: 15px;
}

@mixin hc-modal-button-footer() {
    margin-left: 10px;
    width: auto;
}

@mixin hc-modal-content() {
    background-color: $white;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    max-height: 100%;
    border-radius: 6px;
    height: auto;
}

@mixin hc-modal-open() {
    overflow: hidden;
}

@mixin hc-modal-center-component() {
    display: flex;
    flex-direction: column;
    height: 100%;
    justify-content: center;

}

@mixin hc-modal-resizable() {
    resize: both;
    overflow: hidden;
    min-width: 300px;
}

@mixin hc-modal-static() {
    min-height: auto !important;
}

@mixin hc-modal-close-icon() {
    // !important tag necessary to override hc-icon-button class styles
    position: absolute !important;
    top: 10px;
    right: 15px;
    background-image: url($ico-times-gray) !important;
    background-repeat: no-repeat !important;
    background-position: center !important;

    // Reposition the close icon button for fullscreen modals
    @include media-breakpoint-down(md) {
        top: 65px;
    }
}

@mixin hc-modal-close-icon-tight() {
    top: 7px;
    right: 5px;

    // Reposition the close icon button for fullscreen modals
    @include media-breakpoint-down(md) {
        top: 59px;
    }
}
