@import "../variables/variables";
@import "../mixins/private/token-mixins";

/* BASE CLASS */

span.field {
    display: inline-block;
}

span.field + span.field {
    margin-left: 8px;
}

div.field {
    margin: 16px 0;
}

.field-group {
    display: flex;
    margin: 16px 0;

    > div.field {
        margin: 0;
    }
}

/* BASE CLASS MODS */

span.field--table {
    display: inline-table;
}

div.field--table {
    display: table;
}

.field__description--group {
    display: flex;
    justify-content: flex-end;
}

.field__description--group > :last-child {
    margin-inline-start: 5px;
    text-align: right;
}

.field__description--group > :first-child {
    flex: 1;
}

/* ELEMENT CLASSES */

.field__label {
    margin-right: 8px;
}

.field__description {
    @include color-token(field-description-color, color-foreground-secondary);

    font-size: var(--font-size-small);
    line-height: var(--spacing-200);
    margin-top: var(--spacing-50);
}

.field__description--confirmation {
    @include color-token(
        field-description-confirmation-color,
        color-foreground-confirmation
    );
}

.field__description--information {
    @include color-token(
        field-description-information-color,
        color-foreground-information
    );
}

.field__description--attention {
    @include color-token(
        field-description-attention-color,
        color-foreground-attention
    );
}

.field__group > .field__description,
.field__group > .field__label {
    align-self: center;
}

span.field__group {
    display: inline-flex;
}

div.field__group {
    display: flex;
}

.field__control + span.field__description {
    margin-left: 8px;
}

.field__description .icon {
    display: inline-block;
    margin-right: var(--spacing-50);
}

/* if using a div for description, it implies it's always at bottom of field */
div.field__description {
    margin: var(--spacing-100) 0 0;
}

.field__row {
    display: table-row;

    > .field__control,
    > .field__label,
    > .field__description {
        display: table-cell;
    }

    .field__label {
        margin-right: auto;
        padding-right: 8px;
    }

    .field__control + span.field__description {
        margin-left: 0;
        padding-left: 8px;
    }

    &:first-child {
        > .field__description {
            padding-bottom: 8px;
        }
    }

    &:last-child {
        > .field__description {
            padding-top: 8px;
        }
    }
}

/* ELEMENT CLASS MODS */

.field__label--end {
    margin-left: 4px;
    margin-right: auto;
}

.field__label--stacked {
    display: block;
    margin-bottom: 8px;
}

.field__label--disabled {
    @include color-token(field-label-color-disabled, color-foreground-disabled);
}

.field--fluid,
.field__group--fluid,
.field__control--fluid {
    width: 100%;
}

/* textarea alignment */

.field--align-top .field__label {
    display: inline-block;
    margin-top: 16px;
}

.field--align-top .textbox {
    vertical-align: top;
}

.field__group--align-top > .field__label {
    align-self: flex-start;
    margin-top: 16px;
}

[dir="rtl"] {
    .field__description--group > :last-child {
        text-align: left;
    }
}
