@import 'nav-frontend-core/less/core.less';
@import 'nav-frontend-skjema-style/src/input.less';
@import 'nav-frontend-skjema-style/src/validering.less';

.mixin-transition(@varighet: 150ms, @type: all) {
    transition: @type @varighet cubic-bezier(0.465, 0.183, 0.153, 0.946);
}
.compactInputs() {
    *:focus {
        z-index: 10;
        position: relative;
    }
    .timeInput__hours > input {
        border-top-right-radius: 0;
        border-bottom-right-radius: 0;
    }
    .timeInput__minutes > input {
        border-left: none;
        border-top-left-radius: 0;
        border-bottom-left-radius: 0;
    }
    .timeInput__inputWrapper:first-child {
        margin-right: 0;
    }
}
.timeInputLabelsBelow() {
    > .skjemaelement__label {
        font-weight: normal;
        text-align: center;
        padding: 0.5rem;
        padding-bottom: 0.25rem;
        margin-bottom: 0;
    }
    input {
        text-align: center;
        width: 100%;
        padding: 0.5rem;
    }
    .timeInput {
        &__label {
            display: block;
            position: absolute;
            top: calc(100% + 0.25rem);
            font-size: 0.75rem;
            padding: 0;
            text-align: left;
            line-height: 1rem;
            overflow: hidden;
            width: 100%;
        }
        &__hours,
        &__minutes {
            margin: 0 !important;
        }
        &__contentWrapper {
            white-space: nowrap;
            padding-bottom: 1.25rem;
            display: flex;
            > * {
                flex: 1;
            }
        }
        &__inputWrapper {
            max-width: 3.5rem;
        }
    }
}

.timeInput {
    .skjemaelement__label {
        font-weight: bold;
    }
    &__contentWrapper {
        display: flex;
    }
    &__hours,
    &__minutes {
        width: 100%;
        margin-bottom: 0.5rem;
        &:focus {
            z-index: 2;
        }
    }
    &__inputWrapper {
        display: flex;
        align-items: baseline;
        margin-right: 0.5rem;
        padding: 0;
        position: relative;
        max-width: 3rem;
    }
    &__label {
        padding-left: 0.5rem;
        order: 2;
    }
    &__input {
        order: 1;
    }
    .timeInputLabelsBelow();

    &--compact {
        .compactInputs();
    }
}

.formikTimeInput {
    .skjemaelement__label {
        margin-bottom: 0.5rem;
    }
    &--horizontal {
        flex-direction: row;
        display: flex;
        flex-wrap: wrap;
        .divLegend {
            padding-right: 1rem;
            align-items: flex-start;
            padding-top: 0.5rem;
            white-space: nowrap;
            flex: 1 1 12rem;
        }
        .timeInput {
            flex: 2 1 10rem;
        }
        .timeInput__contentWrapper {
            justify-content: left;
        }
        .timeInput + div {
            width: 100%;
        }
    }
}
