$document-figure-width: 64px;
$document-figure-height: 64px;
$characterization-figure-width: 64px;
$characterization-figure-height: 64px;
$qualitymetric-figure-width: 96px;
$qualitymetric-figure-height: 96px;
$attachment-button-margin: 3px;

.document-title {
    padding: 5px;
    background-color: #fff;
    color: #333;
    border-bottom: 1px solid #c0c0c0;
    font-weight: bold;
    text-align: left;
    font-size: 1rem;
}

/* stylelint-disable-next-line selector-class-pattern */
.type-Characterization.view-detail.type-AntibodyCharacterization {
    padding-top: 0;
    padding-left: 0;
    padding-right: 0;

    h4 {
        margin: 0;
        padding: 5px 20px 8px;
        background-color: desaturate(lighten(#0a253d, 30%), 30%);
        color: #fff;
        font-size: 0.8rem;
        font-weight: bold;
    }

    .row {
        padding-left: 30px;
        padding-right: 30px;
    }

    .panel-footer {
        padding: 0;
    }
}

.characterization-img {
    @include img-responsive();

    max-height: 360px;
}

.document-meta-data {
    margin: 0;
    padding: 10px;

    .label {
        display: inline-block;
        font-size: 0.8rem;
    }

    @media screen and (min-width: $screen-sm-min) {
        flex: 1 1 auto;
    }
}

.characterization-meta-data {
    @extend .document-meta-data;

    padding: 0;
}

.label {
    display: table-cell;
    position: relative;
    text-align: left;
    padding: 0.3em 0.5em 0.4em;
    font-size: 1rem;
    line-height: 1.1;
    background-color: $gray-light;

    @media screen and (min-width: $screen-sm-min) {
        display: inline-block;
        font-size: 1.1rem;
    }
}

%file-icon {
    @include img-responsive();
    @include text-hide;

    width: 100%;
    height: 100%;
    background-position: center center;
    background-repeat: no-repeat;
    background-size: 80% 80%;
}

.file-pdf {
    @extend %file-icon;

    background-image: url(/static/img/file-pdf.svg);
}

.file-generic {
    @extend %file-icon;

    background-image: url(/static/img/file.svg);
}

.file-missing {
    @extend %file-icon;

    background-image: url(/static/img/file-broken.svg);
}

.file-thumbnail {
    @extend %file-icon;

    display: inline-block;

    img {
        height: 100px;
        width: 120px;
    }
}

.facet-term-key {
    margin-right: 5px;
    font-size: 1.1rem;
}

@mixin type-panel($figure-width, $figure-height) {
    margin-top: 0;

    &.view-detail {
        padding: 0;

        @media screen and (min-width: $screen-sm-min) {
            display: flex;
        }

        figure {
            position: relative;
            display: block;
            float: none;
            width: 100%;
            height: $figure-height;
            margin: 0;
            padding: 0;
            border-left: 1px solid #e8e8e8;
            background-color: #fff;

            .attachment, div.file-missing {
                position: absolute;
                display: table;
                top: 0;
                left: 0;
                width: $figure-height;
                height: $figure-height;
                padding: 3px;

                .attachment-button {
                    position: relative;
                    display: table-cell;
                    height: $figure-height - (2 * $attachment-button-margin);
                    width: $figure-height - (2 * $attachment-button-margin);
                    text-align: center;
                    vertical-align: middle;
                    border-radius: 5px;
                    border: 1px solid #a0a0a0;
                    background-color: #f0f0f0;

                    &:hover {
                        background-color: #e0e0e0;
                    }
                }

                &.file-pdf,
                &.file-generic,
                &.file-missing {
                    height: $figure-width - (2 * $attachment-button-margin);
                }

                img {
                    display: inline-block;
                    max-height: 0.8 * $figure-height;
                    max-width: 0.8 * $figure-width;
                    height: auto;
                    width: auto;
                }
            }

            @media screen and (min-width: $screen-sm-min) {
                flex: 0 0 $figure-width;
                margin: 0 0 0 5px;
            }
        }

        h3 {
            line-height: normal;
        }
    }
}

.attachment {
    padding: $attachment-button-margin;

    @at-root #{&}__button {
        display: block;
        position: relative;
        padding: $attachment-button-margin;
        height: $document-figure-height - (2 * $attachment-button-margin);
        width: $document-figure-width - (2 * $attachment-button-margin);
        border-radius: 5px;
        border: 1px solid #a0a0a0;
        overflow: hidden;
    }

    @at-root #{&}__hover {
        position: absolute;
        top: 0;
        right: 0;
        bottom: 0;
        left: 0;
        background-color: transparent;
        z-index: 1;

        &:hover {
            background-color: rgba(0, 0, 0, 0.2);
        }
    }
}

.attachment-list {
    display: flex;
    margin-left: -5px;
    padding: 0;
    flex-wrap: wrap;
}

.attachment-list__panel {
    flex: 0 0 calc(50% - 10px);
    margin: 5px;

    .panel {
        margin: 0;
    }
}

.dl-link {
    word-break: break-all;
}

/**
 * List of documents, normally wrapped into columns within a panel.
 */
.document-list {
    padding: 5px;

    @media screen and (min-width: $screen-sm-min) {
        display: flex;
        flex-wrap: wrap;
        align-items: flex-start;
    }

    @at-root #{&}__document {
        margin: 5px;

        @media screen and (min-width: $screen-sm-min) {
            flex-grow: 0;
            flex-shrink: 1;
            flex-basis: calc(50% - 10px);
            min-width: 0;
        }

        @media screen and (min-width: $screen-md-min) {
            flex-grow: 0;
            flex-shrink: 1;
            flex-basis: calc(33.33% - 10px);
            min-width: 0;
        }

        @media screen and (min-width: $screen-xl-min) {
            flex-grow: 0;
            flex-shrink: 1;
            flex-basis: calc(25% - 10px);
            min-width: 0;
        }
    }
}

// Calc doesn't work correctly in IE11.
/* stylelint-disable-next-line selector-class-pattern */
.uaTrident .document-list__document {
    margin: 4px;
}

// Document styles, normally added to a <Panel> component's classes.
$detail-switch-height: 30px;
$detail-switch-width: 30px;

.document {
    margin: 3px;

    // Document header; normally a document type and/or label
    @at-root #{&}__header {
        padding: 5px;
        border-bottom: 1px solid #c0c0c0;
        font-weight: bold;
        text-transform: capitalize;
    }

    @at-root #{&}__intro {
        display: flex;
        border-bottom: 1px solid #c0c0c0;

        @at-root #{&}--attachment-only {
            border-bottom: none;
        }
    }

    @at-root #{&}__caption {
        flex: 1 1 auto;
        margin: 5px;
        line-height: 1.4;
        word-break: break-word;
    }

    @at-root #{&}__preview {
        flex: 0 0 $document-figure-width;
        align-items: stretch;
        margin: 0;
        border-left: 1px solid #c0c0c0;
    }

    @at-root #{&}__file {
        display: flex;
        align-items: center;

        @at-root #{&}-name {
            flex: 1 1 auto;
            overflow: hidden;
            white-space: nowrap;

            @at-root #{&}-icon {
                display: inline-block;
                padding: 0 5px;
                line-height: $detail-switch-height - 1;
            }

            @at-root #{&}-link {
                display: inline;
                line-height: $detail-switch-height;
            }
        }

        @at-root #{&}-detail-switch {
            flex: 0 0 $detail-switch-width;
            padding: 5px;
            height: $detail-switch-height;
            line-height: $detail-switch-height;
            max-width: $detail-switch-width;
            background-color: #e8e8e8;
            border: none;

            &:hover {
                background-color: #b8c7d5;
            }
        }
    }

    @at-root #{&}__detail {
        display: none;
        margin: 0;
        padding: 10px 5px;
        border-top: 1px solid #c0c0c0;

        &.active {
            display: block;
        }
    }
}

%panel-intro {
    padding: 5px;

    h3 {
        margin: 0;
        font-size: 1.2rem;
    }

    p {
        margin: 2px 0 0 0;
        font-size: 1rem;
        word-wrap: break-word;
    }
}

.document-intro {
    @extend %panel-intro;
}

.characterization-intro {
    @extend %panel-intro;

    padding: 10px;
}

// ***************************************
// Document download file bar classes

// THe file bar itself
.dl-bar {
    position: relative;
    height: $detail-switch-height;
    padding: 0 10px 0 10px;
    line-height: $detail-switch-height;
    border-bottom: 1px solid #e8e8e8;
    white-space: nowrap;
    overflow: hidden;
}

// Icon within .detail-switch to show the current state of the switch
.detail-trigger {
    @extend .icon-caret-down;

    display: block;
    height: $detail-switch-height;
    line-height: $detail-switch-height;
    font-size: 1.4rem;
    cursor: pointer;
    text-align: center;
    transition: 0.1s linear;

    &.collapsed {
        transform: rotate(90deg);
    }
}

.collapsing-doc {
    position: relative;
    display: block;
    padding: 5px;

    &:hover {
        background-color: darken(#d8e0e8, 10%);
        text-decoration: none;
    }
}

.key-value-trigger {
    display: block;
    width: 100%;
    margin: 0;
    background-color: $mainThemeColor;
    text-align: center;
    /* stylelint-disable-next-line function-linear-gradient-no-nonstandard-direction */
    background-image: linear-gradient(top, lighten($mainThemeColor, 5%) 0%, $mainThemeColor 100%);
    background-image: -ms-linear-gradient(top, lighten($mainThemeColor, 5%) 0%, $mainThemeColor 100%);
    border-top: 1px solid #808080 !important;
    border-bottom: none;
    border-left: none;
    border-right: none;
    padding: 0 10px;
    line-height: 32px;
    color: #333;

    &:hover {
        /* stylelint-disable-next-line function-linear-gradient-no-nonstandard-direction */
        background-image: linear-gradient(top, $mainThemeColor 0%, darken($mainThemeColor, 5%) 100%);
    }

    &:focus {
        outline: none;
        box-shadow: 0 0 3px 2px #94bfe7 inset;
    }

    &.panel-footer {
        padding: 0;
    }
}

.document-slider {
    display: none;
    margin: 0;
    padding: 10px 5px;
    border-bottom: 1px solid #e8e8e8;

    &.active {
        display: block;
    }

    > div {
        margin-top: 10px;

        &:first-child {
            margin-top: 0;
        }
    }
}

.characterization-slider {
    display: none;

    &.active {
        display: block;
    }
}

.characterization-slider-shadow {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 40px;
    /* stylelint-disable-next-line function-linear-gradient-no-nonstandard-direction */
    background-image: linear-gradient(top, rgba(0, 0, 0, 0) 0%, rgba(0, 0, 0, 0.3) 100%);

    &.active {
        display: none;
    }
}

.journal {
    margin-top: 5px;
    font-size: 1rem;
    color: #606060;
}

.authors {
    margin-top: 20px;
    line-height: 1.4;
}

// Characterization panel biosample terms
// **********

// area to hold biosample terms
.document__characterization-reviews {
    display: flex;
    margin-right: -1px;
    flex-direction: row;
    flex-wrap: wrap;
    justify-content: space-between;
    align-content: flex-start;
    align-items: flex-start;
    border-bottom: 1px solid #c0c0c0;
}

// each biosample term
.document__characterization-biosample-term {
    flex: 1 1 auto;
    align-self: auto;
    padding: 2px 5px;
    margin-right: 1px;
    text-align: center;
    background-color: #e8e8e8;
    font-size: 0.9rem;
}

.document__characterization-badge {
    flex: 1 1 auto;
    padding: 0 3px;

    .status-list {
        .label {
            display: inline-block;
            margin: 3px 0;
            padding: 0 17px 0 10px;
            text-align: center;
            font-size: 0.85rem;
            line-height: 24px;
        }
    }
}
