<template>
  <view class="modal-mask" v-if="visible" @click="$emit('close')">
    <view class="modal-content" @click.stop>
      <view class="modal-title">{{ title }}</view>
      <slot></slot>
      <view class="modal-actions">
        <button class="btn-default" @click="$emit('close')">取消</button>
        <button class="btn-primary" @click="$emit('confirm')" :loading="loading">{{ confirmText || '确定' }}</button>
      </view>
    </view>
  </view>
</template>

<script>
export default {
  props: {
    visible: Boolean,
    title: String,
    loading: Boolean,
    confirmText: String
  }
}
</script>

<style scoped>
@import '../styles/common.css';

.modal-mask {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.modal-content {
  width: 480px;
  background: #fff;
  border-radius: 8px;
  padding: 24px;
}

.modal-title {
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 20px;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 20px;
}

</style>
