

/***
    Button Strip
*/

.buttonStrip {
    overflow: hidden; /* clearfix */

    // width is label + input + input-margins
    width: $width-big + $width-small + $padding-medium*2;
    &.small {
        width: $width-medium + $width-small + $padding-medium*2;
    }

    button, input {
        margin: 0 $padding-medium;
    }

    .default {
        float: right;
    }
}

header .default {
    float: right;
}
header input + h1 {
    display: inline-block;
}


/***
    dependencies (auto-shown)
*/
.dependent {
    li {
        margin-left: 0;
    }

    &.javascript {
        margin-bottom: 0;
        max-height: 0;
        overflow: hidden;
        transition: 
            max-height .2s ease-out, 
            margin-top .1s ease-out .2s, 
            margin-bottom .1s ease-out .2s, 
            padding-top .1s ease-out .2s,
            padding-bottom .1s ease-out .2s;
    }
    &.visible {
        max-height: 834px;
        transition: 
            max-height .2s ease-in, 
            margin-bottom .1s ease-out .1s,
            margin-top .1s ease-out .1s,
            padding-bottom .1s ease-out .1s,
            padding-top .1s ease-out .1s,;
    }
    &:not(.visible) {
        margin-bottom: 0;
        margin-top: 0;
        padding-bottom: 0;
        padding-top: 0;
    }
    &.list.visible {
        max-height: 100%;   
    }
}


/***
    Form fields
*/
.formFields {
    border-top: 1px solid lightened($color-neutral);
    display: block;
    margin: 0;
    padding: $padding-medium 0;
    overflow: hidden; /* clearfix */

    &:last-of-type {
        border-bottom: 1px solid lightened($color-neutral);
        margin-bottom: $padding-big;
    }

    &.small {
        input[type=date] {
            width: 160px;
        }
        label {
            min-width: 0;
        }
        .right {
            display: inline-block;
            vertical-align: top;
        }
    }

    a {
        font: $font-small;
    }

    div {
        display: inline-block;

        label {
            display: block;
            font: $font-small;
            text-align: center;
            font-style: italic;
            &::after { content: ')' }
            &::before { content: '(' }
        }
    }

    dt {
        display: inline-block;
        width: $width-big;
        vertical-align: top;
        input {
            float: left;
            margin-right: -1.5em;
        }
        label {
            float: left;
            margin-left: 1.5em;
            text-align: left;
        }
    }
    dd {
        &.right {
            display: inline-block;
            width: $width-medium;
        }
    }

    li {
        clear: both;
        display: table;
        line-height: $font-input-line + $padding-medium*2 + 1px;
        max-width: 100%;
        overflow-x: auto;
    }

    td {
        background: lightened($color-neutral);
        height: 100%;
        padding: 0;
        input {
            border: none;
            height: $font-input-line + $padding-medium*2 + 1px;
            line-height: inherit;
            margin: 0;
            vertical-align: middle;
            min-width: 100%;

            &[type=date] {
                border-radius: 0;
                width: 11em; // mm/dd/yyyy plus 3 selectors -- assuming M widths
            }
            &[type=number] {
                border-radius: 0;
                width: 5em;
            }
        }
    }

    .required[style='display: inline;']:not(.box) {
        &:not(.no-hide) {
            font: 0/0 serif;
        }
        & + span + label + input,
        & + label + input,
        & + label + select,
        & + label + textarea {
            border-color: lightened($color-error);
        }
        & + label + .YesNoPicker {
            li {
                border-color: lightened($color-error);
            }
        }
        & + span {
            &>input::before {
                border-left: 1px solid lightened($color-error);
                content: '';
                display: block;
                height: 100%;
                margin-left: -4px;
            }
            &>input:first-of-type::before {
                border-top-left-radius: 0.5em;
            }
            &>input:last-of-type::before {
                border-bottom-left-radius: 0.5em;
            }
        }
    }
    td>.required[style='display: inline;'] {
        & + input {
            box-shadow: inset 0 0 1px 1px lightened($color-error);
        }
    }

    /***
        alignment
    */
    .left {
        clear: left;
        float: left;
        margin-right: $padding-big;
    }

    .right {
        clear: none;
    }

    /***
        field sizes
    */
    input, select {
        &.small {
            width: $width-small;
        }
        &.big {
            width: $width-big;
        }
    }
    label.long {
        line-height: $font-normal-line;
        max-width: $width-big;
        padding-top: $padding-medium;
        text-align: left;
    }
    .small {
        input, select {
            width: $width-small;
        }
        input[type=checkbox] {
            margin-left: $padding-big;
            width: auto;
            & + label {
                margin: 0;
            }
        }
    }
    .big {
        input, select {
            width: $width-big;
        }
    }

}

.required {
    color: $color-error;
    display: inline-block;
    float: right;
    font: $font-small;
    line-height: $font-normal-line;
    position: relative;

    &.box {
        border: 1px solid $color-error;
        display: block;
        float: none;
        padding: $padding-small $padding-medium;
        margin: $padding-big 0;

        &[style='visibility:hidden;'],
        &[style='color:Red;visibility:hidden;'] {
            display: none;
        }
    }
    &.signal::after {
        background-color: rgba(255,0,0,0.4);
        border-color: rgba(255,0,0,1);
    }
    &::after {
        background-color: rgba(0,0,0,0);
        position: absolute; top: -4px; left: -6px; height: 100%; width: 100%; content: '';
        border: 2px solid rgba(0,0,0,0);
        box-sizing: content-box;
        padding: 2px 4px;
        transition: all 1s;
    }
}
.error-link {
    color: $color-error;
    display: inline-block;
    padding: 4px 0;
    margin: 0 8px;

    &.hidden {
        display: none;   
    }
}

select {
    height: $font-input-line + 2px;
}
input, select, textarea {
    background: #fff;
    border: 1px solid $color-border;
    border-radius: $font-input-line / 8;
    color: $color-text-dark;
    font: $font-input;
    height: $font-input-line + 1px;
    margin: $padding-medium;
    padding: 0 $padding-medium;
    vertical-align: top;
    width: $width-medium;

    &[disabled] {
        background: tint(#fff, $color-neutral);
    }

    &[type = file] {
        padding: 0;
    }

    &[type=checkbox], &[type=radio] {
        width: 1em;

        & + label {
            margin-right: $padding-medium;

            &:last-of-type {
                margin-right: 0;
            }

            &::after {
                content: '';
            }
        }
    }

}
input[type='checkbox']+label {
    min-width: 0;
}

button, input[type=button], input[type=submit] {
    background: linear-gradient(#fff, #ccc);
    border: 1px solid $color-border;
    border-radius: $font-input-line / 8;
    color: $color-text-dark;
    font: $font-input;
    height: auto;
    margin: $padding-medium;
    padding: $padding-small $padding-medium;
    vertical-align: top;
    width: auto;
    min-width: $width-small;

    &:active {
        background: linear-gradient(#ccc, #fff);
        color: lightened($color-text-dark);
    }

    &.default {
        background: linear-gradient(lightened($color-accent), darkened($color-accent));
        color: tint(text-color-for($color-accent), $color-accent);
        &:active {
            background: linear-gradient(darkened($color-accent), lightened($color-accent));
        }
    }
}

input[type=image] {
    background: linear-gradient(#fff, #ccc);
    border: 1px solid $color-border;
    border-radius: $font-input-line / 8;
    height: 24px;
    padding: 1px;
    vertical-align: top;
    width: 24px;

    &:active {
        background: linear-gradient(#ccc, #fff);
    }

    &.default {
        background: linear-gradient(lightened($color-accent), darkened($color-accent));
        &:active {
            background: linear-gradient(darkened($color-accent), lightened($color-accent));
        }
    }
}

label {
    display: inline-block;
    margin-left: $padding-medium;
    text-align: right;
    vertical-align: top;

    &:first-of-type {
        margin-left: 0;
        min-width: $width-small;
    }

    &::after {
        content: ':';
    }
}

textarea {
    display: inline-block;
    margin: $padding-small;
    min-height: $height-medium;
    max-height: $height-big;
    min-width: $width-big;
    max-width: $width-big;
}