<template>
  <BaseDialog
    :model-value="modelValue"
    @update:model-value="$emit('update:modelValue', $event)"
    :title="computedTitle"
    :is-modal="true"
    size="large"
    :closable="true"
    :close-on-overlay="true"
    @close="handleClose"
  >
    <!-- Image Content -->
    <div class="image-dialog-content">
      <img 
        v-if="imageUrl" 
        :src="imageUrl" 
        :alt="title"
        class="dialog-image"
      />
      <div v-else class="no-image">
        {{ $t('imageDialog.noImageAvailable') }}
      </div>
      
      <!-- Optionale zusätzliche Inhalte -->
      <div v-if="$slots.default" class="image-extra-content">
        <slot></slot>
      </div>
    </div>

    <!-- Footer mit optionalen Aktionen -->
    <template #footer>
      <slot name="actions">
        <button @click="handleClose" class="btn-secondary">
          {{ $t('imageDialog.close') }}
        </button>
      </slot>
    </template>
  </BaseDialog>
</template>

<script>
import BaseDialog from './BaseDialog.vue';

export default {
  name: 'ImageDialog',
  components: {
    BaseDialog
  },
  props: {
    modelValue: {
      type: Boolean,
      default: false
    },
    title: {
      type: String,
      default: ''
    },
    imageUrl: {
      type: String,
      default: ''
    }
  },
  emits: ['update:modelValue', 'close'],
  computed: {
    computedTitle() {
      return this.title || this.$t('imageDialog.title');
    }
  },
  methods: {
    handleClose() {
      this.$emit('update:modelValue', false);
      this.$emit('close');
    }
  }
};
</script>

<style scoped>
.image-dialog-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
}

.dialog-image {
  max-width: 100%;
  max-height: 70vh;
  object-fit: contain;
  border-radius: 12px;
}

.no-image {
  padding: 2rem;
  text-align: center;
  color: var(--text-muted);
  font-style: italic;
}

.image-extra-content {
  width: 100%;
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border-color);
}

.btn-secondary {
  padding: 0.5rem 1.5rem;
  border: 1px solid var(--border-color);
  border-radius: 10px;
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  background: var(--surface-color);
  color: var(--text-color);
}

.btn-secondary:hover {
  background: var(--surface-muted);
  border-color: var(--primary-soft);
}

/* Responsive */
@media (max-width: 768px) {
  .dialog-image {
    max-height: 60vh;
  }
}
</style>
