@import "../variables/dimensions";
@import "../variables/colors";

$audio-padding-left: 8px !default;
$audio-default-margin: $grid-gutter-width !default;
$audio-button-size: 20px !default;
$audio-progress-bar-total-height: 1px !default;
$audio-progress-bar-left-height: 3px !default;
$audio-progress-indicator-size: 17px !default;
$audio-volume-bar-width: 60px !default;
$audio-volume-bar-height: 5px !default;
$audio-volume-indicator-size: 13px !default;
$audio-border-radius: 100px !default;
$audio-shadow-blur: 2px !default;
$audio-progress-min-width: 40px !default;
$audio-not-progress-width: 220px !default;
$audio-player-full-min-width: $audio-progress-min-width + $audio-not-progress-width + $audio-padding-left + $audio-default-margin;
$audio-player-recorder-min-width: $audio-player-full-min-width + $audio-button-size + $audio-default-margin;
$audio-recorder-min-width: 245px !default;
$audio-recorder-progress-indicator-height: 23px !default;

.rc-audio {
    display: flex;
    align-items: center;
    width: 100%;
    position: relative;

    .rc-audio-player.rc-audio-player-full,
    .rc-audio-player.rc-audio-player-recorder,
    .rc-audio-recorder {
        display: flex;
        flex-wrap: wrap;
        align-items: center;
        background-color: $whiteColor;
        border: 1px solid $lightGrayColor;
        border-radius: $audio-border-radius;
        padding: 1px $grid-gutter-width 1px $audio-padding-left;
        box-sizing: border-box;
        &:not(:last-child) {
            margin-right: $audio-default-margin;
        }

        .audio-button,
        .audio-process-bar {
            &:not(:last-child) {
                margin-right: $audio-default-margin;
            }
        }

        .audio-button {
            padding: 0px;
            font-size: $audio-button-size;
        }

        .audio-process-bar {
            position: relative;
            cursor: pointer;

            .audio-process-bar-total,
            .audio-process-bar-left,
            .audio-process-indicator {
                cursor: pointer;
                position: absolute;
            }

            .audio-process-bar-total {
                width: 100%;
                background-color: $mediumGrayColor;
            }
            .audio-process-bar-left {
                background-color: $audio-primary-color;
            }
            .audio-process-indicator {
                background-color: #ffffff;
                border-radius: 50%;
                border: none;
                box-shadow: 0px 1px $audio-shadow-blur rgba(0, 0, 0, 0.15);
            }
        }

        .audio-volume {
            .audio-volume-button {
                color: $audio-primary-color;
                font-size: $audio-button-size;
                padding: 0;
                margin: 0 $audio-default-margin 2px;
            }
            .audio-process-bar.audio-volume-bar {
                width: $audio-volume-bar-width;
                height: $audio-volume-indicator-size;
                display: inline-block;
                vertical-align: middle;

                .audio-process-bar-total {
                    top: ($audio-volume-indicator-size - $audio-volume-bar-height )/2;
                    height: $audio-volume-bar-height;
                    border-radius: $audio-border-radius;
                }
                .audio-process-bar-left {
                    height: $audio-volume-bar-height;
                    top: ($audio-volume-indicator-size - $audio-volume-bar-height)/2;
                    border-radius: $audio-border-radius 0 0 $audio-border-radius;
                    width: $audio-volume-bar-width - $audio-volume-indicator-size;
                }
                .audio-process-indicator {
                    width: $audio-volume-indicator-size;
                    height: $audio-volume-indicator-size;
                    left: $audio-volume-bar-width - $audio-volume-indicator-size + 1px;
                }
            }
        }

        .audio-duration {
            color: $blackColor;
            font-family: Helvetica;
            font-size: 12px;
            margin: auto;
            height: $audio-button-size - 1px;
        }
    }

    .rc-audio-player {
        flex: auto;
        &.rc-audio-player-full, &.rc-audio-player-recorder {
            .audio-process-bar.audio-progress-bar {
                flex: auto;
                height: $audio-progress-indicator-size;
                .audio-process-bar-total {
                    top: ($audio-progress-indicator-size - $audio-progress-bar-total-height)/2;
                    height: $audio-progress-bar-total-height;
                }
                .audio-process-bar-left {
                    height: $audio-progress-bar-left-height;
                    top: ($audio-progress-indicator-size - $audio-progress-bar-left-height)/2;;
                }
                .audio-process-indicator {
                    width: $audio-progress-indicator-size;
                    height: $audio-progress-indicator-size;
                    left: 0;
                }
            }
        }

        &.rc-audio-player-full {
            min-width: $audio-player-full-min-width;
        }

        &.rc-audio-player-recorder {
            min-width: $audio-player-recorder-min-width;
        }

    }

    .rc-audio-download,
    .rc-audio-upload {
        a {
            color: inherit;
        }
        a, a:hover, a:visited, a:active {
            text-decoration: none;
        }
        color: $audio-primary-color;
        font-size: $audio-button-size;
        &:not(:last-child) {
            margin-right: $audio-default-margin;
        }

        .rc-icon{
            top: 0px;
        }
    }

    .rc-audio-icon-wrapper {
        width: $audio-button-size;
        height: $audio-button-size;
        border: 1px solid $lightGrayColor;
        border-radius: 50%;
        padding: 0px;
        font-size: 12px;
        color: $audio-primary-color;
        cursor: pointer;
        box-sizing: content-box;
        text-align: center;

        &:not(:last-child) {
            margin-right: $audio-default-margin;
        }

        &.rc-audio-record {
            color: $dangerColorAlt !important;
        }

        .rc-icon {
            margin-right: 0px;
            &.rc-icon-record-complete {
                top: 0px;
            }
        }
    }

    .rc-audio + .rc-audio-upload {
        margin-left: $audio-default-margin;
    }

    .rc-audio-recorder {
        min-width: $audio-recorder-min-width;
        &.recorder-progressor {
            padding-top: $grid-gutter-width/2;
            padding-bottom: $grid-gutter-width/2;
        }
        .volume-meter {
            display: flex;
            .volume-meter-unit {
                width: 3px;
                height: 11px;
                background-color: grey;
                border-radius: $audio-border-radius;

                &.volume-unqualified {
                    background-color: $warningColorAlt;
                }
                &.volume-qualified {
                    background-color: $successColorAlt;
                }

                &:not(:last-child) {
                    margin-right: 5px;
                }

            }
        }

        .progress-wav {
            flex: auto;
            display: flex;
            align-items: center;
            margin-right: $audio-default-margin;
            height: $audio-progress-bar-total-height;
            background-color: $mediumGrayColor;

            .progress-volume-meter {
                background-color: $audio-primary-color;
                width: 1px;
                &:not(:last-child) {
                    margin-right: 1px;
                }
            }
        }
    }

    .rc-audio{ //fix audio nested, for player inside recorder
        min-width: $audio-player-recorder-min-width + $audio-button-size + $audio-default-margin + 2px;
    }

    &-invisible {
        visibility: hidden;
        width: 0px;
        display: inline-block;
    }
}

