/*!
    *
    * Wijmo Library 5.20261.50
    * https://developer.mescius.com/wijmo
    *
    * Copyright(c) MESCIUS inc. All rights reserved.
    *
    * Licensed under the End-User License Agreement For MESCIUS Wijmo Software.
    * us.sales@mescius.com
    * https://developer.mescius.com/wijmo/licensing
    *
    */

@use "../misc/variables";

// wj-labeled-input: adapted from MDL styles
//
// The wj-labeled-input class should be used in a DIV element that contains:
//
// 1) A Wijmo input control
// 2) Always followed by a label element, and
// 3) An optional error element
//
// For example:
// <div class="wj-labeled-input">
//     <div id="name" autocomplete="name" required accesskey="n"></div>
//     <label for="name"><span class="accesskey">N</span>ame</label>
//     <div class="wj-error" tabindex="-1">We do need your name...</div>
// </div>

// labeled input container
.wj-labeled-input {
  position: relative;
  display: inline-block;
  width: 12em;
  max-width: 100%;
  margin: 0 20px;
  padding: 20px 0;

  &,
  *,
  *:after,
  *:before {
    // TFS 443339
    box-sizing: border-box;
  }

  &.wide {
    // wide fields
    width: 20em;
  }

  .accesskey {
    // underline access keys
    text-decoration: underline;
    font-size: unset;
  }

  .wj-control.wj-content {
    // labeled Wijmo controls
    margin: 0;
    width: 100%;
    background-color: transparent;
    border: none;
    border-bottom: 1px solid rgba(0, 0, 0, 0.1);

    button {
      // buttons in Wijmo controls
      opacity: 0.75;
      border-color: rgba(0, 0, 0, 0.1);
    }
  }

  .wj-inputnumber.wj-state-empty:not(.wj-state-focused) .wj-btn {
    display: none; // no spinner buttons on empty/unfocused InputNumber controls
  }

  // label in the container (must come after the control)
  label {
    font-size: 16px;
    top: 24px;
    bottom: 0;
    margin: 0;
    pointer-events: none;
    position: absolute;
    display: block;
    width: 100%;
    overflow: hidden;
    white-space: nowrap;
    text-align: left;
    color: rgba(0, 0, 0, 0.258824);
    transition-duration: 0.2s;
    transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
  }

  label:after {
    // underline label
    content: "";
    background-color: variables.$wj-sel-bkg;
    bottom: 20px;
    height: 2px;
    left: 45%;
    position: absolute;
    transition-duration: 0.2s;
    transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
    visibility: hidden;
    width: 10px;
  }

  .wj-state-focused + label:after {
    // show underline when focused
    left: 0;
    visibility: visible;
    width: 100%;
  }

  .wj-error {
    // error messages
    color: variables.$wj-invalid;
    position: absolute;
    font-size: 12px;
    margin-top: 3px;
    visibility: hidden;
    display: block;
    &.wj-error-visible {
      visibility: visible;
    }
  }

  .wj-state-invalid + label {
    color: variables.$wj-invalid;

    &:after {
      background-color: variables.$wj-invalid;
    }
  }

  // checkboxes
  input[type="checkbox"],
  input[type="radio"] {
    display: none; // hide real checkbox

    + label {
      position: relative;
      padding: 0.25em 0 0 1.8em;
      pointer-events: all;
      font-size: unset;
      top: 0;
      overflow: visible;

      &:after {
        // unchecked checkbox
        content: "";
        position: absolute;
        display: block;
        visibility: visible;
        text-align: center;
        left: 0;
        top: 0.25em;
        width: 1.3em;
        height: 1.3em;
        color: white;
        background: #ddd;
        transition: all 0.3s;
      }

      &:hover:after {
        box-shadow: 0 3px 3px rgba(0, 0, 0, 0.4);
      }
    }

    &:checked + label:after {
      // checked checkbox
      content: "\2714";
      background: variables.$wj-sel-bkg;
    }
  }

  // radios
  input[type="radio"] {
    + label:after {
      // radio
      border-radius: 1em;
      transform: scale(1.1);
    }

    &:checked + label:after {
      // checked radio
      content: "";
      background: white;
      border: 0.45em solid variables.$wj-sel-bkg;
    }
  }

  // switches
  &.switch input[type="checkbox"] {
    + label {
      padding-left: 3.1em;

      &:before {
        // track
        content: "";
        position: absolute;
        display: block;
        visibility: visible;
        left: 0;
        top: 0.5em;
        width: 2.5em;
        height: 1em;
        border-radius: 1em;
        background: #ddd;
        transition: all 0.3s;
      }

      &:after {
        // thumb
        content: "";
        left: 0;
        top: 0.25em;
        width: 1.5em;
        height: 1.5em;
        border-radius: 1em;
        border: 1px solid #bbb;
        background: white;
        transition: all 0.3s;
      }
    }

    &:checked + label:before {
      // checked track
      background: variables.$wj-sel-bkg;
      opacity: 0.4;
    }

    &:checked + label:after {
      // checked thumb
      margin-left: 1.25em;
      border: 1px solid variables.$wj-sel-bkg;
      background: variables.$wj-sel-bkg;
    }
  }
}

// move label out of the way when control is focused or not empty
.wj-static-labels .wj-labeled-input :not(.wj-state-focused) + label,
.wj-labeled-input .wj-state-focused + label,
.wj-labeled-input :not(.wj-state-empty) + label {
  font-size: 12px;
  top: 4px;
  color: variables.$wj-sel-bkg;
  visibility: visible;
}
