<template>
  <div class="step-actions">
    <div v-if="showBack" class="step-actions__back">
      <BaseButton
        variant="transparent"
        type="button"
        :text="backText"
        custom-class="step-actions__back-btn"
        @click="emit('back')"
      >
        <template #prependIcon>
          <SvgIcon name="caret-right" :size="12" color="var(--color-sec-gray)" />
        </template>
      </BaseButton>
    </div>
    <div class="step-actions__next">
      <BaseButton
        type="submit"
        :text="nextText"
        :loading="loading"
        custom-class="step-actions__next-btn"
      >
        <template #appendIcon>
          <SvgIcon name="arrow-left" :size="18" color="#fff" />
        </template>
      </BaseButton>
    </div>
  </div>
</template>

<script setup>
import BaseButton from '@/components/BaseButton.vue'
import SvgIcon from '@/components/icons/SvgIcon.vue'

defineProps({
  showBack: { type: Boolean, default: true },
  loading: { type: Boolean, default: false },
  nextText: { type: String, default: 'مرحله بعدی' },
  backText: { type: String, default: 'مرحله قبلی' },
})

const emit = defineEmits(['back'])
</script>

<style lang="scss" scoped>
.step-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;

  &__back {
    flex: 1 1 10rem;
    min-width: 0;
    display: flex;
    justify-content: flex-start;
  }

  &__next {
    flex: 1 1 12rem;
    min-width: 0;
    max-width: 16rem;
    margin-inline-start: auto;

    @media (max-width: 767px) {
      order: -1;
      flex-basis: 100%;
      max-width: none;
    }
  }

  &__back-btn {
    color: #969696;
    padding: 0 1rem;
    width: fit-content;
    font-weight: 500;
  }

  &__next-btn {
    width: 100%;
    min-height: 2.65rem;
    font-weight: 500;
  }

  :deep(.base-button__text) {
    font-size: 0.9375rem;
  }
}
</style>
