<template>
  <div class="action-buttons">
    <button 
      type="button"
      class="btn-cancel" 
      @click="$emit('cancel')"
    >
      {{ cancelText }}
    </button>
    <button 
      type="button"
      class="btn-save" 
      @click="$emit('save')"
      :disabled="disabled || loading"
    >
      <span v-if="loading" class="btn-loader"></span>
      <template v-else>
        <i v-if="saveIcon" :data-lucide="saveIcon"></i>
        <span>{{ saveText }}</span>
      </template>
    </button>
  </div>
</template>

<script setup>
defineProps({
  // Текст кнопки отмены
  cancelText: {
    type: String,
    default: 'Отмена'
  },
  // Текст кнопки сохранения
  saveText: {
    type: String,
    default: 'Сохранить'
  },
  // Иконка кнопки сохранения (lucide icon name)
  saveIcon: {
    type: String,
    default: ''
  },
  // Состояние загрузки
  loading: {
    type: Boolean,
    default: false
  },
  // Отключить кнопку сохранения
  disabled: {
    type: Boolean,
    default: false
  }
})

defineEmits(['save', 'cancel'])
</script>

<style scoped>
.action-buttons {
  display: flex;
  gap: 12px;
  margin-left: auto;
}

.btn-cancel {
  padding: 12px 24px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  color: var(--text-secondary);
  font-family: inherit;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.15s;
}

.btn-cancel:hover {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-primary);
}

.btn-save {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-width: 120px;
  padding: 12px 28px;
  background: var(--accent);
  border: none;
  border-radius: 8px;
  color: #000;
  font-family: inherit;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
}

.btn-save:hover {
  filter: brightness(1.1);
}

.btn-save:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-save i {
  width: 16px;
  height: 16px;
}

.btn-loader {
  display: inline-block;
  width: 18px;
  height: 18px;
  border: 2px solid rgba(0, 0, 0, 0.3);
  border-top-color: #000;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}
</style>
