@import url('./button-vars.less');

button {
  appearance: none;
  width: 100%;
}
.button {
  text-decoration: none;
  text-align: center;
  display: block;
  appearance: none;
  background: none;
  margin: 0;
  white-space: nowrap;
  text-overflow:ellipsis;
  position: relative;
  overflow: hidden;
  font-family: inherit;
  cursor: pointer;
  outline: 0;
  box-sizing: border-box;
  vertical-align: middle;
  justify-content: center;
  align-items: center;
  border: var(--f7-button-border-width, 0px) solid var(--f7-button-border-color, var(--f7-theme-color));
  font-size: var(--f7-button-font-size);
  color: var(--f7-button-text-color, var(--f7-theme-color));
  height: var(--f7-button-height);
  line-height: calc(var(--f7-button-height) - var(--f7-button-border-width, 0) * 2);
  padding: var(--f7-button-padding-vertical, 0px) var(--f7-button-padding-horizontal);
  border-radius: var(--f7-button-border-radius);
  min-width: var(--f7-button-min-width);
  font-weight: var(--f7-button-font-weight);
  letter-spacing: var(--f7-button-letter-spacing);
  text-transform: var(--f7-button-text-transform);
  background-color: var(--f7-button-bg-color);
  box-shadow: var(--f7-button-box-shadow);
  &.active-state {
    background-color: var(--f7-button-pressed-bg-color, rgba(var(--f7-theme-color-rgb), 0.15));
    color: var(--f7-button-pressed-text-color, var(--f7-button-text-color, var(--f7-theme-color)));
  }
  input[type="submit"]&, input[type="button"]&{
    width: 100%;
  }

  > i + span,
  > span + span,
  > span + i,
  > i + i {
    .ltr({
      margin-left: 4px;
    });
    .rtl({
      margin-right: 4px;
    });
  }
}
.subnavbar .button,
.navbar .button,
.toolbar .button,
.searchbar .button,
.appbar .button {
  color: var(--f7-button-text-color, var(--f7-theme-color));
}

.button-round,
.ios .button-round-ios,
.md .button-round-md,
.aurora .button-round-aurora {
  --f7-button-border-radius: var(--f7-button-height);
}
.button-fill,
.ios .button-fill-ios,
.md .button-fill-md,
.aurora .button-fill-aurora,
.button-active,
.button.tab-link-active {
  --f7-button-bg-color: var(--f7-button-fill-bg-color, var(--f7-theme-color));
  --f7-button-text-color: var(--f7-button-fill-text-color, #fff);
  --f7-touch-ripple-color: var(--f7-touch-ripple-white);
}
.button-fill,
.ios .button-fill-ios,
.md .button-fill-md,
.aurora .button-fill-aurora {
  --f7-button-pressed-bg-color: var(--f7-button-fill-pressed-bg-color);
}
.button-active,
.button.tab-link-active {
  --f7-button-pressed-bg-color: var(--f7-button-bg-color);
}

.button-outline,
.ios .button-outline-ios,
.md .button-outline-md,
.aurora .button-outline-aurora {
  --f7-button-border-color: var(--f7-button-outline-border-color, var(--f7-theme-color));
  --f7-button-border-width: var(--f7-button-outline-border-width);
}

.button-large,
.ios .button-large-ios,
.md .button-large-md,
.aurora .button-large-aurora {
  --f7-button-height: var(--f7-button-large-height);
  --f7-button-font-size: var(--f7-button-large-font-size);
  --f7-button-font-weight: var(--f7-button-large-font-weight);
  --f7-button-text-transform: var(--f7-button-large-text-transform);
}
.button-small,
.ios .button-small-ios,
.md .button-small-md,
.aurora .button-small-aurora {
  --f7-button-outline-border-width: var(--f7-button-small-outline-border-width);
  --f7-button-height: var(--f7-button-small-height);
  --f7-button-font-size: var(--f7-button-small-font-size);
  --f7-button-font-weight: var(--f7-button-small-font-weight);
  --f7-button-text-transform: var(--f7-button-small-text-transform);
}
.ios .button-small.button-fill,
.ios .button-small-ios.button-fill,
.ios .button-small.button-fill-ios {
  --f7-button-border-width: var(--f7-button-small-outline-border-width);
  --f7-button-pressed-text-color: var(--f7-theme-color);
  --f7-button-pressed-bg-color: transparent;
}

.segmented {
  align-self: center;
  display: flex;
  flex-wrap: nowrap;
  border-radius: var(--f7-button-border-radius);
  box-shadow: var(--f7-button-box-shadow);
  box-sizing: border-box;
  .button, button {
    width: 100%;
    flex-shrink: 1;
    min-width: 0;
    border-radius: 0;
  }
  .ltr({
    .button:first-child {
      border-radius: var(--f7-button-border-radius) 0 0 var(--f7-button-border-radius);
    }
    .button:not(.button-outline):first-child {
      border-left: none;
    }
    .button.button-outline {
      &:nth-child(n + 2) {
        border-left: none;
      }
    }
    .button:last-child {
      border-radius: 0 var(--f7-button-border-radius) var(--f7-button-border-radius) 0;
    }
    .button-round:first-child {
      border-radius: var(--f7-button-height) 0 0 var(--f7-button-height);
    }
    .button-round:last-child {
      border-radius: 0 var(--f7-button-height) var(--f7-button-height) 0;
    }
  });
  .rtl({
    .button:first-child {
      border-radius: 0 var(--f7-button-border-radius) var(--f7-button-border-radius) 0;
    }
    .button:not(.button-outline):first-child {
      border-right: none;
    }
    .button.button-outline {
      &:nth-child(n + 2) {
        border-right: none;
      }
    }
    .button:last-child {
      border-radius: var(--f7-button-border-radius) 0 0 var(--f7-button-border-radius);
    }
    .button-round:first-child {
      border-radius: 0 var(--f7-button-height) var(--f7-button-height) 0;
    }
    .button-round:last-child {
      border-radius: var(--f7-button-height) 0 0 var(--f7-button-height);
    }
  });
  .button:first-child:last-child {
    border-radius: var(--f7-button-border-radius);
  }
}


.segmented-raised,
.ios .segmented-raised-ios,
.md .segmented-raised-md,
.aurora .segmented-raised-aurora {
  box-shadow: var(--f7-button-raised-box-shadow);
  .button:not(.button-outline) {
    .ltr({
      border-left: 1px solid var(--f7-segmented-raised-divider-color);
    });
    .rtl({
      border-right: 1px solid var(--f7-segmented-raised-divider-color);
    });
  }
}

// Raised
.button-raised,
.ios .button-raised-ios,
.md .button-raised-md,
.aurora .button-raised-aurora {
  --f7-button-box-shadow: var(--f7-button-raised-box-shadow);
  &.active-state {
    --f7-button-box-shadow: var(--f7-button-raised-pressed-box-shadow);
  }
}

// Strong
.segmented-strong,
.ios .segmented-strong-ios,
.md .segmented-strong-md,
.aurora .segmented-strong-aurora {
  --f7-button-bg-color: transparent;
  --f7-button-hover-bg-color: var(--f7-segmented-strong-button-hover-bg-color);
  --f7-button-text-color: var(--f7-segmented-strong-button-text-color);
  --f7-button-font-weight: var(--f7-segmented-strong-button-font-weight);
  --f7-button-text-transform: var(--f7-segmented-strong-button-text-transform);
  --f7-button-pressed-bg-color: var(--f7-segmented-strong-button-pressed-bg-color);
  background: var(--f7-segmented-strong-bg-color);
  border-radius: calc(var(--f7-button-border-radius) + 2px);
  box-shadow: none;
  padding: var(--f7-segmented-strong-padding);
  overflow: hidden;

  .button,
  .button:first-child,
  .button:last-child {
    border-radius: var(--f7-button-border-radius);
  }
  .button + .button {
    .ltr({
      margin-left: var(--f7-segmented-strong-between-buttons);
    });
    .rtl({
      margin-right: var(--f7-segmented-strong-between-buttons);
    });
  }
  .button.button-active,
  .button.tab-link-active {
    --f7-button-hover-bg-color: var(--f7-segmented-strong-button-active-bg-color);
    --f7-button-bg-color: var(--f7-segmented-strong-button-active-bg-color);
    --f7-button-text-color: var(--f7-segmented-strong-button-active-text-color);
    --f7-button-font-weight: var(--f7-segmented-strong-button-active-font-weight);
    --f7-button-box-shadow: var(--f7-segmented-strong-button-active-box-shadow);
  }
}

.segmented-round,
.ios .segmented-round-ios,
.md .segmented-round-md,
.aurora .segmented-round-aurora{
  border-radius: var(--f7-button-height);
}

.subnavbar .segmented {
  width: 100%;
}
.if-ios-theme({
  @import url('./button-ios.less');
});
.if-md-theme({
  @import url('./button-md.less');
});
.if-aurora-theme({
  @import url('./button-aurora.less');
});
