// Mixins
@import "../mixins";

/**
 * Form Row Vertical Spacing
 */
.form-row:not(.cfw-hidden-input) {
    margin-bottom: 0.8em;
}

.cfw-input-wrap-row:last-child {
    .form-row {
        @include media-breakpoint-up(lg) {
            margin-bottom: 0;
        }
    }
}

.checkoutwc .form-row {
    position: relative;

    input[type="text"],
    input[type="email"],
    input[type="tel"],
    input[type="number"],
    input[type="password"],
    select,
    textarea {
        -webkit-appearance: none !important;
        -moz-appearance: none !important;
        appearance: none !important;
        background: #fff;
        transition: all .2s ease;
        color: #333;
        padding: 0.82rem;
        width: 100%;
        box-sizing: border-box;
        font-size: 16px;
        line-height: normal !important;
        border-radius: 5px !important;
        border: 1px solid #d9d9d9 !important;
        transition-delay: 0s, 0s;
        transition-duration: 0.2s, 0s;
        transition-property: all, width;
        transition-timing-function: ease-out, ease;
        height: auto !important;

        &::placeholder {
            color: #ccc;
        }

        &:focus {
            outline: 0;
            box-shadow: 0 0 0 1px var(--cfw-buttons-primary-background-color) !important;
        }
    }

    select[multiple] {
        padding-bottom: 0;
    }

    label {
        display: inline-block;
        margin-bottom: 0.5em;
        margin-top: 0.5em;

        &.cfw-floatable-label {
            user-select: none;
            pointer-events: none;
            position: absolute;
            color: #737373;
            transition: all .2s ease-out;
            font-size: 12px;
            margin-top: .25em;
            margin-bottom: 0;
            padding: 0 1.16em;
            line-height: 1.625;
            opacity: 0;
            height: auto;
            width: auto;
            clip-path: none;
            clip: unset;
            white-space: nowrap;

            abbr[title] {
                text-decoration: none;
            }
        }
    }

    &.cfw-label-is-floated {
        input[type="text"],
        input[type="email"],
        input[type="tel"],
        input[type="number"],
        input[type="password"],
        select,
        textarea {
            padding: 1.35em 0.8em 0.28em 0.8em;
        }

        label.cfw-floatable-label {
            opacity: 1;
            z-index: 1000;
        }

        /**
        Firefox style fixes
         */
        @supports (-moz-appearance:none) {
            select {
                padding: 1.25em 0.8em 0.28em 0.5em;
            }
        }

        #cfw-promo-code {
            padding: 1.35em 0.8em 0.48em 0.8em;
        }
    }

    /**
     * Special handling for radio groups
     */
    &.cfw-radio-input {
        fieldset {
            label {
                display: block;
                margin-bottom: 0.5em;
            }
        }
    }

    &.cfw-wc_checkout_add_ons_radio-input, &.cfw-wc_checkout_add_ons_multicheckbox-input {
        .woocommerce-input-wrapper {
            display: block;
            margin-bottom: 0.5em;
        }
    }

    // Select Dropdown Arrow
    &.cfw-select-input:not(.cfw-multiselect-input,.cfw-wc_checkout_add_ons_multiselect-input) {
        &:after {
            content: '';
            background: url('data:image/svg+xml;utf8,<svg height="512px" id="Layer_1" style="enable-background:new 0 0 512 512;" version="1.1" viewBox="0 0 512 512" width="512px" xml:space="preserve" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"><polygon points="160,115.4 180.7,96 352,256 180.7,416 160,396.7 310.5,256"/></svg>') no-repeat;
            background-position: 50% 50%;
            background-size: cover;
            pointer-events: none; // allow pass through to select element
            position: absolute;
            width: 20px;
            height: 20px;
            right: 12px;
            top: 22px;
            transform: translateY(calc(-50% + 2px)) rotate(90deg);
            z-index: 1000;
        }
    }

    &.cfw-hidden-input {
        display: none;

        label {
            display: none;
        }
    }

    // Hide required notice in labels
    abbr.required {
        display: none;
    }

    /**
     * Placeholder styles
     */
    ::-webkit-input-placeholder {
        color: #737373 !important;
    }

    :-moz-placeholder { /* Firefox 18- */
        color: #737373 !important;
    }

    ::-moz-placeholder { /* Firefox 19+ */
        color: #737373 !important;
    }

    :-ms-input-placeholder {
        color: #737373 !important;
    }
}

/**
 * Checkbox styling
 */
input[type="checkbox"], main.checkoutwc input[type="checkbox"] {
    appearance: none;
    border: 1px solid #d9d9d9;
    border-radius: 5px;
    width: 18px !important;
    height: 18px !important;
    min-width: 18px !important;
    vertical-align: -4px;
    background-color: #ffffff;
    position: relative;
    box-shadow: 0 0 0 0 #000000 inset;
    transition: all 0.2s ease-in-out;
    cursor: pointer;
    outline: none;
    margin-right: 0.5em !important;
    margin-left: 0;

    &:checked {
        border: none;
        box-shadow: 0 0 0 10px #000000 inset;

        &:after {
            transform: scale(1);
            opacity: 1;
        }
    }

    &:after {
        width: 10px;
        height: 8px;
        margin-left: -5px;
        margin-top: -4px;
        background-image: url(data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIxMC4zIiBoZWlnaHQ9IjgiIHZpZXdCb3g9IjguOSAwLjMgMTAuMyA4IiBlbmFibGUtYmFja2dyb3VuZD0ibmV3IDguOSAwLjMgMTAuMyA4Ij48cGF0aCBmaWxsPSIjZmZmIiBkPSJNMTIuNiA4LjFsLTMuNy0zLjggMS0xLjEgMi43IDIuNyA1LjUtNS40IDEgMXoiLz48L3N2Zz4=), none;
        content: "";
        display: block;
        position: absolute;
        top: 50%;
        left: 50%;
        transform: scale(0.2);
        transition: all 0.2s ease-in-out 0.1s;
        opacity: 0;
    }
}

/**
 * Radio buttons styling
 */
input[type="radio"] {
    appearance: none;
    background-color: white;
    border-radius: 50%;
    width: 18px !important;
    height: 18px !important;
    min-width: 18px !important;
    box-shadow: 0 0 0 0 #000000 inset;
    transition: all 0.2s ease-in-out;
    position: relative;
    cursor: pointer;
    vertical-align: -4px;
    border: 1px solid #d9d9d9;
    outline: none;
    margin-right: 0.5em;

    &:after {
        transform: scale(1);
        opacity: 1;
        width: 4px;
        height: 4px;
        margin-left: -2px;
        margin-top: -2px;
        background-color: #fff;
        border-radius: 50%;
        content: "";
        display: block;
        position: absolute;
        top: 50%;
        left: 50%;
        transition: all 0.2s ease-in-out 0.1s;
    }

    &:checked {
        border: none;
        box-shadow: 0 0 0 10px #000000 inset
    }
}

// WooCommerce native checkboxes
// Style so label doesn't wrap under checkbox
.cfw-check-input, .woocommerce-form__label-for-checkbox, .woocommerce-SavedPaymentMethods-saveNew {
    display: flex;
    align-items: center;

    .required {
        display: none;
    }
}

/**
 * Mark required checkboxes with asterisk at the end of the label
 * Might just be used for the terms and conditions checkbox?
 */
.validate-required {
    .woocommerce-form__label-for-checkbox span:after {
        content: "*";
        margin-left: 1px;
    }
}

fieldset {
    margin-top: 0.5em; /* for WooCommerce Subscription Gifting */
    padding: 0;
    border: 0;
    min-width: inherit;
}

/**
 * Normal Labels (The ones that don't float)
 */
.cfw-label-style-normal .form-row:not(.cfw-check-input) label {
    position: relative;
    color: #333;
    font-size: 1em;
    margin-bottom: 4px;
    padding: 0;
    opacity: 1;
    pointer-events: all;
    white-space: normal;
}

.cfw-label-style-normal {
    .form-row:not(.cfw-check-input).cfw-label-is-floated input[type="text"],
    .form-row:not(.cfw-check-input).cfw-label-is-floated input[type="email"],
    .form-row:not(.cfw-check-input).cfw-label-is-floated input[type="tel"],
    .form-row:not(.cfw-check-input).cfw-label-is-floated input[type="password"],
    .form-row:not(.cfw-check-input).cfw-label-is-floated input[type="number"],
    .form-row:not(.cfw-check-input).cfw-label-is-floated select,
    .form-row:not(.cfw-check-input).cfw-label-is-floated textarea {
        padding: 0.82em;
    }
}

.cfw-add-field {
    display: flex;
    align-items: center;
    margin-bottom: 0.8em;

    svg {
        height: 1.1em;
        margin-right: 0.2em;
    }
}

.cfw-password-toggle {
    position: absolute;
    top: 0.7em;
    right: 1em;
    color: #999999 !important;

    svg {
        width: 1.5em;
    }

    .cfw-eye-open {
        display: none;
    }

    .cfw-eye-shut {
        display: block;
    }

    &.cfw-password-eye-open {
        .cfw-eye-open {
            display: block;
        }
        .cfw-eye-shut {
            display: none;
        }
    }

    &:hover {
        color: darken( #999, 20% ) !important;
    }
}

.cfw-label-style-normal .cfw-password-toggle {
    top: 2.8em;
}