

button
{
  font-family: var(--font);
  color: var(--color-text);
  display: inline-block;
  font-size: var(--font-size);

  &:visited, &:link
  {
    text-decoration: none;
  }

  &[disabled]
  {
    cursor: default;
    pointer-events: none;
  }
}

button::-moz-focus-inner
{
  border: 0;
}

.ui-button,
.ui-dot-button,
.ui-icon-button
{
  position: relative;
  display: inline-flex;
  justify-content: space-between;
  align-items: center;
  background: var(--color-button);
  color: var(--color-button-text);
  padding: 0 21px;
  height: 48px;
  border-radius: var(--radius-inner);
  font-size: var(--font-size);
  font-weight: 700;
  margin: 0;
  -webkit-backface-visibility: hidden;
  -webkit-appearance: none;
  cursor: pointer;
  user-select: none;
  border: none;
  overflow: hidden;
  font-family: var(--font);

  &:hover
  {
    opacity: 0.9;
  }

  &:active
  {
    opacity: 1;
  }

  &[disabled]
  {
    cursor: default;
    opacity: 0.7;
    pointer-events: none;
  }

  &.type-big
  {
    height: 50px;
    padding: 0 30px;
  }

  &.type-small
  {
    height: 38px;
    font-size: var(--font-size-s);
    padding: 0 16px;
  }

  &.type-light, &.type-action
  {
    background: var(--color-button-light);
    color: var(--color-text);
    border: 1px solid transparent;
  }

  &.type-primary
  {
    background: var(--color-primary);
    color: var(--color-primary-text);
    min-width: 90px;
    justify-content: center;
  }

  &.type-accent
  {
    //min-width: 90px;
    justify-content: center;
    background: var(--color-accent);
    color: var(--color-accent-fg);
    border: 1px solid transparent;
  }

  &.type-secondary
  {
    background: var(--color-secondary);
    color: var(--color-secondary-text);
    border: 1px solid transparent;
  }

  &.type-primary.type-small
  {
    min-width: 0;
  }


  &.type-light.type-onbg, &.type-action.type-onbg
  {
    background: var(--color-button-light-onbg);
    color: var(--color-text);
    box-shadow: var(--shadow-short);
  }

  &.type-danger
  {
    background: var(--color-accent-error);
    color: white;
  }

  &.type-blank
  {
    background: transparent;
    color: var(--color-text);
    padding: 0 16px;
  }

  &.type-block
  {
    display: flex;
    width: 100%;
  }

  & + .ui-button
  {
    margin-left: 15px;
  }

  &.is-attached
  {
    border-top-right-radius: 0;
    border-bottom-right-radius: 0;

    & + .ui-button, & + .ui-dropdown-container .ui-button
    {
      border-top-left-radius: 0;
      border-bottom-left-radius: 0;
      margin-left: -1px;
      border-left: 1px solid rgba(0,0,0,0.1);
      padding: 0 9px 0 8px;

      .ui-button-icon
      {
        margin: 0 !important;
      }
    }
  }

  .ui-button-icon, .ui-button-caret
  {
    margin-left: 18px;
    margin-right: -3px;
    position: relative;
    font-size: var(--font-size-l);
    top: -1px;
    /*color: var(--color-text-dim);*/
  }

  &.type-small .ui-button-icon
  {
    margin-left: 10px;
    margin-right: -2px;
    font-size: var(--font-size);
  }

  &.no-label .ui-button-icon
  {
    margin: 0 -5px !important;
  }

  &.caret-left
  {
    flex-direction: row-reverse;

    .ui-button-icon, .ui-button-caret
    {
      margin-right: 12px;
      margin-left: -7px;
    }
  }

  &.has-ellipsis .ui-button-text:after
  {
    content: '...';
  }
}

.ui-button-text
{
  span
  {
    font-weight: 400;
  }
}

.ui-button-state
{
  position: absolute;
  left: 50%;
  top: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  margin-left: -8px;
  margin-top: -8px;
  text-align: center;
}

.ui-button-progress
{   
  width: 100%;
  height: 100%;
  z-index: 2;
  border-radius: 40px;
  border: 2px solid rgba(white, 0.2);
  border-left-color: var(--color-button-text);
  opacity: 1;
  will-change: transform;
  animation: rotating .5s linear infinite;
  transition: opacity .25s ease;

  .type-light &, .type-blank &
  {
    //border-color: rgba(white, 0.2);
    border-left-color: var(--color-text);
  }
}

@keyframes rotating
{
  from
  {
    -webkit-transform: rotate(0);
    transform: rotate(0)
  }
  to
  {
    -webkit-transform: rotate(1turn);
    transform: rotate(1turn)
  }
}


// states

.ui-button.has-state:not(.state-default)
{
  > :not(.ui-button-state)
  {
    visibility: hidden;
  }
}


.ui-dot-button
{
  background: transparent;
  padding: 0;
  height: 28px;
  width: 36px;
  text-align: center;
  justify-content: center;
  color: var(--color-text);

  &:hover
  {
    background: var(--color-button-light);
  }

  .ui-button-icon
  {
    font-size: var(--font-size-xl);
    margin: 0;
  }
}


.ui-icon-button
{
  background: var(--color-button-light);
  padding: 0 !important;
  height: 32px;
  width: 32px;
  border-radius: 16px;
  text-align: center;
  justify-content: center;
  font-size: var(--font-size-l);

  &:hover
  {
    opacity: 1;
  }

  .ui-button-icon
  {
    //color: var(--color-text);
    margin: 0;
    top: 0;
  }

  &.type-small
  {
    height: 24px;
    width: 24px;

    .ui-button-icon
    {
      font-size: 13px;
      margin: 0 !important;
    }
  }
}


.ui-select-button
{
  color: var(--color-text);
  display: inline-flex;
  align-items: center;
}

.ui-select-button-icon 
{
  width: 48px;
  height: 48px;
  display: inline-flex;
  justify-content: center;
  align-items: center;
  border-radius: var(--radius-inner);
  background: var(--color-button-light);
  border: 1px solid transparent;
  color: var(--color-text);
  text-align: center;
  font-size: 16px;
  flex-shrink: 0;
  overflow: hidden;

  &.is-image
  {
    padding: 5px;
    font-size: 0;
    color: transparent;
    background: var(--color-image-bg);
    border-radius: var(--radius-inner);
    border: 1px solid var(--color-line-onbg);
    
    img
    {
      object-fit: contain;
      width: 100%;
      height: 100%;
      border-radius: var(--radius-inner);
    }
  }
}

.ui-select-button-content
{
  display: inline-flex;
  flex-direction: column;
  margin: 0 16px;
}

strong.ui-select-button-label
{
  font-weight: 400;

  b, strong
  {
    font-weight: 400;
  }
}

.ui-select-button-description
{
  color: var(--color-text-dim);
  margin-top: 3px;
  font-size: var(--font-size-xs);
  display: -webkit-box;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: normal;
  -webkit-line-clamp: 1;
  max-height: 16px;

  p
  {
    margin: 0;
  }
}