<template>
  <div class="mdis" @click="emit('show-details', dispatch)">
    <div class="mdis__heading">
      <span class="mdis__code">{{ dispatch.code }}</span>
      <div class="mdis__title-wrap">
        <p class="mdis__title">{{ dispatch.title }}</p>
        <div class="mdis__location">
          <SvgIcon name="paper-plane-right" :size="11" color="#989898" />
          <span>{{ dispatch.location }}</span>
        </div>
      </div>
    </div>

    <div class="mdis__meta">
      <div class="mdis__pill">
        <span class="mdis__pill-label">تاریخ اعزام :</span>
        <span class="mdis__pill-value">{{ dispatch.dispatchDate }}</span>
      </div>
    </div>

    <div class="mdis__actions" @click.stop>
      <BaseButton
        text="جزئیات درخواست"
        custom-class="mdis__btn"
        @click="emit('show-details', dispatch)"
      >
        <template #appendIcon>
          <SvgIcon name="arrow-left" :size="16" color="#fff" />
        </template>
      </BaseButton>
    </div>
  </div>
</template>

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

defineProps({
  dispatch: { type: Object, required: true },
})

const emit = defineEmits(['show-details'])
</script>

<style lang="scss" scoped>
.mdis {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  padding: 1rem 1.25rem;
  background: rgba(255, 255, 255, 58%);
  box-shadow: 0 6.75px 19.425px rgba(0, 0, 0, 4%);
  border-radius: 0.75rem;
  margin-bottom: 0.625rem;
  cursor: pointer;
  transition: background 0.15s ease;

  &:hover {
    background: rgba(255, 255, 255, 75%);
  }

  @media (min-width: 1024px) {
    flex-direction: row;
    align-items: center;
    gap: 1.5rem;
    padding: 1rem 2rem;
  }

  &__heading {
    display: flex;
    align-items: center;
    gap: 0.625rem;

    @media (min-width: 1024px) {
      min-width: 8rem;
    }
  }

  &__title-wrap {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    text-align: end;
    gap: 0.35rem;
  }

  &__title {
    font-family: var(--font-family-fa);
    font-weight: 400;
    font-size: 1rem;
    color: #4b4b4b;
    margin: 0;
  }

  &__location {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    font-family: var(--font-family-fa);
    font-weight: 400;
    font-size: 0.7rem;
    color: #989898;
  }

  &__code {
    font-family: var(--font-family-en);
    font-weight: 800;
    font-size: 2.75rem;
    line-height: 1;
    color: #f0f0f0;
  }

  &__meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: flex-end;
    gap: 0.5rem;

    @media (min-width: 1024px) {
      flex: 1;
      justify-content: center;
    }
  }

  &__pill {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.3rem 0.875rem;
    border-radius: 0.75rem;
    background: rgba(107, 107, 107, 4%);
    font-family: var(--font-family-fa);
    white-space: nowrap;
  }

  &__pill-label {
    font-weight: 400;
    font-size: 0.65rem;
    color: #535353;
  }

  &__pill-value {
    font-family: var(--font-family-en);
    font-weight: 400;
    font-size: 0.75rem;
    color: #5d5d5d;
  }

  &__actions {
    display: flex;
    justify-content: center;
    gap: 6px;

    @media (min-width: 1024px) {
      justify-content: flex-start;
    }
  }

  &__btn {
    min-width: 8rem;
    height: 2.5rem;
    padding: 0 1.25rem;
  }
}
</style>
