<template>
  <BasicModal
    title="جزئیات روایت شما"
    title-en="Story Details"
    width="95%"
    max-width="56rem"
    min-width="auto"
  >
    <div class="narrative-details">
      <div class="narrative-details__head">
        <div class="narrative-details__title-block">
          <LineInfoBlock title="عنوان روایت" :desc="narrative.title || '—'" />
        </div>

        <div class="narrative-details__stats">
          <div class="narrative-details__stat">
            <span class="narrative-details__stat-value">{{ narrative.comments ?? 0 }}</span>
            <SvgIcon name="chat-centered-dots" :size="20" />
          </div>
          <span class="narrative-details__stat-divider" />
          <div class="narrative-details__stat">
            <span class="narrative-details__stat-value">{{ narrative.likes ?? 0 }}</span>
            <SvgIcon name="heart" :size="20" />
          </div>
        </div>
      </div>

      <div class="narrative-details__request">
        <LineInfoBlock title="درخواست مرتبط" :desc="narrative.missionaryRequest?.title || '—'" />
      </div>

      <div class="narrative-details__body">
        <LineInfoBlock title="نتیجه یا دستاورد مأموریت" :desc="narrative.body || '—'" />
      </div>

      <div v-if="narrative.media?.length" class="narrative-details__media">
        <p class="narrative-details__media-title">پیوست‌ها</p>
        <MessageAttachments :media="narrative.media" />
      </div>
    </div>
  </BasicModal>
</template>

<script setup>
import { computed } from 'vue'
import useModal from '@/composables/useModal'
import BasicModal from '@/components/BasicModal.vue'
import SvgIcon from '@/components/icons/SvgIcon.vue'
import LineInfoBlock from '@/components/blocks/LineInfoBlock.vue'
import MessageAttachments from '@/components/blocks/MessageAttachments.vue'

defineOptions({ name: 'NarrativeDetailsModal' })

const { getModal } = useModal()

const narrative = computed(() => getModal('NarrativeDetailsModal')?.data ?? {})
</script>

<style lang="scss" scoped>
.narrative-details {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  font-family: var(--font-family-fa);

  &__head {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;

    @media (min-width: 768px) {
      flex-direction: row;
      align-items: center;
      justify-content: space-between;
    }
  }

  &__title-block {
    flex: 1;
    min-width: 0;
  }

  &__stats {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.25rem 0.5rem;
    background: #fff;
    box-shadow: 0 6.75px 19.425px rgba(0, 0, 0, 4%);
    border-radius: 0.75rem;
    align-self: flex-end;
    min-height: 2.25rem;
  }

  &__stat {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0 0.25rem;
  }

  &__stat-divider {
    width: 1.5px;
    height: 1.5rem;
    background: #efefef;
    border-radius: 9999px;
  }

  &__stat-value {
    font-family: var(--font-family-en);
    font-weight: 300;
    font-size: 0.95rem;
    color: #b3b3b3;
  }

  &__body :deep(.line-info__desc) {
    white-space: pre-line;
    line-height: 1.7;
    color: #4e4e4e;
  }

  &__media {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
  }

  &__media-title {
    font-family: var(--font-family-fa);
    font-weight: 400;
    font-size: 0.8rem;
    color: #848484;
    margin: 0;
  }

  &__footer {
    display: flex;
    justify-content: flex-end;
    padding-top: 0.5rem;
  }

  &__close-btn {
    min-width: 10rem;
    height: 2.25rem;
  }
}
</style>
